ima2-gen 3.12.2 → 3.12.3
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/bin/commands/vectorize.js +108 -0
- package/bin/ima2.js +5 -1
- package/docs/API.md +1 -1
- package/docs/API.zh-CN.md +1 -1
- package/docs/API.zh-TW.md +1 -1
- package/docs/CLI.md +1 -0
- package/docs/migration/runtime-test-inventory.md +6 -1
- package/lib/agentImageVideoGen.js +15 -1
- package/lib/agentQueueStore.js +11 -3
- package/lib/agentQueueWorker.js +6 -1
- package/lib/agentRuntime.js +4 -0
- package/lib/db.js +3 -0
- package/lib/imageThumb.js +9 -2
- package/lib/vectorizeImage.js +132 -0
- package/package.json +4 -3
- package/routes/assetDerived.js +79 -2
- package/server.js +8 -0
- package/skills/ima2/SKILL.md +37 -0
- package/ui/dist/.vite/manifest.json +33 -33
- package/ui/dist/assets/{AgentWorkspace-CW1x4uOl.js → AgentWorkspace-AJkVTaU5.js} +2 -2
- package/ui/dist/assets/AssetGenWorkspace-Cguej69V.js +2 -0
- package/ui/dist/assets/AssetsWorkspace-DIQ9wBuD.js +1 -0
- package/ui/dist/assets/{CardNewsWorkspace-nBKX5TXr.js → CardNewsWorkspace-C_Eb2g7d.js} +1 -1
- package/ui/dist/assets/{GenerationRequestLogPanel-CWqbfNis.js → GenerationRequestLogPanel-giH1e4hp.js} +1 -1
- package/ui/dist/assets/{HomeWorkspace-CxqIGhb9.js → HomeWorkspace-DHmXGtqC.js} +1 -1
- package/ui/dist/assets/{NodeCanvas-m41ECrFJ.js → NodeCanvas-CF_NHudI.js} +1 -1
- package/ui/dist/assets/{PromptBuilderPanel-ChOoMAVA.js → PromptBuilderPanel-D7NJto-1.js} +2 -2
- package/ui/dist/assets/{PromptImportDialog-8hDG8MeK.js → PromptImportDialog-B40X9UAa.js} +2 -2
- package/ui/dist/assets/{PromptImportDiscoverySection-D2_TAuLm.js → PromptImportDiscoverySection-BWoUDHj1.js} +1 -1
- package/ui/dist/assets/{PromptImportFolderSection-qv0qhTwq.js → PromptImportFolderSection-DBSEyJb-.js} +1 -1
- package/ui/dist/assets/{PromptLibraryPanel-BPOD61FZ.js → PromptLibraryPanel-DLywJBpt.js} +2 -2
- package/ui/dist/assets/{SettingsWorkspace-BKgXN2l9.js → SettingsWorkspace-BawWId1t.js} +1 -1
- package/ui/dist/assets/SpriteRecipeWorkspace-Biy2yRAk.js +1 -0
- package/ui/dist/assets/VectorizePanel-DdlVvwV1.js +1 -0
- package/ui/dist/assets/{index-Bzt4YWub.js → index-D05Ong5g.js} +3 -3
- package/ui/dist/assets/{index-DB9EfKr6.css → index-DGRIdnsL.css} +1 -1
- package/ui/dist/assets/{index-DTEhasVd.js → index-Sch70vBs.js} +17 -17
- package/ui/dist/assets/{pptxgen.es-BEVsR2-i.js → pptxgen.es-CSd_gCsx.js} +1 -1
- package/ui/dist/assets/useAgentDialogFocus-DcWwFfYd.js +1 -0
- package/ui/dist/index.html +2 -2
- package/ui/dist/assets/AssetGenWorkspace-BQkdilsH.js +0 -2
- package/ui/dist/assets/AssetsWorkspace-CYSkmYU-.js +0 -1
- package/ui/dist/assets/KeyingPanel-CtGvO6-u.js +0 -1
- package/ui/dist/assets/SpriteRecipeWorkspace-D8gHgnt8.js +0 -1
- package/ui/dist/assets/useAgentDialogFocus-Dyj_bA5Q.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
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
|
|
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,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PromptImportDiscoverySection-
|
|
2
|
-
import{u as O,j as e,b as ne,a as o,p as ce,aQ as U,aR as M,aS as pe,aT as de,aU as me,ah as J}from"./index-DTEhasVd.js";function ue(i){const t=i.source;if(!t)return"";if(t.owner&&t.repo){const h=t.ref?`@${t.ref}`:"",s=t.path?`:${t.path}`:"";return`${t.owner}/${t.repo}${h}${s}`}return t.filename??t.sourceId??t.kind??""}function he(i,t){const h=i.tags.find(s=>s.toLowerCase().startsWith(t));return h?h.slice(t.length):null}function be(i){return i.tags.includes("attribution-required")||i.warnings?.some(t=>t.toLowerCase().includes("attribution"))===!0}function ge({candidate:i,selected:t,disabled:h=!1,onToggleSelected:s,onImportOne:g}){const{t:c}=O();if(!i)return e.jsx("aside",{className:"prompt-import-dialog__candidate-preview","aria-label":c("promptLibrary.previewPrompt"),children:e.jsx("div",{className:"prompt-import-dialog__empty",children:c("promptLibrary.importPreviewEmpty")})});const x=ue(i),b=he(i,"license:"),v=be(i);return e.jsxs("aside",{className:"prompt-import-dialog__candidate-preview","aria-label":c("promptLibrary.previewPrompt"),children:[e.jsxs("div",{className:"prompt-import-dialog__preview-header",children:[e.jsxs("div",{children:[e.jsx("span",{children:c("promptLibrary.previewPrompt")}),e.jsx("h4",{children:i.name})]}),e.jsx("button",{type:"button",onClick:()=>g(i),disabled:h,children:c("promptLibrary.importThisPrompt")})]}),e.jsxs("label",{className:"prompt-import-dialog__preview-select",children:[e.jsx("input",{type:"checkbox",checked:t,disabled:h,onChange:l=>s(i.id,l.target.checked)}),e.jsx("span",{children:c(t?"promptLibrary.selectedPrompt":"promptLibrary.selectPrompt")})]}),e.jsxs("div",{className:"prompt-import-dialog__preview-field",children:[e.jsx("strong",{children:c("promptLibrary.promptText")}),e.jsx("p",{children:i.text})]}),i.tags.length>0?e.jsxs("div",{className:"prompt-import-dialog__preview-field",children:[e.jsx("strong",{children:c("promptLibrary.tags")}),e.jsx("div",{className:"prompt-import-dialog__preview-chips",children:i.tags.map(l=>e.jsx("em",{children:l},l))})]}):null,i.warnings?.length?e.jsxs("div",{className:"prompt-import-dialog__preview-field",children:[e.jsx("strong",{children:c("promptLibrary.compatibilityWarnings")}),e.jsx("div",{className:"prompt-import-dialog__preview-chips",children:i.warnings.map(l=>e.jsx("b",{children:l},l))})]}):null,x||b||v?e.jsxs("div",{className:"prompt-import-dialog__preview-field",children:[e.jsx("strong",{children:c("promptLibrary.sourceDetails")}),x?e.jsx("small",{children:x}):null,b?e.jsxs("small",{children:[c("promptLibrary.license"),": ",b]}):null,v?e.jsx("small",{children:c("promptLibrary.attributionRequired")}):null]}):null]})}function xe(i){const t=i.source;if(!t)return"";if(t.owner&&t.repo){const h=t.path?` · ${t.path}`:"";return`github · ${t.owner}/${t.repo}${h}`}return t.filename?t.filename:t.sourceId?t.sourceId:t.kind??""}function ye(i){const t=i.replace(/\s+/g," ").trim();return t.length>220?`${t.slice(0,220)}...`:t}function fe({candidates:i,selectedIds:t,activeCandidateId:h,busy:s=!1,onSelectCandidate:g,onToggleSelected:c,onSelectAll:x,onClearSelection:b,onImportOne:v}){const{t:l}=O();if(i.length===0)return e.jsx("section",{className:"prompt-import-dialog__results","aria-label":l("promptLibrary.searchResults"),children:e.jsx("div",{className:"prompt-import-dialog__empty",children:l("promptLibrary.importPreviewEmpty")})});const F=i.every(n=>t.has(n.id));return e.jsxs("section",{className:"prompt-import-dialog__results","aria-label":l("promptLibrary.searchResults"),children:[e.jsxs("header",{className:"prompt-import-dialog__results-header",children:[e.jsx("strong",{children:l("promptLibrary.searchResultsHeader",{count:i.length})}),e.jsxs("div",{className:"prompt-import-dialog__results-header-actions",children:[e.jsx("button",{type:"button",onClick:x,disabled:F,children:l("promptLibrary.selectAllCandidates")}),e.jsx("button",{type:"button",onClick:b,disabled:t.size===0,children:l("promptLibrary.clearCandidateSelection")})]})]}),i.map(n=>{const y=t.has(n.id),j=h===n.id,L=xe(n);return e.jsxs("article",{className:`prompt-import-dialog__result-card${j?" active":""}`,children:[e.jsxs("button",{type:"button",className:"prompt-import-dialog__result-main",onClick:()=>g(n),children:[e.jsx("strong",{children:n.name}),e.jsx("span",{children:ye(n.text)}),L?e.jsx("small",{children:L}):null]}),e.jsxs("div",{className:"prompt-import-dialog__result-meta",children:[n.warnings?.slice(0,2).map(m=>e.jsx("b",{className:"prompt-import-dialog__hint-chip",children:m},m)),n.tags.slice(0,4).map(m=>e.jsx("em",{children:m},m))]}),e.jsxs("div",{className:"prompt-import-dialog__result-actions",children:[e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:y,onChange:m=>c(n.id,m.target.checked)}),e.jsx("span",{children:l(y?"promptLibrary.selectedPrompt":"promptLibrary.selectPrompt")})]}),e.jsx("button",{type:"button",onClick:()=>g(n),children:l("promptLibrary.previewPrompt")}),e.jsx("button",{type:"button",onClick:()=>v(n),disabled:s,children:l("promptLibrary.importThisPrompt")})]})]},n.id)})]})}const ve=o.lazy(()=>J(()=>import("./PromptImportDiscoverySection-D2_TAuLm.js"),__vite__mapDeps([0,1,2])).then(i=>({default:i.PromptImportDiscoverySection}))),je=o.lazy(()=>J(()=>import("./PromptImportFolderSection-qv0qhTwq.js"),__vite__mapDeps([3,1,2])).then(i=>({default:i.PromptImportFolderSection}))),_e=/\.(txt|md|markdown)$/i;function Se({open:i,onClose:t,onImported:h}){const{t:s}=O(),g=ne(r=>r.showToast),c=o.useRef(null),x=ce(i,t),[b,v]=o.useState(""),[l,F]=o.useState([]),[n,y]=o.useState(new Set),[j,L]=o.useState(null),[m,_]=o.useState(!1),[V,u]=o.useState(null),[K,C]=o.useState(!1),[X,R]=o.useState([]),[A,Y]=o.useState(""),[k,$]=o.useState(new Set),[z,N]=o.useState(!1),[W,P]=o.useState([]),[w,q]=o.useState("curated"),[B,Z]=o.useState(!1),G=l.length>0,I=!G||B,ee=o.useCallback(async()=>{const r=await U();R(r.sources),$(new Set)},[]);o.useEffect(()=>{if(!i)return;let r=!1;return U().then(a=>{r||(R(a.sources),$(new Set))}).catch(()=>{r||R([])}),()=>{r=!0}},[i]);const f=o.useCallback(r=>{F(a=>{const p=new Set(a.map(S=>S.id)),d=[...a];for(const S of r)p.has(S.id)||d.push(S);return L(S=>S??d[0]?.id??null),d})},[]),E=o.useCallback(async r=>{const a=r.filter(p=>_e.test(p.name));if(a.length===0){u(s("promptLibrary.importNoValidFiles"));return}_(!0),u(null);try{const p=[];for(const d of a)p.push(await M({source:{kind:"local",filename:d.name,text:await d.text()}}));f(p.flatMap(d=>d.candidates))}catch(p){u(p instanceof Error?p.message:s("promptLibrary.importFailed"))}finally{_(!1)}},[f,s]),re=o.useCallback(async()=>{if(b.trim()){_(!0),u(null);try{const r=await M({source:{kind:"github",input:b.trim()}});f(r.candidates)}catch(r){u(r instanceof Error?r.message:s("promptLibrary.importFailed"))}finally{_(!1)}}},[f,b,s]),te=o.useCallback(async()=>{N(!0),u(null),P([]);try{const r=await pe({q:A.trim(),sourceIds:[...k]});f(r.results),P(r.warnings),r.results.length===0&&u(s("promptLibrary.noCuratedResults"))}catch(r){u(r instanceof Error?r.message:s("promptLibrary.importFailed"))}finally{N(!1)}},[f,A,k,s]),se=o.useCallback(async r=>{N(!0),u(null),P([]);try{const a=await de({sourceId:r});P(a.warnings),g(s("promptLibrary.curatedRefreshed",{count:a.candidateCount}))}catch(a){u(a instanceof Error?a.message:s("promptLibrary.importFailed"))}finally{N(!1)}},[g,s]),H=o.useCallback((r,a)=>{y(p=>{const d=new Set(p);return a?d.add(r):d.delete(r),d})},[]),ie=o.useCallback(()=>{y(new Set(l.map(r=>r.id)))},[l]),oe=o.useCallback(()=>{y(new Set)},[]),D=o.useCallback(async r=>{if(r.length===0){u(s("promptLibrary.importSelectAtLeastOne"));return}_(!0),u(null);try{const a=await me({candidates:r});await h(),g(s("promptLibrary.imported",{count:a.promptsImported})),t()}catch(a){u(a instanceof Error?a.message:s("promptLibrary.importFailed"))}finally{_(!1)}},[t,h,g,s]),ae=o.useCallback(async()=>{const r=l.filter(a=>n.has(a.id));await D(r)},[l,D,n]),Q=o.useCallback(r=>{y(new Set([r.id])),D([r])},[D]),le=o.useCallback(r=>{const a=Array.from(r.target.files??[]);a.length>0&&E(a),r.target.value=""},[E]),T=o.useCallback(r=>{r.preventDefault(),r.stopPropagation(),C(!1);const a=Array.from(r.dataTransfer?.files??[]);a.length>0&&E(a)},[E]);return o.useEffect(()=>{if(!i)return;const r=p=>{p.preventDefault(),C(!0)},a=p=>{p.relatedTarget===null&&C(!1)};return window.addEventListener("dragover",r),window.addEventListener("dragleave",a),window.addEventListener("drop",T),()=>{window.removeEventListener("dragover",r),window.removeEventListener("dragleave",a),window.removeEventListener("drop",T)}},[T,i]),i?e.jsxs("div",{className:"prompt-import-dialog",role:"presentation",children:[e.jsx("div",{className:"prompt-import-dialog__backdrop",onClick:t}),e.jsxs("div",{ref:x,className:"prompt-import-dialog__panel",role:"dialog","aria-modal":"true","aria-labelledby":"prompt-import-title",tabIndex:-1,children:[e.jsxs("div",{className:"prompt-import-dialog__header",children:[e.jsx("h3",{id:"prompt-import-title",children:s("promptLibrary.importTitle")}),e.jsx("button",{type:"button",onClick:t,"aria-label":s("common.close"),children:"×"})]}),I&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`prompt-import-dialog__dropzone${K?" active":""}`,onDragOver:r=>{r.preventDefault(),C(!0)},onDragLeave:()=>C(!1),onDrop:T,children:[e.jsx("strong",{children:s("promptLibrary.importDropTitle")}),e.jsx("span",{children:s("promptLibrary.importDropHint")}),e.jsx("button",{type:"button",onClick:()=>c.current?.click(),children:s("promptLibrary.importChooseFiles")}),e.jsx("input",{ref:c,className:"prompt-library-panel__file-input",type:"file",accept:".txt,.md,.markdown,text/plain,text/markdown",multiple:!0,onChange:le})]}),e.jsxs("div",{className:"prompt-import-dialog__github",children:[e.jsx("label",{htmlFor:"prompt-import-github",children:s("promptLibrary.importGithubLabel")}),e.jsxs("div",{children:[e.jsx("input",{id:"prompt-import-github",type:"text",value:b,onChange:r=>v(r.target.value),placeholder:"owner/repo:path/to/prompts.md"}),e.jsx("button",{type:"button",onClick:()=>{re()},disabled:m||!b.trim(),children:s("promptLibrary.importPreview")})]})]}),e.jsx(o.Suspense,{fallback:null,children:e.jsx(je,{input:b,disabled:m,onCandidates:f,onError:u})}),e.jsxs("div",{className:"prompt-import-dialog__source-tabs",role:"tablist","aria-label":s("promptLibrary.curatedSources"),children:[e.jsx("button",{type:"button",className:w==="curated"?"active":"",onClick:()=>q("curated"),"aria-pressed":w==="curated",children:s("promptLibrary.curatedSources")}),e.jsx("button",{type:"button",className:w==="discovery"?"active":"",onClick:()=>q("discovery"),"aria-pressed":w==="discovery",children:s("promptLibrary.discovery")})]})]}),(I?w==="curated":!0)&&e.jsxs("div",{className:"prompt-import-dialog__curated",children:[I&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"prompt-import-dialog__section-title",children:[e.jsx("strong",{children:s("promptLibrary.curatedSources")}),e.jsx("span",{children:s("promptLibrary.curatedSourcesHint")})]}),e.jsx("div",{className:"prompt-import-dialog__source-list",children:X.filter(r=>r.trustTier!=="manual-review").map(r=>e.jsxs("label",{className:"prompt-import-dialog__source",children:[e.jsx("input",{type:"checkbox",checked:k.has(r.id),onChange:a=>{$(p=>{const d=new Set(p);return a.target.checked?d.add(r.id):d.delete(r.id),d})}}),e.jsxs("span",{children:[e.jsx("strong",{children:r.displayName}),e.jsxs("small",{children:[r.licenseSpdx," · ",r.trustTier]})]}),e.jsx("button",{type:"button",onClick:()=>{se(r.id)},disabled:z,children:s("promptLibrary.refreshSource")})]},r.id))})]}),e.jsxs("div",{className:"prompt-import-dialog__search-results",children:[e.jsx("input",{type:"text",value:A,onChange:r=>Y(r.target.value),placeholder:s("promptLibrary.curatedSearchPlaceholder"),"aria-label":s("promptLibrary.curatedSearch")}),e.jsx("button",{type:"button",onClick:()=>{te()},disabled:z||k.size===0,children:s(z?"common.loading":"promptLibrary.curatedSearch")})]}),W.length>0?e.jsx("div",{className:"prompt-import-dialog__warning",children:W.slice(0,3).join(" · ")}):null]}),I&&w==="discovery"&&e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"prompt-import-dialog__empty",children:s("common.loading")}),children:e.jsx(ve,{disabled:m,onError:u,onSourcesChanged:ee})}),G&&!B&&e.jsx("button",{type:"button",className:"prompt-import-dialog__add-source-toggle",onClick:()=>Z(!0),children:s("promptLibrary.addAnotherSource")}),V?e.jsx("div",{className:"prompt-import-dialog__error",role:"alert",children:V}):null,e.jsxs("div",{className:"prompt-import-dialog__workspace","aria-live":"polite",children:[e.jsx(fe,{candidates:l,selectedIds:n,activeCandidateId:j,busy:m,onSelectCandidate:r=>L(r.id),onToggleSelected:H,onSelectAll:ie,onClearSelection:oe,onImportOne:Q}),e.jsx(ge,{candidate:l.find(r=>r.id===j)??null,selected:j?n.has(j):!1,disabled:m,onToggleSelected:H,onImportOne:Q})]}),e.jsxs("div",{className:"prompt-import-dialog__footer",children:[e.jsx("button",{type:"button",onClick:t,children:s("common.cancel")}),e.jsx("button",{type:"button",onClick:()=>{ae()},disabled:m||n.size===0,children:m?s("common.loading"):s("promptLibrary.importSelected",{count:n.size})})]})]})]}):null}export{Se as PromptImportDialog};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PromptImportDiscoverySection-BWoUDHj1.js","assets/index-Sch70vBs.js","assets/index-DGRIdnsL.css","assets/PromptImportFolderSection-DBSEyJb-.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as O,j as e,b as ne,a as o,p as ce,aR as M,aS as Q,aT as pe,aU as de,aV as me,ah as J}from"./index-Sch70vBs.js";function ue(i){const t=i.source;if(!t)return"";if(t.owner&&t.repo){const h=t.ref?`@${t.ref}`:"",s=t.path?`:${t.path}`:"";return`${t.owner}/${t.repo}${h}${s}`}return t.filename??t.sourceId??t.kind??""}function he(i,t){const h=i.tags.find(s=>s.toLowerCase().startsWith(t));return h?h.slice(t.length):null}function be(i){return i.tags.includes("attribution-required")||i.warnings?.some(t=>t.toLowerCase().includes("attribution"))===!0}function ge({candidate:i,selected:t,disabled:h=!1,onToggleSelected:s,onImportOne:g}){const{t:c}=O();if(!i)return e.jsx("aside",{className:"prompt-import-dialog__candidate-preview","aria-label":c("promptLibrary.previewPrompt"),children:e.jsx("div",{className:"prompt-import-dialog__empty",children:c("promptLibrary.importPreviewEmpty")})});const x=ue(i),b=he(i,"license:"),v=be(i);return e.jsxs("aside",{className:"prompt-import-dialog__candidate-preview","aria-label":c("promptLibrary.previewPrompt"),children:[e.jsxs("div",{className:"prompt-import-dialog__preview-header",children:[e.jsxs("div",{children:[e.jsx("span",{children:c("promptLibrary.previewPrompt")}),e.jsx("h4",{children:i.name})]}),e.jsx("button",{type:"button",onClick:()=>g(i),disabled:h,children:c("promptLibrary.importThisPrompt")})]}),e.jsxs("label",{className:"prompt-import-dialog__preview-select",children:[e.jsx("input",{type:"checkbox",checked:t,disabled:h,onChange:l=>s(i.id,l.target.checked)}),e.jsx("span",{children:c(t?"promptLibrary.selectedPrompt":"promptLibrary.selectPrompt")})]}),e.jsxs("div",{className:"prompt-import-dialog__preview-field",children:[e.jsx("strong",{children:c("promptLibrary.promptText")}),e.jsx("p",{children:i.text})]}),i.tags.length>0?e.jsxs("div",{className:"prompt-import-dialog__preview-field",children:[e.jsx("strong",{children:c("promptLibrary.tags")}),e.jsx("div",{className:"prompt-import-dialog__preview-chips",children:i.tags.map(l=>e.jsx("em",{children:l},l))})]}):null,i.warnings?.length?e.jsxs("div",{className:"prompt-import-dialog__preview-field",children:[e.jsx("strong",{children:c("promptLibrary.compatibilityWarnings")}),e.jsx("div",{className:"prompt-import-dialog__preview-chips",children:i.warnings.map(l=>e.jsx("b",{children:l},l))})]}):null,x||b||v?e.jsxs("div",{className:"prompt-import-dialog__preview-field",children:[e.jsx("strong",{children:c("promptLibrary.sourceDetails")}),x?e.jsx("small",{children:x}):null,b?e.jsxs("small",{children:[c("promptLibrary.license"),": ",b]}):null,v?e.jsx("small",{children:c("promptLibrary.attributionRequired")}):null]}):null]})}function xe(i){const t=i.source;if(!t)return"";if(t.owner&&t.repo){const h=t.path?` · ${t.path}`:"";return`github · ${t.owner}/${t.repo}${h}`}return t.filename?t.filename:t.sourceId?t.sourceId:t.kind??""}function ye(i){const t=i.replace(/\s+/g," ").trim();return t.length>220?`${t.slice(0,220)}...`:t}function fe({candidates:i,selectedIds:t,activeCandidateId:h,busy:s=!1,onSelectCandidate:g,onToggleSelected:c,onSelectAll:x,onClearSelection:b,onImportOne:v}){const{t:l}=O();if(i.length===0)return e.jsx("section",{className:"prompt-import-dialog__results","aria-label":l("promptLibrary.searchResults"),children:e.jsx("div",{className:"prompt-import-dialog__empty",children:l("promptLibrary.importPreviewEmpty")})});const F=i.every(n=>t.has(n.id));return e.jsxs("section",{className:"prompt-import-dialog__results","aria-label":l("promptLibrary.searchResults"),children:[e.jsxs("header",{className:"prompt-import-dialog__results-header",children:[e.jsx("strong",{children:l("promptLibrary.searchResultsHeader",{count:i.length})}),e.jsxs("div",{className:"prompt-import-dialog__results-header-actions",children:[e.jsx("button",{type:"button",onClick:x,disabled:F,children:l("promptLibrary.selectAllCandidates")}),e.jsx("button",{type:"button",onClick:b,disabled:t.size===0,children:l("promptLibrary.clearCandidateSelection")})]})]}),i.map(n=>{const y=t.has(n.id),j=h===n.id,L=xe(n);return e.jsxs("article",{className:`prompt-import-dialog__result-card${j?" active":""}`,children:[e.jsxs("button",{type:"button",className:"prompt-import-dialog__result-main",onClick:()=>g(n),children:[e.jsx("strong",{children:n.name}),e.jsx("span",{children:ye(n.text)}),L?e.jsx("small",{children:L}):null]}),e.jsxs("div",{className:"prompt-import-dialog__result-meta",children:[n.warnings?.slice(0,2).map(m=>e.jsx("b",{className:"prompt-import-dialog__hint-chip",children:m},m)),n.tags.slice(0,4).map(m=>e.jsx("em",{children:m},m))]}),e.jsxs("div",{className:"prompt-import-dialog__result-actions",children:[e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:y,onChange:m=>c(n.id,m.target.checked)}),e.jsx("span",{children:l(y?"promptLibrary.selectedPrompt":"promptLibrary.selectPrompt")})]}),e.jsx("button",{type:"button",onClick:()=>g(n),children:l("promptLibrary.previewPrompt")}),e.jsx("button",{type:"button",onClick:()=>v(n),disabled:s,children:l("promptLibrary.importThisPrompt")})]})]},n.id)})]})}const ve=o.lazy(()=>J(()=>import("./PromptImportDiscoverySection-BWoUDHj1.js"),__vite__mapDeps([0,1,2])).then(i=>({default:i.PromptImportDiscoverySection}))),je=o.lazy(()=>J(()=>import("./PromptImportFolderSection-DBSEyJb-.js"),__vite__mapDeps([3,1,2])).then(i=>({default:i.PromptImportFolderSection}))),_e=/\.(txt|md|markdown)$/i;function Se({open:i,onClose:t,onImported:h}){const{t:s}=O(),g=ne(r=>r.showToast),c=o.useRef(null),x=ce(i,t),[b,v]=o.useState(""),[l,F]=o.useState([]),[n,y]=o.useState(new Set),[j,L]=o.useState(null),[m,_]=o.useState(!1),[V,u]=o.useState(null),[K,C]=o.useState(!1),[X,R]=o.useState([]),[A,Y]=o.useState(""),[k,$]=o.useState(new Set),[z,N]=o.useState(!1),[W,P]=o.useState([]),[w,q]=o.useState("curated"),[B,Z]=o.useState(!1),G=l.length>0,I=!G||B,ee=o.useCallback(async()=>{const r=await M();R(r.sources),$(new Set)},[]);o.useEffect(()=>{if(!i)return;let r=!1;return M().then(a=>{r||(R(a.sources),$(new Set))}).catch(()=>{r||R([])}),()=>{r=!0}},[i]);const f=o.useCallback(r=>{F(a=>{const p=new Set(a.map(S=>S.id)),d=[...a];for(const S of r)p.has(S.id)||d.push(S);return L(S=>S??d[0]?.id??null),d})},[]),E=o.useCallback(async r=>{const a=r.filter(p=>_e.test(p.name));if(a.length===0){u(s("promptLibrary.importNoValidFiles"));return}_(!0),u(null);try{const p=[];for(const d of a)p.push(await Q({source:{kind:"local",filename:d.name,text:await d.text()}}));f(p.flatMap(d=>d.candidates))}catch(p){u(p instanceof Error?p.message:s("promptLibrary.importFailed"))}finally{_(!1)}},[f,s]),re=o.useCallback(async()=>{if(b.trim()){_(!0),u(null);try{const r=await Q({source:{kind:"github",input:b.trim()}});f(r.candidates)}catch(r){u(r instanceof Error?r.message:s("promptLibrary.importFailed"))}finally{_(!1)}}},[f,b,s]),te=o.useCallback(async()=>{N(!0),u(null),P([]);try{const r=await pe({q:A.trim(),sourceIds:[...k]});f(r.results),P(r.warnings),r.results.length===0&&u(s("promptLibrary.noCuratedResults"))}catch(r){u(r instanceof Error?r.message:s("promptLibrary.importFailed"))}finally{N(!1)}},[f,A,k,s]),se=o.useCallback(async r=>{N(!0),u(null),P([]);try{const a=await de({sourceId:r});P(a.warnings),g(s("promptLibrary.curatedRefreshed",{count:a.candidateCount}))}catch(a){u(a instanceof Error?a.message:s("promptLibrary.importFailed"))}finally{N(!1)}},[g,s]),H=o.useCallback((r,a)=>{y(p=>{const d=new Set(p);return a?d.add(r):d.delete(r),d})},[]),ie=o.useCallback(()=>{y(new Set(l.map(r=>r.id)))},[l]),oe=o.useCallback(()=>{y(new Set)},[]),D=o.useCallback(async r=>{if(r.length===0){u(s("promptLibrary.importSelectAtLeastOne"));return}_(!0),u(null);try{const a=await me({candidates:r});await h(),g(s("promptLibrary.imported",{count:a.promptsImported})),t()}catch(a){u(a instanceof Error?a.message:s("promptLibrary.importFailed"))}finally{_(!1)}},[t,h,g,s]),ae=o.useCallback(async()=>{const r=l.filter(a=>n.has(a.id));await D(r)},[l,D,n]),U=o.useCallback(r=>{y(new Set([r.id])),D([r])},[D]),le=o.useCallback(r=>{const a=Array.from(r.target.files??[]);a.length>0&&E(a),r.target.value=""},[E]),T=o.useCallback(r=>{r.preventDefault(),r.stopPropagation(),C(!1);const a=Array.from(r.dataTransfer?.files??[]);a.length>0&&E(a)},[E]);return o.useEffect(()=>{if(!i)return;const r=p=>{p.preventDefault(),C(!0)},a=p=>{p.relatedTarget===null&&C(!1)};return window.addEventListener("dragover",r),window.addEventListener("dragleave",a),window.addEventListener("drop",T),()=>{window.removeEventListener("dragover",r),window.removeEventListener("dragleave",a),window.removeEventListener("drop",T)}},[T,i]),i?e.jsxs("div",{className:"prompt-import-dialog",role:"presentation",children:[e.jsx("div",{className:"prompt-import-dialog__backdrop",onClick:t}),e.jsxs("div",{ref:x,className:"prompt-import-dialog__panel",role:"dialog","aria-modal":"true","aria-labelledby":"prompt-import-title",tabIndex:-1,children:[e.jsxs("div",{className:"prompt-import-dialog__header",children:[e.jsx("h3",{id:"prompt-import-title",children:s("promptLibrary.importTitle")}),e.jsx("button",{type:"button",onClick:t,"aria-label":s("common.close"),children:"×"})]}),I&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`prompt-import-dialog__dropzone${K?" active":""}`,onDragOver:r=>{r.preventDefault(),C(!0)},onDragLeave:()=>C(!1),onDrop:T,children:[e.jsx("strong",{children:s("promptLibrary.importDropTitle")}),e.jsx("span",{children:s("promptLibrary.importDropHint")}),e.jsx("button",{type:"button",onClick:()=>c.current?.click(),children:s("promptLibrary.importChooseFiles")}),e.jsx("input",{ref:c,className:"prompt-library-panel__file-input",type:"file",accept:".txt,.md,.markdown,text/plain,text/markdown",multiple:!0,onChange:le})]}),e.jsxs("div",{className:"prompt-import-dialog__github",children:[e.jsx("label",{htmlFor:"prompt-import-github",children:s("promptLibrary.importGithubLabel")}),e.jsxs("div",{children:[e.jsx("input",{id:"prompt-import-github",type:"text",value:b,onChange:r=>v(r.target.value),placeholder:"owner/repo:path/to/prompts.md"}),e.jsx("button",{type:"button",onClick:()=>{re()},disabled:m||!b.trim(),children:s("promptLibrary.importPreview")})]})]}),e.jsx(o.Suspense,{fallback:null,children:e.jsx(je,{input:b,disabled:m,onCandidates:f,onError:u})}),e.jsxs("div",{className:"prompt-import-dialog__source-tabs",role:"tablist","aria-label":s("promptLibrary.curatedSources"),children:[e.jsx("button",{type:"button",className:w==="curated"?"active":"",onClick:()=>q("curated"),"aria-pressed":w==="curated",children:s("promptLibrary.curatedSources")}),e.jsx("button",{type:"button",className:w==="discovery"?"active":"",onClick:()=>q("discovery"),"aria-pressed":w==="discovery",children:s("promptLibrary.discovery")})]})]}),(I?w==="curated":!0)&&e.jsxs("div",{className:"prompt-import-dialog__curated",children:[I&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"prompt-import-dialog__section-title",children:[e.jsx("strong",{children:s("promptLibrary.curatedSources")}),e.jsx("span",{children:s("promptLibrary.curatedSourcesHint")})]}),e.jsx("div",{className:"prompt-import-dialog__source-list",children:X.filter(r=>r.trustTier!=="manual-review").map(r=>e.jsxs("label",{className:"prompt-import-dialog__source",children:[e.jsx("input",{type:"checkbox",checked:k.has(r.id),onChange:a=>{$(p=>{const d=new Set(p);return a.target.checked?d.add(r.id):d.delete(r.id),d})}}),e.jsxs("span",{children:[e.jsx("strong",{children:r.displayName}),e.jsxs("small",{children:[r.licenseSpdx," · ",r.trustTier]})]}),e.jsx("button",{type:"button",onClick:()=>{se(r.id)},disabled:z,children:s("promptLibrary.refreshSource")})]},r.id))})]}),e.jsxs("div",{className:"prompt-import-dialog__search-results",children:[e.jsx("input",{type:"text",value:A,onChange:r=>Y(r.target.value),placeholder:s("promptLibrary.curatedSearchPlaceholder"),"aria-label":s("promptLibrary.curatedSearch")}),e.jsx("button",{type:"button",onClick:()=>{te()},disabled:z||k.size===0,children:s(z?"common.loading":"promptLibrary.curatedSearch")})]}),W.length>0?e.jsx("div",{className:"prompt-import-dialog__warning",children:W.slice(0,3).join(" · ")}):null]}),I&&w==="discovery"&&e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"prompt-import-dialog__empty",children:s("common.loading")}),children:e.jsx(ve,{disabled:m,onError:u,onSourcesChanged:ee})}),G&&!B&&e.jsx("button",{type:"button",className:"prompt-import-dialog__add-source-toggle",onClick:()=>Z(!0),children:s("promptLibrary.addAnotherSource")}),V?e.jsx("div",{className:"prompt-import-dialog__error",role:"alert",children:V}):null,e.jsxs("div",{className:"prompt-import-dialog__workspace","aria-live":"polite",children:[e.jsx(fe,{candidates:l,selectedIds:n,activeCandidateId:j,busy:m,onSelectCandidate:r=>L(r.id),onToggleSelected:H,onSelectAll:ie,onClearSelection:oe,onImportOne:U}),e.jsx(ge,{candidate:l.find(r=>r.id===j)??null,selected:j?n.has(j):!1,disabled:m,onToggleSelected:H,onImportOne:U})]}),e.jsxs("div",{className:"prompt-import-dialog__footer",children:[e.jsx("button",{type:"button",onClick:t,children:s("common.cancel")}),e.jsx("button",{type:"button",onClick:()=>{ae()},disabled:m||n.size===0,children:m?s("common.loading"):s("promptLibrary.importSelected",{count:n.size})})]})]})]}):null}export{Se as PromptImportDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as L,a as t,
|
|
1
|
+
import{u as L,a as t,aX as S,aY as C,aZ as P,j as r}from"./index-Sch70vBs.js";const R=["gpt-image-2 prompt","nano banana prompts","typography image prompt"];function k({disabled:d=!1,onError:a,onSourcesChanged:y}){const{t:s}=L(),[l,N]=t.useState("gpt-image-2 prompt"),[v,p]=t.useState([]),[n,c]=t.useState(!1),[g,m]=t.useState([]),[h,_]=t.useState({});t.useEffect(()=>{let e=!1;return S().then(i=>{e||p(i.candidates)}).catch(()=>{e||p([])}),()=>{e=!0}},[]);const w=t.useCallback(async()=>{c(!0),m([]),a(null);try{const e=await C({q:l.trim(),seeds:R});p(e.candidates),m([...e.warnings,...e.rateLimit?.remaining===0?["github-rate-limit-exhausted"]:[]]),e.candidates.length===0&&a(s("promptLibrary.discoveryNoResults"))}catch(e){a(e instanceof Error?e.message:s("promptLibrary.importFailed"))}finally{c(!1)}},[a,l,s]),x=t.useCallback(async(e,i)=>{c(!0),m([]),a(null);try{const j=(h[e.fullName]||"").split(/\r?\n|,/).map(u=>u.trim()).filter(Boolean),b=await P({repo:e.fullName,status:i,allowedPaths:i==="approved"?j:[],defaultSearch:i==="approved"&&j.length>0});m(b.warnings),p(u=>u.map(f=>f.fullName===e.fullName?b.candidate:f)),await y()}catch(o){a(o instanceof Error?o.message:s("promptLibrary.importFailed"))}finally{c(!1)}},[h,a,y,s]);return r.jsxs("div",{className:"prompt-import-dialog__discovery",children:[r.jsxs("div",{className:"prompt-import-dialog__section-title",children:[r.jsx("strong",{children:s("promptLibrary.discovery")}),r.jsx("span",{children:s("promptLibrary.discoveryReviewQueue")})]}),r.jsxs("div",{className:"prompt-import-dialog__discovery-actions",children:[r.jsx("input",{type:"text",value:l,onChange:e=>N(e.target.value),placeholder:s("promptLibrary.discoverySearchPlaceholder"),"aria-label":s("promptLibrary.discoverySearch")}),r.jsx("button",{type:"button",onClick:()=>{w()},disabled:d||n||!l.trim(),children:s(n?"common.loading":"promptLibrary.discoverySearch")})]}),g.length>0?r.jsx("div",{className:"prompt-import-dialog__discovery-warning",children:g.slice(0,3).join(" · ")}):null,v.length===0?r.jsx("div",{className:"prompt-import-dialog__empty",children:s("promptLibrary.discoveryNoResults")}):r.jsx("div",{className:"prompt-import-dialog__discovery-list",children:v.map(e=>r.jsxs("article",{className:"prompt-import-dialog__discovery-candidate",children:[r.jsxs("div",{children:[r.jsx("strong",{children:e.fullName}),r.jsx("small",{children:e.description||e.htmlUrl})]}),r.jsxs("div",{className:"prompt-import-dialog__score",children:[r.jsxs("span",{children:[s("promptLibrary.discoveryScore"),": ",e.score]}),r.jsx("span",{children:e.licenseSpdx}),r.jsx("span",{children:e.status})]}),e.scoreReasons.length>0?r.jsx("em",{children:e.scoreReasons.slice(0,3).join(" · ")}):null,e.warnings.length>0?r.jsx("b",{children:e.warnings.slice(0,2).join(" · ")}):null,r.jsx("textarea",{value:h[e.fullName]||"",onChange:i=>_(o=>({...o,[e.fullName]:i.target.value})),placeholder:"README.md, prompts/example.md","aria-label":s("promptLibrary.discoveryRequiresPaths")}),r.jsxs("div",{className:"prompt-import-dialog__review-actions",children:[r.jsx("button",{type:"button",onClick:()=>{x(e,"approved")},disabled:d||n,children:s("promptLibrary.discoveryApprove")}),r.jsx("button",{type:"button",onClick:()=>{x(e,"rejected")},disabled:d||n,children:s("promptLibrary.discoveryReject")})]})]},e.fullName))})]})}export{k as PromptImportDiscoverySection};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as w,a,
|
|
1
|
+
import{u as w,a,a_ as S,a$ as _,j as t}from"./index-Sch70vBs.js";function F({input:i,disabled:h=!1,onCandidates:u,onError:l}){const{t:s}=w(),[f,g]=a.useState([]),[o,p]=a.useState(new Set),[d,n]=a.useState(!1),[x,c]=a.useState([]),y=a.useCallback(async()=>{if(i.trim()){n(!0),c([]),l(null);try{const e=await S({source:{kind:"github-folder",input:i.trim()}});g(e.files),p(new Set(e.files.slice(0,5).map(r=>r.path))),c(e.warnings),e.files.length===0&&l(s("promptLibrary.folderFilesEmpty"))}catch(e){g([]),p(new Set),l(e instanceof Error?e.message:s("promptLibrary.folderUnsupported"))}finally{n(!1)}}},[i,l,s]),b=a.useCallback(async()=>{const e=[...o];if(e.length===0){l(s("promptLibrary.folderNoSelection"));return}n(!0),c([]),l(null);try{const r=await _({source:{kind:"github-folder",input:i.trim()},paths:e});c(r.warnings),u(r.candidates)}catch(r){l(r instanceof Error?r.message:s("promptLibrary.importFailed"))}finally{n(!1)}},[i,u,l,o,s]);return t.jsxs("div",{className:"prompt-import-dialog__folder",children:[t.jsxs("div",{className:"prompt-import-dialog__section-title",children:[t.jsx("strong",{children:s("promptLibrary.folderFiles")}),t.jsx("span",{children:s("promptLibrary.folderBrowseHint")})]}),t.jsxs("div",{className:"prompt-import-dialog__folder-actions",children:[t.jsx("button",{type:"button",onClick:()=>{y()},disabled:h||d||!i.trim(),children:s(d?"common.loading":"promptLibrary.folderBrowse")}),t.jsx("button",{type:"button",onClick:()=>{b()},disabled:h||d||o.size===0,children:s("promptLibrary.folderPreviewSelected")}),t.jsx("span",{children:s("promptLibrary.folderSelectedCount",{count:o.size})})]}),f.length>0?t.jsx("div",{className:"prompt-import-dialog__folder-list",children:f.map(e=>t.jsxs("label",{className:"prompt-import-dialog__folder-file",children:[t.jsx("input",{type:"checkbox",checked:o.has(e.path),onChange:r=>{p(j=>{const m=new Set(j);return r.target.checked?m.add(e.path):m.delete(e.path),m})}}),t.jsxs("span",{children:[t.jsx("strong",{children:e.name}),t.jsx("small",{children:e.path})]}),t.jsxs("em",{children:[Math.ceil(e.sizeBytes/1024)," KB"]})]},e.path))}):null,x.length>0?t.jsx("div",{className:"prompt-import-dialog__folder-warning",children:x.slice(0,3).join(" · ")}):null]})}export{F as PromptImportFolderSection};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PromptImportDialog-
|
|
2
|
-
import{u as v,p as R,j as e,
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PromptImportDialog-B40X9UAa.js","assets/index-Sch70vBs.js","assets/index-DGRIdnsL.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as v,p as R,j as e,az as j,a as i,b as s,S as $,ah as z}from"./index-Sch70vBs.js";function A({prompt:a,onClose:d,onLoad:c,onInsert:t,onDelete:b,onToggleFavorite:l}){const{t:o}=v(),n=R(!0,d),m=async()=>{try{await navigator.clipboard.writeText(a.text)}catch{}};return e.jsxs("div",{className:"prompt-detail-modal",role:"presentation",children:[e.jsx("div",{className:"prompt-detail-modal__backdrop",onClick:d}),e.jsxs("div",{ref:n,className:"prompt-detail-modal__content",role:"dialog","aria-modal":"true","aria-labelledby":"prompt-detail-title",tabIndex:-1,children:[e.jsxs("div",{className:"prompt-detail-modal__header",children:[e.jsx("h2",{id:"prompt-detail-title",className:"prompt-detail-modal__title",children:a.name||o("promptLibrary.untitled")}),e.jsx("button",{className:"prompt-detail-modal__close",onClick:d,"aria-label":o("common.close"),children:"×"})]}),e.jsxs("div",{className:"prompt-detail-modal__body",children:[e.jsx("div",{className:"prompt-detail-modal__label",children:o("promptLibrary.content")}),e.jsx("div",{className:"prompt-detail-modal__prompt",children:a.text}),a.tags.length>0&&e.jsxs("div",{className:"prompt-detail-modal__tags",children:[e.jsx("div",{className:"prompt-detail-modal__label",children:o("promptLibrary.tags")}),e.jsx("div",{className:"prompt-detail-modal__tag-list",children:a.tags.map(p=>e.jsxs("span",{className:"prompt-detail-modal__tag",children:["#",p]},p))})]})]}),e.jsxs("div",{className:"prompt-detail-modal__footer",children:[e.jsx("button",{className:"prompt-detail-modal__load",onClick:c,children:o("promptLibrary.load")}),e.jsx("button",{className:"prompt-detail-modal__copy",onClick:m,children:o("promptLibrary.copy")}),e.jsxs("button",{className:"prompt-detail-modal__insert",onClick:t,children:["+ ",o("promptLibrary.insert")]}),e.jsxs("button",{className:`prompt-detail-modal__favorite${a.isFavorite?" prompt-detail-modal__favorite--on":""}`,onClick:l,"aria-pressed":a.isFavorite,children:[e.jsx(j,{}),a.isFavorite?o("promptLibrary.unfavorite"):o("promptLibrary.favorite")]}),e.jsx("button",{className:"prompt-detail-modal__delete",onClick:b,children:o("common.delete")})]})]})]})}function M({prompt:a,onLoad:d,onInsert:c,onDelete:t,onToggleFavorite:b}){const{t:l}=v(),[o,n]=i.useState(!1),m=a.text.length>45?a.text.slice(0,45)+"...":a.text;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"prompt-library-row",onClick:()=>n(!0),children:[e.jsxs("div",{className:"prompt-library-row__main",children:[e.jsx("div",{className:"prompt-library-row__title",children:a.name||l("promptLibrary.untitled")}),e.jsx("div",{className:"prompt-library-row__preview",children:m})]}),e.jsxs("div",{className:"prompt-library-row__actions",children:[e.jsx("button",{className:"prompt-library-row__insert",onClick:p=>{p.stopPropagation(),c()},title:l("promptLibrary.insert"),"aria-label":l("promptLibrary.insert"),children:"+"}),e.jsx("button",{className:`prompt-library-row__star${a.isFavorite?" prompt-library-row__star--on":""}`,onClick:p=>{p.stopPropagation(),b()},"aria-label":a.isFavorite?l("promptLibrary.unfavorite"):l("promptLibrary.favorite"),"aria-pressed":a.isFavorite,children:e.jsx(j,{})}),e.jsx("span",{className:"prompt-library-row__chevron",children:"›"})]})]}),o&&e.jsx(A,{prompt:a,onClose:()=>n(!1),onLoad:()=>{d(),n(!1)},onInsert:()=>{c(),n(!1)},onDelete:t,onToggleFavorite:b})]})}const V=i.lazy(()=>z(()=>import("./PromptImportDialog-B40X9UAa.js"),__vite__mapDeps([0,1,2])).then(a=>({default:a.PromptImportDialog})));function B({variant:a="overlay",forceOpen:d=!1,onRequestClose:c}){const{t}=v(),b=s(r=>r.promptLibraryOpen),l=s(r=>r.togglePromptLibrary),o=s(r=>r.promptLibrary),n=s(r=>r.promptLibraryLoading),m=s(r=>r.loadPromptLibrary),p=s(r=>r.deletePromptFromLibrary),w=s(r=>r.togglePromptFavorite),k=s(r=>r.setPrompt),L=s(r=>r.insertPromptToComposer),F=s(r=>r.clearInsertedPrompts),N=s(r=>r.showToast),[y,I]=i.useState(""),[x,S]=i.useState(!1),[O,f]=i.useState(!1),[g,C]=i.useState(!1),h=d||b,_=c??l;i.useEffect(()=>{h&&m()},[h,m]);const D=i.useCallback(r=>{L({id:r.id,name:r.name||t("promptLibrary.untitled"),text:r.text}),N(t("promptLibrary.inserted")),_()},[_,L,N,t]);if(!h)return null;const P=o.prompts.filter(r=>{if(x&&!r.isFavorite)return!1;if(!y.trim())return!0;const u=y.toLowerCase();return r.name.toLowerCase().includes(u)||r.text.toLowerCase().includes(u)||r.tags.some(E=>E.toLowerCase().includes(u))}),T=e.jsxs("div",{className:"prompt-library-panel__drawer",children:[e.jsxs("div",{className:"prompt-library-panel__header",children:[e.jsx("h3",{children:t("promptLibrary.title")}),e.jsxs("div",{className:"prompt-library-panel__actions",children:[e.jsx("button",{className:"prompt-library-panel__add",onClick:()=>f(r=>!r),title:t("promptLibrary.addNew"),"aria-label":t("promptLibrary.addNew"),children:"+"}),e.jsx("button",{className:"prompt-library-panel__import",onClick:()=>C(!0),title:t("promptLibrary.importFiles"),"aria-label":t("promptLibrary.importFiles"),children:t("promptLibrary.import")}),e.jsx("button",{onClick:_,"aria-label":t("common.close"),children:"×"})]}),O&&e.jsx($,{text:"",onClose:()=>f(!1)})]}),e.jsxs("div",{className:"prompt-library-panel__search",children:[e.jsx("input",{type:"text",placeholder:t("promptLibrary.search"),value:y,onChange:r=>I(r.target.value)}),e.jsxs("button",{type:"button",className:`prompt-library-panel__filter-toggle${x?" active":""}`,"aria-pressed":x,title:t("promptLibrary.favorites"),onClick:()=>S(r=>!r),children:[e.jsx(j,{}),e.jsx("span",{children:t("promptLibrary.favorites")})]})]}),n?e.jsx("div",{className:"prompt-library-panel__loading",children:t("common.loading")}):e.jsx("div",{className:"prompt-library-panel__list",children:P.length===0?e.jsx("div",{className:"prompt-library-panel__empty",children:t("promptLibrary.empty")}):P.map(r=>e.jsx(M,{prompt:r,onLoad:()=>{F(),k(r.text),l()},onInsert:()=>D(r),onDelete:()=>p(r.id),onToggleFavorite:()=>w(r.id)},r.id))}),g?e.jsx(i.Suspense,{fallback:null,children:e.jsx(V,{open:g,onClose:()=>C(!1),onImported:m})}):null]});return e.jsxs("div",{className:`prompt-library-panel prompt-library-panel--${a}`,children:[a==="overlay"?e.jsx("div",{className:"prompt-library-panel__backdrop",onClick:_}):null,T]})}export{B as PromptLibraryPanel};
|
|
@@ -1 +1 @@
|
|
|
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-DTEhasVd.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
|
+
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};
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
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};
|