ima2-gen 3.12.3 → 3.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -3
- package/bin/commands/prompt-sub/build.js +5 -1
- package/config.js +14 -0
- package/docs/API.md +21 -0
- package/docs/CLI.md +7 -0
- package/docs/PROMPT_STUDIO.md +9 -0
- package/docs/migration/runtime-test-inventory.md +4 -1
- package/lib/configFileStore.js +44 -0
- package/lib/configKeys.js +4 -0
- package/lib/promptBuilder/client.js +106 -64
- package/lib/promptBuilder/constants.js +20 -2
- package/lib/promptBuilder/requestSchema.js +42 -7
- package/lib/promptBuilder/router.js +70 -0
- package/lib/promptBuilder/transport.js +5 -4
- package/package.json +2 -2
- package/routes/keys.js +6 -32
- package/routes/promptBuilder.js +68 -14
- package/skills/ima2/SKILL.md +40 -3
- package/skills/ima2-front/SKILL.md +1 -1
- package/skills/ima2-front/references/asset-requirements.md +16 -0
- package/ui/dist/.vite/manifest.json +44 -35
- package/ui/dist/assets/{AgentWorkspace-AJkVTaU5.js → AgentWorkspace-CBwn1WUC.js} +1 -1
- package/ui/dist/assets/AssetGenWorkspace-CleWSwPz.js +2 -0
- package/ui/dist/assets/AssetsWorkspace-DdjXb45L.js +1 -0
- package/ui/dist/assets/{CardNewsWorkspace-C_Eb2g7d.js → CardNewsWorkspace-BaNpBvJw.js} +1 -1
- package/ui/dist/assets/{GenerationRequestLogPanel-giH1e4hp.js → GenerationRequestLogPanel-Cd2ArsWr.js} +1 -1
- package/ui/dist/assets/HomeWorkspace-nKDhivwR.js +1 -0
- package/ui/dist/assets/KeyingPanel-DT8zsqpi.js +1 -0
- package/ui/dist/assets/{NodeCanvas-CF_NHudI.js → NodeCanvas-DcKs0w36.js} +1 -1
- package/ui/dist/assets/PromptBuilderPanel-e6BSRAdj.js +2 -0
- package/ui/dist/assets/{PromptImportDialog-B40X9UAa.js → PromptImportDialog-CLkjHz7L.js} +2 -2
- package/ui/dist/assets/{PromptImportDiscoverySection-BWoUDHj1.js → PromptImportDiscoverySection-DoQw4zcd.js} +1 -1
- package/ui/dist/assets/{PromptImportFolderSection-DBSEyJb-.js → PromptImportFolderSection-CcLiliAZ.js} +1 -1
- package/ui/dist/assets/{PromptLibraryPanel-DLywJBpt.js → PromptLibraryPanel-BjxzL7t5.js} +2 -2
- package/ui/dist/assets/SettingsWorkspace-Ctu_usKk.js +1 -0
- package/ui/dist/assets/SpriteRecipeWorkspace-DZjsabce.js +1 -0
- package/ui/dist/assets/index-0fpfY8vu.css +1 -0
- package/ui/dist/assets/index-DueH_AmZ.js +30 -0
- package/ui/dist/assets/index-ICf98ZcU.js +5 -0
- package/ui/dist/assets/{pptxgen.es-CSd_gCsx.js → pptxgen.es-C--aL3JM.js} +1 -1
- package/ui/dist/assets/promptBuilderStore-CkwnWMbR.js +1 -0
- package/ui/dist/assets/useAgentDialogFocus-DPB8JITN.js +1 -0
- package/ui/dist/index.html +2 -2
- package/ui/dist/assets/AssetGenWorkspace-Cguej69V.js +0 -2
- package/ui/dist/assets/AssetsWorkspace-DIQ9wBuD.js +0 -1
- package/ui/dist/assets/HomeWorkspace-DHmXGtqC.js +0 -1
- package/ui/dist/assets/PromptBuilderPanel-D7NJto-1.js +0 -2
- package/ui/dist/assets/SettingsWorkspace-BawWId1t.js +0 -1
- package/ui/dist/assets/SpriteRecipeWorkspace-Biy2yRAk.js +0 -1
- package/ui/dist/assets/VectorizePanel-DdlVvwV1.js +0 -1
- package/ui/dist/assets/index-D05Ong5g.js +0 -5
- package/ui/dist/assets/index-DGRIdnsL.css +0 -1
- package/ui/dist/assets/index-Sch70vBs.js +0 -30
- package/ui/dist/assets/useAgentDialogFocus-DcWwFfYd.js +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SpriteRecipeWorkspace-Biy2yRAk.js","assets/index-Sch70vBs.js","assets/index-DGRIdnsL.css","assets/VectorizePanel-DdlVvwV1.js","assets/useAgentDialogFocus-DcWwFfYd.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{u as G,b as n,a as p,ad as U,j as e,ae as Q,ac as Z,p as J,af as X,ag as Y,ah as ee}from"./index-Sch70vBs.js";import{K as se,V as te,A as ae}from"./VectorizePanel-DdlVvwV1.js";const ne=48;function le({selectedAssetId:t,onPreview:g,onAssetsLoaded:c}){const{t:r}=G(),l=n(d=>d.selectedProjectId),i=n(d=>d.assetGenItems.length),[m,h]=p.useState([]),[v,u]=p.useState(!1);return p.useEffect(()=>{let d=!1;return U({kind:null,folderId:l,tag:null,q:"",limit:ne}).then(b=>{if(d)return;const o=b.assets.filter(j=>j.filePath&&(j.kind==="image"||j.kind==="video"));h(o),c?.(o.length),u(!1)}).catch(()=>{d||u(!0)}),()=>{d=!0}},[l,i]),e.jsxs("aside",{className:"assetgen-rail","aria-label":r("assetGen.railTitle"),children:[e.jsx("h2",{className:"assetgen-rail__title",children:r("assetGen.railTitle")}),v?e.jsx("p",{className:"assetgen-rail__empty",children:r("assetGen.railError")}):m.length===0?e.jsx("p",{className:"assetgen-rail__empty",children:r("assetGen.railEmpty")}):e.jsx("div",{className:"assetgen-rail__list",role:"listbox","aria-label":r("assetGen.railTitle"),children:(()=>{const d=new Map;for(const o of m)d.set(o.name,(d.get(o.name)??0)+1);const b=new Map;return m.map(o=>{const j=o.filePath?Q(o.filePath):null;if(!j)return null;const a=t===o.id,k=d.get(o.name)??1,x=(b.get(o.name)??0)+1;b.set(o.name,x);const f=k>1?`#${x} ${o.name}`:o.name;return e.jsxs("button",{type:"button",role:"option","aria-selected":a,className:`assetgen-rail__tile${a?" is-selected":""}`,title:f,onClick:()=>g(Z(o),o.id),children:[o.kind==="video"?e.jsx("video",{src:j,muted:!0,playsInline:!0,preload:"metadata","aria-hidden":"true"}):e.jsx("img",{src:j,alt:"",loading:"lazy",decoding:"async"}),e.jsx("span",{className:"assetgen-rail__name",children:f})]},o.id)})})()})]})}const re=[{value:"chroma-green",swatch:"#00c853",labelKey:"assetGen.bgChroma"},{value:"white",swatch:"#ffffff",labelKey:"assetGen.bgWhite"},{value:"black",swatch:"#111111",labelKey:"assetGen.bgBlack"},{value:"transparent",swatch:null,labelKey:"assetGen.bgTransparent"}];function ie(){const{t}=G(),g=n(i=>i.assetGenBackground),c=n(i=>i.setAssetGenBackground),r=n(i=>i.assetGenProvider),l=r!=="grok"&&r!=="grok-api";return e.jsxs("div",{className:"assetgen-field",children:[e.jsx("span",{className:"assetgen-field__label",id:"assetgen-bg-label",children:t("assetGen.background")}),e.jsx("div",{className:"assetgen-bg-picker",role:"group","aria-labelledby":"assetgen-bg-label",children:re.map(i=>{const m=i.value==="transparent"&&!l;return e.jsxs("button",{type:"button",className:g===i.value?"is-active":"","aria-pressed":g===i.value,disabled:m,...m?{title:t("assetGen.bgTransparentGptOnly")}:{},onClick:()=>c(i.value),children:[e.jsx("span",{className:i.swatch===null?"assetgen-bg-picker__swatch assetgen-bg-picker__swatch--alpha":"assetgen-bg-picker__swatch",...i.swatch===null?{}:{style:{background:i.swatch}},"aria-hidden":"true"}),t(i.labelKey)]},i.value)})}),e.jsx("p",{className:"assetgen-field__hint",children:t(l?g==="transparent"?"assetGen.backgroundHintTransparent":"assetGen.backgroundHint":"assetGen.bgTransparentGptOnly")})]})}const oe=[{value:"oauth",labelKey:"assetGen.modelGpt"},{value:"grok",labelKey:"assetGen.modelGrok"}];function ce(){const{t}=G(),g=n(l=>l.assetGenProvider),c=n(l=>l.setAssetGenProvider),r=g==="grok"||g==="grok-api"?"grok":"oauth";return e.jsxs("div",{className:"assetgen-field",children:[e.jsx("span",{className:"assetgen-field__label",id:"assetgen-model-label",children:t("assetGen.model")}),e.jsx("div",{className:"assetgen-bg-picker",role:"group","aria-labelledby":"assetgen-model-label",children:oe.map(l=>e.jsx("button",{type:"button",className:r===l.value?"is-active":"","aria-pressed":r===l.value,onClick:()=>c(l.value),children:t(l.labelKey)},l.value))})]})}function de({onClose:t,onSelect:g}){const{t:c}=G(),r=n(u=>u.assetsFolders),[l,i]=p.useState(""),m=p.useRef(null),h=J(!0,t),v=p.useMemo(()=>{const u=r.filter(b=>b.parentId===null),d=l.trim().toLowerCase();return d?u.filter(b=>b.name.toLowerCase().includes(d)):u},[r,l]);return e.jsx("div",{className:"assetgen-popup-backdrop",onClick:t,children:e.jsxs("div",{ref:h,className:"assetgen-popup",role:"dialog","aria-modal":"true","aria-label":c("project.search"),onClick:u=>u.stopPropagation(),children:[e.jsx("input",{ref:m,type:"search",value:l,placeholder:c("project.searchPlaceholder"),"aria-label":c("project.search"),onChange:u=>i(u.target.value)}),e.jsxs("ul",{role:"listbox","aria-label":c("project.select"),children:[e.jsx("li",{children:e.jsx("button",{type:"button",onClick:()=>{g(null),t()},children:c("project.unassigned")})}),v.map(u=>e.jsx("li",{children:e.jsx("button",{type:"button",onClick:()=>{g(u.id),t()},children:u.name})},u.id)),v.length===0&&l.trim()?e.jsx("li",{className:"assetgen-popup__empty",children:c("project.searchEmpty")}):null]}),e.jsx("button",{type:"button",className:"assetgen-popup__close",onClick:t,children:c("project.close")})]})})}function ue(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"})})}function pe(){const{t}=G(),g=n(a=>a.assetsFolders),c=n(a=>a.selectedProjectId),r=n(a=>a.setSelectedProject),l=n(a=>a.loadAssetFolders),i=n(a=>a.createAssetFolder),[m,h]=p.useState(!1),[v,u]=p.useState(!1),d=p.useRef(null);p.useEffect(()=>{l()},[l]),p.useEffect(()=>{c&&g.length>0&&!g.some(a=>a.id===c)&&r(null)},[g,c,r]),p.useEffect(()=>{if(!m)return;const a=x=>{d.current&&!d.current.contains(x.target)&&h(!1)},k=x=>{x.key==="Escape"&&h(!1)};return window.addEventListener("mousedown",a),window.addEventListener("keydown",k),()=>{window.removeEventListener("mousedown",a),window.removeEventListener("keydown",k)}},[m]);const b=g.filter(a=>a.parentId===null),o=b.find(a=>a.id===c),j=async()=>{const a=window.prompt(t("project.newPrompt"));if(!a||!a.trim())return;if(await i(a.trim(),null)){await l();const x=n.getState().assetsFolders.find(f=>f.parentId===null&&f.name===a.trim());x&&r(x.id)}h(!1)};return e.jsxs("div",{className:"assetgen-field assetgen-project",ref:d,children:[e.jsx("span",{className:"assetgen-field__label",id:"assetgen-project-label",children:t("project.select")}),e.jsxs("button",{type:"button",className:"assetgen-project__trigger","aria-haspopup":"listbox","aria-expanded":m,"aria-labelledby":"assetgen-project-label",onClick:()=>h(a=>!a),children:[e.jsx(ue,{}),o?o.name:t("project.unassigned"),e.jsx("span",{className:"assetgen-project__caret","aria-hidden":"true",children:"▾"})]}),m?e.jsxs("ul",{className:"assetgen-project__menu",role:"listbox","aria-labelledby":"assetgen-project-label",children:[e.jsx("li",{children:e.jsx("button",{type:"button","aria-selected":c===null,onClick:()=>{r(null),h(!1)},children:t("project.unassigned")})}),b.map(a=>e.jsx("li",{children:e.jsx("button",{type:"button","aria-selected":c===a.id,onClick:()=>{r(a.id),h(!1)},children:a.name})},a.id)),e.jsx("li",{className:"assetgen-project__menu-divider","aria-hidden":"true"}),e.jsx("li",{children:e.jsx("button",{type:"button",onClick:()=>{j()},children:t("project.new")})}),e.jsx("li",{children:e.jsx("button",{type:"button",onClick:()=>{h(!1),u(!0)},children:t("project.search")})})]}):null,v?e.jsx(de,{onClose:()=>u(!1),onSelect:a=>r(a)}):null]})}const ge=p.lazy(()=>ee(()=>import("./SpriteRecipeWorkspace-Biy2yRAk.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.SpriteRecipeWorkspace})));function me(){const{t}=G(),g=n(s=>s.assetGenPrompt),c=n(s=>s.setAssetGenPrompt),r=n(s=>s.assetGenKind),l=n(s=>s.setAssetGenKind),i=n(s=>s.assetGenProvider),m=n(s=>s.assetGenVideoDuration),h=n(s=>s.setAssetGenVideoDuration),v=n(s=>s.assetGenVideoResolution),u=n(s=>s.setAssetGenVideoResolution),d=n(s=>s.assetGenVideoAspect),b=n(s=>s.setAssetGenVideoAspect),o=n(s=>s.activeGenerations),j=n(s=>s.assetGenItems),a=n(s=>s.generateAssetGen),k=n(s=>s.assetGenSaveFailures),x=n(s=>s.retryAssetGenSave),f=n(s=>s.setKeyingTarget),V=n(s=>s.setVectorizeTarget),A=n(s=>s.assetGenLastError),F=n(s=>s.setAssetGenLastError),I=n(s=>s.setUIMode),_=n(s=>s.assetGenWorkflow),S=n(s=>s.setAssetGenWorkflow),M=X(),[T,C]=p.useState(null),[O,E]=p.useState(null),[D,W]=p.useState(0),z=p.useCallback(()=>{C(null),E(null)},[]),B=p.useCallback((s,y)=>{E(y),C(s)},[]),H=p.useCallback(()=>{document.getElementById("assetgen-prompt")?.focus()},[]),P=i==="grok"||i==="grok-api",N=r==="video"&&!P?"image":r,K=g.trim().length>0,L=e.jsxs("div",{className:"assetgen-workflow-tabs",role:"tablist","aria-label":t("sprite.tabs.label"),onKeyDown:M,children:[e.jsx("button",{type:"button",role:"tab","aria-selected":_==="generate",tabIndex:_==="generate"?0:-1,onClick:()=>S("generate"),children:t("sprite.tabs.generate")}),e.jsx("button",{type:"button",role:"tab","aria-selected":_==="sprite",tabIndex:_==="sprite"?0:-1,onClick:()=>S("sprite"),children:t("sprite.tabs.sprite")})]});return _==="sprite"?e.jsxs("section",{className:"assetgen-workspace","aria-labelledby":"assetgen-title",children:[e.jsxs("aside",{className:"assetgen-form",children:[e.jsx("h1",{id:"assetgen-title",children:t("sprite.title")}),e.jsx("p",{className:"assetgen-form__lede",children:t("sprite.lede")}),L]}),e.jsx("main",{className:"assetgen-results",children:e.jsx(p.Suspense,{fallback:e.jsx("p",{role:"status",children:t("sprite.loading")}),children:e.jsx(ge,{})})})]}):e.jsxs("section",{className:"assetgen-workspace","aria-labelledby":"assetgen-title",children:[e.jsxs("aside",{className:"assetgen-form",children:[e.jsx("h1",{id:"assetgen-title",children:t("assetGen.title")}),e.jsx("p",{className:"assetgen-form__lede",children:t("assetGen.lede")}),L,e.jsx(pe,{}),e.jsxs("div",{className:"assetgen-field",children:[e.jsx("label",{className:"assetgen-field__label",htmlFor:"assetgen-prompt",children:t("assetGen.prompt")}),e.jsx("textarea",{id:"assetgen-prompt",value:g,rows:4,placeholder:t("assetGen.promptPlaceholder"),onChange:s=>c(s.target.value)})]}),e.jsx(ie,{}),e.jsx(ce,{}),e.jsxs("div",{className:"assetgen-field",children:[e.jsx("span",{className:"assetgen-field__label",id:"assetgen-kind-label",children:t("assetGen.kind")}),e.jsxs("div",{className:"assetgen-bg-picker",role:"group","aria-labelledby":"assetgen-kind-label",children:[e.jsx("button",{type:"button",className:N==="image"?"is-active":"","aria-pressed":N==="image",onClick:()=>l("image"),children:t("assetGen.kindImage")}),e.jsx("button",{type:"button",className:N==="video"?"is-active":"","aria-pressed":N==="video",disabled:!P,title:P?void 0:t("assetGen.videoGrokOnly"),onClick:()=>l("video"),children:t("assetGen.kindVideo")})]}),P?null:e.jsx("p",{className:"assetgen-field__hint",children:t("assetGen.videoGrokOnly")})]}),N==="video"?e.jsxs("div",{className:"assetgen-field",children:[e.jsx("span",{className:"assetgen-field__label",id:"assetgen-video-label",children:t("assetGen.videoOptions")}),e.jsx("div",{className:"assetgen-bg-picker",role:"group","aria-label":t("assetGen.videoDuration"),children:[3,5,8].map(s=>e.jsxs("button",{type:"button",className:m===s?"is-active":"","aria-pressed":m===s,onClick:()=>h(s),children:[s,"s"]},s))}),e.jsx("div",{className:"assetgen-bg-picker",role:"group","aria-label":t("assetGen.videoResolution"),children:["480p","720p"].map(s=>e.jsx("button",{type:"button",className:v===s?"is-active":"","aria-pressed":v===s,onClick:()=>u(s),children:s},s))}),e.jsx("div",{className:"assetgen-bg-picker",role:"group","aria-label":t("assetGen.videoAspect"),children:["1:1","16:9","9:16"].map(s=>e.jsx("button",{type:"button",className:d===s?"is-active":"","aria-pressed":d===s,onClick:()=>b(s),children:s},s))})]}):null,e.jsx("button",{type:"button",className:"assetgen-generate",disabled:!K,onClick:()=>{a()},children:o>0?t("assetGen.generating"):t("assetGen.generate")}),K?null:e.jsx("p",{className:"assetgen-generate__hint",children:t("assetGen.generateHint")}),e.jsx(Y,{})]}),e.jsxs("main",{className:"assetgen-results",children:[e.jsxs("div",{className:"assetgen-results__main",children:[A?e.jsxs("div",{className:"assetgen-error",role:"alert",children:[e.jsxs("div",{className:"assetgen-error__text",children:[e.jsx("strong",{children:t("assetGen.errorTitle")}),e.jsx("span",{children:A}),e.jsx("span",{className:"assetgen-error__hint",children:t("assetGen.errorHint")})]}),e.jsx("button",{type:"button",className:"assetgen-error__dismiss",onClick:()=>F(null),children:t("assetGen.errorDismiss")})]}):null,j.length===0?e.jsx("div",{className:"assetgen-empty",children:D>0?e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:t("assetGen.emptySessionTitle")}),e.jsx("p",{children:t("assetGen.emptySessionBody")}),e.jsx("button",{type:"button",className:"assetgen-empty__cta",onClick:()=>I("assets"),children:t("assetGen.emptySessionCta")})]}):e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:t("assetGen.emptyTitle")}),e.jsx("p",{children:t("assetGen.emptyBody")}),e.jsx("button",{type:"button",className:"assetgen-empty__cta",onClick:H,children:t("assetGen.emptyCta")})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"assetgen-saved-hint",children:[t("assetGen.savedHint")," ",e.jsx("button",{type:"button",className:"assetgen-saved-hint__link",onClick:()=>I("assets"),children:t("assetGen.savedLink")})]}),e.jsx("div",{className:"assetgen-grid",children:j.map(s=>{const y=s.kind==="edit",R=s.backgroundPreset==="transparent",w=s.mediaType==="video",$=t(w?"assetGen.videoFallback":"assetGen.imageFallback"),q=t(w?"assetGen.previewVideo":"assetGen.previewImage",{prompt:s.prompt?.trim()||$});return e.jsxs("figure",{className:`assetgen-tile${y?" is-keyed":""}${R?" is-alpha":""}`,children:[y?e.jsx("span",{className:"assetgen-tile__badge",children:t("keying.resultBadge")}):null,e.jsxs("button",{type:"button",className:"assetgen-tile__media","aria-label":q,onClick:()=>C(s),children:[w?e.jsx("video",{src:s.url||s.image,poster:s.thumb||void 0,muted:!0,playsInline:!0,preload:"metadata","aria-hidden":"true"}):e.jsx("img",{src:s.url||s.image,alt:"",loading:"lazy"}),e.jsx("span",{className:"assetgen-tile__open-hint","aria-hidden":"true",children:t(w?"assetGen.openHintVideo":"assetGen.openHintImage")})]}),e.jsx("figcaption",{title:s.prompt,children:s.prompt}),!y&&!R?e.jsx("button",{type:"button",className:"assetgen-tile__key",onClick:()=>f(s),children:t("keying.open")}):null,w?null:e.jsx("button",{type:"button",className:"assetgen-tile__key",onClick:()=>V(s),children:t("vectorize.open")}),!y&&s.requestId&&k.includes(s.requestId)?e.jsx("button",{type:"button",className:"assetgen-tile__retry",onClick:()=>{x(s.requestId)},children:t("project.saveRetry")}):null]},`${s.requestId}-${s.filename??s.createdAt}`)})})]})]}),e.jsx(le,{selectedAssetId:O,onPreview:B,onAssetsLoaded:W})]}),e.jsx(se,{}),e.jsx(te,{}),T?e.jsx(ae,{item:T,onClose:z}):null]})}const xe=Object.freeze(Object.defineProperty({__proto__:null,AssetGenWorkspace:me},Symbol.toStringTag,{value:"Module"}));export{xe as A,pe as P};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as I,b as v,a as d,j as s,a1 as Q,a2 as q,m as de,a3 as ce,a4 as ue,a5 as me,a6 as he,o as pe,a7 as fe,a8 as ge,a9 as xe,aa as be,J as ve,t as je,q as ye,v as _e,ab as we,ac as ke,p as Ne}from"./index-Sch70vBs.js";import{K as Ae,V as Se,A as Ie}from"./VectorizePanel-DdlVvwV1.js";import"./useAgentDialogFocus-DcWwFfYd.js";function Ce({folder:e,depth:a}){const{t:r}=I(),l=v(t=>t.assetsFilters.folderId),p=v(t=>t.setAssetsFilters),f=v(t=>t.renameAssetFolder),j=v(t=>t.deleteAssetFolder),o=v(t=>t.showToast),[i,g]=d.useState(!1),[_,h]=d.useState(e.name),[x,b]=d.useState(!1),k=l===e.id;async function m(){const t=_.trim();if(!t||t===e.name){h(e.name),g(!1);return}await f(e.id,t)||o(r("assets.actionFailed"),!0),g(!1)}async function u(){if(!x){b(!0);return}await j(e.id)||o(r("assets.actionFailed"),!0),b(!1)}return s.jsxs("div",{className:"assets-folder-row",style:{"--folder-depth":a},children:[i?s.jsx("input",{className:"assets-folder-input",value:_,autoFocus:!0,"aria-label":r("assets.renameFolder"),onChange:t=>h(t.target.value),onBlur:()=>{m()},onKeyDown:t=>{t.key==="Enter"&&m(),t.key==="Escape"&&(h(e.name),g(!1))}}):s.jsx("button",{type:"button",className:`assets-folder-row__name${k?" is-active":""}`,"aria-current":k?"page":void 0,onClick:()=>p({folderId:e.id,kind:null}),children:e.name}),!i&&s.jsxs("span",{className:"assets-folder-row__actions",children:[s.jsx("button",{type:"button","aria-label":r("assets.renameFolder"),onClick:()=>g(!0),children:s.jsx(Q,{})}),s.jsx("button",{type:"button","aria-label":r(x?"assets.confirmDelete":"assets.deleteFolder"),className:x?"is-danger is-armed":"",onClick:()=>{u()},children:x?r("assets.confirmDelete"):"×"})]})]})}function Fe(){const{t:e}=I(),a=v(m=>m.assetsFolders),r=v(m=>m.assetsFilters.folderId),l=v(m=>m.assetsFilters.kind),p=v(m=>m.setAssetsFilters),f=v(m=>m.createAssetFolder),j=v(m=>m.showToast),[o,i]=d.useState(!1),[g,_]=d.useState(""),h=r===null&&l!=="element",x=r===null&&l==="element",b=d.useMemo(()=>{const m=[],u=(t,c)=>a.filter(y=>y.parentId===t).forEach(y=>{m.push({folder:y,depth:c}),u(y.id,c+1)});return u(null,0),m},[a]);async function k(){const m=g.trim();if(!m){i(!1);return}await f(m,r)||j(e("assets.actionFailed"),!0),_(""),i(!1)}return s.jsxs("aside",{className:"assets-folders","aria-label":e("assets.rootFolder"),children:[s.jsxs("div",{className:"assets-folders__heading",children:[s.jsx("span",{children:e("assets.rootFolder")}),s.jsx("button",{type:"button","aria-label":e("assets.newFolder"),onClick:()=>i(!0),children:"+"})]}),s.jsxs("div",{className:"assets-folders__rows",children:[s.jsx("button",{type:"button",className:`assets-folder-all${h?" is-active":""}`,"aria-current":h?"page":void 0,onClick:()=>p({folderId:null,kind:null}),children:e("assets.allAssets")}),s.jsxs("button",{type:"button",className:`assets-folder-all assets-folder-elements${x?" is-active":""}`,"aria-current":x?"page":void 0,onClick:()=>p({folderId:null,kind:"element"}),children:[s.jsx("span",{className:"assets-folder-elements__glyph","aria-hidden":"true",children:"@"}),e("assets.elementLibrary")]}),b.map(({folder:m,depth:u})=>s.jsx(Ce,{folder:m,depth:u},m.id)),o&&s.jsx("input",{className:"assets-folder-input assets-folder-input--new",value:g,autoFocus:!0,"aria-label":e("assets.newFolder"),placeholder:e("assets.newFolder"),onChange:m=>_(m.target.value),onBlur:()=>{g.trim()||i(!1)},onKeyDown:m=>{m.key==="Enter"&&k(),m.key==="Escape"&&(_(""),i(!1))}})]})]})}let T={status:"idle",elements:[]},D=null;const G=new Set;function M(e){T=e,G.forEach(a=>a())}function Te(e){return G.add(e),()=>G.delete(e)}function z(e=!1){return!e&&T.status==="ready"?Promise.resolve(!0):D||(M({...T,status:"loading"}),D=de().then(a=>(M({status:"ready",elements:a}),!0)).catch(a=>(console.error("[ElementMembership] load failed",a),M({...T,status:"error"}),!1)).finally(()=>{D=null}),D)}function Ee(e){const a=[e,...T.elements.filter(r=>r.id!==e.id)];M({status:"ready",elements:a})}function Y(e){M({status:"ready",elements:T.elements.filter(a=>a.id!==e)})}function Pe(e){e.stopPropagation()}function De(e){e.stopPropagation()}function Me(e){(e.key==="Enter"||e.key===" ")&&e.stopPropagation()}async function Re(e,a){if(a){await ce(a.id),Y(a.id);return}const{asset:r}=await ue({result:{filePath:e.filePath??void 0},sourceAssetId:e.id,elementKind:"character",name:e.name,notes:e.notes??void 0,folderId:e.folderId,tags:[me(e.id)]});Ee(r)}function O({active:e,busy:a,label:r,onToggle:l}){return s.jsx("button",{type:"button",className:`asset-element-toggle${e?" is-active":""}`,title:r,"aria-label":r,"aria-pressed":e,"aria-busy":a||void 0,disabled:a,onPointerDown:Pe,onDoubleClick:De,onKeyDown:Me,onClick:p=>{p.stopPropagation(),l()},children:s.jsx("span",{className:"asset-element-toggle__glyph","aria-hidden":"true",children:"@"})})}function $e({item:e}){const{t:a}=I(),r=v(b=>b.showToast),l=v(b=>b.deleteAssetItem),[p,f]=d.useState(!1),j=e.kind==="element",o=j||(e.kind==="image"||e.kind==="video")&&!!e.filePath,i=a("assets.elementLibrary"),g=d.useSyncExternalStore(Te,()=>T,()=>T),_=!j&&o?q(g.elements,e.id):null,h=p||g.status==="loading"||g.status==="idle";if(d.useEffect(()=>{o&&!j&&z()},[o,j]),j){const b=async()=>{if(!p){f(!0);try{await l(e.id)?Y(e.id):r(a("assets.actionFailed"),!0)}finally{f(!1)}}};return s.jsx(O,{active:!0,busy:p,label:a("assets.removeFromElements"),onToggle:()=>{b()}})}if(!o)return null;async function x(){if(p||g.status==="loading")return;if(g.status!=="ready"&&!await z(!0)){r(a("assets.actionFailed"),!0);return}const b=q(T.elements,e.id);f(!0);try{await Re(e,b)}catch(k){console.error("[ElementMembership] toggle failed",k),r(a("assets.actionFailed"),!0)}finally{f(!1)}}return s.jsx(O,{active:!!_,busy:h,label:i,onToggle:()=>{x()}})}const L=12,V=180;function Be(e){return`/generated/${e.split("/").map(encodeURIComponent).join("/")}`}function Le({item:e,selected:a,onSelect:r,onPreview:l}){const{t:p}=I(),f=v(w=>w.deleteAssetItem),j=v(w=>w.updateAssetItem),o=v(w=>w.showToast),[i,g]=d.useState(!1),[_,h]=d.useState(!1),[x,b]=d.useState(!1),k=d.useRef(null);d.useEffect(()=>{const w=k.current;if(!w||e.kind!=="video"||typeof IntersectionObserver>"u"){b(!0);return}const R=new IntersectionObserver(([P])=>{P?.isIntersecting&&b(!0)},{rootMargin:"300px"});return R.observe(w),()=>R.disconnect()},[e.kind]);const m=e.kind==="element"&&!e.filePath?pe(e):e.filePath,u=m?Be(m):null,t=e.kind==="video",c=p(t?"assetGen.videoFallback":"assetGen.imageFallback"),y=p(t?"assetGen.previewVideo":"assetGen.previewImage",{prompt:e.name.trim()||c});async function A(){if(!i){g(!0);return}await f(e.id)||o(p("assets.actionFailed"),!0),g(!1)}const N=e.tags.includes("starred");async function S(){if(!_){h(!0);try{const w=ge(e.tags,N);await j(e.id,{tags:w})||o(p("assets.actionFailed"),!0)}finally{h(!1)}}}return s.jsxs("article",{ref:k,className:`assets-tile${a?" is-selected":""}`,tabIndex:0,"aria-selected":a,onClick:()=>r?.(e.id),onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&r&&(w.preventDefault(),r(e.id))},children:[s.jsxs("div",{className:"assets-tile__media",children:[u?s.jsxs("button",{type:"button",className:"assets-tile__preview","aria-label":y,onClick:w=>{w.stopPropagation(),r?.(e.id),l?.(e)},onKeyDown:w=>w.stopPropagation(),children:[t?x?s.jsx("video",{src:u,preload:"metadata",muted:!0,playsInline:!0,"aria-hidden":"true"}):null:s.jsx("img",{src:u,alt:"",loading:"lazy",decoding:"async"}),s.jsx("span",{className:"assets-tile__preview-hint","aria-hidden":"true",children:p(t?"assetGen.openHintVideo":"assetGen.openHintImage")})]}):s.jsx("span",{className:"assets-tile__glyph","aria-hidden":"true",children:e.kind.slice(0,1).toUpperCase()}),s.jsx(fe,{variant:"asset",active:N,busy:_,label:p(N?"assets.unstarAsset":"assets.starAsset"),onToggle:S}),s.jsx($e,{item:e}),s.jsx("button",{type:"button",className:`assets-tile__delete${i?" is-danger":""}`,"aria-label":p(i?"assets.confirmDelete":"assets.deleteAsset"),onClick:w=>{w.stopPropagation(),A()},children:i?p("assets.confirmDelete"):"×"})]}),s.jsxs("div",{className:"assets-tile__meta",children:[s.jsxs("div",{className:"assets-tile__title",children:[s.jsx("strong",{title:e.name,children:e.name}),s.jsx("span",{children:e.kind})]}),e.tags.length>0&&s.jsxs("div",{className:"assets-tile__tags",children:[e.tags.slice(0,2).map(w=>s.jsx("span",{children:w},w)),e.tags.length>2&&s.jsxs("span",{children:["+",e.tags.length-2]})]})]})]})}function Ue({onSelectAsset:e,onPreviewAsset:a,selectedId:r}){const{t:l}=I(),p=v(c=>c.assets),f=v(c=>c.assetsLoading),j=v(c=>c.assetsCursor),o=v(c=>c.loadMoreAssets),i=d.useRef(null),[g,_]=d.useState(960),h=Math.max(1,Math.floor((g+L)/(V+L))),x=d.useMemo(()=>Array.from({length:Math.ceil(p.length/h)},(c,y)=>p.slice(y*h,(y+1)*h)),[p,h]);d.useEffect(()=>{const c=i.current;if(!c)return;const y=()=>{const N=getComputedStyle(c),S=(parseFloat(N.paddingLeft)||0)+(parseFloat(N.paddingRight)||0);_(Math.max(0,c.clientWidth-S))};y();const A=new ResizeObserver(y);return A.observe(c),()=>A.disconnect()},[]);const b=Math.max(V,(g-L*(h-1))/h)+70+L,k=he({count:x.length,getScrollElement:()=>i.current,estimateSize:()=>b,overscan:4}),m=k.getVirtualItems(),u=m.at(-1)?.index,t=d.useCallback(()=>{j&&!f&&o()},[j,f,o]);return d.useEffect(()=>{u===x.length-1&&t()},[u,t,x.length]),s.jsxs("div",{ref:i,className:"assets-grid-scroll",children:[s.jsx("div",{className:"assets-grid-virtual",style:{height:k.getTotalSize()},children:m.map(c=>s.jsx("div",{className:"assets-grid-row",style:{transform:`translateY(${c.start}px)`,gridTemplateColumns:`repeat(${h}, minmax(0, 1fr))`},children:x[c.index]?.map(y=>s.jsx(Le,{item:y,selected:y.id===r,onSelect:e,onPreview:a},y.id))},c.key))}),j&&s.jsx("button",{type:"button",className:"assets-load-more",disabled:f,onClick:t,children:l("assets.loadMore")})]})}const Ke=5e3;function Ge({refs:e,onChange:a,maxRefs:r=6}){const{t:l}=I(),[p,f]=d.useState(null),[j,o]=d.useState(null),[i,g]=d.useState(null),_=d.useRef(null);d.useEffect(()=>()=>{_.current&&window.clearTimeout(_.current)},[]);const h=(u,t)=>{if(t<0||t>=e.length||u===t)return;const c=[...e],[y]=c.splice(u,1);c.splice(t,0,y),a(c)},x=u=>{if(e.length<=1)return;const t=e[u];a(e.filter((c,y)=>y!==u)),g({ref:t,index:u}),_.current&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>g(null),Ke)},b=()=>{if(!i||e.some(t=>t.path===i.ref.path))return;const u=[...e];u.splice(Math.min(i.index,u.length),0,i.ref),a(u.slice(0,r)),g(null)},k=(u,t)=>{u.preventDefault();const c=u.dataTransfer.getData("application/ima2-element-ref")||p,y=e.findIndex(S=>S.id===c);if(f(null),y<0||y===t)return;const A=e[y],N=e.find((S,w)=>w!==y&&S.path===A.path);if(N){o(N.id),window.setTimeout(()=>o(null),1200);return}h(y,t)},m=(u,t)=>a(e.map((c,y)=>y===u?{...c,alt:t}:c));return s.jsxs("section",{className:"element-ref-grid","aria-labelledby":"element-refs-title",children:[s.jsxs("div",{className:"element-detail__section-heading",children:[s.jsxs("div",{children:[s.jsx("h3",{id:"element-refs-title",children:l("element.refsTitle")}),s.jsx("p",{children:l("element.refsHelp")})]}),s.jsxs("span",{children:[e.length," / ",r]})]}),s.jsx("div",{className:"element-ref-grid__items",children:e.map((u,t)=>s.jsxs("div",{className:`element-ref-card${p===u.id?" is-dragging":""}${j===u.id?" is-duplicate":""}`,draggable:!0,onDragStart:c=>{f(u.id),c.dataTransfer.setData("application/ima2-element-ref",u.id),c.dataTransfer.effectAllowed="move"},onDragEnd:()=>f(null),onDragOver:c=>c.preventDefault(),onDrop:c=>k(c,t),children:[s.jsxs("div",{className:"element-ref-card__image",children:[s.jsx("img",{src:u.previewUrl||u.path,alt:u.alt||l("element.refAlt",{n:t+1})}),t===0?s.jsx("span",{children:l("element.refPrimary")}):null]}),s.jsxs("div",{className:"element-ref-card__controls",children:[s.jsxs("label",{children:[l("element.refLabel"),s.jsx("input",{value:u.alt,maxLength:80,placeholder:l("element.refLabelPlaceholder"),onChange:c=>m(t,c.target.value)})]}),s.jsxs("div",{children:[s.jsx("button",{type:"button",disabled:t===0,onClick:()=>h(t,t-1),"aria-label":l("element.refMoveUp",{n:t+1}),children:"↑"}),s.jsx("button",{type:"button",disabled:t===e.length-1,onClick:()=>h(t,t+1),"aria-label":l("element.refMoveDown",{n:t+1}),children:"↓"}),s.jsx("button",{type:"button",className:"is-danger",disabled:e.length<=1,onClick:()=>x(t),"aria-label":l("element.refRemove"),children:l("element.refRemove")})]})]})]},u.id))}),i?s.jsxs("div",{className:"element-ref-grid__undo",role:"status",children:[s.jsx("span",{children:l("element.refRemoved")}),s.jsx("button",{type:"button",onClick:b,children:l("element.refUndo")})]}):null]})}const He=/^[A-Za-z0-9_-]{1,32}$/;function qe({bindings:e,refs:a,onSave:r}){const{t:l}=I(),p=e.find(b=>b.provider==="runway"),f=e.find(b=>b.provider==="higgsfield"),[j,o]=d.useState(p?.tag??""),[i,g]=d.useState(!1),[_,h]=d.useState(null),x=async()=>{const b=j.trim();if(b&&!He.test(b)){h(l("assets.bindingTagInvalid"));return}h(null),g(!0);try{const k=[{provider:"runway",mode:"stateless-refs",...b?{tag:b}:{}},...f?[f]:[]];await r(k)||h(l("assets.actionFailed"))}finally{g(!1)}};return s.jsxs("section",{className:"element-detail__section","data-testid":"character-bindings-card",children:[s.jsx("div",{className:"element-detail__section-heading",children:s.jsxs("div",{children:[s.jsx("h3",{children:l("assets.bindingsTitle")}),s.jsx("p",{children:l("assets.bindingsHelp")})]})}),s.jsxs("div",{className:"character-binding-row",children:[s.jsx("span",{className:"character-binding-row__provider",children:"Runway"}),s.jsx("span",{className:"character-binding-row__mode",children:l("assets.bindingStateless")}),s.jsx("input",{value:j,maxLength:32,placeholder:l("assets.bindingTagPlaceholder"),"aria-label":l("assets.bindingTagPlaceholder"),onChange:b=>o(b.target.value)}),s.jsx("button",{type:"button",disabled:i,onClick:()=>{x()},children:l(i?"assets.bindingSaving":"assets.bindingSave")})]}),xe(a)?s.jsx("p",{className:"element-detail__error",role:"alert",children:l("assets.bindingCapWarning",{count:a.length})}):null,s.jsxs("div",{className:"character-binding-row character-binding-row--locked",children:[s.jsx("span",{className:"character-binding-row__provider",children:"Higgsfield"}),f?.status?s.jsx("span",{className:"character-binding-row__status",children:f.status}):null,s.jsx("button",{type:"button",disabled:!0,title:l("assets.bindingTrainLockedHint"),children:l("assets.bindingTrain")}),s.jsx("span",{className:"character-binding-row__badge",children:l("assets.bindingPaidPlan")})]}),f&&be(a,f)?s.jsx("p",{className:"element-detail__error",role:"alert",children:l("assets.bindingDriftWarning")}):null,_?s.jsx("p",{className:"element-detail__error",role:"alert",children:_}):null]})}const ze=["character","product","style","scene"],W=e=>e[0].toUpperCase()+e.slice(1);function J(e){return{id:e?.id,name:e?.name??"",kind:e?.kind??"character",refs:(e?.refs??[]).filter(a=>typeof a=="string"&&a.length>0).map((a,r)=>({id:`${e?.id??"new"}-${r}-${a}`,path:a,previewUrl:`/generated/${a.split("/").map(encodeURIComponent).join("/")}`,alt:""})),notes:e?.notes??"",defaultStrength:e?.defaultStrength??.75}}function Oe({element:e,saving:a,testing:r,onSave:l,onDelete:p,onRunTestSheet:f,onSaveBindings:j}){const{t:o}=I(),[i,g]=d.useState(()=>J(e)),[_,h]=d.useState(null);d.useEffect(()=>{g(J(e)),h(null)},[e]);const x=800-i.notes.length,b=d.useMemo(()=>i.notes.trim()?`[Element: ${i.name.trim()||"Untitled"}] ${i.notes.trim()}`:null,[i.name,i.notes]),k=(t,c)=>g(y=>({...y,[t]:c})),m=async()=>{if(!i.name.trim())return h(o("element.errorName"));if(!i.refs.length)return h(o("element.errorRefs"));h(null),await l({...i,name:i.name.trim(),notes:i.notes.trim()?i.notes:""})},u=ze.map(t=>({value:t,label:o(`element.kind${W(t)}`)}));return s.jsxs("aside",{className:"element-detail","aria-label":o("element.ariaLabel"),children:[s.jsxs("header",{className:"element-detail__header",children:[s.jsxs("div",{children:[s.jsx("span",{children:o("element.title")}),s.jsx("h2",{children:o(e?"element.titleEdit":"element.titleNew")})]}),e?s.jsx("span",{className:"element-detail__status",children:o("element.saved")}):null]}),s.jsxs("label",{className:"element-detail__field",children:[o("element.name"),s.jsx("input",{value:i.name,maxLength:120,placeholder:o("element.namePlaceholder"),onChange:t=>k("name",t.target.value)})]}),s.jsx(ve,{title:o("element.kind"),items:u,value:i.kind,onChange:t=>k("kind",t)}),s.jsx("p",{className:"element-detail__kind-help",children:o(`element.help${W(i.kind)}`)}),s.jsx(Ge,{refs:i.refs,onChange:t=>k("refs",t),maxRefs:6}),e&&i.kind==="character"&&j?s.jsx(qe,{bindings:e.characterBindings??[],refs:e.refs,onSave:t=>j(e.id,t)}):null,s.jsxs("section",{className:"element-detail__section",children:[s.jsxs("div",{className:"element-detail__section-heading",children:[s.jsxs("div",{children:[s.jsx("h3",{children:o("element.notes")}),s.jsx("p",{children:o("element.notesHelp")})]}),x<=100?s.jsx("span",{children:o("element.remaining",{n:x})}):null]}),s.jsx("textarea",{value:i.notes,maxLength:800,rows:6,placeholder:o("element.notesPlaceholder"),onChange:t=>k("notes",t.target.value)}),b?s.jsx("p",{className:"element-detail__note-preview",children:b}):null]}),s.jsxs("section",{className:"element-detail__section",children:[s.jsxs("div",{className:"element-detail__section-heading",children:[s.jsxs("div",{children:[s.jsx("h3",{children:o("element.strength")}),s.jsx("p",{children:o("element.strengthHelp")})]}),s.jsx("output",{children:i.defaultStrength.toFixed(2)})]}),s.jsx("input",{className:"element-detail__strength",type:"range",min:"0",max:"1",step:"0.05",value:i.defaultStrength,onChange:t=>k("defaultStrength",Number(t.target.value))}),s.jsx("button",{type:"button",className:"element-detail__reset",onClick:()=>k("defaultStrength",.75),children:o("element.resetDefault")})]}),_?s.jsx("p",{className:"element-detail__error",role:"alert",children:_}):null,s.jsxs("footer",{className:"element-detail__actions",children:[s.jsx("button",{type:"button",className:"element-detail__save",disabled:a,onClick:()=>{m()},children:o(a?"element.saving":"element.save")}),s.jsx("button",{type:"button",disabled:!e||r,onClick:()=>e&&void f(e.id),children:o(r?"element.testing":"element.runTest")}),e&&p?s.jsx("button",{type:"button",className:"is-danger",onClick:()=>{p(e.id)},children:o("element.delete")}):null]})]})}const Ve=["image","video","element","preset","template"];function We(e,a){return Ne(e,a)}function es(){const{t:e}=I(),a=v(n=>n.assets),r=v(n=>n.assetsTags),l=v(n=>n.assetsFilters),p=v(n=>n.assetsLoading),f=v(n=>n.assetsLoadError),j=v(n=>n.loadAssets),o=v(n=>n.setUIMode),i=v(n=>n.setAssetsFilters),g=v(n=>n.updateAssetItem),_=v(n=>n.deleteAssetItem),h=v(n=>n.showToast),[x,b]=d.useState(l.q),[k,m]=d.useState(null),[u,t]=d.useState(null),[c,y]=d.useState(null),A=je(),N=v(n=>n.keyingTarget),S=v(n=>n.pendingAssetDetailId);d.useEffect(()=>{if(!S)return;const n=S;v.setState({pendingAssetDetailId:null});const E=v.getState().assets.find(F=>F.id===n)??null;y(E),i({kind:null,folderId:null,tag:null,q:""}),b(""),m(n),E||ye(n).then(({asset:F})=>{v.setState(K=>({assets:[F,...K.assets.filter(B=>B.id!==F.id)]})),y(F)}).catch(()=>{})},[S,i]);const w=d.useRef(!1);d.useEffect(()=>{if(N){w.current=!0;return}w.current&&(w.current=!1,j(!0))},[N,j]);const R=d.useMemo(()=>[{value:"",label:e("assets.kindAll")},...Ve.map(n=>({value:n,label:e(`assets.kind${n[0].toUpperCase()}${n.slice(1)}`)}))],[e]);d.useEffect(()=>{j(!0)},[j]),d.useEffect(()=>{const n=window.setTimeout(()=>i({q:x}),300);return()=>window.clearTimeout(n)},[x,i]);const P=!!(l.q||l.kind||l.tag),Z=a.length===0&&!p,U=l.kind==="element"&&!l.folderId&&!l.q&&!l.tag,X=U?"assets.emptyElementsTitle":l.folderId?"assets.emptyFolderTitle":P?"assets.emptySearchTitle":"assets.emptyTitle",ee=U?"assets.emptyElementsBody":l.folderId?"assets.emptyFolderBody":P?"assets.emptySearchBody":"assets.emptyBody",C=a.find(n=>n.id===k)??(c?.id===k?c:null),H=C?.kind==="element"?Qe(C):null,$=d.useCallback(()=>m(null),[]),se=We(!!(C&&A),$),te=d.useCallback(()=>t(null),[]),ae=async n=>{(!n.id||!await g(n.id,{name:n.name,notes:n.notes}))&&h(e("assets.actionFailed"),!0)},ne=async(n,E)=>{const K={...a.find(oe=>oe.id===n)?.metadata??{},characterBindings:E},B=await g(n,{metadata:K});return B||h(e("assets.actionFailed"),!0),B},le=async(n,E)=>{const F=await g(n,{name:E});return F||h(e("assets.actionFailed"),!0),F},ie=async n=>{await _(n)?$():h(e("assets.actionFailed"),!0)},re=async()=>h(e("assets.testSheetsUnavailable"),!0);return s.jsxs("section",{className:`assets-workspace${C?" assets-workspace--detail-open":""}`,"aria-labelledby":"assets-title",children:[s.jsx(Fe,{}),s.jsxs("main",{className:"assets-workspace__main",children:[s.jsxs("header",{className:"assets-toolbar",children:[s.jsxs("div",{className:"assets-toolbar__title",children:[s.jsx("h1",{id:"assets-title",children:e("assets.title")}),s.jsx("span",{children:e("assets.itemCount",{count:a.length})})]}),s.jsxs("div",{className:"assets-toolbar__controls",children:[s.jsx("input",{type:"search",value:x,placeholder:e("assets.searchPlaceholder"),"aria-label":e("assets.searchPlaceholder"),onChange:n=>b(n.target.value)}),s.jsx(_e,{items:R,value:l.kind??"",onChange:n=>i({kind:n||null}),ariaLabel:e("assets.kindAll")}),a.length>0&&s.jsx("button",{type:"button",className:"assets-clear-btn",onClick:async()=>{confirm(e("assets.clearConfirm"))&&(await we(),j(!0))},children:e("assets.clearAll")})]}),r.length>0&&s.jsx("div",{className:"assets-tag-filter",children:r.map(n=>s.jsx("button",{type:"button",className:l.tag===n?"is-active":"",onClick:()=>i({tag:l.tag===n?null:n}),children:n},n))})]}),f&&a.length===0?s.jsxs("div",{className:"assets-empty",role:"alert",children:[s.jsx("h2",{children:e("assets.loadErrorTitle")}),s.jsx("p",{children:e("assets.loadErrorBody")}),s.jsx("button",{type:"button",className:"assets-empty__cta",onClick:()=>{j(!0)},children:e("assets.retry")})]}):Z?s.jsxs("div",{className:"assets-empty",children:[s.jsx("h2",{children:e(X)}),s.jsx("p",{children:e(ee)}),U||!P&&!l.folderId?s.jsx("button",{type:"button",className:"assets-empty__cta",onClick:()=>o("classic"),children:e("nav.create")}):null]}):s.jsx(Ue,{selectedId:k??void 0,onSelectAsset:m,onPreviewAsset:n=>t(ke(n))})]}),C&&A?s.jsx("button",{type:"button",className:"assets-workspace__detail-backdrop","aria-label":e("assets.detailClose"),onClick:$}):null,C&&s.jsxs("aside",{ref:se,className:"assets-workspace__detail",role:A?"dialog":void 0,"aria-modal":A?!0:void 0,"aria-label":e("assets.detailAria",{name:C.name}),children:[s.jsx("button",{type:"button",className:"assets-workspace__detail-close",onClick:$,"aria-label":e("assets.detailClose"),children:"×"}),H?s.jsx(Oe,{element:H,saving:!1,testing:!1,onSave:ae,onSaveBindings:ne,onDelete:ie,onRunTestSheet:re}):s.jsx(Je,{asset:C,onRename:n=>le(C.id,n)})]}),s.jsx(Ae,{}),s.jsx(Se,{}),u?s.jsx(Ie,{item:u,onClose:te}):null]})}function Je({asset:e,onRename:a}){const{t:r,locale:l}=I(),[p,f]=d.useState(!1),[j,o]=d.useState(e.name),i=d.useRef(!1),g=typeof e.metadata?.prompt=="string"?e.metadata.prompt:null,_=typeof e.metadata?.provider=="string"?e.metadata.provider:null;d.useEffect(()=>{o(e.name),f(!1)},[e.id,e.name]);async function h(){if(i.current)return;const x=j.trim();if(!x||x===e.name){o(e.name),f(!1);return}i.current=!0;try{await a(x)||o(e.name)}finally{i.current=!1,f(!1)}}return s.jsxs("div",{className:"assets-workspace__detail-meta",children:[s.jsx("div",{className:"assets-workspace__detail-title",children:p?s.jsx("input",{className:"assets-folder-input assets-workspace__detail-name-input",value:j,autoFocus:!0,"aria-label":r("assets.renameAsset"),onChange:x=>o(x.target.value),onBlur:()=>{h()},onKeyDown:x=>{x.key==="Enter"&&h(),x.key==="Escape"&&(o(e.name),f(!1))}}):s.jsxs(s.Fragment,{children:[s.jsx("h2",{children:e.name}),s.jsx("button",{type:"button",className:"assets-workspace__detail-rename","aria-label":r("assets.renameAsset"),title:r("assets.renameAsset"),onClick:()=>f(!0),children:s.jsx(Q,{})})]})}),s.jsxs("dl",{children:[s.jsx("dt",{children:r("assets.detailKind")}),s.jsx("dd",{children:r(`assets.kind${e.kind[0].toUpperCase()}${e.kind.slice(1)}`)}),s.jsx("dt",{children:r("assets.detailCreated")}),s.jsx("dd",{children:new Intl.DateTimeFormat(l,{dateStyle:"medium",timeStyle:"short"}).format(new Date(e.createdAt))}),_?s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:r("assets.detailProvider")}),s.jsx("dd",{children:_})]}):null,g?s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:r("assets.detailPrompt")}),s.jsx("dd",{className:"assets-workspace__detail-prompt",children:g})]}):null,e.tags.length>0?s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:r("assets.detailTags")}),s.jsx("dd",{children:e.tags.join(", ")})]}):null]})]})}function Qe(e){const a=e.metadata??{},r=a.elementKind,l=a.refs,p=Array.isArray(a.characterBindings)?a.characterBindings:void 0;return{id:e.id,name:e.name,kind:r==="product"||r==="style"||r==="scene"?r:"character",refs:Array.isArray(l)?l.filter(f=>typeof f=="string"):e.filePath?[e.filePath]:[],notes:e.notes??void 0,defaultStrength:typeof a.defaultStrength=="number"?a.defaultStrength:void 0,characterBindings:p}}export{es as AssetsWorkspace};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as i,u as m,am as I,j as e,an as A,ao as k,ap as P,v as E,aq as M,a as x,ar as w,as as R,at as T,au as C,av as L,aw as O,ax as H,ay as S}from"./index-Sch70vBs.js";const G={oauth:"GPT OAuth",api:"GPT API",grok:"Grok OAuth","grok-api":"Grok API",agy:"Antigravity","gemini-api":"Gemini API",atlascloud:"Atlas Cloud",minimax:"MiniMax",nai:"NovelAI",comfy:"ComfyUI"};function U(s){if(s.kind==="attachment")return s.source.dataUrl;if(s.source.thumbnailUrl)return s.source.thumbnailUrl;const t=s.source.referenceFilenames[0];if(t)return t.startsWith("/generated/")?t:`/generated/${t.split("/").map(encodeURIComponent).join("/")}`}function D({providerAvailability:s}){const t=i(o=>o.prompt),r=i(o=>o.setPrompt),n=i(o=>o.provider),a=i(o=>o.setProvider),c=i(o=>o.selectedPresetIds),p=i(o=>o.removePreset),d=i(o=>o.generate),v=i(o=>o.activeGenerations),h=i(o=>o.trayItems),{t:l}=m(),f=new Set(c),j=I().filter(o=>f.has(o.id)),b=v>0,y=Object.entries(G).map(([o,u])=>{const g=o,_=s[g];return{value:g,label:u,sub:_.ok?l("readiness.ready"):_.reason,disabled:!_.ok}});return e.jsxs("div",{className:"home-prompt",children:[j.length>0?e.jsx(A,{className:"home-prompt__chips",ariaLabel:l("home.selectedPresets"),children:j.map(o=>e.jsx(k,{selected:!0,onRemove:()=>p(o.id),removeLabel:l("common.removeNamed",{name:o.name}),title:o.category,children:o.name},o.id))}):null,h.length>0?e.jsxs("div",{className:"home-prompt__reference-strip",role:"group","aria-label":l("home.referenceTrayAria",{count:h.length}),children:[e.jsx("span",{className:"home-prompt__reference-thumbs","aria-hidden":"true",children:h.map(o=>{const u=U(o);return e.jsx("span",{className:"home-prompt__reference-thumb",children:u?e.jsx("img",{src:u,alt:"",loading:"lazy",decoding:"async"}):"@"},o.tokenId)})}),e.jsx("span",{className:"home-prompt__reference-count",children:l("home.referenceTrayCount",{count:h.length})})]}):null,e.jsx("label",{className:"home-prompt__label",htmlFor:"home-prompt-input",children:l("prompt.label")}),e.jsx("textarea",{id:"home-prompt-input",className:"home-prompt__textarea",rows:5,value:t,placeholder:l("prompt.placeholder"),onChange:o=>r(o.target.value)}),e.jsx(P,{variant:"home"}),e.jsxs("div",{className:"home-prompt__footer",children:[e.jsx(E,{className:"home-prompt__provider",items:y,value:n,onChange:a,ariaLabel:l("readiness.provider")}),e.jsx("button",{type:"button",className:"home-prompt__generate",disabled:b||t.trim().length===0,onClick:()=>{d();const o=i.getState().setUIMode;o("classic")},children:b?l("generate.buttonLoading",{n:v}):l("generate.button")})]})]})}const N=/\.(mp4|webm|mov)(?:$|[?#])/i;function V(s){return s.mediaType==="video"||N.test(s.filename??"")||N.test(s.url??s.image)?s.thumb:s.thumb||s.url||s.image||void 0}function B({item:s,featured:t}){const{t:r}=m(),[n,a]=x.useState(!1),c=V(s),p=(s.userPrompt?.trim()||s.prompt?.trim()||r("home.untitledResult")).slice(0,60),d=r("home.recentResultAlt",{prompt:p});return!c||n?e.jsx("div",{className:"home-recent-card__fallback",role:"img","aria-label":d,children:r("home.mediaUnavailable")}):e.jsx("img",{src:c,alt:d,loading:t?"eager":"lazy",decoding:"async",onError:()=>a(!0)})}function F(){const s=i(n=>n.history),{t}=m(),r=s.slice(0,5);return r.length===0?e.jsx("p",{className:"home-recent-empty",role:"status",children:t("history.emptyRecent")}):e.jsx("div",{className:"home-recent-row",role:"list","aria-label":t("home.recentTitle"),children:r.map((n,a)=>{const c=a===0;return e.jsx("figure",{className:`home-recent-card${c?" is-featured":""}`,role:"listitem",children:e.jsx(B,{item:n,featured:c})},M(n))})})}function $(){return e.jsxs("svg",{className:"home-hero__mode-arrow",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M5 12h14"}),e.jsx("path",{d:"m12 5 7 7-7 7"})]})}function W(){const{t:s}=m(),t=w(),r=x.useMemo(()=>Object.values(t).filter(a=>a?.ok).length,[t]),n=x.useMemo(()=>Object.keys(t).length,[t]);return e.jsxs("div",{className:"home-hero",children:[e.jsx("div",{className:"home-hero__mark","aria-hidden":"true",children:"IMA2"}),e.jsxs("header",{className:"home-hero__intro",children:[e.jsx("h1",{className:"home-hero__title",children:s("home.heroTitle")}),e.jsx("p",{className:"home-hero__lede",children:s("home.heroLede")})]}),e.jsxs("p",{className:"home-hero__readiness",role:"status",children:[e.jsx("span",{className:`home-hero__dot${r>0?" is-ready":""}`,"aria-hidden":"true"}),r>0?s("home.lanesReady",{ready:r,total:n}):s("home.lanesNone")]}),e.jsx("div",{className:"home-workspace__composer",children:e.jsx(D,{providerAvailability:t})}),e.jsxs("section",{className:"home-workspace__recent","aria-labelledby":"home-recent-title",children:[e.jsx("h2",{id:"home-recent-title",children:s("home.recentTitle")}),e.jsx(F,{})]}),e.jsx(z,{})]})}function z(){const{t:s}=m(),t=i(a=>a.setUIMode),r=[{mode:"classic",label:s("nav.create"),hint:s("home.modeCreateHint"),enabled:!0,icon:R},{mode:"node",label:s("nav.node"),hint:s("home.modeNodeHint"),enabled:C,icon:T},{mode:"agent",label:s("nav.agent"),hint:s("home.modeAgentHint"),enabled:O,icon:L},{mode:"assets",label:s("nav.assets"),hint:s("home.modeAssetsHint"),enabled:!0,icon:H}];function n(a){t(a),history.replaceState(null,"",S[a]??"#create")}return e.jsxs("nav",{className:"home-modes","aria-label":s("home.modesTitle"),children:[e.jsx("h2",{className:"home-modes__title",children:s("home.modesTitle")}),r.filter(a=>a.enabled).map(a=>e.jsxs("button",{type:"button",className:"home-modes__item",onClick:()=>n(a.mode),children:[e.jsx("span",{className:"home-modes__icon",children:e.jsx(a.icon,{})}),e.jsx("span",{className:"home-modes__label",children:a.label}),e.jsx("span",{className:"home-modes__hint",children:a.hint}),e.jsx($,{})]},a.mode))]})}function K(){const{t:s}=m();return e.jsx("section",{className:"home-workspace","aria-label":s("nav.home"),children:e.jsx("div",{className:"home-workspace__inner",children:e.jsx(W,{})})})}export{K as HomeWorkspace};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{aO as S,aP as M,aQ as v,b as u,u as f,j as t,v as T,a as j}from"./index-Sch70vBs.js";function E(e){return e.filename??e.url??e.image}let A=0;function y(){return`pb_${Date.now()}_${++A}`}async function C(e){const n=y(),r=e.type.startsWith("image/")?"image":"file";if(r==="image"){const s=await new Promise((o,d)=>{const l=new FileReader;l.onload=()=>o(l.result),l.onerror=()=>d(l.error??new Error(v("modal.attachmentReadFailed"))),l.readAsDataURL(e)});return{id:n,kind:r,name:e.name,mimeType:e.type,size:e.size,dataUrl:s}}return{id:n,kind:r,name:e.name,mimeType:e.type,size:e.size}}const m=S()((e,n)=>({messages:[],scope:{kind:"draft"},draft:"",model:"gpt-5.6-luna",loading:!1,attachments:[],error:null,setDraft:r=>e({draft:r}),setModel:r=>e({model:r}),clearMessages:()=>e({messages:[],error:null}),clearImageScope:()=>e({scope:{kind:"draft"}}),setScopeFromImage:r=>{const s=E(r);e({scope:{kind:"image",imageKey:s}})},addAttachments:async r=>{try{const s=await Promise.all(r.map(C));e(o=>({attachments:[...o.attachments,...s],error:null}))}catch{e({error:v("modal.attachmentReadFailed")})}},removeAttachment:r=>{e(s=>({attachments:s.attachments.filter(o=>o.id!==r)}))},sendMessage:async r=>{const{draft:s,attachments:o,model:d,messages:l}=n(),p=s.trim()||(o.length>0?"Use the attached file as context and help with the prompt":"");if(!p&&o.length===0)return;const i={id:y(),role:"user",content:p,attachments:o.length>0?[...o]:void 0};e(c=>({messages:[...c.messages,i],draft:"",attachments:[],loading:!0,error:null}));try{const c=[...l,i].map(x=>({role:x.role,content:x.content,attachments:x.attachments?.map(h=>({kind:h.kind,name:h.name,mimeType:h.mimeType,size:h.size,dataUrl:h.dataUrl,text:h.text}))})),g=await M({model:d,messages:c,context:r}),_={id:y(),role:"assistant",content:g.message.content};e(x=>({messages:[...x.messages,_],loading:!1}))}catch(c){const g=c instanceof Error?c.message:"Prompt builder request failed";e({loading:!1,error:g})}}}));function k(e){return e?.filename??e?.url??e?.image??null}function F(e){const n=e.split(/[\\/]/).pop()??e;return n.length<=32?n:`${n.slice(0,14)}...${n.slice(-12)}`}function K(){const e=m(i=>i.scope),n=m(i=>i.clearImageScope),r=u(i=>i.currentImage),s=u(i=>i.history),{t:o}=f();if(e.kind==="draft")return t.jsx("span",{className:"prompt-builder__scope",children:o("promptBuilder.scopeDraft")});const l=k(r)===e.imageKey?r:s.find(i=>k(i)===e.imageKey)??null;if(!l)return t.jsx("span",{className:"prompt-builder__scope",children:o("promptBuilder.scopeDraft")});const p=o("promptBuilder.scopeImage",{name:F(e.imageKey)||o("promptBuilder.scopeImageFallback")});return t.jsxs("div",{className:"prompt-builder__scope-card",children:[t.jsx("img",{className:"prompt-builder__scope-thumb",src:l.thumb||l.url||l.image,alt:""}),t.jsx("span",{className:"prompt-builder__scope-name",children:p}),t.jsx("button",{type:"button",className:"prompt-builder__scope-remove",onClick:n,"aria-label":o("promptBuilder.removeScopeImage"),title:o("promptBuilder.removeScopeImage"),children:"×"})]})}const D=["gpt-5.6-luna","gpt-5.6-terra","gpt-5.6-sol","gpt-5.5","gpt-5.4","gpt-5.4-mini"],$=D.map(e=>({value:e,label:e}));function R(){const e=m(s=>s.model),n=m(s=>s.setModel),{t:r}=f();return t.jsx(T,{className:"prompt-builder__model-picker",items:$,value:e,onChange:n,ariaLabel:r("promptBuilder.model"),portal:!0})}const w={"Brief Intent Summary":"summary","Final Prompt - Korean":"ko","Final Prompt - English":"en",Notes:"notes"},z=/^(Brief Intent Summary|Final Prompt - Korean|Final Prompt - English|Notes):\s*(.*)$/gim;function U(e){const n=e.trim();return(n.match(/^```(?:[a-zA-Z0-9_-]+)?\s*([\s\S]*?)\s*```$/)?.[1]??n).trim()}function L(e){const n={},r=Array.from(e.matchAll(z));for(let s=0;s<r.length;s+=1){const o=r[s],d=o[1]??"",l=w[d];if(!l||typeof o.index!="number")continue;const p=o[2]?.trim()??"",i=o.index+o[0].length,c=r[s+1]?.index??e.length,g=U([p,e.slice(i,c)].filter(Boolean).join(`
|
|
2
|
-
`));g&&(n[l]=g)}return n}function O(e){const n=L(e),r=[];return n.ko&&r.push({language:"ko",heading:"Final Prompt - Korean",text:n.ko}),n.en&&r.push({language:"en",heading:"Final Prompt - English",text:n.en}),r.length===0?null:{summary:n.summary,prompts:r,notes:n.notes}}function q({messageId:e,prompt:n}){const r=u(c=>c.setPrompt),s=u(c=>c.insertPromptToComposer),o=u(c=>c.showToast),{t:d}=f(),l=n.language==="ko"?d("promptBuilder.finalKoreanPrompt"):d("promptBuilder.finalEnglishPrompt"),p=()=>{r(n.text),o(d("promptBuilder.applied"))},i=()=>{s({id:`builder_${e}_${n.language}`,name:l,text:n.text,placement:"after"}),o(d("promptBuilder.inserted"))};return t.jsxs("section",{className:"prompt-builder__structured-card","aria-label":l,children:[t.jsxs("div",{className:"prompt-builder__structured-card-header",children:[t.jsx("strong",{children:l}),t.jsx("span",{children:n.language.toUpperCase()})]}),t.jsx("p",{children:n.text}),t.jsxs("div",{className:"prompt-builder__structured-actions",children:[t.jsx("button",{type:"button",onClick:p,children:d("promptBuilder.applyToPrompt")}),t.jsx("button",{type:"button",onClick:i,children:d("promptBuilder.insertAsBlock")})]})]})}function G(e){return e.kind==="image"?"IMG":e.kind==="text"?"TXT":"FILE"}function H({message:e}){const{t:n}=f(),r=e.role==="assistant"?O(e.content):null;return t.jsxs("article",{className:`prompt-builder__message prompt-builder__message--${e.role}`,children:[t.jsx("div",{className:"prompt-builder__message-role",children:e.role==="user"?n("promptBuilder.user"):n("promptBuilder.assistant")}),r?t.jsxs("div",{className:"prompt-builder__structured-prompts",children:[r.summary?t.jsx("p",{className:"prompt-builder__structured-summary",children:r.summary}):null,r.prompts.map(s=>t.jsx(q,{messageId:e.id,prompt:s},`${e.id}-${s.language}`)),r.notes?t.jsx("p",{className:"prompt-builder__structured-notes",children:r.notes}):null]}):t.jsx("p",{children:e.content}),e.attachments&&e.attachments.length>0?t.jsx("div",{className:"prompt-builder__message-attachments",children:e.attachments.map(s=>t.jsxs("span",{className:"prompt-builder__message-attachment",children:[s.kind==="image"&&s.dataUrl?t.jsx("img",{src:s.dataUrl,alt:""}):t.jsx("span",{children:G(s)}),t.jsx("em",{children:s.name})]},s.id))}):null]})}function X(){const e=m(o=>o.messages),n=m(o=>o.loading),r=j.useRef(null),{t:s}=f();return j.useEffect(()=>{const o=r.current;o&&(o.scrollTop=o.scrollHeight)},[e.length,n]),t.jsxs("div",{ref:r,className:"prompt-builder__messages",children:[e.length===0&&t.jsx("div",{className:"prompt-builder__empty",children:s("promptBuilder.empty")}),e.map(o=>t.jsx(H,{message:o},o.id)),n&&t.jsxs("div",{className:"prompt-builder__thinking",role:"status","aria-live":"polite",children:[t.jsxs("span",{className:"prompt-builder__thinking-dots","aria-hidden":"true",children:[t.jsx("span",{}),t.jsx("span",{}),t.jsx("span",{})]}),t.jsx("span",{children:s("promptBuilder.thinking")})]})]})}function Q(e){return e.kind==="image"?"IMG":e.kind==="text"?"TXT":"FILE"}function W(){const e=m(s=>s.attachments),n=m(s=>s.removeAttachment),{t:r}=f();return e.length===0?null:t.jsx("div",{className:"prompt-builder__attachments",children:e.map(s=>t.jsxs("span",{className:"prompt-builder__attachment",children:[s.kind==="image"&&s.dataUrl?t.jsx("img",{src:s.dataUrl,alt:""}):t.jsx("span",{children:Q(s)}),t.jsx("em",{children:s.name}),t.jsx("button",{type:"button",onClick:()=>n(s.id),"aria-label":r("promptBuilder.removeAttachment",{name:s.name}),title:r("promptBuilder.removeAttachment",{name:s.name}),children:"×"})]},s.id))})}function Y(){const e=m(a=>a.draft),n=m(a=>a.setDraft),r=m(a=>a.loading),s=m(a=>a.addAttachments),o=m(a=>a.sendMessage),d=m(a=>a.messages),l=m(a=>a.clearMessages),p=m(a=>a.attachments),i=u(a=>a.prompt),c=u(a=>a.insertedPrompts),g=u(a=>a.quality),_=u(a=>a.getResolvedSize),x=u(a=>a.currentImage),h=j.useRef(null),{t:b}=f(),B=()=>{!e.trim()&&p.length===0||r||o({currentPrompt:i,insertedPrompts:c.map(a=>({name:a.name,text:a.text})),settings:{quality:g,size:_()},currentResultPrompt:x?.prompt??null})},N=a=>{a.length!==0&&s(a)},I=a=>{const P=Array.from(a.clipboardData?.files??[]);P.length!==0&&(a.preventDefault(),N(P))};return t.jsxs("div",{className:"prompt-builder__composer",children:[t.jsx(W,{}),t.jsx("textarea",{value:e,placeholder:b("promptBuilder.placeholder"),onChange:a=>n(a.target.value),onPaste:I,onKeyDown:a=>{a.key==="Enter"&&(a.ctrlKey||a.metaKey)&&(a.preventDefault(),B())}}),t.jsx("input",{ref:h,type:"file",multiple:!0,hidden:!0,onChange:a=>{N(Array.from(a.target.files??[])),a.target.value=""}}),t.jsxs("div",{className:"prompt-builder__composer-actions",children:[t.jsx("button",{type:"button",className:"prompt-builder__attach",onClick:()=>h.current?.click(),disabled:r,"aria-label":b("promptBuilder.attach"),title:b("promptBuilder.attach"),children:"+"}),t.jsx("button",{type:"button",className:"prompt-builder__clear",onClick:l,disabled:d.length===0||r,children:b("promptBuilder.clear")}),t.jsx("button",{type:"button",className:"prompt-builder__send",onClick:B,disabled:!e.trim()&&p.length===0||r,children:b(r?"promptBuilder.sending":"promptBuilder.send")})]})]})}function J({variant:e="panel"}){const{t:n}=f();return t.jsxs("section",{className:`prompt-builder prompt-builder--${e}`,"aria-label":n("promptBuilder.title"),children:[t.jsxs("div",{className:"prompt-builder__header",children:[t.jsxs("div",{children:[t.jsx("span",{className:"section-title",children:n("promptBuilder.title")}),t.jsx(K,{})]}),t.jsx("div",{className:"prompt-builder__header-actions",children:t.jsx(R,{})})]}),t.jsx(X,{}),t.jsx(Y,{})]})}export{J as PromptBuilderPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as l,u as K,j as e,v as D,x as ie,y as re,z as le,A as ce,b as S,I as oe,B as H,V as z,C as Q,D as de,O as V,G as Y,E as ue,U as ge,F as me,H as he,J as pe,K as fe,L as xe,M as ye,N as je,P as ve,Q as be,T as _e,W as we,X as Ne,Y as ke}from"./index-Sch70vBs.js";function Se(){const[s,a]=l.useState(null);return l.useEffect(()=>{let i=!1;return(async()=>{try{const n=await fetch("/api/agy/status");if(i)return;const m=await n.json();a(m)}catch{i||a({installed:!1})}})(),()=>{i=!0}},[]),s}function B({provider:s,label:a,placeholder:i,maskedKey:t,source:n,configured:m,onSaved:g}){const{t:o}=K(),[y,p]=l.useState(""),[f,v]=l.useState(!1),[_,h]=l.useState(!1),[r,x]=l.useState(null),[j,C]=l.useState(!1),L=n==="env",w=y.trim().length>0,M=m&&!f&&!w,$=l.useCallback(async()=>{if(w){h(!0),x(null),C(!1);try{const b=await(await fetch(`/api/keys/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:y.trim()})})).json();b.ok?(p(""),v(!1),C(!0),g(),setTimeout(()=>C(!1),3e3)):x(b.error||o("settings.apiKeys.saveFailed"))}catch{x(o("settings.apiKeys.networkError"))}finally{h(!1)}}},[y,s,w,g,o]),O=l.useCallback(async()=>{try{if(!(await fetch(`/api/keys/${s}`,{method:"DELETE"})).ok){x(o("settings.apiKeys.removeFailed"));return}p(""),v(!1),g()}catch{x(o("settings.apiKeys.networkError"))}},[s,g,o]),A=l.useCallback(()=>{m&&v(!0)},[m]),P=l.useCallback(()=>{w||v(!1)},[w]);return e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("p",{className:"settings-eyebrow",children:o(L?"settings.apiKeys.envSource":"settings.apiKeys.configSource")}),e.jsx("h4",{children:a}),e.jsxs("div",{className:"api-key-input-group",children:[M?e.jsx("input",{type:"text",className:"api-key-input is-masked",value:t||"●●●●●●",readOnly:!0,onFocus:A,onClick:A}):e.jsx("input",{type:"password",className:`api-key-input${r?" is-invalid":""}`,placeholder:i,value:y,onChange:c=>{p(c.target.value),x(null)},onBlur:P,readOnly:!1,autoComplete:"off",autoFocus:f,spellCheck:!1,"data-1p-ignore":!0,"data-lpignore":"true","data-form-type":"other"}),e.jsxs("div",{className:"api-key-actions",children:[e.jsx("button",{type:"button",className:"settings-action-btn",onClick:$,disabled:!w||_,children:o(_?"settings.apiKeys.saving":j?"settings.apiKeys.saved":"settings.apiKeys.save")}),m&&!L&&e.jsx("button",{type:"button",className:"settings-action-btn settings-action-btn--danger",onClick:O,children:o("settings.apiKeys.remove")})]})]}),r&&e.jsx("p",{className:"api-key-error",children:r})]}),e.jsxs("div",{className:`settings-status${m?" is-ok":""}`,children:[e.jsx("span",{"aria-hidden":"true"}),o(m?"settings.apiKeys.status.valid":"settings.apiKeys.status.notConfigured")]})]})}function Ce({configured:s,maskedKey:a,source:i,onSaved:t}){const{t:n}=K(),[m,g]=l.useState(""),[o,y]=l.useState(!1),[p,f]=l.useState(!1),[v,_]=l.useState(null),[h,r]=l.useState(!1),x=i==="env",j=m.trim().length>0,C=s&&!o&&!j,L=l.useCallback(async()=>{if(j){f(!0),_(null),r(!1);try{const A=await(await fetch("/api/keys/vertex",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({serviceAccountJson:m.trim()})})).json();A.ok?(g(""),y(!1),r(!0),t(),setTimeout(()=>r(!1),3e3)):_(A.error||n("settings.apiKeys.saveFailed"))}catch{_(n("settings.apiKeys.networkError"))}finally{f(!1)}}},[m,j,t,n]),w=l.useCallback(async()=>{try{if(!(await fetch("/api/keys/vertex",{method:"DELETE"})).ok){_(n("settings.apiKeys.removeFailed"));return}g(""),y(!1),t()}catch{_(n("settings.apiKeys.networkError"))}},[t,n]),M=l.useCallback(()=>{s&&!x&&y(!0)},[s,x]),$=l.useCallback(()=>{j||y(!1)},[j]);return e.jsxs("div",{className:"vertex-json-section",children:[e.jsx("p",{className:"settings-eyebrow",children:n(x?"settings.apiKeys.envSource":"settings.apiKeys.configSource")}),s&&a&&e.jsx("p",{className:"vertex-project-id",children:a}),C?e.jsx("textarea",{className:"vertex-json-textarea is-masked",value:`●●● (${n("settings.apiKeys.configuredReplace")})`,readOnly:!0,onFocus:M,onClick:M}):e.jsx("textarea",{className:`vertex-json-textarea${v?" is-invalid":""}`,placeholder:n("settings.apiKeys.vertex.placeholder"),value:m,onChange:O=>{g(O.target.value),_(null)},onBlur:$,readOnly:x,autoFocus:o,spellCheck:!1,"data-1p-ignore":!0,"data-lpignore":"true","data-form-type":"other"}),e.jsxs("div",{className:"api-key-actions",style:{marginTop:8},children:[!x&&e.jsx("button",{type:"button",className:"settings-action-btn",onClick:L,disabled:!j||p,children:n(p?"settings.apiKeys.saving":h?"settings.apiKeys.saved":"settings.apiKeys.save")}),s&&!x&&e.jsx("button",{type:"button",className:"settings-action-btn settings-action-btn--danger",onClick:w,children:n("settings.apiKeys.remove")})]}),v&&e.jsx("p",{className:"api-key-error",children:v}),e.jsxs("div",{className:`settings-status${s?" is-ok":""}`,style:{marginTop:8},children:[e.jsx("span",{"aria-hidden":"true"}),n(s?"settings.apiKeys.status.valid":"settings.apiKeys.status.notConfigured")]})]})}function Le({keyStatus:s,onSaved:a}){const{t:i}=K(),t=s.vertex?.configured??!1,n=s.gemini?.configured??!1,m=s.geminiAuthMode==="vertex"?"vertex":"apikey",[g,o]=l.useState(m),[y,p]=l.useState(!1);l.useEffect(()=>{y||o(m)},[m,y]);const f=v=>{p(!0),o(v),fetch("/api/keys/gemini-auth-mode",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:v})}).catch(()=>{})};return e.jsxs("div",{className:"gemini-key-section",children:[e.jsxs("div",{className:"gemini-key-section__header",children:[e.jsx("h5",{children:i("settings.apiKeys.gemini.label")}),e.jsx(D,{value:g,onChange:f,items:[{value:"apikey",label:i("settings.apiKeys.vertex.authModeApiKey")},{value:"vertex",label:i("settings.apiKeys.vertex.authModeVertex")}]})]}),g==="apikey"?e.jsx(B,{provider:"gemini",label:"",placeholder:i("settings.apiKeys.gemini.placeholder"),maskedKey:s.gemini?.maskedKey??null,source:s.gemini?.source??"none",configured:n,onSaved:a}):e.jsx(Ce,{configured:t,maskedKey:s.vertex?.maskedKey??null,source:s.vertex?.source??"none",onSaved:a})]})}function Ee(s){return s>80?"var(--red)":s>50?"var(--amber)":"var(--blue)"}function Ke(s){if(!s)return"";const a=new Date(s);return`${a.getMonth()+1}/${a.getDate()} ${String(a.getHours()).padStart(2,"0")}:${String(a.getMinutes()).padStart(2,"0")}`}function te({window:s}){const a=Ke(s.resetsAt);return e.jsxs("div",{className:"quota-bar",children:[e.jsx("span",{className:"quota-bar__label",children:s.label}),e.jsx("div",{className:"quota-bar__track",children:e.jsx("div",{className:"quota-bar__fill",style:{width:`${Math.min(s.percent,100)}%`,background:Ee(s.percent)}})}),e.jsxs("span",{className:"quota-bar__pct",children:[s.percent,"%"]}),a&&e.jsx("span",{className:"quota-bar__reset",children:a})]})}function ne({provider:s,onComplete:a}){const{t:i}=K(),[t,n]=l.useState({phase:"idle"}),[m,g]=l.useState(!1),o=l.useRef(!1),y=l.useCallback(async()=>{if(!o.current){o.current=!0,n({phase:"starting"});try{const p=await fetch("/api/auth/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:s})});if(!p.ok){const v=await p.json().catch(()=>({error:i("settings.quota.switchFailed")}));n({phase:"error",error:v.error||`HTTP ${p.status}`});return}const f=await p.json();n({phase:"waiting",...f}),window.open(f.verificationUrl,"_blank")}catch(p){o.current=!1,n({phase:"error",error:p.message})}}},[s]);return l.useEffect(()=>{if(t.phase!=="waiting"||!t.sessionId)return;let p=!1;const f=async()=>{try{const h=await(await fetch(`/api/auth/switch/${t.sessionId}`)).json();if(p)return;if(h.status==="complete"){n({phase:"complete"}),setTimeout(a,1e3);return}if(h.status==="error"||h.status==="expired"){n({phase:"error",error:h.error||h.status});return}}catch{}p||setTimeout(f,3e3)},v=setTimeout(f,3e3);return()=>{p=!0,clearTimeout(v)}},[t.phase,t.sessionId,a]),t.phase==="idle"?e.jsx("button",{type:"button",className:"settings-action-btn",style:{width:"100%",marginTop:"6px"},onClick:y,children:i("settings.quota.switchAccount",{provider:s==="grok"?"Grok":"Codex"})}):t.phase==="starting"?e.jsx("div",{className:"quota-card__hint",style:{textAlign:"center",marginTop:"6px"},children:i("settings.quota.startingLogin")}):t.phase==="waiting"?e.jsxs("div",{style:{marginTop:"6px",padding:"8px",background:"var(--surface, #f5f5f5)",borderRadius:"var(--r-sm)",fontSize:"12px"},children:[e.jsx("div",{style:{textAlign:"center",marginBottom:"4px"},children:i("settings.quota.enterCode")}),e.jsx("div",{style:{textAlign:"center",fontSize:"18px",fontWeight:700,fontFamily:"monospace",letterSpacing:"2px",margin:"6px 0"},children:t.userCode}),t.verificationUrl&&e.jsxs("div",{style:{display:"flex",gap:"4px",margin:"6px 0"},children:[e.jsx("button",{type:"button",className:"settings-action-btn",style:{flex:1,fontSize:"11px"},onClick:()=>{o.current=!1,y()},children:i("settings.quota.retry")}),e.jsx("button",{type:"button",className:"settings-action-btn",style:{flex:1,fontSize:"11px"},onClick:()=>{navigator.clipboard?.writeText(t.verificationUrl).then(()=>{g(!0),setTimeout(()=>g(!1),2e3)})},children:i(m?"settings.quota.copied":"settings.quota.copyLink")})]}),e.jsx("div",{style:{textAlign:"center",color:"var(--text-dim, #888)",fontSize:"11px"},children:i("settings.quota.waitingApproval")})]}):t.phase==="complete"?e.jsx("div",{className:"quota-card__hint",style:{textAlign:"center",marginTop:"6px",color:"var(--green)"},children:i("settings.quota.switchComplete")}):t.phase==="error"?e.jsxs("div",{style:{marginTop:"6px"},children:[e.jsx("div",{className:"quota-card__hint",style:{color:"var(--red)",marginBottom:"4px"},children:t.error||i("settings.quota.switchFailed")}),e.jsx("button",{type:"button",className:"settings-action-btn",style:{width:"100%",fontSize:"11px"},onClick:()=>{o.current=!1,n({phase:"idle"})},children:i("settings.quota.tryAgain")})]}):null}function Te(){const[s,a]=l.useState(null),[i,t]=l.useState(!0),n=l.useCallback(()=>{t(!0),fetch("/api/quota").then(m=>m.json()).then(a).catch(()=>a(null)).finally(()=>t(!1))},[]);return l.useEffect(()=>{const m=setTimeout(n,1500);return()=>clearTimeout(m)},[n]),{data:s,loading:i,refreshQuota:n}}function Ie({data:s,loading:a,onRefresh:i}){const{t}=K(),n=s?.codex,m=n?.windows&&n.windows.length>0,g=n?.account?[n.account.email,n.account.plan].filter(Boolean).join(" · "):null;return e.jsxs("div",{className:"quota-card",children:[g?e.jsx("div",{className:"quota-card__header",children:e.jsx("span",{className:"quota-card__account",children:g})}):null,a?e.jsx("span",{className:"quota-card__loading",children:t("common.loading")}):m?n.windows.map(o=>e.jsx(te,{window:o},o.label)):n?.authenticated===!1?e.jsx("span",{className:"quota-card__hint",children:t("settings.quota.codexNotLoggedIn")}):n?.error?e.jsx("span",{className:"quota-card__hint",children:t("settings.quota.fetchError")}):e.jsx("span",{className:"quota-card__hint",children:t("settings.quota.noData")}),e.jsx(ne,{provider:"codex",onComplete:i})]})}function Me({data:s,loading:a,onRefresh:i}){const{t}=K(),n=s?.grok,m=n?.windows&&n.windows.length>0,g=n?.account?[n.account.email,n.account.plan].filter(Boolean).join(" · "):null;return e.jsxs("div",{className:"quota-card",children:[g||n?.billing?e.jsxs("div",{className:"quota-card__header",style:{display:"flex",alignItems:"center"},children:[g&&e.jsx("span",{className:"quota-card__account",children:g}),n?.billing&&e.jsxs("span",{style:{marginLeft:"auto",fontSize:"11px",color:"var(--text-dim, #888)",whiteSpace:"nowrap"},children:["$",n.billing.usedUsd.toFixed(1),"/$",n.billing.limitUsd]})]}):null,a?e.jsx("span",{className:"quota-card__loading",children:t("common.loading")}):m?n.windows.map(o=>e.jsx(te,{window:o},o.label)):n?.authenticated===!1?e.jsx("span",{className:"quota-card__hint",children:t("settings.quota.codexNotLoggedIn")}):e.jsx("a",{href:"https://grok.com/?_s=usage",target:"_blank",rel:"noopener noreferrer",className:"settings-action-btn",children:t("settings.quota.grokUsageLink")}),e.jsx(ne,{provider:"grok",onComplete:i})]})}function X(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M22.282 9.821a5.985 5.985 0 0 0-.516-4.91 6.046 6.046 0 0 0-6.51-2.9A6.065 6.065 0 0 0 4.981 4.18a5.998 5.998 0 0 0-3.998 2.9 6.049 6.049 0 0 0 .743 7.097 5.98 5.98 0 0 0 .51 4.911 6.051 6.051 0 0 0 6.515 2.9A5.985 5.985 0 0 0 13.26 24a6.056 6.056 0 0 0 5.772-4.206 5.99 5.99 0 0 0 3.997-2.9 6.056 6.056 0 0 0-.747-7.073zM13.26 22.43a4.476 4.476 0 0 1-2.876-1.04l.141-.081 4.779-2.758a.795.795 0 0 0 .392-.681v-6.737l2.02 1.168a.071.071 0 0 1 .038.052v5.583a4.504 4.504 0 0 1-4.494 4.494zM3.6 18.304a4.47 4.47 0 0 1-.535-3.014l.142.085 4.783 2.759a.771.771 0 0 0 .78 0l5.843-3.369v2.332a.08.08 0 0 1-.033.062L9.74 19.95a4.5 4.5 0 0 1-6.14-1.646zM2.34 7.896a4.485 4.485 0 0 1 2.366-1.973V11.6a.766.766 0 0 0 .388.676l5.815 3.355-2.02 1.168a.076.076 0 0 1-.071 0l-4.83-2.786A4.504 4.504 0 0 1 2.34 7.872zm16.597 3.855l-5.833-3.387L15.119 7.2a.076.076 0 0 1 .071 0l4.83 2.791a4.494 4.494 0 0 1-.676 8.105v-5.678a.79.79 0 0 0-.407-.667zm2.01-3.023l-.141-.085-4.774-2.782a.776.776 0 0 0-.785 0L9.409 9.23V6.897a.066.066 0 0 1 .028-.061l4.83-2.787a4.5 4.5 0 0 1 6.68 4.66zm-12.64 4.135l-2.02-1.164a.08.08 0 0 1-.038-.057V6.075a4.5 4.5 0 0 1 7.375-3.453l-.142.08L8.704 5.46a.795.795 0 0 0-.393.681zm1.097-2.365l2.602-1.5 2.607 1.5v2.999l-2.597 1.5-2.612-1.5z"})})}function Oe(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd","aria-hidden":"true",children:e.jsx("path",{d:"M9.27 15.29l7.978-5.897c.391-.29.95-.177 1.137.272.98 2.369.542 5.215-1.41 7.169-1.951 1.954-4.667 2.382-7.149 1.406l-2.711 1.257c3.889 2.661 8.611 2.003 11.562-.953 2.341-2.344 3.066-5.539 2.388-8.42l.006.007c-.983-4.232.242-5.924 2.75-9.383.06-.082.12-.164.179-.248l-3.301 3.305v-.01L9.267 15.292M7.623 16.723c-2.792-2.67-2.31-6.801.071-9.184 1.761-1.763 4.647-2.483 7.166-1.425l2.705-1.25a7.808 7.808 0 00-1.829-1A8.975 8.975 0 005.984 5.83c-2.533 2.536-3.33 6.436-1.962 9.764 1.022 2.487-.653 4.246-2.34 6.022-.599.63-1.199 1.259-1.682 1.925l7.62-6.815"})})}function Ae(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M12 24A14.304 14.304 0 0 0 0 12 14.304 14.304 0 0 0 12 0a14.305 14.305 0 0 0 12 12 14.305 14.305 0 0 0-12 12"})})}function Z(s,a){return s(a==="ready"?"settings.account.status.ready":a==="auth_required"?"settings.account.status.authRequired":a==="starting"?"settings.account.status.starting":a==="offline"?"settings.account.status.offline":a==="no_image_model"?"settings.account.status.noImageModel":a==="error"?"settings.account.status.error":"settings.account.status.checking")}function ee(s){return s==="ready"?"ok":s==="error"||s==="offline"?"err":"warn"}function Re(){const{t:s}=K(),a=ie(),i=re(),t=Se(),{data:n,error:m}=le(),{data:g,mutate:o}=ce(),y=Te(),[p,f]=l.useState(!1),v=n?.apiKeySource==="env"||n?.apiKeySource==="config"||n?.apiKeyValid===!0,_=n?.apiKeySource==="config"?s("settings.account.apiSourceConfig"):s("settings.account.apiSourceEnv"),h=n?.apiKeyValid===!0;return e.jsxs(e.Fragment,{children:[e.jsxs("article",{className:"provider-card",children:[e.jsxs("div",{className:"provider-card__head",children:[e.jsx("span",{className:"provider-card__brand",children:e.jsx(X,{})}),e.jsx("h4",{children:s("settings.account.oauthTitle")}),e.jsx("span",{className:"provider-card__eyebrow",children:s("settings.account.primaryEyebrow")}),e.jsx("span",{className:`provider-chip provider-chip--${ee(a?.status)}`,children:Z(s,a?.status)})]}),e.jsx("div",{className:"settings-row__copy",children:e.jsx("p",{children:s("settings.account.oauthBody")})}),e.jsx(Ie,{data:y.data,loading:y.loading,onRefresh:y.refreshQuota})]}),v?e.jsxs("article",{className:"provider-card",children:[e.jsxs("div",{className:"provider-card__head",children:[e.jsx("span",{className:"provider-card__brand",children:e.jsx(X,{})}),e.jsx("h4",{children:s("settings.account.apiTitle")}),e.jsx("span",{className:"provider-card__eyebrow",children:_}),e.jsx("span",{className:`provider-chip provider-chip--${m?"err":h?"ok":"warn"}`,children:s(m?"settings.account.apiUnknown":h?"settings.account.apiReady":"settings.account.apiUnavailable")})]}),e.jsx("div",{className:"settings-row__copy",children:e.jsx("p",{children:s("settings.account.apiBody")})})]}):null,e.jsxs("article",{className:"provider-card",children:[e.jsxs("div",{className:"provider-card__head",children:[e.jsx("span",{className:"provider-card__brand",children:e.jsx(Oe,{})}),e.jsx("h4",{children:s("settings.account.grokTitle")}),e.jsx("span",{className:"provider-card__eyebrow",children:s("settings.account.grokEyebrow")}),e.jsx("span",{className:`provider-chip provider-chip--${ee(i?.status)}`,children:Z(s,i?.status)})]}),e.jsx("div",{className:"settings-row__copy",children:e.jsx("p",{children:s("settings.account.grokBody")})}),e.jsx(Me,{data:y.data,loading:y.loading,onRefresh:y.refreshQuota})]}),e.jsxs("article",{className:"provider-card",children:[e.jsxs("div",{className:"provider-card__head",children:[e.jsx("span",{className:"provider-card__brand",children:e.jsx(Ae,{})}),e.jsx("h4",{children:s("settings.account.agyTitle")}),e.jsx("span",{className:"provider-card__eyebrow",children:s("settings.account.agyEyebrow")}),e.jsx("span",{className:`provider-chip provider-chip--${t?.installed?"ok":"warn"}`,children:t?.installed?s("settings.account.agyInstalled"):s("settings.account.agyMissing")})]}),e.jsxs("div",{className:"settings-row__copy",children:[t?.installed?e.jsx("p",{children:s("settings.account.agyInstalledBody")}):e.jsxs("p",{children:[s("settings.account.agyMissingBody")," ",e.jsx("a",{href:"https://antigravity.google/docs/cli-install",target:"_blank",rel:"noopener noreferrer",children:s("settings.account.agyMissingLink")})]}),e.jsx("p",{style:{fontSize:"12px",color:"var(--text-dim, #888)",marginTop:"4px"},children:s("settings.account.agyFineprint")})]})]}),g&&e.jsxs("article",{className:"settings-row settings-accordion",children:[e.jsxs("button",{type:"button",className:"settings-accordion__trigger",onClick:()=>f(!p),children:[e.jsx("h4",{children:s("settings.apiKeys.accordionTitle")}),e.jsx("span",{className:`settings-accordion__arrow${p?" is-open":""}`,children:"▼"})]}),p&&e.jsxs("div",{className:"settings-accordion__body",children:[e.jsx(B,{provider:"openai",label:s("settings.apiKeys.openai.label"),placeholder:s("settings.apiKeys.openai.placeholder"),maskedKey:g.openai?.maskedKey??null,source:g.openai?.source??"none",configured:g.openai?.configured??!1,onSaved:o}),e.jsx(B,{provider:"xai",label:s("settings.apiKeys.xai.label"),placeholder:s("settings.apiKeys.xai.placeholder"),maskedKey:g.xai?.maskedKey??null,source:g.xai?.source??"none",configured:g.xai?.configured??!1,onSaved:o}),e.jsx(B,{provider:"atlascloud",label:s("settings.apiKeys.atlascloud.label"),placeholder:s("settings.apiKeys.atlascloud.placeholder"),maskedKey:g.atlascloud?.maskedKey??null,source:g.atlascloud?.source??"none",configured:g.atlascloud?.configured??!1,onSaved:o}),e.jsx(B,{provider:"minimax",label:s("settings.apiKeys.minimax.label"),placeholder:s("settings.apiKeys.minimax.placeholder"),maskedKey:g.minimax?.maskedKey??null,source:g.minimax?.source??"none",configured:g.minimax?.configured??!1,onSaved:o}),e.jsx(B,{provider:"nai",label:s("settings.apiKeys.nai.label"),placeholder:s("settings.apiKeys.nai.placeholder"),maskedKey:g.nai?.maskedKey??null,source:g.nai?.source??"none",configured:g.nai?.configured??!1,onSaved:o}),e.jsx(Le,{keyStatus:g,onSaved:o})]})]})]})}function $e({variant:s}){const{t:a}=K(),[i,t]=l.useState(!1),n=l.useRef(null),m=l.useRef(null),g=l.useRef(null),o=l.useRef([]),[y,p]=l.useState({top:0,left:12,width:280,maxHeight:480}),f=S(c=>c.imageModel),v=S(c=>c.provider),_=S(c=>c.setImageModel),h=S(c=>c.setProvider),r=S(c=>c.videoModelSelected),x=S(c=>c.selectVideoModel),j=S(c=>c.reasoningEffort),C=S(c=>c.setReasoningEffort),L=s==="settings"?"settings-image-model":"sidebar-image-model",w=oe,M=w.find(c=>c.value===f&&(!c.providerHint||c.providerHint===v))??w.find(c=>c.value===f)??w[0],$=H.find(c=>c.value===j)??H[0],O=()=>o.current.filter(c=>c!==null),A=c=>{const b=O();if(b.length===0)return;const u=(c+b.length)%b.length;b[u]?.focus()},P=c=>{const b=O();if(b.length===0)return;const u=b.findIndex(T=>T===document.activeElement),N=b.length-1;if(c.key==="ArrowDown"||c.key==="ArrowRight"){c.preventDefault(),A(u>=0?u+1:0);return}if(c.key==="ArrowUp"||c.key==="ArrowLeft"){c.preventDefault(),A(u>=0?u-1:N);return}if(c.key==="Home"){c.preventDefault(),A(0);return}if(c.key==="End"){c.preventDefault(),A(N);return}c.key==="Escape"&&(c.preventDefault(),t(!1),m.current?.focus())};if(l.useEffect(()=>{if(s!=="sidebar"||!i)return;const c=u=>{const N=u.target;N instanceof Node&&(n.current?.contains(N)||g.current?.contains(N)||t(!1))},b=u=>{u.key==="Escape"&&t(!1)};return document.addEventListener("pointerdown",c),document.addEventListener("keydown",b),()=>{document.removeEventListener("pointerdown",c),document.removeEventListener("keydown",b)}},[i,s]),l.useLayoutEffect(()=>{if(s!=="sidebar"||!i)return;(()=>{const N=m.current?.getBoundingClientRect();if(N){const R=Math.min(280,Math.max(218,window.innerWidth-24)),F=N.right-R,W=window.innerWidth-R-12,d=Math.max(12,Math.min(F,W)),k=N.bottom+7,E=Math.max(160,window.innerHeight-k-12);p({top:k,left:d,width:R,maxHeight:E})}})();const b=N=>{N&&g.current?.contains(N.target)||t(!1)},u=document.querySelector(".sidebar__scroll");return u?.addEventListener("scroll",b,{passive:!0}),window.addEventListener("scroll",b,!0),window.addEventListener("resize",b),()=>{u?.removeEventListener("scroll",b),window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",b)}},[i,s]),l.useEffect(()=>{if(s!=="sidebar"||!i)return;const c=w.findIndex(u=>u.value===f),b=requestAnimationFrame(()=>{A(c>=0?c:0)});return()=>cancelAnimationFrame(b)},[f,w,i,s]),s==="sidebar"){const c=r?z.find(u=>u.value===r)?.shortLabel??z[0].shortLabel:M.shortLabel.split(" ")[0],b=Q(f)?M.shortLabel.split(" ")[1]||"":$.shortLabel;return e.jsxs("div",{ref:n,className:"image-model-select image-model-select--sidebar",children:[e.jsxs("button",{ref:m,id:L,type:"button",className:"image-model-select__trigger image-model-select__trigger--pill","aria-haspopup":"menu","aria-expanded":i,"aria-label":a("sidebar.quickSettingsAria",{model:c,effort:b}),onClick:()=>t(u=>!u),children:[e.jsxs("span",{className:"image-model-select__trigger-top",children:[e.jsx("span",{className:"image-model-select__trigger-model",children:c}),e.jsx("span",{className:"image-model-select__trigger-chevron","aria-hidden":"true",children:"▾"})]}),e.jsx("span",{className:"image-model-select__trigger-effort",children:b})]}),i?de.createPortal(e.jsxs("div",{ref:g,className:"image-model-select__menu",role:"menu","aria-label":a("sidebar.quickSettingsMenu"),onKeyDown:P,style:{position:"fixed",top:y.top,left:y.left,width:y.width,maxHeight:y.maxHeight,overflowY:"auto",zIndex:160},children:[e.jsxs("div",{className:"image-model-select__section",role:"group","aria-label":a("sidebar.imageSectionLabel"),children:[e.jsx("div",{className:"image-model-select__section-title",children:a("sidebar.imageSectionLabel")}),e.jsx("div",{className:"image-model-select__subsection-title",children:a("sidebar.gptImageSubLabel")}),V.map((u,N)=>e.jsxs("button",{ref:T=>{o.current[N]=T},type:"button",className:`image-model-select__item${u.value===f&&!r?" is-active":""}`,role:"menuitemradio","aria-checked":u.value===f&&!r,tabIndex:-1,onClick:()=>{_(u.value),t(!1)},children:[e.jsx("span",{children:u.shortLabel}),e.jsx("small",{children:a(u.fullLabelKey)})]},u.value)),e.jsx("div",{className:"image-model-select__subsection-title",children:a("sidebar.grokImageSubLabel")}),Y.map((u,N)=>e.jsxs("button",{ref:T=>{o.current[V.length+N]=T},type:"button",className:`image-model-select__item${u.value===f&&!r?" is-active":""}`,role:"menuitemradio","aria-checked":u.value===f&&!r,tabIndex:-1,onClick:()=>{_(u.value),t(!1)},children:[e.jsx("span",{children:u.shortLabel}),e.jsx("small",{children:a(u.fullLabelKey)})]},u.value)),e.jsx("div",{className:"image-model-select__subsection-title",children:a("sidebar.geminiImageSubLabel")}),ue.map((u,N)=>{const T=u.providerHint,R=u.value===f&&T===v&&!r;return e.jsxs("button",{ref:F=>{o.current[V.length+Y.length+N]=F},type:"button",className:`image-model-select__item${R?" is-active":""}`,role:"menuitemradio","aria-checked":R,tabIndex:-1,onClick:()=>{T&&h(T),_(u.value),t(!1)},children:[e.jsx("span",{children:u.shortLabel}),e.jsx("small",{children:a(u.fullLabelKey)})]},`${u.value}-${T||N}`)})]}),e.jsxs("div",{className:"image-model-select__section",role:"group","aria-label":a("sidebar.videoSectionLabel"),children:[e.jsx("div",{className:"image-model-select__section-title",children:a("sidebar.videoSectionLabel")}),z.map((u,N)=>e.jsxs("button",{ref:T=>{o.current[w.length+N]=T},type:"button",className:`image-model-select__item${r===u.value?" is-active":""}`,role:"menuitemradio","aria-checked":r===u.value,tabIndex:-1,onClick:()=>{x(u.value),t(!1)},children:[e.jsx("span",{children:u.shortLabel}),e.jsx("small",{children:a(u.fullLabelKey)})]},u.value))]}),!Q(f)&&e.jsxs("details",{className:"image-model-select__section image-model-select__collapsible",children:[e.jsxs("summary",{className:"image-model-select__section-title image-model-select__section-title--toggle",children:[a("sidebar.reasoningLabel"),e.jsx("span",{className:"image-model-select__chevron","aria-hidden":"true",children:"▸"})]}),e.jsx("div",{role:"group","aria-label":a("sidebar.reasoningLabel"),children:H.map((u,N)=>e.jsxs("button",{ref:T=>{o.current[w.length+z.length+N]=T},type:"button",className:`image-model-select__item${u.value===j?" is-active":""}`,role:"menuitemradio","aria-checked":u.value===j,tabIndex:-1,onClick:()=>{C(u.value),t(!1)},children:[e.jsx("span",{children:u.shortLabel}),e.jsx("small",{children:a(u.fullLabelKey)})]},u.value))})]})]}),document.body):null]})}return e.jsx("div",{className:"image-model-select image-model-select--settings",children:e.jsx(D,{id:L,value:f,onChange:c=>_(c),items:[...w.map(c=>({value:c.value,label:a(c.fullLabelKey)})),...ge.map(c=>({value:c.value,label:a(c.fullLabelKey),disabled:!0}))]})})}function Pe(){const{t:s}=K(),a=S(n=>n.reasoningEffort),i=S(n=>n.setReasoningEffort),t=H.map(n=>({value:n.value,label:s(n.fullLabelKey)}));return e.jsx("div",{className:"ctl-select-wrap settings-reasoning-effort",children:e.jsx(D,{id:"settings-reasoning-effort",items:t,value:a,onChange:i})})}const qe={ko:"KO",en:"EN","zh-Hant":"正體","zh-Hans":"简体"};function Be(){const{t:s,locale:a}=K(),i=S(t=>t.setLocale);return e.jsx("div",{className:"lang-toggle",role:"group","aria-label":s("language.label"),children:me.map(t=>e.jsx("button",{type:"button",className:`lang-toggle__btn ${a===t?"is-active":""}`,onClick:()=>i(t),"aria-pressed":a===t,title:s(`language.${t}`),children:e.jsx("span",{className:"lang-toggle__label",children:qe[t]})},t))})}const De=["light","dark","system"];function Fe(){const{t:s}=K(),{mode:a,setMode:i}=he();return e.jsx("div",{className:"lang-toggle",role:"group","aria-label":s("settings.theme.label"),children:De.map(t=>e.jsx("button",{type:"button",className:`lang-toggle__btn ${a===t?"is-active":""}`,onClick:()=>i(t),"aria-pressed":a===t,title:s(`settings.theme.${t}`),children:e.jsx("span",{className:"lang-toggle__label",children:s(`settings.theme.${t}`)})},t))})}const ze=["rail","horizontal","sidebar"];function Ge(){const{t:s}=K(),a=S(t=>t.historyStripLayout),i=S(t=>t.setHistoryStripLayout);return e.jsx(pe,{className:"history-layout-toggle",items:ze.map(t=>({value:t,label:s(`settings.appearance.historyStripLayout.${t}`)})),value:a,onChange:i})}const Ue=[{value:"default",labelKey:"workspace.defaultLabel",descKey:"workspace.defaultDesc"},{value:"prompt-studio",labelKey:"workspace.promptStudioLabel",descKey:"workspace.promptStudioDesc"}];function He(){const s=S(t=>t.workspaceProfile),a=S(t=>t.setWorkspaceProfile),{t:i}=K();return e.jsx("div",{className:"settings-field",children:e.jsx(D,{id:"workspace-profile-select",value:s,onChange:t=>a(t),ariaLabel:i("workspace.profileLabel"),items:Ue.map(t=>({value:t.value,label:i(t.labelKey)}))})})}function We(){const{t:s}=K(),[a,i]=l.useState(null);l.useEffect(()=>{fetch("/api/config/grok-planner").then(n=>n.json()).then(i).catch(()=>{})},[]);const t=async n=>{try{await fetch("/api/config/grok-planner",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:n})}),i(m=>m?{...m,model:n}:null)}catch{}};return a?e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.grokPlanner.title")}),e.jsx("p",{children:s("settings.grokPlanner.body")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(D,{items:a.options.map(n=>({value:n,label:n})),value:a.model,onChange:n=>{t(n)},ariaLabel:s("settings.grokPlanner.title")})})]}):null}function Ve(s){return s==="connected"?"ok":s==="error"||s==="offline"?"err":"warn"}function Je(s){const a=s.status.snapshotDiff;return a?a.drifted.length+a.missing.length+a.added.length:0}function Qe(){const{t:s}=K(),{providers:a,loading:i,error:t,refresh:n}=fe(),[m,g]=l.useState(null),[o,y]=l.useState(!1),[p,f]=l.useState(null),v=async()=>{if(!o){y(!0);try{await n()}finally{y(!1)}}},_=async(h,r)=>{g({provider:h.id,action:r}),f(null);try{r==="connect"?await xe(h.id):r==="refresh"?await ye(h.id):await je(h.id),await n()}catch(x){const j=x instanceof Error&&x.message==="MCP_POPUP_BLOCKED"?s("mcp.popupBlocked"):s("mcp.connectionActionFailed");f({provider:h.id,message:j})}finally{g(null)}};return e.jsxs("div",{"aria-labelledby":"mcp-provider-connections-title",children:[e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{id:"mcp-provider-connections-title",children:s("mcp.connectionsTitle")}),e.jsx("p",{children:s("mcp.connectionsBody")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx("button",{type:"button",className:"settings-action-btn",onClick:()=>{v()},disabled:i||o,"aria-busy":i||o,children:s(i||o?"mcp.loadingProviders":"mcp.refreshList")})})]}),t?e.jsx("p",{role:"alert",className:"settings-row__microcopy",children:s("mcp.providersLoadFailed")}):null,a.map(h=>{const r=h.status.state,x=!h.enabled||h.executable===!1,j=m?.provider===h.id?m.action:null,C=j!==null,L=Je(h);return e.jsxs("article",{className:"provider-card",children:[e.jsxs("div",{className:"provider-card__head",children:[e.jsx("h4",{children:h.id}),e.jsx("span",{className:"provider-card__eyebrow",children:"MCP"}),e.jsx("span",{className:`provider-chip provider-chip--${Ve(r)}`,children:s(`mcp.status.${r}`)})]}),e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("p",{children:h.endpoint}),e.jsxs("p",{children:[typeof h.status.toolCount=="number"?s("mcp.toolCount",{count:h.status.toolCount}):s("mcp.toolCountUnknown"),L>0?` · ${s("mcp.snapshotChanges",{count:L})}`:""]}),x?e.jsx("p",{className:"settings-row__microcopy",children:h.enabled?h.lockReason??s("mcp.higgsfieldLocked"):s("mcp.disabledProvider")}):h.status.detail?e.jsx("p",{className:"settings-row__microcopy",children:h.status.detail}):null,p?.provider===h.id?e.jsx("p",{role:"alert",className:"settings-row__microcopy",children:p.message}):null]}),e.jsxs("div",{className:"provider-card__head",children:[e.jsx("span",{className:"provider-card__eyebrow",children:s("mcp.billingLabel")}),e.jsx("span",{className:"provider-chip provider-chip--warn",children:s("mcp.billingUnknown")})]}),e.jsx("div",{className:"settings-row__control","aria-live":"polite",children:r==="connected"&&!x?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"settings-action-btn",onClick:()=>{_(h,"refresh")},disabled:C,"aria-busy":j==="refresh",children:s(j==="refresh"?"mcp.refreshingConnection":"mcp.refreshConnection")}),e.jsx("button",{type:"button",className:"settings-action-btn settings-action-btn--danger",onClick:()=>{_(h,"disconnect")},disabled:C,"aria-busy":j==="disconnect",children:s("mcp.disconnect")})]}):e.jsx("button",{type:"button",className:"settings-action-btn",onClick:()=>{_(h,"connect")},disabled:C||x,"aria-busy":j==="connect",title:s(x?"mcp.higgsfieldLocked":"mcp.connectOpensBrowser"),children:s(j==="connect"?"mcp.connecting":"mcp.connect")})})]},h.id)})]})}const Ye=[137,80,78,71,13,10,26,10];async function Xe(s){const a=new Uint8Array(await s.arrayBuffer());if(Ye.every((t,n)=>a[n]===t)){let t="";for(const n of a)t+=String.fromCharCode(n);return{pngBase64:btoa(t)}}return{graph:JSON.parse(new TextDecoder().decode(a))}}const se=["prompt","negativePrompt","width","height","seed","refImage","output"];function G(s){return s.input?`${s.node}.${s.input}`:s.node}function Ze(){const{t:s}=K(),[a,i]=l.useState([]),[t,n]=l.useState(!0),[m,g]=l.useState(null),[o,y]=l.useState(null),[p,f]=l.useState({}),[v,_]=l.useState(""),[h,r]=l.useState(""),[x,j]=l.useState("image"),[C,L]=l.useState("http://127.0.0.1:8188"),[w,M]=l.useState({kind:"idle"}),[$,O]=l.useState(null),[A,P]=l.useState(!1),c=l.useRef(null),b=l.useCallback(async()=>{n(!0);try{const d=await ve();i(d.workflows)}catch{i([])}finally{n(!1)}},[]);l.useEffect(()=>{b()},[b]);const u=async d=>{if(d){O(null);try{const k=await Xe(d),E=await _e(k);y(k),g(E),j(E.mediaKind??"image");const q={};for(const I of E.candidates)I.unambiguous&&(q[I.field]=G(I));f(q),v||_(d.name.replace(/\.[^.]+$/,"").toLowerCase().replace(/[^a-z0-9_-]+/g,"-").slice(0,64))}catch(k){g(null),y(null),O(k instanceof Error?k.message:s("comfy.inspectFailed"))}}},N=async()=>{M({kind:"idle"});try{const d=await we(C);M(d.health.ok?{kind:"ok",...d.health.version?{detail:d.health.version}:{}}:{kind:"unreachable"})}catch(d){M({kind:"invalid",detail:d instanceof Error?d.message:void 0})}},T=(m?.candidates??[]).filter(d=>!d.unambiguous).map(d=>d.field).filter((d,k,E)=>E.indexOf(d)===k).filter(d=>!p[d]),R=!!(m&&v&&p.prompt&&p.output&&T.length===0&&!A),F=async()=>{if(!(!R||!o)){P(!0),O(null);try{const d={};for(const k of se){const E=p[k];if(!E)continue;if(k==="output"){d.output={node:E};continue}const q=E.indexOf(".");d[k]={node:E.slice(0,q),input:E.slice(q+1)}}await Ne({...o,id:v,...h?{label:h}:{},origin:C,mediaKind:x,bind:d}),g(null),y(null),f({}),_(""),r(""),j("image"),c.current&&(c.current.value=""),await b()}catch(d){O(d instanceof Error?d.message:s("comfy.registerFailed"))}finally{P(!1)}}},W=async d=>{P(!0);try{await be(d),await b()}catch(k){O(k instanceof Error?k.message:s("comfy.removeFailed"))}finally{P(!1)}};return e.jsxs("div",{"aria-labelledby":"comfy-workflow-manager-title",children:[e.jsx("article",{className:"settings-row",children:e.jsxs("div",{className:"settings-row-main",children:[e.jsx("div",{className:"section-title",id:"comfy-workflow-manager-title",children:s("comfy.workflowsTitle")}),t?e.jsx("div",{className:"muted",children:s("comfy.loading")}):null,!t&&a.length===0?e.jsx("div",{className:"muted",children:s("comfy.empty")}):null,a.length>0?e.jsxs("table",{className:"comfy-workflow-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:s("comfy.colId")}),e.jsx("th",{scope:"col",children:s("comfy.colKind")}),e.jsx("th",{scope:"col",children:s("comfy.colOrigin")}),e.jsx("th",{scope:"col",children:s("comfy.colStatus")}),e.jsx("th",{scope:"col",children:e.jsx("span",{className:"sr-only",children:s("comfy.colActions")})})]})}),e.jsx("tbody",{children:a.map(d=>{const k=d.health?.ok===!0,E=`comfy-status-${d.id}`;return e.jsxs("tr",{children:[e.jsx("td",{children:d.label||d.id}),e.jsx("td",{children:s(d.mediaKind==="video"?"comfy.kindVideo":"comfy.kindImage")}),e.jsx("td",{className:"mono",children:d.origin}),e.jsx("td",{id:E,children:e.jsx("span",{className:k?"status-ok":"status-warn",children:s(k?"comfy.statusReady":"comfy.statusOffline")})}),e.jsx("td",{children:e.jsx("button",{type:"button",onClick:()=>{W(d.id)},disabled:A,"aria-describedby":E,children:s("comfy.remove")})})]},d.id)})})]}):null]})}),e.jsx("article",{className:"settings-row",children:e.jsxs("div",{className:"settings-row-main",children:[e.jsx("div",{className:"section-title",children:s("comfy.addTitle")}),e.jsxs("div",{className:"comfy-field",children:[e.jsx("label",{htmlFor:"comfy-file",children:s("comfy.fileLabel")}),e.jsx("input",{id:"comfy-file",ref:c,type:"file",accept:".json,.png,application/json,image/png",onChange:d=>{u(d.target.files?.[0])}})]}),e.jsxs("div",{className:"comfy-field",children:[e.jsx("label",{htmlFor:"comfy-origin",children:s("comfy.originLabel")}),e.jsxs("div",{className:"comfy-origin-row",children:[e.jsx("input",{id:"comfy-origin",value:C,onChange:d=>{L(d.target.value),M({kind:"idle"})},spellCheck:!1}),e.jsx("button",{type:"button",onClick:()=>{N()},children:s("comfy.checkOrigin")})]})]}),w.kind==="ok"?e.jsxs("div",{className:"status-ok",children:[s("comfy.originReachable"),w.detail?` (${w.detail})`:""]}):null,w.kind==="unreachable"?e.jsx("div",{className:"status-warn",children:s("comfy.originUnreachable")}):null,w.kind==="invalid"?e.jsx("div",{className:"status-err",children:s("comfy.originInvalid")}):null,m?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"comfy-field",children:[e.jsx("label",{htmlFor:"comfy-id",children:s("comfy.idLabel")}),e.jsx("input",{id:"comfy-id",value:v,onChange:d=>_(d.target.value),spellCheck:!1})]}),e.jsxs("div",{className:"comfy-field",children:[e.jsx("label",{htmlFor:"comfy-label",children:s("comfy.labelLabel")}),e.jsx("input",{id:"comfy-label",value:h,onChange:d=>r(d.target.value)})]}),e.jsxs("div",{className:"comfy-field",children:[e.jsx("label",{htmlFor:"comfy-kind",children:s("comfy.kindLabel")}),e.jsxs("select",{id:"comfy-kind",value:x,onChange:d=>j(d.target.value),children:[e.jsx("option",{value:"image",children:s("comfy.kindImage")}),e.jsx("option",{value:"video",children:s("comfy.kindVideo")})]}),x==="video"?e.jsx("div",{className:"muted",children:s("comfy.videoKindHint")}):null]}),e.jsx("div",{className:"section-title",children:s("comfy.bindTitle")}),m.needsConfirmation?e.jsx("div",{className:"muted",children:s("comfy.bindAmbiguous")}):null,se.map(d=>{const k=m.candidates.filter(I=>I.field===d);if(k.length===0)return null;const E=k.some(I=>!I.unambiguous),q=`comfy-bind-${d}`;return e.jsxs("div",{className:"comfy-bind-row",children:[e.jsx("label",{htmlFor:q,children:s(`comfy.field.${d}`)}),e.jsxs("select",{id:q,value:p[d]??"",onChange:I=>f(ae=>({...ae,[d]:I.target.value})),"aria-invalid":E&&!p[d],children:[e.jsx("option",{value:"",children:s("comfy.choose")}),k.map(I=>e.jsxs("option",{value:G(I),children:[G(I)," — ",I.classType,I.title?` "${I.title}"`:""]},G(I)))]})]},d)}),e.jsx("button",{type:"button",onClick:()=>{F()},disabled:!R,children:s("comfy.register")})]}):null,$?e.jsx("div",{className:"status-err",role:"alert",children:$}):null]})})]})}const U=["providers","workspace","general"];function J({id:s,setRef:a,children:i}){const{t}=K();return e.jsxs("section",{id:s,ref:n=>a(s,n),className:"settings-section","aria-labelledby":`settings-section-${s}`,children:[e.jsx("header",{className:"settings-section__header",children:e.jsx("h3",{id:`settings-section-${s}`,children:t(`settings.sections.${s}.title`)})}),e.jsx("div",{className:"settings-section__body",children:i})]})}function ss(){const{t:s}=K(),a=S(r=>r.activeSettingsSection),i=S(r=>r.setActiveSettingsSection),t=S(r=>r.closeSettings),n=S(r=>r.openReadinessPopup),m=S(r=>r.galleryDefaultScope),g=S(r=>r.setGalleryDefaultScope),o=S(r=>r.provider),y=l.useRef(null),p=l.useRef(null),f=l.useRef(!1),v=l.useRef({providers:null,workspace:null,general:null}),_=(r,x)=>{v.current[r]=x},h=r=>{i(r),f.current=!0;const x=y.current,j=v.current[r];if(x&&j){const C=x.getBoundingClientRect().top,L=j.getBoundingClientRect().top,w=Number.parseFloat(window.getComputedStyle(j).scrollMarginTop)||0;x.scrollTo({top:x.scrollTop+L-C-w,behavior:"auto"})}p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{f.current=!1,p.current=null},120)};return l.useEffect(()=>{const r=x=>{x.key==="Escape"&&t()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[t]),l.useEffect(()=>{const r=y.current;if(!r||typeof IntersectionObserver!="function")return;const x=new IntersectionObserver(j=>{if(f.current)return;const L=j.filter(w=>w.isIntersecting).sort((w,M)=>M.intersectionRatio-w.intersectionRatio)[0]?.target.id;L&&U.includes(L)&&i(L)},{root:r,threshold:[.35,.6]});for(const j of U){const C=v.current[j];C&&x.observe(C)}return()=>x.disconnect()},[i]),l.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current)},[]),e.jsx("main",{className:"settings-workspace","aria-labelledby":"settings-title",children:e.jsxs("div",{className:"settings-shell",children:[e.jsxs("header",{className:"settings-header",children:[e.jsx("div",{children:e.jsx("h2",{id:"settings-title",children:s("settings.title")})}),e.jsx("button",{type:"button",className:"settings-close",onClick:t,"aria-label":s("settings.closeAria"),title:s("settings.closeTitle"),children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"m6 6 12 12"})]})})]}),e.jsxs("div",{className:"settings-layout",children:[e.jsx("nav",{className:"settings-nav settings-nav--mobile","aria-label":s("settings.navAria"),children:e.jsx("div",{className:"settings-mobile-nav",role:"list",children:U.map(r=>e.jsxs("button",{type:"button",className:`settings-mobile-nav__item${a===r?" is-active":""}`,onClick:()=>h(r),"aria-current":a===r?"true":void 0,children:[e.jsx("span",{children:s(`settings.sections.${r}.title`)}),e.jsx("small",{children:s(`settings.sections.${r}.hint`)})]},r))})}),e.jsx("nav",{className:"settings-nav","aria-label":s("settings.navAria"),children:U.map(r=>e.jsxs("button",{type:"button",className:`settings-nav__item${a===r?" is-active":""}`,onClick:()=>h(r),"aria-label":s("settings.jumpTo",{section:s(`settings.sections.${r}.title`)}),children:[e.jsx("span",{children:s(`settings.sections.${r}.title`)}),e.jsx("small",{children:s(`settings.sections.${r}.hint`)})]},r))}),e.jsxs("section",{ref:y,className:"settings-content","aria-label":s("settings.contentAria"),children:[e.jsxs(J,{id:"providers",setRef:_,children:[e.jsx(Re,{}),e.jsx(Qe,{}),e.jsx(Ze,{}),e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("readiness.settingsTitle")}),e.jsx("p",{children:s("readiness.settingsBody")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx("button",{type:"button",className:"settings-action-btn",onClick:n,children:s("readiness.open")})})]}),e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.imageModel.title")}),e.jsx("p",{children:s("settings.imageModel.body")}),e.jsx("p",{className:"settings-row__microcopy",children:s("settings.imageModel.unsupportedHelp")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx($e,{variant:"settings"})})]}),o==="grok"?e.jsxs(e.Fragment,{children:[e.jsx("article",{className:"settings-row",children:e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.grokCompatibility.title")}),e.jsx("p",{children:s("settings.grokCompatibility.body")})]})}),e.jsx(We,{})]}):o==="agy"||o==="gemini-api"?e.jsx("article",{className:"settings-row",children:e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s(o==="gemini-api"?"provider.geminiApiCompatTitle":"provider.agyCompatTitle")}),e.jsx("p",{children:s(o==="gemini-api"?"provider.geminiApiCompatBodyLong":"provider.agyCompatBodyLong")})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.reasoning.title")}),e.jsx("p",{children:s("settings.reasoning.body")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(Pe,{})})]}),e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.webSearch.title")}),e.jsx("p",{children:s("settings.webSearch.body")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(ke,{})})]})]})]}),e.jsxs(J,{id:"workspace",setRef:_,children:[e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("workspace.sectionTitle")}),e.jsx("p",{children:s("workspace.sectionBody")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(He,{})})]}),e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.appearance.historyStripLayoutTitle")}),e.jsx("p",{children:s("settings.appearance.historyStripLayoutBody")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(Ge,{})})]}),e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.gallery.defaultScopeTitle")}),e.jsx("p",{children:s("settings.gallery.defaultScopeBody")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(D,{ariaLabel:s("settings.gallery.defaultScopeTitle"),value:m,onChange:r=>g(r),items:[{value:"current-session",label:s("gallery.scope.current")},{value:"all",label:s("gallery.scope.all")}]})})]})]}),e.jsxs(J,{id:"general",setRef:_,children:[e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.language.title")}),e.jsx("p",{children:s("settings.language.body")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(Be,{})})]}),e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.theme.title")}),e.jsx("p",{children:s("settings.theme.body")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(Fe,{})})]})]})]})]})]})})}export{ss as SettingsWorkspace};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as d,j as e,a as x,p as j,b as m}from"./index-Sch70vBs.js";import{P as v}from"./AssetGenWorkspace-Cguej69V.js";import"./VectorizePanel-DdlVvwV1.js";import"./useAgentDialogFocus-DcWwFfYd.js";function g({draft:i,disabled:s,errors:r,onChange:l,onSubmit:a}){const{t:n}=d(),c=t=>e.jsxs("label",{children:[n(`sprite.recipe.${t}`),e.jsx("input",{value:i[t],disabled:s,"aria-invalid":!!r[t],onChange:p=>l({[t]:p.target.value})}),r[t]?e.jsx("span",{role:"alert",children:r[t]}):null]});return e.jsxs("form",{className:"sprite-recipe-form",onSubmit:t=>{t.preventDefault(),a()},children:[c("name"),c("characterId"),c("description"),c("style"),c("baseAssetId"),e.jsxs("fieldset",{children:[e.jsx("legend",{children:n("sprite.cell.title")}),["width","height","safeMarginX","safeMarginY"].map(t=>e.jsxs("label",{children:[n(`sprite.cell.${t}`),e.jsx("input",{type:"number",min:"0",value:i.cell[t],onChange:p=>l({cell:{...i.cell,[t]:Number(p.target.value)}})})]},t))]}),e.jsxs("label",{children:[n("sprite.chroma.hex"),e.jsx("input",{type:"color",value:i.chroma.hex,onChange:t=>l({chroma:{...i.chroma,hex:t.target.value}})})]}),e.jsxs("fieldset",{children:[e.jsx("legend",{children:n("sprite.states.title")}),i.states.map((t,p)=>e.jsxs("div",{className:"sprite-state",children:[e.jsx("input",{"aria-label":n("sprite.states.key"),value:t.key,onChange:u=>l({states:i.states.map((o,h)=>h===p?{...o,key:u.target.value}:o)})}),e.jsx("input",{"aria-label":n("sprite.states.frames"),type:"number",min:"1",value:t.frames,onChange:u=>l({states:i.states.map((o,h)=>h===p?{...o,frames:Number(u.target.value)}:o)})}),e.jsx("button",{type:"button",onClick:()=>l({states:i.states.filter((u,o)=>o!==p)}),children:n("sprite.states.remove")})]},`${t.key}-${p}`)),e.jsx("button",{type:"button",onClick:()=>l({states:[...i.states,{key:"",frames:4,fps:8,loop:!0,action:""}]}),children:n("sprite.states.add")})]}),e.jsx("button",{className:"assetgen-generate",disabled:s||!i.name.trim()||!i.characterId.trim(),children:n(s?"sprite.recipe.saving":"sprite.recipe.save")})]})}function b({onCancel:i,onConfirm:s}){const{t:r}=d(),l=j(!0,i);return e.jsxs("div",{className:"sprite-anchor-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"sprite-confirm-title",ref:l,children:[e.jsx("h3",{id:"sprite-confirm-title",children:r("sprite.anchor.confirmTitle")}),e.jsx("p",{children:r("sprite.anchor.confirmBody")}),e.jsx("button",{"data-modal-initial-focus":!0,onClick:i,children:r("sprite.anchor.cancel")}),e.jsx("button",{onClick:s,children:r("sprite.anchor.confirm")})]})}function f({recipe:i,candidate:s,generating:r,onGenerate:l,onApprove:a}){const{t:n}=d(),[c,t]=x.useState(!1);return e.jsxs("section",{className:"sprite-anchor-gate","aria-labelledby":"sprite-anchor-title",children:[e.jsx("h2",{id:"sprite-anchor-title",children:n("sprite.anchor.title")}),s?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:s.url,alt:""}),e.jsx("p",{children:n("sprite.anchor.candidate")}),e.jsx("button",{onClick:l,disabled:r,children:n("sprite.anchor.regenerate")}),e.jsx("button",{onClick:()=>t(!0),children:n("sprite.anchor.approve")})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{children:n(i.anchorStatus==="approved"?"sprite.anchor.approved":"sprite.anchor.missing")}),e.jsx("button",{onClick:l,disabled:r,children:n(r?"sprite.anchor.generating":"sprite.anchor.generate")})]}),c?e.jsx(b,{onCancel:()=>t(!1),onConfirm:()=>{a(s.assetId),t(!1)}}):null]})}function S({recipe:i,selected:s,onSelectionChange:r,onGenerate:l,onCancel:a,onPreview:n}){const{t:c}=d();return e.jsxs("section",{className:"sprite-row-list","aria-live":"polite",children:[e.jsx("h2",{children:c("sprite.rows.title")}),e.jsxs("div",{className:"sprite-row-actions",children:[e.jsx("button",{onClick:()=>l(),children:c("sprite.rows.generateAll")}),e.jsx("button",{disabled:!s.length,onClick:()=>l(s),children:c("sprite.rows.generateSelected")})]}),i.rows.map(t=>e.jsxs("article",{children:[e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:s.includes(t.stateKey),onChange:()=>r(s.includes(t.stateKey)?s.filter(p=>p!==t.stateKey):[...s,t.stateKey])}),t.stateKey]}),e.jsx("span",{children:c(`sprite.rows.status.${t.status}`)}),t.progress!=null?e.jsx("progress",{value:t.progress,max:"100"}):null,t.imageUrl||t.previewUrl?e.jsxs("button",{onClick:()=>n(t),children:[e.jsx("img",{src:t.imageUrl||t.previewUrl,alt:""}),c("sprite.rows.preview")]}):null,t.status==="error"?e.jsx("button",{onClick:()=>l([t.stateKey]),children:c("sprite.rows.regenerate")}):null,t.requestId&&(t.status==="running"||t.status==="queued")?e.jsx("button",{onClick:()=>a(t.requestId),children:c("sprite.rows.cancel")}):null,t.error?e.jsx("p",{role:"alert",children:t.error}):null]},t.stateKey))]})}function I(){const{t:i}=d(),s=m();x.useEffect(()=>{s.loadSpriteRecipes()},[]);const r=s.activeSpriteRecipe,l=s.spriteRecipeDraft.name.trim()?{}:{name:i("sprite.error.INVALID_SPRITE_RECIPE")};return e.jsxs("section",{className:"sprite-recipe-workspace",children:[e.jsxs("aside",{children:[e.jsx(v,{}),e.jsxs("label",{children:[i("sprite.recipe.select"),e.jsxs("select",{value:s.activeSpriteRecipeId??"",onChange:a=>{s.selectSpriteRecipe(a.target.value||null)},children:[e.jsx("option",{value:"",children:i("sprite.recipe.new")}),s.spriteRecipes.map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))]})]}),e.jsx(g,{draft:s.spriteRecipeDraft,disabled:s.spriteRecipeSaving,errors:l,onChange:s.updateSpriteRecipeDraft,onSubmit:()=>{s.saveSpriteRecipe()}})]}),e.jsxs("main",{children:[s.spriteRecipeError?e.jsxs("div",{role:"alert",children:[s.spriteRecipeError,e.jsx("button",{onClick:()=>{s.loadSpriteRecipes()},children:i("sprite.retry")})]}):null,s.spriteRecipeLoading?e.jsx("p",{role:"status",children:i("sprite.loading")}):r?r.anchorStatus!=="approved"?e.jsx(f,{recipe:r,candidate:r.candidate??null,generating:s.spriteRecipeGenerating,onGenerate:()=>{s.generateSpriteAnchor()},onApprove:a=>{s.approveSpriteAnchor(a)}}):e.jsx(S,{recipe:r,selected:s.spriteSelectedStates,onSelectionChange:a=>m.setState({spriteSelectedStates:a}),onGenerate:a=>{s.generateSpriteRows(a)},onCancel:a=>{s.cancelSpriteJob(a)},onPreview:()=>{}}):e.jsxs("div",{className:"sprite-empty",children:[e.jsx("h2",{children:i("sprite.empty.title")}),e.jsx("p",{children:i("sprite.empty.body")})]})]})]})}export{I as SpriteRecipeWorkspace};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as te,a as b,b as $,q as pe,j as n,p as le,ai as me,aj as ye,ak as xe,al as ke}from"./index-Sch70vBs.js";import{u as be}from"./useAgentDialogFocus-DcWwFfYd.js";function ve(){return n.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18","aria-hidden":"true",children:n.jsx("path",{d:"M6 6l12 12M18 6 6 18",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"})})}function _e({zoomed:e}){return n.jsxs("svg",{viewBox:"0 0 24 24",width:"18",height:"18","aria-hidden":"true",children:[n.jsx("circle",{cx:"10.5",cy:"10.5",r:"6.5",fill:"none",stroke:"currentColor",strokeWidth:"1.7"}),n.jsx("path",{d:"M15.5 15.5 21 21M7.5 10.5h6",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"}),e?null:n.jsx("path",{d:"M10.5 7.5v6",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})]})}function Ve({item:e,onClose:t}){const{t:s}=te(),[a,o]=b.useState(!1),c=e.metadata??null,[m,l]=b.useState(c),u=b.useId(),f=$(g=>g.setKeyingTarget),d=$(g=>g.setVectorizeTarget),i=$(g=>g.setCuratorTarget),y=b.useCallback(()=>t(),[t]),r=be(!0,y),p=e.mediaType==="video",v=e.kind!=="edit"&&!!e.filename&&e.backgroundPreset!=="transparent",w=c??m,C=typeof w?.spriteRunId=="string"?w.spriteRunId:null,B=typeof w?.manifestPath=="string"?w.manifestPath:null,E=!!(C&&B&&e.filename),D=!p&&!!e.filename&&!/\.svg$/i.test(e.filename??""),M=s(p?"assetGen.videoFallback":"assetGen.imageFallback"),P=e.prompt?.trim()||M,U=b.useCallback(()=>{f(e),t()},[e,t,f]),k=b.useCallback(()=>{d(e),t()},[e,t,d]),_=b.useCallback(()=>{!C||!B||!e.filename||(i({runId:C,atlasFile:e.filename,manifestFile:B}),t())},[e.filename,B,t,i,C]);return b.useEffect(()=>{l(c);const g=e.requestId?.startsWith("asset:")?e.requestId.slice(6):null;if(!g||c)return;let x=!0;return pe(g).then(({asset:N})=>{x&&l(N.metadata)}).catch(()=>{x&&l(null)}),()=>{x=!1}},[c,e.requestId]),b.useEffect(()=>{const g=document.body.style.overflow,x=document.documentElement.style.overflow;return document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",()=>{document.body.style.overflow=g,document.documentElement.style.overflow=x}},[]),n.jsxs("div",{className:"assetgen-lightbox",role:"presentation",children:[n.jsx("button",{type:"button",className:"assetgen-lightbox__backdrop","aria-label":s("assetGen.closePreview"),onClick:y}),n.jsxs("section",{ref:r,className:"assetgen-lightbox__panel",role:"dialog","aria-modal":"true","aria-labelledby":u,children:[n.jsxs("header",{className:"assetgen-lightbox__header",children:[n.jsx("h2",{id:u,children:s("assetGen.previewDialogTitle",{prompt:P})}),n.jsx("button",{type:"button",className:"assetgen-lightbox__control","aria-label":s("assetGen.closePreview"),onClick:y,children:n.jsx(ve,{})})]}),n.jsx("div",{className:["assetgen-lightbox__stage",e.kind==="edit"?"is-keyed":"",a?"is-zoomed":""].filter(Boolean).join(" "),tabIndex:a?0:void 0,children:p?n.jsx("video",{src:e.url||e.image,poster:e.thumb||void 0,controls:!0,autoPlay:!0,muted:!0,playsInline:!0,preload:"metadata","aria-label":P}):n.jsx("img",{src:e.url||e.image,alt:P})}),!p||v||E?n.jsxs("footer",{className:"assetgen-lightbox__footer",children:[E?n.jsx("button",{type:"button",className:"assetgen-lightbox__zoom assetgen-lightbox__curate",onClick:_,children:s("spriteCurator.open")}):null,v?n.jsx("button",{type:"button",className:"assetgen-lightbox__zoom assetgen-lightbox__keybtn",onClick:U,children:s("keying.open")}):null,D?n.jsx("button",{type:"button",className:"assetgen-lightbox__zoom assetgen-lightbox__vectorbtn",onClick:k,children:s("vectorize.open")}):null,p?null:n.jsxs("button",{type:"button",className:"assetgen-lightbox__zoom","aria-pressed":a,"aria-label":s(a?"assetGen.zoomOut":"assetGen.zoomIn"),onClick:()=>o(g=>!g),children:[n.jsx(_e,{zoomed:a}),n.jsx("span",{children:s(a?"assetGen.zoomOut":"assetGen.zoomIn")})]})]}):null]})]})}const H={tolerance:40,softness:10,spill:50};function se(e,t,s){const a=128-.168736*e-.331264*t+.5*s,o=128+.5*e-.418688*t-.081312*s;return[a,o]}function ae(e,t,s){return .299*e+.587*t+.114*s}function je(e,t,s,a){const o=t*s,c=new Uint8Array(o);for(let i=0;i<o;i++)e[i]<a&&(c[i]=1);const m=new Uint8Array(o),l=new Int32Array(o);let u=0,f=0;const d=i=>{c[i]&&!m[i]&&(m[i]=1,l[f++]=i)};for(let i=0;i<t;i++)d(i),d((s-1)*t+i);for(let i=0;i<s;i++)d(i*t),d(i*t+t-1);for(;u<f;){const i=l[u++],y=i%t,r=(i-y)/t;y>0&&d(i-1),y<t-1&&d(i+1),r>0&&d(i-t),r<s-1&&d(i+t)}for(let i=0;i<o;i++)c[i]&&!m[i]&&(e[i]=a)}function oe(e){const{width:t,height:s,data:a}=e;if(t<2||s<2||a.length<t*s*4)throw new Error("colorKey: image too small or malformed pixel buffer");const o=4,c=[0,Math.max(0,t-o)],m=[0,Math.max(0,s-o)],l=[],u=[],f=[];for(const i of c)for(const y of m)for(let r=y;r<Math.min(y+o,s);r++)for(let p=i;p<Math.min(i+o,t);p++){const v=(r*t+p)*4;l.push(a[v]),u.push(a[v+1]),f.push(a[v+2])}const d=i=>{const y=[...i].sort((r,p)=>r-p);return y[Math.floor(y.length/2)]};return{r:d(l),g:d(u),b:d(f)}}function we(e,t){const{width:s,height:a,data:o}=e;if(!s||!a||o.length!==s*a*4)throw new Error("colorKey: empty or malformed pixel buffer");const c=Math.max(0,Math.min(100,t.tolerance)),m=Math.max(0,Math.min(50,t.softness)),l=Math.max(0,Math.min(100,t.spill))/100,u=c/100*120,f=u+m/100*120,[d,i]=se(t.keyColor.r,t.keyColor.g,t.keyColor.b),y=t.keyColor.r,r=t.keyColor.g,p=t.keyColor.b,v=r>y+20&&r>p+20&&r>60,C=Math.max(y,r,p)-Math.min(y,r,p)<40,B=ae(y,r,p),E=10+c/100*15,D=400,M=s*a,P=new Float32Array(M);for(let g=0;g<M;g++){const x=g*4,N=o[x],T=o[x+1],I=o[x+2],[K,R]=se(N,T,I),S=Math.hypot(K-d,R-i);if(C)if(S>E)P[g]=D;else{const A=Math.abs(ae(N,T,I)-B)*.8;P[g]=Math.hypot(S,A)}else P[g]=S}const U=new Float32Array(M);for(let g=0;g<a;g++)for(let x=0;x<s;x++){const N=g*s+x;if(P[N]>=D){U[N]=D;continue}let T=0,I=0;for(let K=-1;K<=1;K++){const R=g+K;if(!(R<0||R>=a))for(let S=-1;S<=1;S++){const A=x+S;if(A<0||A>=s)continue;const L=P[R*s+A];L>=D||(T+=L,I++)}}U[N]=I>0?T/I:D}C&&je(U,s,a,f);const k=f+l*120,_=new Uint8ClampedArray(o.length);for(let g=0;g<M;g++){const x=g*4,N=o[x],T=o[x+1],I=o[x+2],K=o[x+3],R=U[g];let S;R<=u?S=0:R<f?S=Math.pow((R-u)/(f-u),1.5)*255:S=255;let A=N,L=T,G=I;if(v&&l>0&&S>0){const W=k>u?Math.max(0,1-(R-u)/(k-u)):0;if(W>0){const Z=(N+I)/2,h=Math.max(0,T-Z)*W*l;L=Math.round(T-h);const j=h*.3;A=Math.min(255,Math.round(N+j)),G=Math.min(255,Math.round(I+j))}}_[x]=A,_[x+1]=L,_[x+2]=G,_[x+3]=Math.min(K,Math.round(S))}if(v&&l>0){let g=new Uint8Array(M);for(let x=0;x<a;x++)for(let N=0;N<s;N++){const T=x*s+N;if(_[T*4+3]===0)continue;let I=!1;e:for(let K=-1;K<=1;K++){const R=x+K;if(!(R<0||R>=a))for(let S=-1;S<=1;S++){const A=N+S;if(!(A<0||A>=s)&&_[(R*s+A)*4+3]===0){I=!0;break e}}}I&&(g[T]=1)}for(let x=0;x<3;x++){const N=new Uint8Array(M);for(let T=0;T<a;T++)for(let I=0;I<s;I++){const K=T*s+I;if(g[K]){N[K]=1;continue}if(_[K*4+3]===0)continue;let R=!1;for(let S=-1;S<=1&&!R;S++){const A=T+S;if(!(A<0||A>=a))for(let L=-1;L<=1&&!R;L++){const G=I+L;G<0||G>=s||g[A*s+G]&&(R=!0)}}R&&(N[K]=1)}g=N}for(let x=0;x<M;x++){if(!g[x])continue;const N=x*4,T=_[N],I=_[N+1],K=_[N+2],R=Math.max(T,K);if(I>R-8){const S=Math.max(0,R-4),A=Math.max(0,I-S);_[N+1]=Math.max(0,I-A),_[N]=Math.min(255,T+Math.round(A*.25)),_[N+2]=Math.min(255,K+Math.round(A*.25))}}}return{width:s,height:a,data:_}}function Ce(e){return Math.round(Math.max(0,Math.min(100,e))*.7)}function re(e,t,s){const a=Math.max(0,Math.min(t-1,Math.round(e.x*(t-1))));return Math.max(0,Math.min(s-1,Math.round(e.y*(s-1))))*t+a}function Me(e,t,s,a){for(const o of s)if(Math.max(Math.abs(e[t]-o.r),Math.abs(e[t+1]-o.g),Math.abs(e[t+2]-o.b))<=a)return!0;return!1}function Ne(e,t,s){const{width:a,height:o,data:c}=e,m=a*o,l=new Uint8Array(m),u=new Uint8Array(m),f=new Int32Array(m),d=t.map(r=>{const p=re(r,a,o)*4;return{r:c[p],g:c[p+1],b:c[p+2]}});let i=0;const y=r=>{u[r]||(u[r]=1,c[r*4+3]!==0&&Me(c,r*4,d,s)&&(f[i++]=r))};for(const r of t)y(re(r,a,o));for(;i>0;){const r=f[--i];l[r]=1;const p=r%a;p>0&&y(r-1),p<a-1&&y(r+1),r>=a&&y(r-a),r<m-a&&y(r+a)}return l}function Se(e,t,s,a){if(s.length===0)return;if(e.width!==t.width||e.height!==t.height||e.data.length!==t.data.length)throw new Error("wandErase: target/source buffer size mismatch");const o=Ne(t,s,Ce(a));for(let c=0;c<o.length;c++)o[c]&&(e.data[c*4+3]=0)}const Ee={reach:4,spillMaxFraction:.005},ce=18,Ie=180,Ae=40,ze=2,Q=0,Te=1,ue=2,de=3;function ee(e){const t=[e.r,e.g,e.b],s=[],a=[];for(let o=0;o<3;o++)if(t[o]>=192)s.push(o);else if(t[o]<64)a.push(o);else return null;return s.length===0||a.length===0?null:{keyed:s,unkeyed:a}}function X(e,t,s,a){const o=[e,t,s];let c=0;for(const l of a.keyed)c+=o[l];let m=0;for(const l of a.unkeyed)m+=o[l];return c/a.keyed.length-m/a.unkeyed.length}function Re(e,t,s,a){return Math.hypot(e-a.r,t-a.g,s-a.b)}function he(e,t,s,a,o,c){const m=Math.min(c/o,1),l=1-m;if(l<=0)return[0,0,0,0];const u=(f,d)=>Math.min(255,Math.max(0,Math.round((f-m*d)/l)));return[l,u(e,a.r),u(t,a.g),u(s,a.b)]}function Pe(e,t,s,a){const o=t*s,c=255,m=new Uint8Array(o).fill(c);let l=[];for(let f=0;f<o;f++)e[f]&&(m[f]=0,l.push(f));let u=0;for(;l.length>0&&u<a;){u++;const f=[];for(const d of l){const i=d%t,y=(d-i)/t;for(let r=-1;r<=1;r++){const p=y+r;if(!(p<0||p>=s))for(let v=-1;v<=1;v++){const w=i+v;if(w<0||w>=t)continue;const C=p*t+w;m[C]===c&&(m[C]=u,f.push(C))}}}l=f}return m}function Ue(e,t,s,a){const o=e.width*e.height,c=new Uint8Array(o),m=new Uint8Array(o);for(let l=0;l<o;l++){const u=l*4;if(t.data[u+3]===0){c[l]=Q,m[l]=1;continue}const f=e.data[u],d=e.data[u+1],i=e.data[u+2];X(f,d,i,a)<ce?c[l]=Te:Re(f,d,i,s)<=Ie?c[l]=ue:c[l]=de}return{classes:c,keyedMask:m}}function De(e,t,s,a,o,c,m,l){const u=t.width*t.height,f=new Uint8Array(u);for(let d=0;d<u;d++){const i=c[d];if(!(i>0&&i<=l))continue;const y=m[d];if(y===ue){if(i>ze)continue}else if(y!==de)continue;const r=d*4,p=t.data[r],v=t.data[r+1],w=t.data[r+2],C=X(p,v,w,a),[B,E,D,M]=he(p,v,w,s,o,C),P=Math.round(t.data[r+3]*B);P<=0?(e.data[r]=0,e.data[r+1]=0,e.data[r+2]=0,e.data[r+3]=0):(e.data[r]=E,e.data[r+1]=D,e.data[r+2]=M,e.data[r+3]=P),f[d]=1}return f}function Fe(e,t,s,a,o,c,m,l){const{width:u,height:f}=t,d=u*f;let i=0;for(let w=0;w<d;w++)c[w]!==Q&&i++;const y=Math.max(32,Math.round(i*l)),r=new Float32Array(d).fill(-1);for(let w=0;w<d;w++){if(m[w]||c[w]===Q)continue;const C=w*4;if(e.data[C+3]===0)continue;const B=X(t.data[C],t.data[C+1],t.data[C+2],a);B>=ce&&(r[w]=B)}const p=new Uint8Array(d),v=[];for(let w=0;w<d;w++){if(r[w]<0||p[w])continue;p[w]=1,v.length=0,v.push(w);const C=[];let B=-1;for(;v.length>0;){const E=v.pop();C.push(E),r[E]>B&&(B=r[E]);const D=E%u,M=(E-D)/u;for(let P=-1;P<=1;P++){const U=M+P;if(!(U<0||U>=f))for(let k=-1;k<=1;k++){const _=D+k;if(_<0||_>=u)continue;const g=U*u+_;r[g]>=0&&!p[g]&&(p[g]=1,v.push(g))}}}if(!(C.length>y)&&!(B<=Ae))for(const E of C){const D=E*4,M=t.data[D],P=t.data[D+1],U=t.data[D+2],[k,_,g,x]=he(M,P,U,s,o,r[E]);k<=0||(e.data[D]=_,e.data[D+1]=g,e.data[D+2]=x)}}}function Ke(e,t,s){if(!e.width||!e.height||e.width!==t.width||e.height!==t.height||e.data.length!==t.data.length||e.data.length!==e.width*e.height*4)throw new Error("softUnmix: empty or mismatched pixel buffers");const a=ee(s.keyColor);if(!a)return;const o=X(s.keyColor.r,s.keyColor.g,s.keyColor.b,a);if(o<=0)return;const c=Math.max(0,Math.min(254,Math.round(s.reach))),{classes:m,keyedMask:l}=Ue(t,e,s.keyColor,a);let u;if(c>0){const f=Pe(l,t.width,t.height,c);u=De(e,t,s.keyColor,a,o,f,m,c)}else u=new Uint8Array(t.width*t.height);s.spillMaxFraction>0&&Fe(e,t,s.keyColor,a,o,m,u,s.spillMaxFraction)}function ie(e,t,s){const a=`/generated/${encodeURIComponent(t)}`;return{...e,image:a,url:a,filename:t,mediaType:s,kind:"edit",requestId:`derived:${t}`,createdAt:Date.now(),providerUrl:null}}function qe(){const{t:e}=te(),t=$(h=>h.keyingTarget),s=$(h=>h.setKeyingTarget),a=le(!!t,()=>s(null)),o=$(h=>h.addAssetGenDerivedItem),c=$(h=>h.selectedProjectId),m=$(h=>h.showToast),[l,u]=b.useState("loading"),[f,d]=b.useState(!1),[i,y]=b.useState(null),[r,p]=b.useState(null),[v,w]=b.useState(H.tolerance),[C,B]=b.useState(H.softness),[E,D]=b.useState(H.spill),[M,P]=b.useState(null),[U,k]=b.useState("erase"),[_,g]=b.useState([]),[x,N]=b.useState(!0),T=b.useRef(null),I=b.useRef(null),K=b.useRef(0),R=b.useRef(null),S=b.useRef(null),A=b.useCallback(()=>{R.current?.(),R.current=null},[]),L=t?.mediaType==="video",G=t?L&&t.filename?`/api/video/frame?file=${encodeURIComponent(t.filename)}&position=0`:t.url||t.image:null;b.useEffect(()=>{if(!G)return;let h=!0;u("loading"),T.current=null,P(null),g([]),k("erase");const j=new Image;return j.onload=()=>{if(h)try{const z=document.createElement("canvas");z.width=j.naturalWidth,z.height=j.naturalHeight;const F=z.getContext("2d");if(!F)throw new Error("no 2d context");F.drawImage(j,0,0);const O=F.getImageData(0,0,z.width,z.height);T.current=O,P(oe(O)),u("ready")}catch{h&&u("error")}},j.onerror=()=>{h&&u("error")},j.src=G,()=>{h=!1,j.onload=null,j.onerror=null}},[G]),b.useEffect(()=>(S.current=t?.filename??null,A(),d(!1),p(null),y(null),A),[A,t?.filename]),b.useEffect(()=>{if(!(l!=="ready"||!M))return cancelAnimationFrame(K.current),K.current=requestAnimationFrame(()=>{const h=T.current,j=I.current;if(!(!h||!j))try{const z=we({width:h.width,height:h.height,data:h.data},{keyColor:M,tolerance:v,softness:C,spill:E});x&&ee(M)&&Ke(z,{width:h.width,height:h.height,data:h.data},{keyColor:M,...Ee}),_.length>0&&Se(z,{width:h.width,height:h.height,data:h.data},_,v),j.width=z.width,j.height=z.height;const F=j.getContext("2d");if(!F)return;const O=F.createImageData(z.width,z.height);O.data.set(z.data),F.putImageData(O,0,0)}catch{u("error")}}),()=>cancelAnimationFrame(K.current)},[l,M,v,C,E,_,x]);const W=b.useCallback(h=>{const j=T.current,z=I.current;if(!j||!z)return;const F=z.getBoundingClientRect(),O=Math.max(0,Math.min(1,(h.clientX-F.left)/F.width)),Y=Math.max(0,Math.min(1,(h.clientY-F.top)/F.height));if(U==="erase"&&!L){g(ge=>[...ge,{x:O,y:Y}]);return}const V=Math.floor((h.clientX-F.left)/F.width*j.width),fe=Math.floor((h.clientY-F.top)/F.height*j.height),J=(Math.max(0,Math.min(j.height-1,fe))*j.width+Math.max(0,Math.min(j.width-1,V)))*4;P({r:j.data[J],g:j.data[J+1],b:j.data[J+2]})},[U,L]),Z=b.useCallback(()=>{const h=I.current;h&&h.toBlob(j=>{if(!j)return;const z=URL.createObjectURL(j),F=document.createElement("a");F.href=z,F.download=`${(t?.filename||"asset").replace(/\.[a-z]+$/i,"")}-keyed.png`,F.click(),URL.revokeObjectURL(z)},"image/png")},[t]),ne=b.useCallback(()=>{const h=I.current;if(!(!h||!t?.filename||f)){if(d(!0),y(null),L){me({source:t.filename,keyParams:{tolerance:v,softness:C,keyColor:M??void 0},projectId:c,name:`${(t.prompt||"asset").trim().slice(0,60)} (keyed)`}).then(({requestId:j})=>{if(S.current!==t.filename)return;p(0),A();const z=ye(j,null,(F,O)=>{const Y=O&&typeof O=="object"?O:{};if(F==="keying-progress"){const V=Y.outTimeMs;p(typeof V=="number"&&Number.isFinite(V)?V:0)}else if(F==="keying-done"){A();const V=Y.filePath;if(typeof V=="string"&&V.trim()){o(ie(t,V.trim(),"video")),d(!1),p(null),m(e("keying.videoSaved")),s(null);return}d(!1),p(null),y(e("keying.saveError"))}else F==="keying-error"&&(A(),d(!1),p(null),y(typeof Y.error=="string"&&Y.error?Y.error:e("keying.saveError")))});R.current=z}).catch(j=>{S.current===t.filename&&(d(!1),y(j instanceof Error?j.message:e("keying.saveError")))});return}h.toBlob(j=>{if(S.current===t.filename){if(!j){d(!1),y(e("keying.saveError"));return}xe(j,{source:t.filename,projectId:c,name:`${(t.prompt||"asset").trim().slice(0,60)} (keyed)`,meta:{keyParams:{tolerance:v,softness:C,spill:E},prompt:t.prompt}}).then(({filePath:z})=>{if(S.current===t.filename){if(typeof z!="string"||!z.trim())throw new Error(e("keying.saveError"));o(ie(t,z.trim(),"image")),m(e("keying.saved")),s(null)}}).catch(z=>{S.current===t.filename&&y(z instanceof Error?z.message:e("keying.saveError"))}).finally(()=>{S.current===t.filename&&d(!1)})}},"image/png")}},[t,f,L,M,c,v,C,E,A,o,m,s,e]);return t?n.jsx("div",{className:"assetgen-popup-backdrop",onClick:()=>s(null),children:n.jsxs("div",{ref:a,className:"keying-panel",role:"dialog","aria-modal":"true","aria-label":e("keying.title"),onClick:h=>h.stopPropagation(),children:[n.jsxs("header",{className:"keying-panel__head",children:[n.jsx("h2",{children:e("keying.title")}),M?n.jsxs("span",{className:"keying-panel__key",title:e("keying.keyColor"),children:[L?null:n.jsxs("span",{className:"keying-panel__modes",role:"group","aria-label":e("keying.clickMode"),children:[n.jsx("button",{type:"button",className:U==="erase"?"is-active":"","aria-pressed":U==="erase",onClick:()=>k("erase"),children:e("keying.modeErase")}),n.jsx("button",{type:"button",className:U==="pick"?"is-active":"","aria-pressed":U==="pick",onClick:()=>k("pick"),children:e("keying.modePick")})]}),_.length>0?n.jsx("button",{type:"button",className:"keying-panel__undo",onClick:()=>g(h=>h.slice(0,-1)),children:e("keying.undoClick",{count:String(_.length)})}):null,n.jsx("span",{className:"assetgen-bg-picker__swatch",style:{background:`rgb(${M.r},${M.g},${M.b})`},"aria-hidden":"true"}),n.jsx("span",{className:"keying-panel__hint",children:e(U==="erase"&&!L?"keying.eraseHint":"keying.pickHint")})]}):null]}),n.jsx("div",{className:"keying-panel__compare","aria-busy":l==="loading",children:l==="error"?n.jsxs("div",{className:"keying-panel__error",role:"alert",children:[n.jsx("p",{children:e("keying.loadError")}),n.jsx("button",{type:"button",onClick:()=>s(null),children:e("project.close")})]}):n.jsxs(n.Fragment,{children:[n.jsxs("figure",{className:"keying-panel__preview",children:[n.jsx("figcaption",{className:"keying-panel__preview-label",children:e("keying.original")}),n.jsx("div",{className:"keying-panel__stage keying-panel__stage--original",children:n.jsx("img",{src:G??"",alt:e("keying.originalAlt")})})]}),n.jsxs("figure",{className:"keying-panel__preview",children:[n.jsx("figcaption",{className:"keying-panel__preview-label",children:e("keying.removed")}),n.jsxs("div",{className:"keying-panel__stage",children:[n.jsx("canvas",{ref:I,className:"keying-panel__canvas",onClick:W,"aria-label":e("keying.previewAlt")}),l==="loading"?n.jsx("span",{className:"keying-panel__loading",role:"status",children:e("keying.previewLoading")}):null]})]})]})}),n.jsxs("details",{className:"keying-panel__advanced",children:[n.jsx("summary",{children:e("keying.advanced")}),n.jsxs("div",{className:"keying-panel__controls",children:[n.jsxs("label",{children:[e("keying.tolerance")," ",n.jsx("output",{children:v}),n.jsx("input",{type:"range",min:0,max:100,value:v,onChange:h=>w(Number(h.target.value))})]}),n.jsxs("label",{children:[e("keying.softness")," ",n.jsx("output",{children:C}),n.jsx("input",{type:"range",min:0,max:50,value:C,onChange:h=>B(Number(h.target.value))})]}),n.jsxs("label",{children:[e("keying.spill")," ",n.jsx("output",{children:E}),n.jsx("input",{type:"range",min:0,max:100,value:E,onChange:h=>D(Number(h.target.value))})]}),n.jsxs("label",{className:"keying-panel__unmix",children:[n.jsx("input",{type:"checkbox",checked:x,disabled:!M||!ee(M),onChange:h=>N(h.target.checked)}),e("keying.unmix"),n.jsx("span",{className:"keying-panel__hint",children:e("keying.unmixHint")})]}),n.jsx("button",{type:"button",className:"keying-panel__reset",onClick:()=>{w(H.tolerance),B(H.softness),D(H.spill),g([]),N(!0),T.current&&P(oe(T.current))},children:e("keying.reset")})]})]}),n.jsxs("footer",{className:"keying-panel__actions",children:[i?n.jsx("span",{className:"keying-panel__save-error",role:"alert",children:i}):null,n.jsx("button",{type:"button",className:"assetgen-generate",disabled:l!=="ready"||f||!t.filename,onClick:ne,children:f?r!==null?e("keying.videoKeying",{seconds:String(Math.round(r/1e3))}):e("keying.saving"):e(L?"keying.videoSave":"keying.save")}),L?null:n.jsx("button",{type:"button",className:"assetgen-popup__close",disabled:l!=="ready",onClick:Z,children:e("keying.download")}),n.jsx("button",{type:"button",className:"assetgen-popup__close",onClick:()=>s(null),children:e("project.close")})]})]})}):null}const Be=["auto","flat","detailed","mono"],q={colorPrecision:8,filterSpeckle:4,cornerThreshold:60};function Le(e,t){const s=`/generated/${encodeURIComponent(t)}`;return{...e,image:s,url:s,filename:t,mediaType:"image",kind:"edit",requestId:`derived:${t}`,createdAt:Date.now(),providerUrl:null}}function $e(e){return`${Math.round(e/1024)}KB`}function Ye(){const{t:e}=te(),t=$(k=>k.vectorizeTarget),s=$(k=>k.setVectorizeTarget),a=le(!!t,()=>s(null)),o=$(k=>k.addAssetGenDerivedItem),c=$(k=>k.selectedProjectId),m=$(k=>k.showToast),[l,u]=b.useState("auto"),[f,d]=b.useState(q.colorPrecision),[i,y]=b.useState(q.filterSpeckle),[r,p]=b.useState(q.cornerThreshold),[v,w]=b.useState(!1),[C,B]=b.useState(null),[E,D]=b.useState(null),M=b.useCallback(()=>{if(!t?.filename||v)return;const k=t.filename;w(!0),B(null),ke({source:k,preset:l,...f!==q.colorPrecision?{colorPrecision:f}:{},...i!==q.filterSpeckle?{filterSpeckle:i}:{},...r!==q.cornerThreshold?{cornerThreshold:r}:{},projectId:c}).then(_=>{if(!_.filePath)throw new Error(e("vectorize.saveError"));D({filePath:_.filePath,pathCount:_.pathCount,bytes:_.bytes}),o(Le(t,_.filePath)),m(e("vectorize.saved"))}).catch(_=>{B(_ instanceof Error?_.message:e("vectorize.saveError"))}).finally(()=>w(!1))},[t,v,l,f,i,r,c,o,m,e]);if(!t)return null;const P=t.url||t.image,U=E?`/generated/${encodeURIComponent(E.filePath)}`:null;return n.jsx("div",{className:"assetgen-popup-backdrop",onClick:()=>s(null),children:n.jsxs("div",{ref:a,className:"keying-panel vectorize-panel",role:"dialog","aria-modal":"true","aria-label":e("vectorize.title"),onClick:k=>k.stopPropagation(),children:[n.jsxs("header",{className:"keying-panel__head",children:[n.jsx("h2",{children:e("vectorize.title")}),n.jsx("span",{className:"keying-panel__hint",children:e("vectorize.hint")})]}),n.jsxs("div",{className:"keying-panel__compare","aria-busy":v,children:[n.jsxs("figure",{className:"keying-panel__preview",children:[n.jsx("figcaption",{className:"keying-panel__preview-label",children:e("vectorize.original")}),n.jsx("div",{className:"keying-panel__stage keying-panel__stage--original",children:n.jsx("img",{src:P??"",alt:e("vectorize.originalAlt")})})]}),n.jsxs("figure",{className:"keying-panel__preview",children:[n.jsx("figcaption",{className:"keying-panel__preview-label",children:e("vectorize.result")}),n.jsx("div",{className:"keying-panel__stage",children:U?n.jsx("img",{src:U,alt:e("vectorize.resultAlt")}):n.jsx("span",{className:"keying-panel__loading",role:"status",children:e(v?"vectorize.running":"vectorize.idle")})})]})]}),n.jsx("div",{className:"keying-panel__modes",role:"group","aria-label":e("vectorize.preset"),children:Be.map(k=>n.jsx("button",{type:"button",className:l===k?"is-active":"","aria-pressed":l===k,onClick:()=>u(k),children:e(`vectorize.preset_${k}`)},k))}),E?n.jsx("p",{className:"vectorize-panel__stats",role:"status",children:e("vectorize.stats",{paths:String(E.pathCount),size:$e(E.bytes)})}):null,n.jsxs("details",{className:"keying-panel__advanced",children:[n.jsx("summary",{children:e("vectorize.advanced")}),n.jsxs("div",{className:"keying-panel__controls",children:[n.jsxs("label",{children:[e("vectorize.colorPrecision")," ",n.jsx("output",{children:f}),n.jsx("input",{type:"range",min:1,max:8,value:f,onChange:k=>d(Number(k.target.value))})]}),n.jsxs("label",{children:[e("vectorize.filterSpeckle")," ",n.jsx("output",{children:i}),n.jsx("input",{type:"range",min:0,max:32,value:i,onChange:k=>y(Number(k.target.value))})]}),n.jsxs("label",{children:[e("vectorize.cornerThreshold")," ",n.jsx("output",{children:r}),n.jsx("input",{type:"range",min:0,max:180,value:r,onChange:k=>p(Number(k.target.value))})]}),n.jsx("button",{type:"button",className:"keying-panel__reset",onClick:()=>{d(q.colorPrecision),y(q.filterSpeckle),p(q.cornerThreshold)},children:e("vectorize.reset")})]})]}),n.jsxs("footer",{className:"keying-panel__actions",children:[C?n.jsx("span",{className:"keying-panel__save-error",role:"alert",children:C}):null,n.jsx("button",{type:"button",className:"assetgen-generate",disabled:v||!t.filename,onClick:M,children:e(v?"vectorize.running":"vectorize.run")}),U?n.jsx("a",{className:"assetgen-popup__close",href:U,download:E?.filePath,children:e("vectorize.download")}):null,n.jsx("button",{type:"button",className:"assetgen-popup__close",onClick:()=>s(null),children:e("project.close")})]})]})})}export{Ve as A,qe as K,Ye as V};
|