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 +0,0 @@
|
|
|
1
|
-
import{f as d,j as s}from"./index-B-iNVdeL.js";import{u as I,a as b,Z as Q,_ as z,l as de,$ as ce,a0 as ue,a1 as me,a2 as he,j as pe,a3 as fe,a4 as ge,a5 as xe,a6 as ve,C as be,p as je,m as ye,t as _e,a7 as we,a8 as ke,a9 as Ne,k as Ae}from"./App-x_fzCXKb.js";import{A as Se}from"./AssetMediaLightbox-ordAqhjX.js";import{K as Ie}from"./KeyingPanel-SsAIeDy3.js";import"./useAgentDialogFocus-ALfcs_Em.js";function Ce({folder:e,depth:a}){const{t:r}=I(),l=b(t=>t.assetsFilters.folderId),p=b(t=>t.setAssetsFilters),f=b(t=>t.renameAssetFolder),j=b(t=>t.deleteAssetFolder),o=b(t=>t.showToast),[i,g]=d.useState(!1),[_,h]=d.useState(e.name),[x,v]=d.useState(!1),k=l===e.id;async function m(){const t=_.trim();if(!t||t===e.name){h(e.name),g(!1);return}await f(e.id,t)||o(r("assets.actionFailed"),!0),g(!1)}async function u(){if(!x){v(!0);return}await j(e.id)||o(r("assets.actionFailed"),!0),v(!1)}return s.jsxs("div",{className:"assets-folder-row",style:{"--folder-depth":a},children:[i?s.jsx("input",{className:"assets-folder-input",value:_,autoFocus:!0,"aria-label":r("assets.renameFolder"),onChange:t=>h(t.target.value),onBlur:()=>{m()},onKeyDown:t=>{t.key==="Enter"&&m(),t.key==="Escape"&&(h(e.name),g(!1))}}):s.jsx("button",{type:"button",className:`assets-folder-row__name${k?" is-active":""}`,"aria-current":k?"page":void 0,onClick:()=>p({folderId:e.id,kind:null}),children:e.name}),!i&&s.jsxs("span",{className:"assets-folder-row__actions",children:[s.jsx("button",{type:"button","aria-label":r("assets.renameFolder"),onClick:()=>g(!0),children:s.jsx(Q,{})}),s.jsx("button",{type:"button","aria-label":r(x?"assets.confirmDelete":"assets.deleteFolder"),className:x?"is-danger is-armed":"",onClick:()=>{u()},children:x?r("assets.confirmDelete"):"×"})]})]})}function Fe(){const{t:e}=I(),a=b(m=>m.assetsFolders),r=b(m=>m.assetsFilters.folderId),l=b(m=>m.assetsFilters.kind),p=b(m=>m.setAssetsFilters),f=b(m=>m.createAssetFolder),j=b(m=>m.showToast),[o,i]=d.useState(!1),[g,_]=d.useState(""),h=r===null&&l!=="element",x=r===null&&l==="element",v=d.useMemo(()=>{const m=[],u=(t,c)=>a.filter(y=>y.parentId===t).forEach(y=>{m.push({folder:y,depth:c}),u(y.id,c+1)});return u(null,0),m},[a]);async function k(){const m=g.trim();if(!m){i(!1);return}await f(m,r)||j(e("assets.actionFailed"),!0),_(""),i(!1)}return s.jsxs("aside",{className:"assets-folders","aria-label":e("assets.rootFolder"),children:[s.jsxs("div",{className:"assets-folders__heading",children:[s.jsx("span",{children:e("assets.rootFolder")}),s.jsx("button",{type:"button","aria-label":e("assets.newFolder"),onClick:()=>i(!0),children:"+"})]}),s.jsxs("div",{className:"assets-folders__rows",children:[s.jsx("button",{type:"button",className:`assets-folder-all${h?" is-active":""}`,"aria-current":h?"page":void 0,onClick:()=>p({folderId:null,kind:null}),children:e("assets.allAssets")}),s.jsxs("button",{type:"button",className:`assets-folder-all assets-folder-elements${x?" is-active":""}`,"aria-current":x?"page":void 0,onClick:()=>p({folderId:null,kind:"element"}),children:[s.jsx("span",{className:"assets-folder-elements__glyph","aria-hidden":"true",children:"@"}),e("assets.elementLibrary")]}),v.map(({folder:m,depth:u})=>s.jsx(Ce,{folder:m,depth:u},m.id)),o&&s.jsx("input",{className:"assets-folder-input assets-folder-input--new",value:g,autoFocus:!0,"aria-label":e("assets.newFolder"),placeholder:e("assets.newFolder"),onChange:m=>_(m.target.value),onBlur:()=>{g.trim()||i(!1)},onKeyDown:m=>{m.key==="Enter"&&k(),m.key==="Escape"&&(_(""),i(!1))}})]})]})}let T={status:"idle",elements:[]},D=null;const G=new Set;function M(e){T=e,G.forEach(a=>a())}function Te(e){return G.add(e),()=>G.delete(e)}function O(e=!1){return!e&&T.status==="ready"?Promise.resolve(!0):D||(M({...T,status:"loading"}),D=de().then(a=>(M({status:"ready",elements:a}),!0)).catch(a=>(console.error("[ElementMembership] load failed",a),M({...T,status:"error"}),!1)).finally(()=>{D=null}),D)}function Ee(e){const a=[e,...T.elements.filter(r=>r.id!==e.id)];M({status:"ready",elements:a})}function Y(e){M({status:"ready",elements:T.elements.filter(a=>a.id!==e)})}function Pe(e){e.stopPropagation()}function De(e){e.stopPropagation()}function Me(e){(e.key==="Enter"||e.key===" ")&&e.stopPropagation()}async function Re(e,a){if(a){await ce(a.id),Y(a.id);return}const{asset:r}=await ue({result:{filePath:e.filePath??void 0},sourceAssetId:e.id,elementKind:"character",name:e.name,notes:e.notes??void 0,folderId:e.folderId,tags:[me(e.id)]});Ee(r)}function q({active:e,busy:a,label:r,onToggle:l}){return s.jsx("button",{type:"button",className:`asset-element-toggle${e?" is-active":""}`,title:r,"aria-label":r,"aria-pressed":e,"aria-busy":a||void 0,disabled:a,onPointerDown:Pe,onDoubleClick:De,onKeyDown:Me,onClick:p=>{p.stopPropagation(),l()},children:s.jsx("span",{className:"asset-element-toggle__glyph","aria-hidden":"true",children:"@"})})}function $e({item:e}){const{t:a}=I(),r=b(v=>v.showToast),l=b(v=>v.deleteAssetItem),[p,f]=d.useState(!1),j=e.kind==="element",o=j||(e.kind==="image"||e.kind==="video")&&!!e.filePath,i=a("assets.elementLibrary"),g=d.useSyncExternalStore(Te,()=>T,()=>T),_=!j&&o?z(g.elements,e.id):null,h=p||g.status==="loading"||g.status==="idle";if(d.useEffect(()=>{o&&!j&&O()},[o,j]),j){const v=async()=>{if(!p){f(!0);try{await l(e.id)?Y(e.id):r(a("assets.actionFailed"),!0)}finally{f(!1)}}};return s.jsx(q,{active:!0,busy:p,label:a("assets.removeFromElements"),onToggle:()=>{v()}})}if(!o)return null;async function x(){if(p||g.status==="loading")return;if(g.status!=="ready"&&!await O(!0)){r(a("assets.actionFailed"),!0);return}const v=z(T.elements,e.id);f(!0);try{await Re(e,v)}catch(k){console.error("[ElementMembership] toggle failed",k),r(a("assets.actionFailed"),!0)}finally{f(!1)}}return s.jsx(q,{active:!!_,busy:h,label:i,onToggle:()=>{x()}})}const L=12,V=180;function Be(e){return`/generated/${e.split("/").map(encodeURIComponent).join("/")}`}function Le({item:e,selected:a,onSelect:r,onPreview:l}){const{t:p}=I(),f=b(w=>w.deleteAssetItem),j=b(w=>w.updateAssetItem),o=b(w=>w.showToast),[i,g]=d.useState(!1),[_,h]=d.useState(!1),[x,v]=d.useState(!1),k=d.useRef(null);d.useEffect(()=>{const w=k.current;if(!w||e.kind!=="video"||typeof IntersectionObserver>"u"){v(!0);return}const R=new IntersectionObserver(([P])=>{P?.isIntersecting&&v(!0)},{rootMargin:"300px"});return R.observe(w),()=>R.disconnect()},[e.kind]);const m=e.kind==="element"&&!e.filePath?pe(e):e.filePath,u=m?Be(m):null,t=e.kind==="video",c=p(t?"assetGen.videoFallback":"assetGen.imageFallback"),y=p(t?"assetGen.previewVideo":"assetGen.previewImage",{prompt:e.name.trim()||c});async function A(){if(!i){g(!0);return}await f(e.id)||o(p("assets.actionFailed"),!0),g(!1)}const N=e.tags.includes("starred");async function S(){if(!_){h(!0);try{const w=ge(e.tags,N);await j(e.id,{tags:w})||o(p("assets.actionFailed"),!0)}finally{h(!1)}}}return s.jsxs("article",{ref:k,className:`assets-tile${a?" is-selected":""}`,tabIndex:0,"aria-selected":a,onClick:()=>r?.(e.id),onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&r&&(w.preventDefault(),r(e.id))},children:[s.jsxs("div",{className:"assets-tile__media",children:[u?s.jsxs("button",{type:"button",className:"assets-tile__preview","aria-label":y,onClick:w=>{w.stopPropagation(),r?.(e.id),l?.(e)},onKeyDown:w=>w.stopPropagation(),children:[t?x?s.jsx("video",{src:u,preload:"metadata",muted:!0,playsInline:!0,"aria-hidden":"true"}):null:s.jsx("img",{src:u,alt:"",loading:"lazy",decoding:"async"}),s.jsx("span",{className:"assets-tile__preview-hint","aria-hidden":"true",children:p(t?"assetGen.openHintVideo":"assetGen.openHintImage")})]}):s.jsx("span",{className:"assets-tile__glyph","aria-hidden":"true",children:e.kind.slice(0,1).toUpperCase()}),s.jsx(fe,{variant:"asset",active:N,busy:_,label:p(N?"assets.unstarAsset":"assets.starAsset"),onToggle:S}),s.jsx($e,{item:e}),s.jsx("button",{type:"button",className:`assets-tile__delete${i?" is-danger":""}`,"aria-label":p(i?"assets.confirmDelete":"assets.deleteAsset"),onClick:w=>{w.stopPropagation(),A()},children:i?p("assets.confirmDelete"):"×"})]}),s.jsxs("div",{className:"assets-tile__meta",children:[s.jsxs("div",{className:"assets-tile__title",children:[s.jsx("strong",{title:e.name,children:e.name}),s.jsx("span",{children:e.kind})]}),e.tags.length>0&&s.jsxs("div",{className:"assets-tile__tags",children:[e.tags.slice(0,2).map(w=>s.jsx("span",{children:w},w)),e.tags.length>2&&s.jsxs("span",{children:["+",e.tags.length-2]})]})]})]})}function Ue({onSelectAsset:e,onPreviewAsset:a,selectedId:r}){const{t:l}=I(),p=b(c=>c.assets),f=b(c=>c.assetsLoading),j=b(c=>c.assetsCursor),o=b(c=>c.loadMoreAssets),i=d.useRef(null),[g,_]=d.useState(960),h=Math.max(1,Math.floor((g+L)/(V+L))),x=d.useMemo(()=>Array.from({length:Math.ceil(p.length/h)},(c,y)=>p.slice(y*h,(y+1)*h)),[p,h]);d.useEffect(()=>{const c=i.current;if(!c)return;const y=()=>{const N=getComputedStyle(c),S=(parseFloat(N.paddingLeft)||0)+(parseFloat(N.paddingRight)||0);_(Math.max(0,c.clientWidth-S))};y();const A=new ResizeObserver(y);return A.observe(c),()=>A.disconnect()},[]);const v=Math.max(V,(g-L*(h-1))/h)+70+L,k=he({count:x.length,getScrollElement:()=>i.current,estimateSize:()=>v,overscan:4}),m=k.getVirtualItems(),u=m.at(-1)?.index,t=d.useCallback(()=>{j&&!f&&o()},[j,f,o]);return d.useEffect(()=>{u===x.length-1&&t()},[u,t,x.length]),s.jsxs("div",{ref:i,className:"assets-grid-scroll",children:[s.jsx("div",{className:"assets-grid-virtual",style:{height:k.getTotalSize()},children:m.map(c=>s.jsx("div",{className:"assets-grid-row",style:{transform:`translateY(${c.start}px)`,gridTemplateColumns:`repeat(${h}, minmax(0, 1fr))`},children:x[c.index]?.map(y=>s.jsx(Le,{item:y,selected:y.id===r,onSelect:e,onPreview:a},y.id))},c.key))}),j&&s.jsx("button",{type:"button",className:"assets-load-more",disabled:f,onClick:t,children:l("assets.loadMore")})]})}const Ke=5e3;function Ge({refs:e,onChange:a,maxRefs:r=6}){const{t:l}=I(),[p,f]=d.useState(null),[j,o]=d.useState(null),[i,g]=d.useState(null),_=d.useRef(null);d.useEffect(()=>()=>{_.current&&window.clearTimeout(_.current)},[]);const h=(u,t)=>{if(t<0||t>=e.length||u===t)return;const c=[...e],[y]=c.splice(u,1);c.splice(t,0,y),a(c)},x=u=>{if(e.length<=1)return;const t=e[u];a(e.filter((c,y)=>y!==u)),g({ref:t,index:u}),_.current&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>g(null),Ke)},v=()=>{if(!i||e.some(t=>t.path===i.ref.path))return;const u=[...e];u.splice(Math.min(i.index,u.length),0,i.ref),a(u.slice(0,r)),g(null)},k=(u,t)=>{u.preventDefault();const c=u.dataTransfer.getData("application/ima2-element-ref")||p,y=e.findIndex(S=>S.id===c);if(f(null),y<0||y===t)return;const A=e[y],N=e.find((S,w)=>w!==y&&S.path===A.path);if(N){o(N.id),window.setTimeout(()=>o(null),1200);return}h(y,t)},m=(u,t)=>a(e.map((c,y)=>y===u?{...c,alt:t}:c));return s.jsxs("section",{className:"element-ref-grid","aria-labelledby":"element-refs-title",children:[s.jsxs("div",{className:"element-detail__section-heading",children:[s.jsxs("div",{children:[s.jsx("h3",{id:"element-refs-title",children:l("element.refsTitle")}),s.jsx("p",{children:l("element.refsHelp")})]}),s.jsxs("span",{children:[e.length," / ",r]})]}),s.jsx("div",{className:"element-ref-grid__items",children:e.map((u,t)=>s.jsxs("div",{className:`element-ref-card${p===u.id?" is-dragging":""}${j===u.id?" is-duplicate":""}`,draggable:!0,onDragStart:c=>{f(u.id),c.dataTransfer.setData("application/ima2-element-ref",u.id),c.dataTransfer.effectAllowed="move"},onDragEnd:()=>f(null),onDragOver:c=>c.preventDefault(),onDrop:c=>k(c,t),children:[s.jsxs("div",{className:"element-ref-card__image",children:[s.jsx("img",{src:u.previewUrl||u.path,alt:u.alt||l("element.refAlt",{n:t+1})}),t===0?s.jsx("span",{children:l("element.refPrimary")}):null]}),s.jsxs("div",{className:"element-ref-card__controls",children:[s.jsxs("label",{children:[l("element.refLabel"),s.jsx("input",{value:u.alt,maxLength:80,placeholder:l("element.refLabelPlaceholder"),onChange:c=>m(t,c.target.value)})]}),s.jsxs("div",{children:[s.jsx("button",{type:"button",disabled:t===0,onClick:()=>h(t,t-1),"aria-label":l("element.refMoveUp",{n:t+1}),children:"↑"}),s.jsx("button",{type:"button",disabled:t===e.length-1,onClick:()=>h(t,t+1),"aria-label":l("element.refMoveDown",{n:t+1}),children:"↓"}),s.jsx("button",{type:"button",className:"is-danger",disabled:e.length<=1,onClick:()=>x(t),"aria-label":l("element.refRemove"),children:l("element.refRemove")})]})]})]},u.id))}),i?s.jsxs("div",{className:"element-ref-grid__undo",role:"status",children:[s.jsx("span",{children:l("element.refRemoved")}),s.jsx("button",{type:"button",onClick:v,children:l("element.refUndo")})]}):null]})}const He=/^[A-Za-z0-9_-]{1,32}$/;function ze({bindings:e,refs:a,onSave:r}){const{t:l}=I(),p=e.find(v=>v.provider==="runway"),f=e.find(v=>v.provider==="higgsfield"),[j,o]=d.useState(p?.tag??""),[i,g]=d.useState(!1),[_,h]=d.useState(null),x=async()=>{const v=j.trim();if(v&&!He.test(v)){h(l("assets.bindingTagInvalid"));return}h(null),g(!0);try{const k=[{provider:"runway",mode:"stateless-refs",...v?{tag:v}:{}},...f?[f]:[]];await r(k)||h(l("assets.actionFailed"))}finally{g(!1)}};return s.jsxs("section",{className:"element-detail__section","data-testid":"character-bindings-card",children:[s.jsx("div",{className:"element-detail__section-heading",children:s.jsxs("div",{children:[s.jsx("h3",{children:l("assets.bindingsTitle")}),s.jsx("p",{children:l("assets.bindingsHelp")})]})}),s.jsxs("div",{className:"character-binding-row",children:[s.jsx("span",{className:"character-binding-row__provider",children:"Runway"}),s.jsx("span",{className:"character-binding-row__mode",children:l("assets.bindingStateless")}),s.jsx("input",{value:j,maxLength:32,placeholder:l("assets.bindingTagPlaceholder"),"aria-label":l("assets.bindingTagPlaceholder"),onChange:v=>o(v.target.value)}),s.jsx("button",{type:"button",disabled:i,onClick:()=>{x()},children:l(i?"assets.bindingSaving":"assets.bindingSave")})]}),xe(a)?s.jsx("p",{className:"element-detail__error",role:"alert",children:l("assets.bindingCapWarning",{count:a.length})}):null,s.jsxs("div",{className:"character-binding-row character-binding-row--locked",children:[s.jsx("span",{className:"character-binding-row__provider",children:"Higgsfield"}),f?.status?s.jsx("span",{className:"character-binding-row__status",children:f.status}):null,s.jsx("button",{type:"button",disabled:!0,title:l("assets.bindingTrainLockedHint"),children:l("assets.bindingTrain")}),s.jsx("span",{className:"character-binding-row__badge",children:l("assets.bindingPaidPlan")})]}),f&&ve(a,f)?s.jsx("p",{className:"element-detail__error",role:"alert",children:l("assets.bindingDriftWarning")}):null,_?s.jsx("p",{className:"element-detail__error",role:"alert",children:_}):null]})}const Oe=["character","product","style","scene"],W=e=>e[0].toUpperCase()+e.slice(1);function Z(e){return{id:e?.id,name:e?.name??"",kind:e?.kind??"character",refs:(e?.refs??[]).filter(a=>typeof a=="string"&&a.length>0).map((a,r)=>({id:`${e?.id??"new"}-${r}-${a}`,path:a,previewUrl:`/generated/${a.split("/").map(encodeURIComponent).join("/")}`,alt:""})),notes:e?.notes??"",defaultStrength:e?.defaultStrength??.75}}function qe({element:e,saving:a,testing:r,onSave:l,onDelete:p,onRunTestSheet:f,onSaveBindings:j}){const{t:o}=I(),[i,g]=d.useState(()=>Z(e)),[_,h]=d.useState(null);d.useEffect(()=>{g(Z(e)),h(null)},[e]);const x=800-i.notes.length,v=d.useMemo(()=>i.notes.trim()?`[Element: ${i.name.trim()||"Untitled"}] ${i.notes.trim()}`:null,[i.name,i.notes]),k=(t,c)=>g(y=>({...y,[t]:c})),m=async()=>{if(!i.name.trim())return h(o("element.errorName"));if(!i.refs.length)return h(o("element.errorRefs"));h(null),await l({...i,name:i.name.trim(),notes:i.notes.trim()?i.notes:""})},u=Oe.map(t=>({value:t,label:o(`element.kind${W(t)}`)}));return s.jsxs("aside",{className:"element-detail","aria-label":o("element.ariaLabel"),children:[s.jsxs("header",{className:"element-detail__header",children:[s.jsxs("div",{children:[s.jsx("span",{children:o("element.title")}),s.jsx("h2",{children:o(e?"element.titleEdit":"element.titleNew")})]}),e?s.jsx("span",{className:"element-detail__status",children:o("element.saved")}):null]}),s.jsxs("label",{className:"element-detail__field",children:[o("element.name"),s.jsx("input",{value:i.name,maxLength:120,placeholder:o("element.namePlaceholder"),onChange:t=>k("name",t.target.value)})]}),s.jsx(be,{title:o("element.kind"),items:u,value:i.kind,onChange:t=>k("kind",t)}),s.jsx("p",{className:"element-detail__kind-help",children:o(`element.help${W(i.kind)}`)}),s.jsx(Ge,{refs:i.refs,onChange:t=>k("refs",t),maxRefs:6}),e&&i.kind==="character"&&j?s.jsx(ze,{bindings:e.characterBindings??[],refs:e.refs,onSave:t=>j(e.id,t)}):null,s.jsxs("section",{className:"element-detail__section",children:[s.jsxs("div",{className:"element-detail__section-heading",children:[s.jsxs("div",{children:[s.jsx("h3",{children:o("element.notes")}),s.jsx("p",{children:o("element.notesHelp")})]}),x<=100?s.jsx("span",{children:o("element.remaining",{n:x})}):null]}),s.jsx("textarea",{value:i.notes,maxLength:800,rows:6,placeholder:o("element.notesPlaceholder"),onChange:t=>k("notes",t.target.value)}),v?s.jsx("p",{className:"element-detail__note-preview",children:v}):null]}),s.jsxs("section",{className:"element-detail__section",children:[s.jsxs("div",{className:"element-detail__section-heading",children:[s.jsxs("div",{children:[s.jsx("h3",{children:o("element.strength")}),s.jsx("p",{children:o("element.strengthHelp")})]}),s.jsx("output",{children:i.defaultStrength.toFixed(2)})]}),s.jsx("input",{className:"element-detail__strength",type:"range",min:"0",max:"1",step:"0.05",value:i.defaultStrength,onChange:t=>k("defaultStrength",Number(t.target.value))}),s.jsx("button",{type:"button",className:"element-detail__reset",onClick:()=>k("defaultStrength",.75),children:o("element.resetDefault")})]}),_?s.jsx("p",{className:"element-detail__error",role:"alert",children:_}):null,s.jsxs("footer",{className:"element-detail__actions",children:[s.jsx("button",{type:"button",className:"element-detail__save",disabled:a,onClick:()=>{m()},children:o(a?"element.saving":"element.save")}),s.jsx("button",{type:"button",disabled:!e||r,onClick:()=>e&&void f(e.id),children:o(r?"element.testing":"element.runTest")}),e&&p?s.jsx("button",{type:"button",className:"is-danger",onClick:()=>{p(e.id)},children:o("element.delete")}):null]})]})}const Ve=["image","video","element","preset","template"];function We(e,a){return Ae(e,a)}function ts(){const{t:e}=I(),a=b(n=>n.assets),r=b(n=>n.assetsTags),l=b(n=>n.assetsFilters),p=b(n=>n.assetsLoading),f=b(n=>n.assetsLoadError),j=b(n=>n.loadAssets),o=b(n=>n.setUIMode),i=b(n=>n.setAssetsFilters),g=b(n=>n.updateAssetItem),_=b(n=>n.deleteAssetItem),h=b(n=>n.showToast),[x,v]=d.useState(l.q),[k,m]=d.useState(null),[u,t]=d.useState(null),[c,y]=d.useState(null),A=je(),N=b(n=>n.keyingTarget),S=b(n=>n.pendingAssetDetailId);d.useEffect(()=>{if(!S)return;const n=S;b.setState({pendingAssetDetailId:null});const E=b.getState().assets.find(F=>F.id===n)??null;y(E),i({kind:null,folderId:null,tag:null,q:""}),v(""),m(n),E||ye(n).then(({asset:F})=>{b.setState(K=>({assets:[F,...K.assets.filter(B=>B.id!==F.id)]})),y(F)}).catch(()=>{})},[S,i]);const w=d.useRef(!1);d.useEffect(()=>{if(N){w.current=!0;return}w.current&&(w.current=!1,j(!0))},[N,j]);const R=d.useMemo(()=>[{value:"",label:e("assets.kindAll")},...Ve.map(n=>({value:n,label:e(`assets.kind${n[0].toUpperCase()}${n.slice(1)}`)}))],[e]);d.useEffect(()=>{j(!0)},[j]),d.useEffect(()=>{const n=window.setTimeout(()=>i({q:x}),300);return()=>window.clearTimeout(n)},[x,i]);const P=!!(l.q||l.kind||l.tag),J=a.length===0&&!p,U=l.kind==="element"&&!l.folderId&&!l.q&&!l.tag,X=U?"assets.emptyElementsTitle":l.folderId?"assets.emptyFolderTitle":P?"assets.emptySearchTitle":"assets.emptyTitle",ee=U?"assets.emptyElementsBody":l.folderId?"assets.emptyFolderBody":P?"assets.emptySearchBody":"assets.emptyBody",C=a.find(n=>n.id===k)??(c?.id===k?c:null),H=C?.kind==="element"?Qe(C):null,$=d.useCallback(()=>m(null),[]),se=We(!!(C&&A),$),te=d.useCallback(()=>t(null),[]),ae=async n=>{(!n.id||!await g(n.id,{name:n.name,notes:n.notes}))&&h(e("assets.actionFailed"),!0)},ne=async(n,E)=>{const K={...a.find(oe=>oe.id===n)?.metadata??{},characterBindings:E},B=await g(n,{metadata:K});return B||h(e("assets.actionFailed"),!0),B},le=async(n,E)=>{const F=await g(n,{name:E});return F||h(e("assets.actionFailed"),!0),F},ie=async n=>{await _(n)?$():h(e("assets.actionFailed"),!0)},re=async()=>h(e("assets.testSheetsUnavailable"),!0);return s.jsxs("section",{className:`assets-workspace${C?" assets-workspace--detail-open":""}`,"aria-labelledby":"assets-title",children:[s.jsx(Fe,{}),s.jsxs("main",{className:"assets-workspace__main",children:[s.jsxs("header",{className:"assets-toolbar",children:[s.jsxs("div",{className:"assets-toolbar__title",children:[s.jsx("h1",{id:"assets-title",children:e("assets.title")}),s.jsx("span",{children:e("assets.itemCount",{count:a.length})})]}),s.jsxs("div",{className:"assets-toolbar__controls",children:[s.jsx("input",{type:"search",value:x,placeholder:e("assets.searchPlaceholder"),"aria-label":e("assets.searchPlaceholder"),onChange:n=>v(n.target.value)}),s.jsx(_e,{items:R,value:l.kind??"",onChange:n=>i({kind:n||null}),ariaLabel:e("assets.kindAll")}),a.length>0&&s.jsx("button",{type:"button",className:"assets-clear-btn",onClick:async()=>{confirm(e("assets.clearConfirm"))&&(await we(),j(!0))},children:e("assets.clearAll")})]}),r.length>0&&s.jsx("div",{className:"assets-tag-filter",children:r.map(n=>s.jsx("button",{type:"button",className:l.tag===n?"is-active":"",onClick:()=>i({tag:l.tag===n?null:n}),children:n},n))})]}),f&&a.length===0?s.jsxs("div",{className:"assets-empty",role:"alert",children:[s.jsx("h2",{children:e("assets.loadErrorTitle")}),s.jsx("p",{children:e("assets.loadErrorBody")}),s.jsx("button",{type:"button",className:"assets-empty__cta",onClick:()=>{j(!0)},children:e("assets.retry")})]}):J?s.jsxs("div",{className:"assets-empty",children:[s.jsx("h2",{children:e(X)}),s.jsx("p",{children:e(ee)}),U||!P&&!l.folderId?s.jsx("button",{type:"button",className:"assets-empty__cta",onClick:()=>o("classic"),children:e("nav.create")}):null]}):s.jsx(Ue,{selectedId:k??void 0,onSelectAsset:m,onPreviewAsset:n=>t(ke(n))})]}),C&&A?s.jsx("button",{type:"button",className:"assets-workspace__detail-backdrop","aria-label":e("assets.detailClose"),onClick:$}):null,C&&s.jsxs("aside",{ref:se,className:"assets-workspace__detail",role:A?"dialog":void 0,"aria-modal":A?!0:void 0,"aria-label":e("assets.detailAria",{name:C.name}),children:[s.jsx("button",{type:"button",className:"assets-workspace__detail-close",onClick:$,"aria-label":e("assets.detailClose"),children:"×"}),H?s.jsx(qe,{element:H,saving:!1,testing:!1,onSave:ae,onSaveBindings:ne,onDelete:ie,onRunTestSheet:re}):s.jsx(Ze,{asset:C,onRename:n=>le(C.id,n)})]}),s.jsx(Ie,{}),s.jsx(Ne,{}),u?s.jsx(Se,{item:u,onClose:te}):null]})}function Ze({asset:e,onRename:a}){const{t:r,locale:l}=I(),[p,f]=d.useState(!1),[j,o]=d.useState(e.name),i=d.useRef(!1),g=typeof e.metadata?.prompt=="string"?e.metadata.prompt:null,_=typeof e.metadata?.provider=="string"?e.metadata.provider:null;d.useEffect(()=>{o(e.name),f(!1)},[e.id,e.name]);async function h(){if(i.current)return;const x=j.trim();if(!x||x===e.name){o(e.name),f(!1);return}i.current=!0;try{await a(x)||o(e.name)}finally{i.current=!1,f(!1)}}return s.jsxs("div",{className:"assets-workspace__detail-meta",children:[s.jsx("div",{className:"assets-workspace__detail-title",children:p?s.jsx("input",{className:"assets-folder-input assets-workspace__detail-name-input",value:j,autoFocus:!0,"aria-label":r("assets.renameAsset"),onChange:x=>o(x.target.value),onBlur:()=>{h()},onKeyDown:x=>{x.key==="Enter"&&h(),x.key==="Escape"&&(o(e.name),f(!1))}}):s.jsxs(s.Fragment,{children:[s.jsx("h2",{children:e.name}),s.jsx("button",{type:"button",className:"assets-workspace__detail-rename","aria-label":r("assets.renameAsset"),title:r("assets.renameAsset"),onClick:()=>f(!0),children:s.jsx(Q,{})})]})}),s.jsxs("dl",{children:[s.jsx("dt",{children:r("assets.detailKind")}),s.jsx("dd",{children:r(`assets.kind${e.kind[0].toUpperCase()}${e.kind.slice(1)}`)}),s.jsx("dt",{children:r("assets.detailCreated")}),s.jsx("dd",{children:new Intl.DateTimeFormat(l,{dateStyle:"medium",timeStyle:"short"}).format(new Date(e.createdAt))}),_?s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:r("assets.detailProvider")}),s.jsx("dd",{children:_})]}):null,g?s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:r("assets.detailPrompt")}),s.jsx("dd",{className:"assets-workspace__detail-prompt",children:g})]}):null,e.tags.length>0?s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:r("assets.detailTags")}),s.jsx("dd",{children:e.tags.join(", ")})]}):null]})]})}function Qe(e){const a=e.metadata??{},r=a.elementKind,l=a.refs,p=Array.isArray(a.characterBindings)?a.characterBindings:void 0;return{id:e.id,name:e.name,kind:r==="product"||r==="style"||r==="scene"?r:"character",refs:Array.isArray(l)?l.filter(f=>typeof f=="string"):e.filePath?[e.filePath]:[],notes:e.notes??void 0,defaultStrength:typeof a.defaultStrength=="number"?a.defaultStrength:void 0,characterBindings:p}}export{ts as AssetsWorkspace};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PromptImportDialog-B5Wv2cie.js","assets/index-B-iNVdeL.js","assets/index-CxX85A3B.css","assets/App-x_fzCXKb.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{j as e,f as i,_ as R}from"./index-B-iNVdeL.js";import{u as v,k as $,au as j,a as s,S as A}from"./App-x_fzCXKb.js";function z({prompt:a,onClose:d,onLoad:c,onInsert:t,onDelete:b,onToggleFavorite:l}){const{t:o}=v(),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}=v(),[o,n]=i.useState(!1),m=a.text.length>45?a.text.slice(0,45)+"...":a.text;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"prompt-library-row",onClick:()=>n(!0),children:[e.jsxs("div",{className:"prompt-library-row__main",children:[e.jsx("div",{className:"prompt-library-row__title",children:a.name||l("promptLibrary.untitled")}),e.jsx("div",{className:"prompt-library-row__preview",children:m})]}),e.jsxs("div",{className:"prompt-library-row__actions",children:[e.jsx("button",{className:"prompt-library-row__insert",onClick:p=>{p.stopPropagation(),c()},title:l("promptLibrary.insert"),"aria-label":l("promptLibrary.insert"),children:"+"}),e.jsx("button",{className:`prompt-library-row__star${a.isFavorite?" prompt-library-row__star--on":""}`,onClick:p=>{p.stopPropagation(),b()},"aria-label":a.isFavorite?l("promptLibrary.unfavorite"):l("promptLibrary.favorite"),"aria-pressed":a.isFavorite,children:e.jsx(j,{})}),e.jsx("span",{className:"prompt-library-row__chevron",children:"›"})]})]}),o&&e.jsx(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-B5Wv2cie.js"),__vite__mapDeps([0,1,2,3])).then(a=>({default:a.PromptImportDialog})));function G({variant:a="overlay",forceOpen:d=!1,onRequestClose:c}){const{t}=v(),b=s(r=>r.promptLibraryOpen),l=s(r=>r.togglePromptLibrary),o=s(r=>r.promptLibrary),n=s(r=>r.promptLibraryLoading),m=s(r=>r.loadPromptLibrary),p=s(r=>r.deletePromptFromLibrary),w=s(r=>r.togglePromptFavorite),k=s(r=>r.setPrompt),L=s(r=>r.insertPromptToComposer),F=s(r=>r.clearInsertedPrompts),N=s(r=>r.showToast),[y,I]=i.useState(""),[x,S]=i.useState(!1),[O,f]=i.useState(!1),[g,C]=i.useState(!1),h=d||b,_=c??l;i.useEffect(()=>{h&&m()},[h,m]);const D=i.useCallback(r=>{L({id:r.id,name:r.name||t("promptLibrary.untitled"),text:r.text}),N(t("promptLibrary.inserted")),_()},[_,L,N,t]);if(!h)return null;const P=o.prompts.filter(r=>{if(x&&!r.isFavorite)return!1;if(!y.trim())return!0;const u=y.toLowerCase();return r.name.toLowerCase().includes(u)||r.text.toLowerCase().includes(u)||r.tags.some(E=>E.toLowerCase().includes(u))}),T=e.jsxs("div",{className:"prompt-library-panel__drawer",children:[e.jsxs("div",{className:"prompt-library-panel__header",children:[e.jsx("h3",{children:t("promptLibrary.title")}),e.jsxs("div",{className:"prompt-library-panel__actions",children:[e.jsx("button",{className:"prompt-library-panel__add",onClick:()=>f(r=>!r),title:t("promptLibrary.addNew"),"aria-label":t("promptLibrary.addNew"),children:"+"}),e.jsx("button",{className:"prompt-library-panel__import",onClick:()=>C(!0),title:t("promptLibrary.importFiles"),"aria-label":t("promptLibrary.importFiles"),children:t("promptLibrary.import")}),e.jsx("button",{onClick:_,"aria-label":t("common.close"),children:"×"})]}),O&&e.jsx(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};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{f as l,i as q,g as $,j as e,L as H,S as ue,u as ge,o as me}from"./index-B-iNVdeL.js";import{s as R,u as C,t as z,v as he,x as pe,y as fe,z as xe,a as S,I as ye,R as Y,V,A as ne,r as je,O as Z,G as ae,B as ve,U as be,C as _e,D as Ne,E as we,F as ke,H as Se,J as Le,K as Ce,L as ie,M as Ee,N as Ke,P as Te,W as Ie}from"./App-x_fzCXKb.js";import{u as B}from"./promptBuilderStore-CQxHJQz4.js";function Me(){const[s,n]=l.useState(null);return l.useEffect(()=>{if(q())return;const i=$();let t=!1;return(async()=>{try{const g=await R("/api/agy/status");if(t)return;const c=await g.json();if(t||q()||i!==$())return;n(c)}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:c}){const{t:d}=C(),[f,j]=l.useState(""),[p,u]=l.useState(!1),[v,y]=l.useState(!1),[r,x]=l.useState(null),[b,L]=l.useState(!1),E=a==="env",N=f.trim().length>0,A=g&&!p&&!N,D=l.useCallback(async()=>{if(N){y(!0),x(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),c(),setTimeout(()=>L(!1),3e3)):x(_.error||d("settings.apiKeys.saveFailed"))}catch(o){if(o?.code==="LAN_TOKEN_REQUIRED")return;x(d("settings.apiKeys.networkError"))}finally{y(!1)}}},[f,s,N,c,d]),K=l.useCallback(async()=>{try{if(!(await R(`/api/keys/${s}`,{method:"DELETE"})).ok){x(d("settings.apiKeys.removeFailed"));return}j(""),u(!1),c()}catch(o){if(o?.code==="LAN_TOKEN_REQUIRED")return;x(d("settings.apiKeys.networkError"))}},[s,c,d]),O=l.useCallback(()=>{g&&u(!0)},[g]),F=l.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:d(E?"settings.apiKeys.envSource":"settings.apiKeys.configSource")}),e.jsx("h4",{children:n}),e.jsxs("div",{className:"api-key-input-group",children:[A?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:o=>{j(o.target.value),x(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:d(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:d("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"}),d(g?"settings.apiKeys.status.valid":"settings.apiKeys.status.notConfigured")]})]})}function Ae({configured:s,maskedKey:n,source:i,onSaved:t}){const{t:a}=C(),[g,c]=l.useState(""),[d,f]=l.useState(!1),[j,p]=l.useState(!1),[u,v]=l.useState(null),[y,r]=l.useState(!1),x=i==="env",b=g.trim().length>0,L=s&&!d&&!b,E=l.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?(c(""),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=l.useCallback(async()=>{try{if(!(await R("/api/keys/vertex",{method:"DELETE"})).ok){v(a("settings.apiKeys.removeFailed"));return}c(""),f(!1),t()}catch(K){if(K?.code==="LAN_TOKEN_REQUIRED")return;v(a("settings.apiKeys.networkError"))}},[t,a]),A=l.useCallback(()=>{s&&!x&&f(!0)},[s,x]),D=l.useCallback(()=>{b||f(!1)},[b]);return e.jsxs("div",{className:"vertex-json-section",children:[e.jsx("p",{className:"settings-eyebrow",children:a(x?"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:A,onClick:A}):e.jsx("textarea",{className:`vertex-json-textarea${u?" is-invalid":""}`,placeholder:a("settings.apiKeys.vertex.placeholder"),value:g,onChange:K=>{c(K.target.value),v(null)},onBlur:D,readOnly:x,autoFocus:d,spellCheck:!1,"data-1p-ignore":!0,"data-lpignore":"true","data-form-type":"other"}),e.jsxs("div",{className:"api-key-actions",style:{marginTop:8},children:[!x&&e.jsx("button",{type:"button",className:"settings-action-btn",onClick:E,disabled:!b||j,children:a(j?"settings.apiKeys.saving":y?"settings.apiKeys.saved":"settings.apiKeys.save")}),s&&!x&&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 Oe({keyStatus:s,onSaved:n}){const{t:i}=C(),t=s.vertex?.configured??!1,a=s.gemini?.configured??!1,g=s.geminiAuthMode==="vertex"?"vertex":"apikey",[c,d]=l.useState(g),[f,j]=l.useState(!1);l.useEffect(()=>{f||d(g)},[g,f]);const p=u=>{j(!0),d(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:c,onChange:p,items:[{value:"apikey",label:i("settings.apiKeys.vertex.authModeApiKey")},{value:"vertex",label:i("settings.apiKeys.vertex.authModeVertex")}]})]}),c==="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(Ae,{configured:t,maskedKey:s.vertex?.maskedKey??null,source:s.vertex?.source??"none",onSaved:n})]})}function qe(s){return s>80?"var(--red)":s>50?"var(--amber)":"var(--blue)"}function Re(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 oe({window:s}){const n=Re(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:qe(s.percent)}})}),e.jsxs("span",{className:"quota-bar__pct",children:[s.percent,"%"]}),n&&e.jsx("span",{className:"quota-bar__reset",children:n})]})}function Be({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 ce({provider:s,onComplete:n}){const{t:i}=C(),[t,a]=l.useState({phase:"idle"}),[g,c]=l.useState(!1),d=l.useRef(!1),f=l.useCallback(async()=>{if(d.current||q())return;const j=$();d.current=!0,a({phase:"starting"});try{const p=await R("/api/auth/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:s})});if(!p.ok){const v=await p.json().catch(()=>({error:i("settings.quota.switchFailed")}));a({phase:"error",error:v.error||`HTTP ${p.status}`});return}const u=await p.json();if(q()||j!==$())return;a({phase:"waiting",...u}),window.open(u.verificationUrl,"_blank")}catch(p){if(d.current=!1,p?.code==="LAN_TOKEN_REQUIRED")return;a({phase:"error",error:p.message})}},[s]);return l.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)},y=async()=>{if(!(p||q()||j!==$())){try{const x=await(await R(`/api/auth/switch/${t.sessionId}`)).json();if(p||q()||j!==$())return;if(x.status==="complete"){a({phase:"complete"});return}if(x.status==="error"||x.status==="expired"){a({phase:"error",error:x.error||x.status});return}}catch{}!p&&!q()&&j===$()&&(u=setTimeout(y,3e3))}};return window.addEventListener(H,v),u=setTimeout(y,3e3),v},[t.phase,t.sessionId,n]),l.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:[e.jsx("div",{style:{textAlign:"center",marginBottom:"4px"},children:i("settings.quota.enterCode")}),e.jsx("div",{style:{textAlign:"center",fontSize:"18px",fontWeight:700,fontFamily:"monospace",letterSpacing:"2px",margin:"6px 0"},children:t.userCode}),t.verificationUrl&&e.jsxs("div",{style:{display:"flex",gap:"4px",margin:"6px 0"},children:[e.jsx("button",{type:"button",className:"settings-action-btn",style:{flex:1,fontSize:"11px"},onClick:()=>{d.current=!1,f()},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(()=>{c(!0),setTimeout(()=>c(!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")})]}):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:()=>{d.current=!1,a({phase:"idle"})},children:i("settings.quota.tryAgain")})]}):null}function Pe(){const[s,n]=l.useState(null),[i,t]=l.useState(!0),a=l.useCallback(()=>{t(!0),R("/api/quota").then(g=>g.json()).then(n).catch(()=>n(null)).finally(()=>t(!1))},[]);return l.useEffect(()=>{if(q())return;const g=setTimeout(()=>{c(),a()},1500),c=()=>{clearTimeout(g),window.removeEventListener(H,c)};return window.addEventListener(H,c),c},[a]),{data:s,loading:i,refreshQuota:a}}function $e({data:s,loading:n}){const{t:i}=C(),t=s?.nai,a=t?.nai,g=t?.windows.find(d=>d.label==="v5-battery"),c=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 c||!a?e.jsx("div",{className:"quota-card",children:e.jsx("span",{className:n?"quota-card__loading":"quota-card__hint",children:c??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(Be,{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 De({data:s,loading:n,onRefresh:i}){const{t}=C(),a=s?.codex,g=a?.windows&&a.windows.length>0,c=a?.account?[a.account.email,a.account.plan].filter(Boolean).join(" · "):null;return e.jsxs("div",{className:"quota-card",children:[c?e.jsx("div",{className:"quota-card__header",children:e.jsx("span",{className:"quota-card__account",children:c})}):null,n?e.jsx("span",{className:"quota-card__loading",children:t("common.loading")}):g?a.windows.map(d=>e.jsx(oe,{window:d},d.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 Fe({data:s,loading:n,onRefresh:i}){const{t}=C(),a=s?.grok,g=a?.windows&&a.windows.length>0,c=a?.account?[a.account.email,a.account.plan].filter(Boolean).join(" · "):null;return e.jsxs("div",{className:"quota-card",children:[c||a?.billing?e.jsxs("div",{className:"quota-card__header",style:{display:"flex",alignItems:"center"},children:[c&&e.jsx("span",{className:"quota-card__account",children:c}),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(d=>e.jsx(oe,{window:d},d.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 Ue(){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 ze(){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 Ge(){const{t:s}=C(),n=he(),i=pe(),t=Me(),{data:a,error:g}=fe(),{data:c,mutate:d}=xe(),f=Pe(),[j,p]=l.useState(!1),u=a?.apiKeySource==="env"||a?.apiKeySource==="config"||a?.apiKeyValid===!0,v=a?.apiKeySource==="config"?s("settings.account.apiSourceConfig"):s("settings.account.apiSourceEnv"),y=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(De,{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":y?"ok":"warn"}`,children:s(g?"settings.account.apiUnknown":y?"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(Ue,{})}),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(Fe,{data:f.data,loading:f.loading,onRefresh:f.refreshQuota})]}),c?.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($e,{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(ze,{})}),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")})]})]}),c&&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:c.openai?.maskedKey??null,source:c.openai?.source??"none",configured:c.openai?.configured??!1,onSaved:d}),e.jsx(G,{provider:"xai",label:s("settings.apiKeys.xai.label"),placeholder:s("settings.apiKeys.xai.placeholder"),maskedKey:c.xai?.maskedKey??null,source:c.xai?.source??"none",configured:c.xai?.configured??!1,onSaved:d}),e.jsx(G,{provider:"atlascloud",label:s("settings.apiKeys.atlascloud.label"),placeholder:s("settings.apiKeys.atlascloud.placeholder"),maskedKey:c.atlascloud?.maskedKey??null,source:c.atlascloud?.source??"none",configured:c.atlascloud?.configured??!1,onSaved:d}),e.jsx(G,{provider:"minimax",label:s("settings.apiKeys.minimax.label"),placeholder:s("settings.apiKeys.minimax.placeholder"),maskedKey:c.minimax?.maskedKey??null,source:c.minimax?.source??"none",configured:c.minimax?.configured??!1,onSaved:d}),e.jsx(G,{provider:"nai",label:s("settings.apiKeys.nai.label"),placeholder:s("settings.apiKeys.nai.placeholder"),maskedKey:c.nai?.maskedKey??null,source:c.nai?.source??"none",configured:c.nai?.configured??!1,onSaved:d}),e.jsx(Oe,{keyStatus:c,onSaved:d})]})]})]})}function He({variant:s}){const{t:n}=C(),[i,t]=l.useState(!1),a=l.useRef(null),g=l.useRef(null),c=l.useRef(null),d=l.useRef([]),[f,j]=l.useState({top:0,left:12,width:280,maxHeight:480}),p=S(o=>o.imageModel),u=S(o=>o.provider),v=S(o=>o.setImageModel),y=S(o=>o.setProvider),r=S(o=>o.videoModelSelected),x=S(o=>o.selectVideoModel),b=S(o=>o.reasoningEffort),L=S(o=>o.setReasoningEffort),E=s==="settings"?"settings-image-model":"sidebar-image-model",N=ye,A=N.find(o=>o.value===p&&(!o.providerHint||o.providerHint===u))??N.find(o=>o.value===p)??N[0],D=Y.find(o=>o.value===b)??Y[0],K=()=>d.current.filter(o=>o!==null),O=o=>{const _=K();if(_.length===0)return;const h=(o+_.length)%_.length;_[h]?.focus()},F=o=>{const _=K();if(_.length===0)return;const h=_.findIndex(I=>I===document.activeElement),w=_.length-1;if(o.key==="ArrowDown"||o.key==="ArrowRight"){o.preventDefault(),O(h>=0?h+1:0);return}if(o.key==="ArrowUp"||o.key==="ArrowLeft"){o.preventDefault(),O(h>=0?h-1:w);return}if(o.key==="Home"){o.preventDefault(),O(0);return}if(o.key==="End"){o.preventDefault(),O(w);return}o.key==="Escape"&&(o.preventDefault(),t(!1),g.current?.focus())};if(l.useEffect(()=>{if(s!=="sidebar"||!i)return;const o=h=>{const w=h.target;w instanceof Node&&(a.current?.contains(w)||c.current?.contains(w)||t(!1))},_=h=>{h.key==="Escape"&&t(!1)};return document.addEventListener("pointerdown",o),document.addEventListener("keydown",_),()=>{document.removeEventListener("pointerdown",o),document.removeEventListener("keydown",_)}},[i,s]),l.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&&c.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]),l.useEffect(()=>{if(s!=="sidebar"||!i)return;const o=N.findIndex(h=>h.value===p),_=requestAnimationFrame(()=>{O(o>=0?o:0)});return()=>cancelAnimationFrame(_)},[p,N,i,s]),s==="sidebar"){const o=r?V.find(h=>h.value===r)?.shortLabel??V[0].shortLabel:A.shortLabel.split(" ")[0],_=ne(p)?A.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:o,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:o}),e.jsx("span",{className:"image-model-select__trigger-chevron","aria-hidden":"true",children:"▾"})]}),e.jsx("span",{className:"image-model-select__trigger-effort",children:_})]}),i?je.createPortal(e.jsxs("div",{ref:c,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:I=>{d.current[w]=I},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:I=>{d.current[Z.length+w]=I},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")}),ve.map((h,w)=>{const I=h.providerHint,P=h.value===p&&I===u&&!r;return e.jsxs("button",{ref:W=>{d.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:()=>{I&&y(I),v(h.value),t(!1)},children:[e.jsx("span",{children:h.shortLabel}),e.jsx("small",{children:n(h.fullLabelKey)})]},`${h.value}-${I||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:I=>{d.current[N.length+w]=I},type:"button",className:`image-model-select__item${r===h.value?" is-active":""}`,role:"menuitemradio","aria-checked":r===h.value,tabIndex:-1,onClick:()=>{x(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:I=>{d.current[N.length+V.length+w]=I},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:o=>v(o),items:[...N.map(o=>({value:o.value,label:n(o.fullLabelKey)})),...be.map(o=>({value:o.value,label:n(o.fullLabelKey),disabled:!0}))]})})}function We(){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 Ve={ko:"KO",en:"EN","zh-Hant":"正體","zh-Hans":"简体"};function Qe(){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:Ve[t]})},t))})}const Je=["light","dark","system"];function Ye(){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:Je.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 Xe=["rail","horizontal","sidebar"];function Ze(){const{t:s}=C(),n=S(t=>t.historyStripLayout),i=S(t=>t.setHistoryStripLayout);return e.jsx(_e,{className:"history-layout-toggle",items:Xe.map(t=>({value:t,label:s(`settings.appearance.historyStripLayout.${t}`)})),value:n,onChange:i})}const es=[{value:"default",labelKey:"workspace.defaultLabel",descKey:"workspace.defaultDesc"},{value:"prompt-studio",labelKey:"workspace.promptStudioLabel",descKey:"workspace.promptStudioDesc"}];function ss(){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:es.map(t=>({value:t.value,label:i(t.labelKey)}))})})}function ts(){const{t:s}=C(),[n,i]=l.useState(null);l.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 ns(s){return s==="connected"?"ok":s==="error"||s==="offline"?"err":"warn"}function as(s){const n=s.status.snapshotDiff;return n?n.drifted.length+n.missing.length+n.added.length:0}function is(){const{t:s}=C(),{providers:n,loading:i,error:t,refresh:a}=Ne(),[g,c]=l.useState(null),[d,f]=l.useState(!1),[j,p]=l.useState(null),u=async()=>{if(!d){f(!0);try{await a()}finally{f(!1)}}},v=async(y,r)=>{c({provider:y.id,action:r}),p(null);try{r==="connect"?await we(y.id):r==="refresh"?await ke(y.id):await Se(y.id),await a()}catch(x){const b=x instanceof Error&&x.message==="MCP_POPUP_BLOCKED"?s("mcp.popupBlocked"):s("mcp.connectionActionFailed");p({provider:y.id,message:b})}finally{c(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||d,"aria-busy":i||d,children:s(i||d?"mcp.loadingProviders":"mcp.refreshList")})})]}),t?e.jsx("p",{role:"alert",className:"settings-row__microcopy",children:s("mcp.providersLoadFailed")}):null,n.map(y=>{const r=y.status.state,x=!y.enabled||y.executable===!1,b=g?.provider===y.id?g.action:null,L=b!==null,E=as(y);return e.jsxs("article",{className:"provider-card",children:[e.jsxs("div",{className:"provider-card__head",children:[e.jsx("h4",{children:y.id}),e.jsx("span",{className:"provider-card__eyebrow",children:"MCP"}),e.jsx("span",{className:`provider-chip provider-chip--${ns(r)}`,children:s(`mcp.status.${r}`)})]}),e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("p",{children:y.endpoint}),e.jsxs("p",{children:[typeof y.status.toolCount=="number"?s("mcp.toolCount",{count:y.status.toolCount}):s("mcp.toolCountUnknown"),E>0?` · ${s("mcp.snapshotChanges",{count:E})}`:""]}),x?e.jsx("p",{className:"settings-row__microcopy",children:y.enabled?y.lockReason??s("mcp.higgsfieldLocked"):s("mcp.disabledProvider")}):y.status.detail?e.jsx("p",{className:"settings-row__microcopy",children:y.status.detail}):null,j?.provider===y.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"&&!x?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"settings-action-btn",onClick:()=>{v(y,"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(y,"disconnect")},disabled:L,"aria-busy":b==="disconnect",children:s("mcp.disconnect")})]}):e.jsx("button",{type:"button",className:"settings-action-btn",onClick:()=>{v(y,"connect")},disabled:L||x,"aria-busy":b==="connect",title:s(x?"mcp.higgsfieldLocked":"mcp.connectOpensBrowser"),children:s(b==="connect"?"mcp.connecting":"mcp.connect")})})]},y.id)})]})}const rs=[137,80,78,71,13,10,26,10];async function ls(s){const n=new Uint8Array(await s.arrayBuffer());if(rs.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 le=["prompt","negativePrompt","width","height","seed","refImage","output"];function Q(s){return s.input?`${s.node}.${s.input}`:s.node}function os(){const{t:s}=C(),[n,i]=l.useState([]),[t,a]=l.useState(!0),[g,c]=l.useState(null),[d,f]=l.useState(null),[j,p]=l.useState({}),[u,v]=l.useState(""),[y,r]=l.useState(""),[x,b]=l.useState("image"),[L,E]=l.useState("http://127.0.0.1:8188"),[N,A]=l.useState({kind:"idle"}),[D,K]=l.useState(null),[O,F]=l.useState(!1),o=l.useRef(null),_=l.useCallback(async()=>{a(!0);try{const m=await Le();i(m.workflows)}catch{i([])}finally{a(!1)}},[]);l.useEffect(()=>{_()},[_]);const h=async m=>{if(m){K(null);try{const k=await ls(m),T=await Ee(k);f(k),c(T),b(T.mediaKind??"image");const U={};for(const M of T.candidates)M.unambiguous&&(U[M.field]=Q(M));p(U),u||v(m.name.replace(/\.[^.]+$/,"").toLowerCase().replace(/[^a-z0-9_-]+/g,"-").slice(0,64))}catch(k){c(null),f(null),K(k instanceof Error?k.message:s("comfy.inspectFailed"))}}},w=async()=>{A({kind:"idle"});try{const m=await Ke(L);A(m.health.ok?{kind:"ok",...m.health.version?{detail:m.health.version}:{}}:{kind:"unreachable"})}catch(m){A({kind:"invalid",detail:m instanceof Error?m.message:void 0})}},I=(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&&I.length===0&&!O),W=async()=>{if(!(!P||!d)){F(!0),K(null);try{const m={};for(const k of le){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 Te({...d,id:u,...y?{label:y}:{},origin:L,mediaKind:x,bind:m}),c(null),f(null),p({}),v(""),r(""),b("image"),o.current&&(o.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 Ce(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:o,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),A({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:y,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:x,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")})]}),x==="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,le.map(m=>{const k=g.candidates.filter(M=>M.field===m);if(k.length===0)return null;const T=k.some(M=>!M.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:M=>p(de=>({...de,[m]:M.target.value})),"aria-invalid":T&&!j[m],children:[e.jsx("option",{value:"",children:s("comfy.choose")}),k.map(M=>e.jsxs("option",{value:Q(M),children:[Q(M)," — ",M.classType,M.title?` "${M.title}"`:""]},Q(M)))]})]},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 cs(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 ds(){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),c=B(u=>u.configLoaded),d=B(u=>u.configLoading),f=B(u=>u.error),j=B(u=>u.loadConfig),p=B(u=>u.updateConfig);return l.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,d?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:cs(u,s)})),onChange:u=>{p(u)},ariaLabel:s("settings.promptBuilder.backendLabel"),disabled:!c||d||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:!c||d||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 hs(){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),c=S(r=>r.setGalleryDefaultScope),d=S(r=>r.provider),f=l.useRef(null),j=l.useRef(null),p=l.useRef(!1),u=l.useRef({providers:null,workspace:null,general:null}),v=(r,x)=>{u.current[r]=x},y=r=>{i(r),p.current=!0;const x=f.current,b=u.current[r];if(x&&b){const L=x.getBoundingClientRect().top,E=b.getBoundingClientRect().top,N=Number.parseFloat(window.getComputedStyle(b).scrollMarginTop)||0;x.scrollTo({top:x.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 l.useEffect(()=>{const r=x=>{x.key==="Escape"&&t()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[t]),l.useEffect(()=>{const r=f.current;if(!r||typeof IntersectionObserver!="function")return;const x=new IntersectionObserver(b=>{if(p.current)return;const E=b.filter(N=>N.isIntersecting).sort((N,A)=>A.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&&x.observe(L)}return()=>x.disconnect()},[i]),l.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:()=>y(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:()=>y(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(Ge,{}),e.jsx(is,{}),e.jsx(os,{}),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(He,{variant:"settings"})})]}),e.jsx(ds,{}),d==="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(ts,{})]}):d==="agy"||d==="gemini-api"?e.jsx("article",{className:"settings-row",children:e.jsxs("div",{className:"settings-row__copy",children:[e.jsx("h4",{children:s(d==="gemini-api"?"provider.geminiApiCompatTitle":"provider.agyCompatTitle")}),e.jsx("p",{children:s(d==="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(We,{})})]}),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(ss,{})})]}),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(Ze,{})})]}),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=>c(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(Qe,{})})]}),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(Ye,{})})]})]})]})]})]})})}export{hs as SettingsWorkspace};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{k as u}from"./App-x_fzCXKb.js";function r(o,a,s={}){return u(o,a,{trap:s.modal!==!1})}export{r as u};
|
|
Binary file
|