ima2-gen 3.18.0 → 3.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/commands/doctor.js +13 -8
- package/bin/commands/gpt.js +216 -0
- package/bin/ima2.js +89 -53
- package/bin/lib/doctor-providers.js +19 -4
- package/docs/API.md +6 -3
- package/docs/migration/runtime-test-inventory.md +4 -1
- package/lib/authStatus.js +93 -0
- package/lib/chatgptAuth.js +236 -0
- package/lib/chatgptLogin.js +257 -0
- package/lib/codexDetect.js +16 -10
- package/lib/oauthLauncher.js +32 -0
- package/lib/oauthProxy/runtime.js +3 -0
- package/node_modules/openai-oauth/dist/chunk-2AENSHRT.js +84 -14
- package/node_modules/openai-oauth/package.json +2 -2
- package/package.json +3 -3
- package/routes/auth.js +111 -204
- package/routes/health.js +23 -9
- package/routes/quota.js +4 -9
- package/server.js +56 -11
- package/ui/dist/.vite/manifest.json +64 -64
- package/ui/dist/assets/{AgentWorkspace-CxbtxZYs.js → AgentWorkspace-C6ke6Eo4.js} +1 -1
- package/ui/dist/assets/{App-x_fzCXKb.js → App-pMN1OjNW.js} +8 -8
- package/ui/dist/assets/{AssetGenWorkspace-BIYh26wL.js → AssetGenWorkspace-DzEfpUy_.js} +2 -2
- package/ui/dist/assets/{AssetMediaLightbox-ordAqhjX.js → AssetMediaLightbox-Bx0azN0S.js} +1 -1
- package/ui/dist/assets/AssetsWorkspace-CHw1u9VC.js +1 -0
- package/ui/dist/assets/{CardNewsWorkspace-BfR-FMwo.js → CardNewsWorkspace-DsjqhaYO.js} +2 -2
- package/ui/dist/assets/{GenerationRequestLogPanel-CaVBCWhI.js → GenerationRequestLogPanel-EYEiHIr9.js} +1 -1
- package/ui/dist/assets/{HomeWorkspace-x-oJypd7.js → HomeWorkspace-DbnY1YF2.js} +1 -1
- package/ui/dist/assets/{KeyingPanel-SsAIeDy3.js → KeyingPanel-8J_RMrxg.js} +1 -1
- package/ui/dist/assets/{NodeCanvas-B1R-fOYq.js → NodeCanvas-DmjbNcTa.js} +1 -1
- package/ui/dist/assets/{PromptBuilderPanel-gGHOSb6l.js → PromptBuilderPanel-CL34Jpso.js} +1 -1
- package/ui/dist/assets/{PromptImportDialog-B5Wv2cie.js → PromptImportDialog-B24cvEkK.js} +2 -2
- package/ui/dist/assets/{PromptImportDiscoverySection-B5AdpMnV.js → PromptImportDiscoverySection-Bbw1_J_3.js} +1 -1
- package/ui/dist/assets/{PromptImportFolderSection-DgIWI0j2.js → PromptImportFolderSection-CMpxuE8e.js} +1 -1
- package/ui/dist/assets/PromptLibraryPanel-Ct98TJ61.js +2 -0
- package/ui/dist/assets/SettingsWorkspace-DL9Tm90P.js +1 -0
- package/ui/dist/assets/{SpriteRecipeWorkspace-ghZGUlM8.js → SpriteRecipeWorkspace-BJUH1ddP.js} +1 -1
- package/ui/dist/assets/{index-B-iNVdeL.js → index-CHeVGnoy.js} +6 -6
- package/ui/dist/assets/{index-Co3ZHk9P.js → index-D_LpLGWV.js} +3 -3
- package/ui/dist/assets/{pptxgen.es-D6s2Ip8Q.js → pptxgen.es-s4xfPXLT.js} +1 -1
- package/ui/dist/assets/{promptBuilderStore-CQxHJQz4.js → promptBuilderStore-DQR29LwN.js} +1 -1
- package/ui/dist/assets/useAgentDialogFocus-DAeS9IWG.js +1 -0
- package/ui/dist/index.html +1 -1
- package/vendor/openai-oauth-1.0.2-ima2.2.tgz +0 -0
- package/ui/dist/assets/AssetsWorkspace-BuiwpbQQ.js +0 -1
- package/ui/dist/assets/PromptLibraryPanel-CGcqRRsJ.js +0 -2
- package/ui/dist/assets/SettingsWorkspace-BhbAnrYw.js +0 -1
- package/ui/dist/assets/useAgentDialogFocus-ALfcs_Em.js +0 -1
- package/vendor/openai-oauth-1.0.2-ima2.1.tgz +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PromptImportDiscoverySection-
|
|
2
|
-
import{j as e,f as o,_ as J}from"./index-B-iNVdeL.js";import{u as O,a as ne,k as ce,aO as M,aP as U,aQ as pe,aR as de,aS as me}from"./App-x_fzCXKb.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 R=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:R,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-B5AdpMnV.js"),__vite__mapDeps([0,1,2,3])).then(i=>({default:i.PromptImportDiscoverySection}))),je=o.lazy(()=>J(()=>import("./PromptImportFolderSection-DgIWI0j2.js"),__vite__mapDeps([4,1,2,3])).then(i=>({default:i.PromptImportFolderSection}))),_e=/\.(txt|md|markdown)$/i;function Le({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,R]=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,T]=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();T(r.sources),$(new Set)},[]);o.useEffect(()=>{if(!i)return;let r=!1;return M().then(a=>{r||(T(a.sources),$(new Set))}).catch(()=>{r||T([])}),()=>{r=!0}},[i]);const f=o.useCallback(r=>{R(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 U({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 U({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]),F=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",F),()=>{window.removeEventListener("dragover",r),window.removeEventListener("dragleave",a),window.removeEventListener("drop",F)}},[F,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:F,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{Le as PromptImportDialog};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PromptImportDiscoverySection-Bbw1_J_3.js","assets/index-CHeVGnoy.js","assets/index-CxX85A3B.css","assets/App-pMN1OjNW.js","assets/PromptImportFolderSection-CMpxuE8e.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{j as e,f as o,_ as J}from"./index-CHeVGnoy.js";import{u as O,a as ne,k as ce,aP as M,aQ as U,aR as pe,aS as de,aT as me}from"./App-pMN1OjNW.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-Bbw1_J_3.js"),__vite__mapDeps([0,1,2,3])).then(i=>({default:i.PromptImportDiscoverySection}))),je=o.lazy(()=>J(()=>import("./PromptImportFolderSection-CMpxuE8e.js"),__vite__mapDeps([4,1,2,3])).then(i=>({default:i.PromptImportFolderSection}))),_e=/\.(txt|md|markdown)$/i;function Le({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 U({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 U({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{Le as PromptImportDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as t,j as r}from"./index-
|
|
1
|
+
import{f as t,j as r}from"./index-CHeVGnoy.js";import{u as L,aU as S,aV as C,aW as P}from"./App-pMN1OjNW.js";const R=["gpt-image-2 prompt","nano banana prompts","typography image prompt"];function I({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{I as PromptImportDiscoverySection};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as a,j as t}from"./index-
|
|
1
|
+
import{f as a,j as t}from"./index-CHeVGnoy.js";import{u as w,aX as S,aY as _}from"./App-pMN1OjNW.js";function k({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{k as PromptImportFolderSection};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PromptImportDialog-B24cvEkK.js","assets/index-CHeVGnoy.js","assets/index-CxX85A3B.css","assets/App-pMN1OjNW.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{j as e,f as i,_ as R}from"./index-CHeVGnoy.js";import{u,k as $,av as j,a as s,S as A}from"./App-pMN1OjNW.js";function z({prompt:a,onClose:d,onLoad:c,onInsert:t,onDelete:b,onToggleFavorite:l}){const{t:o}=u(),n=$(!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}=u(),[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(z,{prompt:a,onClose:()=>n(!1),onLoad:()=>{d(),n(!1)},onInsert:()=>{c(),n(!1)},onDelete:t,onToggleFavorite:b})]})}const V=i.lazy(()=>R(()=>import("./PromptImportDialog-B24cvEkK.js"),__vite__mapDeps([0,1,2,3])).then(a=>({default:a.PromptImportDialog})));function G({variant:a="overlay",forceOpen:d=!1,onRequestClose:c}){const{t}=u(),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 v=y.toLowerCase();return r.name.toLowerCase().includes(v)||r.text.toLowerCase().includes(v)||r.tags.some(E=>E.toLowerCase().includes(v))}),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(A,{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{G as PromptLibraryPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as o,i as q,g as $,j as e,L as H,S as ue,u as ge,o as me}from"./index-CHeVGnoy.js";import{s as R,u as C,t as z,O as he,v as pe,x as fe,y as xe,z as ye,a as S,I as je,R as Y,V,A as ne,r as ve,B as Z,G as ae,C as be,U as _e,D as Ne,E as we,F as ke,H as Se,J as Le,K as Ce,L as Ee,M as ie,N as Ke,P as Te,Q as Ae,W as Ie}from"./App-pMN1OjNW.js";import{u as B}from"./promptBuilderStore-DQR29LwN.js";function Me(){const[s,n]=o.useState(null);return o.useEffect(()=>{if(q())return;const i=$();let t=!1;return(async()=>{try{const g=await R("/api/agy/status");if(t)return;const d=await g.json();if(t||q()||i!==$())return;n(d)}catch{!t&&!q()&&i===$()&&n({installed:!1})}})(),()=>{t=!0}},[]),s}function G({provider:s,label:n,placeholder:i,maskedKey:t,source:a,configured:g,onSaved:d}){const{t:c}=C(),[f,j]=o.useState(""),[p,u]=o.useState(!1),[v,x]=o.useState(!1),[r,y]=o.useState(null),[b,L]=o.useState(!1),E=a==="env",N=f.trim().length>0,M=g&&!p&&!N,D=o.useCallback(async()=>{if(N){x(!0),y(null),L(!1);try{const _=await(await R(`/api/keys/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:f.trim()})})).json();_.ok?(j(""),u(!1),L(!0),d(),setTimeout(()=>L(!1),3e3)):y(_.error||c("settings.apiKeys.saveFailed"))}catch(l){if(l?.code==="LAN_TOKEN_REQUIRED")return;y(c("settings.apiKeys.networkError"))}finally{x(!1)}}},[f,s,N,d,c]),K=o.useCallback(async()=>{try{if(!(await R(`/api/keys/${s}`,{method:"DELETE"})).ok){y(c("settings.apiKeys.removeFailed"));return}j(""),u(!1),d()}catch(l){if(l?.code==="LAN_TOKEN_REQUIRED")return;y(c("settings.apiKeys.networkError"))}},[s,d,c]),O=o.useCallback(()=>{g&&u(!0)},[g]),F=o.useCallback(()=>{N||u(!1)},[N]);return e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("p",{className:"settings-eyebrow",children:c(E?"settings.apiKeys.envSource":"settings.apiKeys.configSource")}),e.jsx("h4",{children:n}),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:O,onClick:O}):e.jsx("input",{type:"password",className:`api-key-input${r?" is-invalid":""}`,placeholder:i,value:f,onChange:l=>{j(l.target.value),y(null)},onBlur:F,readOnly:!1,autoComplete:"off",autoFocus:p,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:D,disabled:!N||v,children:c(v?"settings.apiKeys.saving":b?"settings.apiKeys.saved":"settings.apiKeys.save")}),g&&!E&&e.jsx("button",{type:"button",className:"settings-action-btn settings-action-btn--danger",onClick:K,children:c("settings.apiKeys.remove")})]})]}),r&&e.jsx("p",{className:"api-key-error",children:r})]}),e.jsxs("div",{className:`settings-status${g?" is-ok":""}`,children:[e.jsx("span",{"aria-hidden":"true"}),c(g?"settings.apiKeys.status.valid":"settings.apiKeys.status.notConfigured")]})]})}function Oe({configured:s,maskedKey:n,source:i,onSaved:t}){const{t:a}=C(),[g,d]=o.useState(""),[c,f]=o.useState(!1),[j,p]=o.useState(!1),[u,v]=o.useState(null),[x,r]=o.useState(!1),y=i==="env",b=g.trim().length>0,L=s&&!c&&!b,E=o.useCallback(async()=>{if(b){p(!0),v(null),r(!1);try{const O=await(await R("/api/keys/vertex",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({serviceAccountJson:g.trim()})})).json();O.ok?(d(""),f(!1),r(!0),t(),setTimeout(()=>r(!1),3e3)):v(O.error||a("settings.apiKeys.saveFailed"))}catch(K){if(K?.code==="LAN_TOKEN_REQUIRED")return;v(a("settings.apiKeys.networkError"))}finally{p(!1)}}},[g,b,t,a]),N=o.useCallback(async()=>{try{if(!(await R("/api/keys/vertex",{method:"DELETE"})).ok){v(a("settings.apiKeys.removeFailed"));return}d(""),f(!1),t()}catch(K){if(K?.code==="LAN_TOKEN_REQUIRED")return;v(a("settings.apiKeys.networkError"))}},[t,a]),M=o.useCallback(()=>{s&&!y&&f(!0)},[s,y]),D=o.useCallback(()=>{b||f(!1)},[b]);return e.jsxs("div",{className:"vertex-json-section",children:[e.jsx("p",{className:"settings-eyebrow",children:a(y?"settings.apiKeys.envSource":"settings.apiKeys.configSource")}),s&&n&&e.jsx("p",{className:"vertex-project-id",children:n}),L?e.jsx("textarea",{className:"vertex-json-textarea is-masked",value:`●●● (${a("settings.apiKeys.configuredReplace")})`,readOnly:!0,onFocus:M,onClick:M}):e.jsx("textarea",{className:`vertex-json-textarea${u?" is-invalid":""}`,placeholder:a("settings.apiKeys.vertex.placeholder"),value:g,onChange:K=>{d(K.target.value),v(null)},onBlur:D,readOnly:y,autoFocus:c,spellCheck:!1,"data-1p-ignore":!0,"data-lpignore":"true","data-form-type":"other"}),e.jsxs("div",{className:"api-key-actions",style:{marginTop:8},children:[!y&&e.jsx("button",{type:"button",className:"settings-action-btn",onClick:E,disabled:!b||j,children:a(j?"settings.apiKeys.saving":x?"settings.apiKeys.saved":"settings.apiKeys.save")}),s&&!y&&e.jsx("button",{type:"button",className:"settings-action-btn settings-action-btn--danger",onClick:N,children:a("settings.apiKeys.remove")})]}),u&&e.jsx("p",{className:"api-key-error",children:u}),e.jsxs("div",{className:`settings-status${s?" is-ok":""}`,style:{marginTop:8},children:[e.jsx("span",{"aria-hidden":"true"}),a(s?"settings.apiKeys.status.valid":"settings.apiKeys.status.notConfigured")]})]})}function qe({keyStatus:s,onSaved:n}){const{t:i}=C(),t=s.vertex?.configured??!1,a=s.gemini?.configured??!1,g=s.geminiAuthMode==="vertex"?"vertex":"apikey",[d,c]=o.useState(g),[f,j]=o.useState(!1);o.useEffect(()=>{f||c(g)},[g,f]);const p=u=>{j(!0),c(u),R("/api/keys/gemini-auth-mode",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:u})}).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(z,{value:d,onChange:p,items:[{value:"apikey",label:i("settings.apiKeys.vertex.authModeApiKey")},{value:"vertex",label:i("settings.apiKeys.vertex.authModeVertex")}]})]}),d==="apikey"?e.jsx(G,{provider:"gemini",label:"",placeholder:i("settings.apiKeys.gemini.placeholder"),maskedKey:s.gemini?.maskedKey??null,source:s.gemini?.source??"none",configured:a,onSaved:n}):e.jsx(Oe,{configured:t,maskedKey:s.vertex?.maskedKey??null,source:s.vertex?.source??"none",onSaved:n})]})}function Re(s){return s>80?"var(--red)":s>50?"var(--amber)":"var(--blue)"}function Be(s){if(!s)return"";const n=new Date(s);return`${n.getMonth()+1}/${n.getDate()} ${String(n.getHours()).padStart(2,"0")}:${String(n.getMinutes()).padStart(2,"0")}`}function le({window:s}){const n=Be(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:Re(s.percent)}})}),e.jsxs("span",{className:"quota-bar__pct",children:[s.percent,"%"]}),n&&e.jsx("span",{className:"quota-bar__reset",children:n})]})}function Pe({window:s}){const{t:n}=C(),i=Math.max(0,Math.min(s.percent,100)),t=i>50?"var(--blue)":i>=20?"var(--amber)":"var(--red)",a=s.resetsAt===null?null:Math.max(0,Math.ceil((Date.parse(s.resetsAt)-Date.now())/6e4));return e.jsxs("div",{className:"quota-bar quota-bar--charge",children:[e.jsx("span",{className:"quota-bar__label",children:n("settings.quota.naiBattery")}),e.jsx("div",{className:"quota-bar__track",role:"meter","aria-label":n("settings.quota.naiBattery"),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":i,children:e.jsx("div",{className:"quota-bar__fill",style:{width:`${i}%`,background:t}})}),e.jsxs("span",{className:"quota-bar__pct",children:[s.percent,"%"]}),a!==null&&Number.isFinite(a)&&e.jsx("span",{className:"quota-bar__reset",children:n("settings.quota.naiNextPercent",{minutes:a})})]})}function $e(){const s=window.location.hostname.replace(/^\[|\]$/g,"");return s==="localhost"||s==="127.0.0.1"||s==="::1"?"browser":"device"}function ce({provider:s,onComplete:n}){const{t:i}=C(),[t,a]=o.useState({phase:"idle"}),[g,d]=o.useState(!1),c=o.useRef(!1),f=o.useCallback(async j=>{if(c.current||q())return;const p=s==="codex"?j??$e():"device",u=$();c.current=!0,a({phase:"starting"});try{const v=await R("/api/auth/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:s,flow:p})});if(!v.ok){const r=await v.json().catch(()=>({error:i("settings.quota.switchFailed")}));a({phase:"error",error:r.error||`HTTP ${v.status}`});return}const x=await v.json();if(q()||u!==$())return;a({phase:"waiting",...x,flow:x.flow??p}),window.open(x.verificationUrl,"_blank")}catch(v){if(c.current=!1,v?.code==="LAN_TOKEN_REQUIRED")return;a({phase:"error",error:v.message})}},[s]);return o.useEffect(()=>{if(t.phase!=="waiting"||!t.sessionId||q())return;const j=$();let p=!1,u;const v=()=>{p=!0,clearTimeout(u),window.removeEventListener(H,v)},x=async()=>{if(!(p||q()||j!==$())){try{const y=await(await R(`/api/auth/switch/${t.sessionId}`)).json();if(p||q()||j!==$())return;if(y.status==="complete"){a({phase:"complete"}),window.dispatchEvent(new Event(he));return}if(y.status==="error"||y.status==="expired"){a({phase:"error",error:y.error||y.status});return}}catch{}!p&&!q()&&j===$()&&(u=setTimeout(x,3e3))}};return window.addEventListener(H,v),u=setTimeout(x,3e3),v},[t.phase,t.sessionId,n]),o.useEffect(()=>{if(t.phase!=="complete"||q())return;const j=setTimeout(()=>{p(),n()},1e3),p=()=>{clearTimeout(j),window.removeEventListener(H,p)};return window.addEventListener(H,p),p},[t.phase,n]),t.phase==="idle"?e.jsx("button",{type:"button",className:"settings-action-btn",style:{width:"100%",marginTop:"6px"},onClick:()=>{f()},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:[t.userCode?e.jsxs(e.Fragment,{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})]}):e.jsx("div",{style:{textAlign:"center",marginBottom:"4px"},children:i("settings.quota.completeInBrowser")}),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:()=>{c.current=!1,f(t.flow)},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(()=>{d(!0),setTimeout(()=>d(!1),2e3)})},children:i(g?"settings.quota.copied":"settings.quota.copyLink")})]}),e.jsx("div",{style:{textAlign:"center",color:"var(--text-dim, #888)",fontSize:"11px"},children:i("settings.quota.waitingApproval")}),s==="codex"&&t.flow==="browser"&&e.jsx("button",{type:"button",className:"settings-action-btn",style:{width:"100%",fontSize:"11px",marginTop:"6px"},onClick:()=>{c.current=!1,f("device")},children:i("settings.quota.useDeviceCode")})]}):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:()=>{c.current=!1,a({phase:"idle"})},children:i("settings.quota.tryAgain")})]}):null}function De(){const[s,n]=o.useState(null),[i,t]=o.useState(!0),a=o.useCallback(()=>{t(!0),R("/api/quota").then(g=>g.json()).then(n).catch(()=>n(null)).finally(()=>t(!1))},[]);return o.useEffect(()=>{if(q())return;const g=setTimeout(()=>{d(),a()},1500),d=()=>{clearTimeout(g),window.removeEventListener(H,d)};return window.addEventListener(H,d),d},[a]),{data:s,loading:i,refreshQuota:a}}function Fe({data:s,loading:n}){const{t:i}=C(),t=s?.nai,a=t?.nai,g=t?.windows.find(c=>c.label==="v5-battery"),d=n?i("common.loading"):t?.authenticated===!1?i("settings.quota.naiNotConfigured"):!t||t.error?i("settings.quota.fetchError"):a?null:i("settings.quota.noData");return d||!a?e.jsx("div",{className:"quota-card",children:e.jsx("span",{className:n?"quota-card__loading":"quota-card__hint",children:d??i("settings.quota.noData")})}):e.jsxs("div",{className:"quota-card",children:[e.jsxs("div",{className:"quota-card__header",children:[e.jsx("span",{className:"quota-card__account",children:t?.account?.plan}),a.isNegative&&e.jsx("span",{className:"provider-chip provider-chip--warn",children:i("settings.quota.naiNegative")})]}),a.meter==="missing"||!g?e.jsx("span",{className:"quota-card__hint",children:i("settings.quota.naiMeterMissing")}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{window:g}),g.percent===0&&a.anlasFixed+a.anlasPurchased>0&&e.jsx("p",{className:"quota-card__hint",children:i("settings.quota.naiAnlasFallback")})]}),e.jsxs("p",{className:"quota-card__anlas",children:[i("settings.quota.naiAnlas"),": ",a.anlasFixed," + ",a.anlasPurchased]})]})}function Ue({data:s,loading:n,onRefresh:i}){const{t}=C(),a=s?.codex,g=a?.windows&&a.windows.length>0,d=a?.account?[a.account.email,a.account.plan].filter(Boolean).join(" · "):null;return e.jsxs("div",{className:"quota-card",children:[d?e.jsx("div",{className:"quota-card__header",children:e.jsx("span",{className:"quota-card__account",children:d})}):null,n?e.jsx("span",{className:"quota-card__loading",children:t("common.loading")}):g?a.windows.map(c=>e.jsx(le,{window:c},c.label)):a?.authenticated===!1?e.jsx("span",{className:"quota-card__hint",children:t("settings.quota.codexNotLoggedIn")}):a?.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(ce,{provider:"codex",onComplete:i})]})}function ze({data:s,loading:n,onRefresh:i}){const{t}=C(),a=s?.grok,g=a?.windows&&a.windows.length>0,d=a?.account?[a.account.email,a.account.plan].filter(Boolean).join(" · "):null;return e.jsxs("div",{className:"quota-card",children:[d||a?.billing?e.jsxs("div",{className:"quota-card__header",style:{display:"flex",alignItems:"center"},children:[d&&e.jsx("span",{className:"quota-card__account",children:d}),a?.billing&&e.jsxs("span",{style:{marginLeft:"auto",fontSize:"11px",color:"var(--text-dim, #888)",whiteSpace:"nowrap"},children:["$",a.billing.usedUsd.toFixed(1),"/$",a.billing.limitUsd]})]}):null,n?e.jsx("span",{className:"quota-card__loading",children:t("common.loading")}):g?a.windows.map(c=>e.jsx(le,{window:c},c.label)):a?.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(ce,{provider:"grok",onComplete:i})]})}function re(){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 Ge(){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 He(){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 ee(s,n){return s(n==="ready"?"settings.account.status.ready":n==="auth_required"?"settings.account.status.authRequired":n==="starting"?"settings.account.status.starting":n==="offline"?"settings.account.status.offline":n==="no_image_model"?"settings.account.status.noImageModel":n==="error"?"settings.account.status.error":"settings.account.status.checking")}function se(s){return s==="ready"?"ok":s==="error"||s==="offline"?"err":"warn"}function We(){const{t:s}=C(),n=pe(),i=fe(),t=Me(),{data:a,error:g}=xe(),{data:d,mutate:c}=ye(),f=De(),[j,p]=o.useState(!1),u=a?.apiKeySource==="env"||a?.apiKeySource==="config"||a?.apiKeyValid===!0,v=a?.apiKeySource==="config"?s("settings.account.apiSourceConfig"):s("settings.account.apiSourceEnv"),x=a?.apiKeyValid===!0,r=f.loading?"starting":f.data?.nai?.authenticated===!1?"auth_required":!f.data?.nai||f.data.nai.error?"error":"ready";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(re,{})}),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--${se(n?.status)}`,children:ee(s,n?.status)})]}),e.jsx("div",{className:"settings-row__copy",children:e.jsx("p",{children:s("settings.account.oauthBody")})}),e.jsx(Ue,{data:f.data,loading:f.loading,onRefresh:f.refreshQuota})]}),u?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(re,{})}),e.jsx("h4",{children:s("settings.account.apiTitle")}),e.jsx("span",{className:"provider-card__eyebrow",children:v}),e.jsx("span",{className:`provider-chip provider-chip--${g?"err":x?"ok":"warn"}`,children:s(g?"settings.account.apiUnknown":x?"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(Ge,{})}),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--${se(i?.status)}`,children:ee(s,i?.status)})]}),e.jsx("div",{className:"settings-row__copy",children:e.jsx("p",{children:s("settings.account.grokBody")})}),e.jsx(ze,{data:f.data,loading:f.loading,onRefresh:f.refreshQuota})]}),d?.nai?.configured&&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("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M5 20V4l14 16V4",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"})})}),e.jsx("h4",{children:s("settings.account.naiTitle")}),e.jsx("span",{className:"provider-card__eyebrow",children:s("settings.account.naiEyebrow")}),e.jsx("span",{className:`provider-chip provider-chip--${se(r)}`,children:ee(s,r)})]}),e.jsx("div",{className:"settings-row__copy",children:e.jsx("p",{children:s("settings.account.naiBody")})}),e.jsx(Fe,{data:f.data,loading:f.loading})]}),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(He,{})}),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")})]})]}),d&&e.jsxs("article",{className:"settings-row settings-accordion",children:[e.jsxs("button",{type:"button",className:"settings-accordion__trigger",onClick:()=>p(!j),children:[e.jsx("h4",{children:s("settings.apiKeys.accordionTitle")}),e.jsx("span",{className:`settings-accordion__arrow${j?" is-open":""}`,children:"▼"})]}),j&&e.jsxs("div",{className:"settings-accordion__body",children:[e.jsx(G,{provider:"openai",label:s("settings.apiKeys.openai.label"),placeholder:s("settings.apiKeys.openai.placeholder"),maskedKey:d.openai?.maskedKey??null,source:d.openai?.source??"none",configured:d.openai?.configured??!1,onSaved:c}),e.jsx(G,{provider:"xai",label:s("settings.apiKeys.xai.label"),placeholder:s("settings.apiKeys.xai.placeholder"),maskedKey:d.xai?.maskedKey??null,source:d.xai?.source??"none",configured:d.xai?.configured??!1,onSaved:c}),e.jsx(G,{provider:"atlascloud",label:s("settings.apiKeys.atlascloud.label"),placeholder:s("settings.apiKeys.atlascloud.placeholder"),maskedKey:d.atlascloud?.maskedKey??null,source:d.atlascloud?.source??"none",configured:d.atlascloud?.configured??!1,onSaved:c}),e.jsx(G,{provider:"minimax",label:s("settings.apiKeys.minimax.label"),placeholder:s("settings.apiKeys.minimax.placeholder"),maskedKey:d.minimax?.maskedKey??null,source:d.minimax?.source??"none",configured:d.minimax?.configured??!1,onSaved:c}),e.jsx(G,{provider:"nai",label:s("settings.apiKeys.nai.label"),placeholder:s("settings.apiKeys.nai.placeholder"),maskedKey:d.nai?.maskedKey??null,source:d.nai?.source??"none",configured:d.nai?.configured??!1,onSaved:c}),e.jsx(qe,{keyStatus:d,onSaved:c})]})]})]})}function Ve({variant:s}){const{t:n}=C(),[i,t]=o.useState(!1),a=o.useRef(null),g=o.useRef(null),d=o.useRef(null),c=o.useRef([]),[f,j]=o.useState({top:0,left:12,width:280,maxHeight:480}),p=S(l=>l.imageModel),u=S(l=>l.provider),v=S(l=>l.setImageModel),x=S(l=>l.setProvider),r=S(l=>l.videoModelSelected),y=S(l=>l.selectVideoModel),b=S(l=>l.reasoningEffort),L=S(l=>l.setReasoningEffort),E=s==="settings"?"settings-image-model":"sidebar-image-model",N=je,M=N.find(l=>l.value===p&&(!l.providerHint||l.providerHint===u))??N.find(l=>l.value===p)??N[0],D=Y.find(l=>l.value===b)??Y[0],K=()=>c.current.filter(l=>l!==null),O=l=>{const _=K();if(_.length===0)return;const h=(l+_.length)%_.length;_[h]?.focus()},F=l=>{const _=K();if(_.length===0)return;const h=_.findIndex(A=>A===document.activeElement),w=_.length-1;if(l.key==="ArrowDown"||l.key==="ArrowRight"){l.preventDefault(),O(h>=0?h+1:0);return}if(l.key==="ArrowUp"||l.key==="ArrowLeft"){l.preventDefault(),O(h>=0?h-1:w);return}if(l.key==="Home"){l.preventDefault(),O(0);return}if(l.key==="End"){l.preventDefault(),O(w);return}l.key==="Escape"&&(l.preventDefault(),t(!1),g.current?.focus())};if(o.useEffect(()=>{if(s!=="sidebar"||!i)return;const l=h=>{const w=h.target;w instanceof Node&&(a.current?.contains(w)||d.current?.contains(w)||t(!1))},_=h=>{h.key==="Escape"&&t(!1)};return document.addEventListener("pointerdown",l),document.addEventListener("keydown",_),()=>{document.removeEventListener("pointerdown",l),document.removeEventListener("keydown",_)}},[i,s]),o.useLayoutEffect(()=>{if(s!=="sidebar"||!i)return;(()=>{const w=g.current?.getBoundingClientRect();if(w){const P=Math.min(280,Math.max(218,window.innerWidth-24)),W=w.right-P,X=window.innerWidth-P-12,m=Math.max(12,Math.min(W,X)),k=w.bottom+7,T=Math.max(160,window.innerHeight-k-12);j({top:k,left:m,width:P,maxHeight:T})}})();const _=w=>{w&&d.current?.contains(w.target)||t(!1)},h=document.querySelector(".sidebar__scroll");return h?.addEventListener("scroll",_,{passive:!0}),window.addEventListener("scroll",_,!0),window.addEventListener("resize",_),()=>{h?.removeEventListener("scroll",_),window.removeEventListener("scroll",_,!0),window.removeEventListener("resize",_)}},[i,s]),o.useEffect(()=>{if(s!=="sidebar"||!i)return;const l=N.findIndex(h=>h.value===p),_=requestAnimationFrame(()=>{O(l>=0?l:0)});return()=>cancelAnimationFrame(_)},[p,N,i,s]),s==="sidebar"){const l=r?V.find(h=>h.value===r)?.shortLabel??V[0].shortLabel:M.shortLabel.split(" ")[0],_=ne(p)?M.shortLabel.split(" ")[1]||"":D.shortLabel;return e.jsxs("div",{ref:a,className:"image-model-select image-model-select--sidebar",children:[e.jsxs("button",{ref:g,id:E,type:"button",className:"image-model-select__trigger image-model-select__trigger--pill","aria-haspopup":"menu","aria-expanded":i,"aria-label":n("sidebar.quickSettingsAria",{model:l,effort:_}),onClick:()=>t(h=>!h),children:[e.jsxs("span",{className:"image-model-select__trigger-top",children:[e.jsx("span",{className:"image-model-select__trigger-model",children:l}),e.jsx("span",{className:"image-model-select__trigger-chevron","aria-hidden":"true",children:"▾"})]}),e.jsx("span",{className:"image-model-select__trigger-effort",children:_})]}),i?ve.createPortal(e.jsxs("div",{ref:d,className:"image-model-select__menu",role:"menu","aria-label":n("sidebar.quickSettingsMenu"),onKeyDown:F,style:{position:"fixed",top:f.top,left:f.left,width:f.width,maxHeight:f.maxHeight,overflowY:"auto",zIndex:160},children:[e.jsxs("div",{className:"image-model-select__section",role:"group","aria-label":n("sidebar.imageSectionLabel"),children:[e.jsx("div",{className:"image-model-select__section-title",children:n("sidebar.imageSectionLabel")}),e.jsx("div",{className:"image-model-select__subsection-title",children:n("sidebar.gptImageSubLabel")}),Z.map((h,w)=>e.jsxs("button",{ref:A=>{c.current[w]=A},type:"button",className:`image-model-select__item${h.value===p&&!r?" is-active":""}`,role:"menuitemradio","aria-checked":h.value===p&&!r,tabIndex:-1,onClick:()=>{v(h.value),t(!1)},children:[e.jsx("span",{children:h.shortLabel}),e.jsx("small",{children:n(h.fullLabelKey)})]},h.value)),e.jsx("div",{className:"image-model-select__subsection-title",children:n("sidebar.grokImageSubLabel")}),ae.map((h,w)=>e.jsxs("button",{ref:A=>{c.current[Z.length+w]=A},type:"button",className:`image-model-select__item${h.value===p&&!r?" is-active":""}`,role:"menuitemradio","aria-checked":h.value===p&&!r,tabIndex:-1,onClick:()=>{v(h.value),t(!1)},children:[e.jsx("span",{children:h.shortLabel}),e.jsx("small",{children:n(h.fullLabelKey)})]},h.value)),e.jsx("div",{className:"image-model-select__subsection-title",children:n("sidebar.geminiImageSubLabel")}),be.map((h,w)=>{const A=h.providerHint,P=h.value===p&&A===u&&!r;return e.jsxs("button",{ref:W=>{c.current[Z.length+ae.length+w]=W},type:"button",className:`image-model-select__item${P?" is-active":""}`,role:"menuitemradio","aria-checked":P,tabIndex:-1,onClick:()=>{A&&x(A),v(h.value),t(!1)},children:[e.jsx("span",{children:h.shortLabel}),e.jsx("small",{children:n(h.fullLabelKey)})]},`${h.value}-${A||w}`)})]}),e.jsxs("div",{className:"image-model-select__section",role:"group","aria-label":n("sidebar.videoSectionLabel"),children:[e.jsx("div",{className:"image-model-select__section-title",children:n("sidebar.videoSectionLabel")}),V.map((h,w)=>e.jsxs("button",{ref:A=>{c.current[N.length+w]=A},type:"button",className:`image-model-select__item${r===h.value?" is-active":""}`,role:"menuitemradio","aria-checked":r===h.value,tabIndex:-1,onClick:()=>{y(h.value),t(!1)},children:[e.jsx("span",{children:h.shortLabel}),e.jsx("small",{children:n(h.fullLabelKey)})]},h.value))]}),!ne(p)&&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:[n("sidebar.reasoningLabel"),e.jsx("span",{className:"image-model-select__chevron","aria-hidden":"true",children:"▸"})]}),e.jsx("div",{role:"group","aria-label":n("sidebar.reasoningLabel"),children:Y.map((h,w)=>e.jsxs("button",{ref:A=>{c.current[N.length+V.length+w]=A},type:"button",className:`image-model-select__item${h.value===b?" is-active":""}`,role:"menuitemradio","aria-checked":h.value===b,tabIndex:-1,onClick:()=>{L(h.value),t(!1)},children:[e.jsx("span",{children:h.shortLabel}),e.jsx("small",{children:n(h.fullLabelKey)})]},h.value))})]})]}),document.body):null]})}return e.jsx("div",{className:"image-model-select image-model-select--settings",children:e.jsx(z,{id:E,value:p,onChange:l=>v(l),items:[...N.map(l=>({value:l.value,label:n(l.fullLabelKey)})),..._e.map(l=>({value:l.value,label:n(l.fullLabelKey),disabled:!0}))]})})}function Qe(){const{t:s}=C(),n=S(a=>a.reasoningEffort),i=S(a=>a.setReasoningEffort),t=Y.map(a=>({value:a.value,label:s(a.fullLabelKey)}));return e.jsx("div",{className:"ctl-select-wrap settings-reasoning-effort",children:e.jsx(z,{id:"settings-reasoning-effort",items:t,value:n,onChange:i})})}const Je={ko:"KO",en:"EN","zh-Hant":"正體","zh-Hans":"简体"};function Ye(){const{t:s,locale:n}=C(),i=S(t=>t.setLocale);return e.jsx("div",{className:"lang-toggle",role:"group","aria-label":s("language.label"),children:ue.map(t=>e.jsx("button",{type:"button",className:`lang-toggle__btn ${n===t?"is-active":""}`,onClick:()=>i(t),"aria-pressed":n===t,title:s(`language.${t}`),children:e.jsx("span",{className:"lang-toggle__label",children:Je[t]})},t))})}const Xe=["light","dark","system"];function Ze(){const{t:s}=C(),{mode:n,setMode:i}=ge();return e.jsx("div",{className:"lang-toggle",role:"group","aria-label":s("settings.theme.label"),children:Xe.map(t=>e.jsx("button",{type:"button",className:`lang-toggle__btn ${n===t?"is-active":""}`,onClick:()=>i(t),"aria-pressed":n===t,title:s(`settings.theme.${t}`),children:e.jsx("span",{className:"lang-toggle__label",children:s(`settings.theme.${t}`)})},t))})}const es=["rail","horizontal","sidebar"];function ss(){const{t:s}=C(),n=S(t=>t.historyStripLayout),i=S(t=>t.setHistoryStripLayout);return e.jsx(Ne,{className:"history-layout-toggle",items:es.map(t=>({value:t,label:s(`settings.appearance.historyStripLayout.${t}`)})),value:n,onChange:i})}const ts=[{value:"default",labelKey:"workspace.defaultLabel",descKey:"workspace.defaultDesc"},{value:"prompt-studio",labelKey:"workspace.promptStudioLabel",descKey:"workspace.promptStudioDesc"}];function ns(){const s=S(t=>t.workspaceProfile),n=S(t=>t.setWorkspaceProfile),{t:i}=C();return e.jsx("div",{className:"settings-field",children:e.jsx(z,{id:"workspace-profile-select",value:s,onChange:t=>n(t),ariaLabel:i("workspace.profileLabel"),items:ts.map(t=>({value:t.value,label:i(t.labelKey)}))})})}function as(){const{t:s}=C(),[n,i]=o.useState(null);o.useEffect(()=>{R("/api/config/grok-planner").then(a=>a.json()).then(i).catch(()=>{})},[]);const t=async a=>{try{await R("/api/config/grok-planner",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:a})}),i(g=>g?{...g,model:a}:null)}catch{}};return n?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(z,{items:n.options.map(a=>({value:a,label:a})),value:n.model,onChange:a=>{t(a)},ariaLabel:s("settings.grokPlanner.title")})})]}):null}function is(s){return s==="connected"?"ok":s==="error"||s==="offline"?"err":"warn"}function rs(s){const n=s.status.snapshotDiff;return n?n.drifted.length+n.missing.length+n.added.length:0}function os(){const{t:s}=C(),{providers:n,loading:i,error:t,refresh:a}=we(),[g,d]=o.useState(null),[c,f]=o.useState(!1),[j,p]=o.useState(null),u=async()=>{if(!c){f(!0);try{await a()}finally{f(!1)}}},v=async(x,r)=>{d({provider:x.id,action:r}),p(null);try{r==="connect"?await ke(x.id):r==="refresh"?await Se(x.id):await Le(x.id),await a()}catch(y){const b=y instanceof Error&&y.message==="MCP_POPUP_BLOCKED"?s("mcp.popupBlocked"):s("mcp.connectionActionFailed");p({provider:x.id,message:b})}finally{d(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:()=>{u()},disabled:i||c,"aria-busy":i||c,children:s(i||c?"mcp.loadingProviders":"mcp.refreshList")})})]}),t?e.jsx("p",{role:"alert",className:"settings-row__microcopy",children:s("mcp.providersLoadFailed")}):null,n.map(x=>{const r=x.status.state,y=!x.enabled||x.executable===!1,b=g?.provider===x.id?g.action:null,L=b!==null,E=rs(x);return e.jsxs("article",{className:"provider-card",children:[e.jsxs("div",{className:"provider-card__head",children:[e.jsx("h4",{children:x.id}),e.jsx("span",{className:"provider-card__eyebrow",children:"MCP"}),e.jsx("span",{className:`provider-chip provider-chip--${is(r)}`,children:s(`mcp.status.${r}`)})]}),e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("p",{children:x.endpoint}),e.jsxs("p",{children:[typeof x.status.toolCount=="number"?s("mcp.toolCount",{count:x.status.toolCount}):s("mcp.toolCountUnknown"),E>0?` · ${s("mcp.snapshotChanges",{count:E})}`:""]}),y?e.jsx("p",{className:"settings-row__microcopy",children:x.enabled?x.lockReason??s("mcp.higgsfieldLocked"):s("mcp.disabledProvider")}):x.status.detail?e.jsx("p",{className:"settings-row__microcopy",children:x.status.detail}):null,j?.provider===x.id?e.jsx("p",{role:"alert",className:"settings-row__microcopy",children:j.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"&&!y?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"settings-action-btn",onClick:()=>{v(x,"refresh")},disabled:L,"aria-busy":b==="refresh",children:s(b==="refresh"?"mcp.refreshingConnection":"mcp.refreshConnection")}),e.jsx("button",{type:"button",className:"settings-action-btn settings-action-btn--danger",onClick:()=>{v(x,"disconnect")},disabled:L,"aria-busy":b==="disconnect",children:s("mcp.disconnect")})]}):e.jsx("button",{type:"button",className:"settings-action-btn",onClick:()=>{v(x,"connect")},disabled:L||y,"aria-busy":b==="connect",title:s(y?"mcp.higgsfieldLocked":"mcp.connectOpensBrowser"),children:s(b==="connect"?"mcp.connecting":"mcp.connect")})})]},x.id)})]})}const ls=[137,80,78,71,13,10,26,10];async function cs(s){const n=new Uint8Array(await s.arrayBuffer());if(ls.every((t,a)=>n[a]===t)){let t="";for(const a of n)t+=String.fromCharCode(a);return{pngBase64:btoa(t)}}return{graph:JSON.parse(new TextDecoder().decode(n))}}const oe=["prompt","negativePrompt","width","height","seed","refImage","output"];function Q(s){return s.input?`${s.node}.${s.input}`:s.node}function ds(){const{t:s}=C(),[n,i]=o.useState([]),[t,a]=o.useState(!0),[g,d]=o.useState(null),[c,f]=o.useState(null),[j,p]=o.useState({}),[u,v]=o.useState(""),[x,r]=o.useState(""),[y,b]=o.useState("image"),[L,E]=o.useState("http://127.0.0.1:8188"),[N,M]=o.useState({kind:"idle"}),[D,K]=o.useState(null),[O,F]=o.useState(!1),l=o.useRef(null),_=o.useCallback(async()=>{a(!0);try{const m=await Ce();i(m.workflows)}catch{i([])}finally{a(!1)}},[]);o.useEffect(()=>{_()},[_]);const h=async m=>{if(m){K(null);try{const k=await cs(m),T=await Ke(k);f(k),d(T),b(T.mediaKind??"image");const U={};for(const I of T.candidates)I.unambiguous&&(U[I.field]=Q(I));p(U),u||v(m.name.replace(/\.[^.]+$/,"").toLowerCase().replace(/[^a-z0-9_-]+/g,"-").slice(0,64))}catch(k){d(null),f(null),K(k instanceof Error?k.message:s("comfy.inspectFailed"))}}},w=async()=>{M({kind:"idle"});try{const m=await Te(L);M(m.health.ok?{kind:"ok",...m.health.version?{detail:m.health.version}:{}}:{kind:"unreachable"})}catch(m){M({kind:"invalid",detail:m instanceof Error?m.message:void 0})}},A=(g?.candidates??[]).filter(m=>!m.unambiguous).map(m=>m.field).filter((m,k,T)=>T.indexOf(m)===k).filter(m=>!j[m]),P=!!(g&&u&&j.prompt&&j.output&&A.length===0&&!O),W=async()=>{if(!(!P||!c)){F(!0),K(null);try{const m={};for(const k of oe){const T=j[k];if(!T)continue;if(k==="output"){m.output={node:T};continue}const U=T.indexOf(".");m[k]={node:T.slice(0,U),input:T.slice(U+1)}}await Ae({...c,id:u,...x?{label:x}:{},origin:L,mediaKind:y,bind:m}),d(null),f(null),p({}),v(""),r(""),b("image"),l.current&&(l.current.value=""),await Promise.all([_(),ie()])}catch(m){K(m instanceof Error?m.message:s("comfy.registerFailed"))}finally{F(!1)}}},X=async m=>{F(!0);try{await Ee(m),await Promise.all([_(),ie()])}catch(k){K(k instanceof Error?k.message:s("comfy.removeFailed"))}finally{F(!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&&n.length===0?e.jsx("div",{className:"muted",children:s("comfy.empty")}):null,n.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:n.map(m=>{const k=m.health?.ok===!0,T=`comfy-status-${m.id}`;return e.jsxs("tr",{children:[e.jsx("td",{children:m.label||m.id}),e.jsx("td",{children:s(m.mediaKind==="video"?"comfy.kindVideo":"comfy.kindImage")}),e.jsx("td",{className:"mono",children:m.origin}),e.jsx("td",{id:T,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:()=>{X(m.id)},disabled:O,"aria-describedby":T,children:s("comfy.remove")})})]},m.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:l,type:"file",accept:".json,.png,application/json,image/png",onChange:m=>{h(m.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:L,onChange:m=>{E(m.target.value),M({kind:"idle"})},spellCheck:!1}),e.jsx("button",{type:"button",onClick:()=>{w()},children:s("comfy.checkOrigin")})]})]}),N.kind==="ok"?e.jsxs("div",{className:"status-ok",children:[s("comfy.originReachable"),N.detail?` (${N.detail})`:""]}):null,N.kind==="unreachable"?e.jsx("div",{className:"status-warn",children:s("comfy.originUnreachable")}):null,N.kind==="invalid"?e.jsx("div",{className:"status-err",children:s("comfy.originInvalid")}):null,g?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:u,onChange:m=>v(m.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:x,onChange:m=>r(m.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:y,onChange:m=>b(m.target.value),children:[e.jsx("option",{value:"image",children:s("comfy.kindImage")}),e.jsx("option",{value:"video",children:s("comfy.kindVideo")})]}),y==="video"?e.jsx("div",{className:"muted",children:s("comfy.videoKindHint")}):null]}),e.jsx("div",{className:"section-title",children:s("comfy.bindTitle")}),g.needsConfirmation?e.jsx("div",{className:"muted",children:s("comfy.bindAmbiguous")}):null,oe.map(m=>{const k=g.candidates.filter(I=>I.field===m);if(k.length===0)return null;const T=k.some(I=>!I.unambiguous),U=`comfy-bind-${m}`;return e.jsxs("div",{className:"comfy-bind-row",children:[e.jsx("label",{htmlFor:U,children:s(`comfy.field.${m}`)}),e.jsxs("select",{id:U,value:j[m]??"",onChange:I=>p(de=>({...de,[m]:I.target.value})),"aria-invalid":T&&!j[m],children:[e.jsx("option",{value:"",children:s("comfy.choose")}),k.map(I=>e.jsxs("option",{value:Q(I),children:[Q(I)," — ",I.classType,I.title?` "${I.title}"`:""]},Q(I)))]})]},m)}),e.jsx("button",{type:"button",onClick:()=>{W()},disabled:!P,children:s("comfy.register")})]}):null,D?e.jsx("div",{className:"status-err",role:"alert",children:D}):null]})})]})}function us(s,n){return n(s==="auto"?"promptBuilder.backends.auto":s==="oauth"?"promptBuilder.backends.oauth":s==="grok"?"promptBuilder.backends.grok":s==="api"?"promptBuilder.backends.api":"promptBuilder.backends.grokApi")}function gs(){const{t:s}=C(),n=B(u=>u.backend),i=B(u=>u.model),t=B(u=>u.backendOptions),a=B(u=>u.modelOptions),g=B(u=>u.locked),d=B(u=>u.configLoaded),c=B(u=>u.configLoading),f=B(u=>u.error),j=B(u=>u.loadConfig),p=B(u=>u.updateConfig);return o.useEffect(()=>{j()},[j]),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.promptBuilder.title")}),e.jsx("p",{children:s("settings.promptBuilder.body")}),g.backend||g.model?e.jsx("p",{className:"settings-row__microcopy",children:s("settings.promptBuilder.envLocked")}):null,c?e.jsx("p",{className:"settings-row__microcopy",children:s("promptBuilder.configLoading")}):null,f?e.jsx("p",{className:"settings-row__microcopy",role:"alert",children:f}):null]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(z,{value:n,items:t.map(u=>({value:u,label:us(u,s)})),onChange:u=>{p(u)},ariaLabel:s("settings.promptBuilder.backendLabel"),disabled:!d||c||g.backend||g.model})})]}),e.jsxs("article",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s("settings.promptBuilder.modelLabel")}),e.jsx("p",{children:s("settings.promptBuilder.modelBody")})]}),e.jsx("div",{className:"settings-row__control",children:e.jsx(z,{value:i,items:a.map(u=>({value:u,label:u==="auto"?s("promptBuilder.modelAuto"):u})),onChange:u=>{p(n,u)},ariaLabel:s("settings.promptBuilder.modelLabel"),disabled:!d||c||g.model})})]})]})}const J=["providers","workspace","general"];function te({id:s,setRef:n,children:i}){const{t}=C();return e.jsxs("section",{id:s,ref:a=>n(s,a),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 fs(){const{t:s}=C(),n=S(r=>r.activeSettingsSection),i=S(r=>r.setActiveSettingsSection),t=S(r=>r.closeSettings),a=S(r=>r.openReadinessPopup),g=S(r=>r.galleryDefaultScope),d=S(r=>r.setGalleryDefaultScope),c=S(r=>r.provider),f=o.useRef(null),j=o.useRef(null),p=o.useRef(!1),u=o.useRef({providers:null,workspace:null,general:null}),v=(r,y)=>{u.current[r]=y},x=r=>{i(r),p.current=!0;const y=f.current,b=u.current[r];if(y&&b){const L=y.getBoundingClientRect().top,E=b.getBoundingClientRect().top,N=Number.parseFloat(window.getComputedStyle(b).scrollMarginTop)||0;y.scrollTo({top:y.scrollTop+E-L-N,behavior:"auto"})}j.current!==null&&window.clearTimeout(j.current),j.current=window.setTimeout(()=>{p.current=!1,j.current=null},120)};return o.useEffect(()=>{const r=y=>{y.key==="Escape"&&t()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[t]),o.useEffect(()=>{const r=f.current;if(!r||typeof IntersectionObserver!="function")return;const y=new IntersectionObserver(b=>{if(p.current)return;const E=b.filter(N=>N.isIntersecting).sort((N,M)=>M.intersectionRatio-N.intersectionRatio)[0]?.target.id;E&&J.includes(E)&&i(E)},{root:r,threshold:[.35,.6]});for(const b of J){const L=u.current[b];L&&y.observe(L)}return()=>y.disconnect()},[i]),o.useEffect(()=>()=>{j.current!==null&&window.clearTimeout(j.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:J.map(r=>e.jsxs("button",{type:"button",className:`settings-mobile-nav__item${n===r?" is-active":""}`,onClick:()=>x(r),"aria-current":n===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:J.map(r=>e.jsxs("button",{type:"button",className:`settings-nav__item${n===r?" is-active":""}`,onClick:()=>x(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:f,className:"settings-content","aria-label":s("settings.contentAria"),children:[e.jsxs(te,{id:"providers",setRef:v,children:[e.jsx(We,{}),e.jsx(os,{}),e.jsx(ds,{}),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:a,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(Ve,{variant:"settings"})})]}),e.jsx(gs,{}),c==="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(as,{})]}):c==="agy"||c==="gemini-api"?e.jsx("article",{className:"settings-row",children:e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s(c==="gemini-api"?"provider.geminiApiCompatTitle":"provider.agyCompatTitle")}),e.jsx("p",{children:s(c==="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(Qe,{})})]}),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(Ie,{})})]})]})]}),e.jsxs(te,{id:"workspace",setRef:v,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(ns,{})})]}),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(ss,{})})]}),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(z,{ariaLabel:s("settings.gallery.defaultScopeTitle"),value:g,onChange:r=>d(r),items:[{value:"current-session",label:s("gallery.scope.current")},{value:"all",label:s("gallery.scope.all")}]})})]})]}),e.jsxs(te,{id:"general",setRef:v,children:[e.jsx(me,{}),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(Ye,{})})]}),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(Ze,{})})]})]})]})]})]})})}export{fs as SettingsWorkspace};
|
package/ui/dist/assets/{SpriteRecipeWorkspace-ghZGUlM8.js → SpriteRecipeWorkspace-BJUH1ddP.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,f as x}from"./index-
|
|
1
|
+
import{j as e,f as x}from"./index-CHeVGnoy.js";import{u as d,k as j,a as m}from"./App-pMN1OjNW.js";import{P as v}from"./AssetGenWorkspace-DzEfpUy_.js";import"./AssetMediaLightbox-Bx0azN0S.js";import"./useAgentDialogFocus-DAeS9IWG.js";import"./KeyingPanel-8J_RMrxg.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 A(){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{A as SpriteRecipeWorkspace};
|