ima2-gen 3.12.1 → 3.12.2
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/docs/migration/runtime-test-inventory.md +9 -1
- package/package.json +5 -4
- package/ui/dist/.vite/manifest.json +37 -37
- package/ui/dist/assets/AgentWorkspace-CW1x4uOl.js +3 -0
- package/ui/dist/assets/AssetGenWorkspace-B7tTK0Sx.css +1 -0
- package/ui/dist/assets/AssetGenWorkspace-BQkdilsH.js +2 -0
- package/ui/dist/assets/AssetsWorkspace-BdptASFf.css +1 -0
- package/ui/dist/assets/AssetsWorkspace-CYSkmYU-.js +1 -0
- package/ui/dist/assets/{CardNewsWorkspace-DGOw6UH_.js → CardNewsWorkspace-nBKX5TXr.js} +2 -2
- package/ui/dist/assets/GenerationRequestLogPanel-CWqbfNis.js +1 -0
- package/ui/dist/assets/{HomeWorkspace-CuJY4Jr6.js → HomeWorkspace-CxqIGhb9.js} +1 -1
- package/ui/dist/assets/KeyingPanel-CtGvO6-u.js +1 -0
- package/ui/dist/assets/NodeCanvas-m41ECrFJ.js +7 -0
- package/ui/dist/assets/{PromptBuilderPanel-Dt4gO_Rb.js → PromptBuilderPanel-ChOoMAVA.js} +1 -1
- package/ui/dist/assets/PromptImportDialog-8hDG8MeK.js +2 -0
- package/ui/dist/assets/{PromptImportDiscoverySection-Bmyt_NVl.js → PromptImportDiscoverySection-D2_TAuLm.js} +1 -1
- package/ui/dist/assets/{PromptImportFolderSection-DGqoTx-h.js → PromptImportFolderSection-qv0qhTwq.js} +1 -1
- package/ui/dist/assets/PromptLibraryPanel-BPOD61FZ.js +2 -0
- package/ui/dist/assets/SettingsWorkspace-BKgXN2l9.js +1 -0
- package/ui/dist/assets/SpriteRecipeWorkspace-D8gHgnt8.js +1 -0
- package/ui/dist/assets/index-Bzt4YWub.js +5 -0
- package/ui/dist/assets/index-DB9EfKr6.css +1 -0
- package/ui/dist/assets/index-DTEhasVd.js +30 -0
- package/ui/dist/assets/{pptxgen.es-Cza43xx3.js → pptxgen.es-BEVsR2-i.js} +1 -1
- package/ui/dist/assets/useAgentDialogFocus-Dyj_bA5Q.js +1 -0
- package/ui/dist/index.html +2 -2
- package/ui/dist/assets/AgentWorkspace-CKAWZD7U.js +0 -3
- package/ui/dist/assets/AssetGenWorkspace-Dkr80l12.css +0 -1
- package/ui/dist/assets/AssetGenWorkspace-wsNksO-Q.js +0 -2
- package/ui/dist/assets/AssetsWorkspace-Bgk5sj1a.js +0 -1
- package/ui/dist/assets/AssetsWorkspace-BkUjPPKU.css +0 -1
- package/ui/dist/assets/GenerationRequestLogPanel-BGatd8qE.js +0 -1
- package/ui/dist/assets/KeyingPanel-DYJN_oNF.js +0 -1
- package/ui/dist/assets/NodeCanvas-fil6cXN8.js +0 -7
- package/ui/dist/assets/PromptImportDialog-uyJdrdTs.js +0 -2
- package/ui/dist/assets/PromptLibraryPanel-BIi5_Rvq.js +0 -2
- package/ui/dist/assets/SettingsWorkspace-CVying69.js +0 -1
- package/ui/dist/assets/SpriteRecipeWorkspace-ztdiDwSf.js +0 -1
- package/ui/dist/assets/index-BPKt0DUF.css +0 -1
- package/ui/dist/assets/index-CumGbxai.js +0 -5
- package/ui/dist/assets/index-TU0_IXQH.js +0 -30
- package/ui/dist/assets/useAgentDialogFocus-D741d8_6.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{u,
|
|
2
|
-
`)}function R(s,r){const c=s.slotId?r?.slots.find(n=>n.id===s.slotId):null;return c?{left:`${c.x/20.48}%`,top:`${c.y/20.48}%`,width:`${c.w/20.48}%`,minHeight:`${c.h/20.48}%`}:B(s)}const b={"top-left":{left:"10%",top:"10%",width:"34%"},"top-center":{left:"50%",top:"10%",width:"42%",transform:"translateX(-50%)"},"top-right":{right:"10%",top:"10%",width:"34%"},"center-left":{left:"10%",top:"50%",width:"34%",transform:"translateY(-50%)"},center:{left:"50%",top:"50%",width:"44%",transform:"translate(-50%, -50%)"},"center-right":{right:"10%",top:"50%",width:"34%",transform:"translateY(-50%)"},"bottom-left":{left:"10%",bottom:"10%",width:"34%"},"bottom-center":{left:"50%",bottom:"10%",width:"42%",transform:"translateX(-50%)"},"bottom-right":{right:"10%",bottom:"10%",width:"34%"},free:{left:"50%",top:"50%",width:"44%",transform:"translate(-50%, -50%)"}};function B(s){return b[s.placement]||b.center}function D(){const{t:s}=u(),r=l(a=>a.activePlan),c=l(a=>a.selectedCardId),n=l(a=>a.selectedTextFieldId),t=l(a=>a.templates),p=l(a=>a.plannerMeta),m=l(a=>a.retryCard),x=l(a=>a.selectTextField),o=r?.cards.find(a=>a.id===c)||r?.cards[0],w=r?t.find(a=>a.id===r.imageTemplateId):void 0,d=o?.textFields.filter(a=>a.renderMode==="in-image")||[];return!r||!o?e.jsxs("section",{className:"card-news-empty",children:[e.jsxs("div",{className:"card-news-empty__deck","aria-hidden":"true",children:[e.jsx("div",{className:"card-news-empty__card card-news-empty__card--back"}),e.jsx("div",{className:"card-news-empty__card card-news-empty__card--mid"}),e.jsxs("div",{className:"card-news-empty__card",children:[e.jsx("span",{}),e.jsx("strong",{}),e.jsx("em",{})]})]}),e.jsxs("div",{className:"card-news-empty__copy",children:[e.jsx("span",{children:s("uiMode.cardNews")}),e.jsx("h2",{children:s("cardNews.emptyTitle")}),e.jsx("p",{children:s("cardNews.emptyBody")})]})]}):e.jsxs("section",{className:"card-news-stage",children:[e.jsxs("div",{className:"card-news-stage__header",children:[e.jsxs("div",{children:[e.jsx("h2",{children:r.title}),e.jsx("p",{children:r.generationStrategy}),e.jsx(P,{meta:p})]}),e.jsxs("span",{children:[o.order," / ",r.cards.length]})]}),e.jsx(E,{}),e.jsxs("div",{className:"card-news-preview",children:[o.status==="queued"||o.status==="generating"?e.jsx("div",{className:"card-news-preview__loading",children:s("cardNews.progress.cardGenerating")}):o.status==="error"?e.jsxs("div",{className:"card-news-preview__error",children:[e.jsx("span",{children:o.error||s("cardNews.error")}),o.locked?null:e.jsx("button",{type:"button",onClick:()=>{m(o.id)},children:s("cardNews.retryCard")})]}):o.url?e.jsx("img",{src:o.url,alt:o.headline}):e.jsx("div",{className:"card-news-preview__slot"}),d.length?e.jsx("div",{className:"card-news-stage-overlay",children:d.map(a=>e.jsx("button",{type:"button",className:`card-news-stage-overlay__field card-news-stage-overlay__field--${a.placement}${n===a.id?" selected":""}`,style:R(a,w),onClick:()=>x(a.id),"aria-label":s("cardNews.selectTextField",{text:a.text||a.kind}),children:e.jsx("span",{children:a.text||a.kind})},a.id))}):null]}),o.url?e.jsxs("div",{className:"card-news-result-actions",children:[e.jsx("button",{type:"button",onClick:()=>navigator.clipboard?.writeText(o.visualPrompt),children:s("cardNews.actions.copyPrompt")}),e.jsx("button",{type:"button",onClick:()=>navigator.clipboard?.writeText(L(o)),children:s("cardNews.actions.copyCopy")}),e.jsx("a",{href:o.url,target:"_blank",rel:"noreferrer",children:s("cardNews.actions.openImage")}),e.jsx("a",{href:o.url,download:!0,children:s("cardNews.actions.downloadCard")})]}):null]})}function y(s,r){const c=`cardNews.placements.${s}`,n=r(c);return n===c?s:n}function q({placement:s}){const{t:r}=u();return e.jsx("span",{className:"card-news-placement-chip",children:y(s,r)})}const K=["headline","body","caption","cta","badge","number"],Y=["top-left","top-center","top-right","center-left","center","center-right","bottom-left","bottom-center","bottom-right","free"],A=["in-image","ui-only"],H=["primary","secondary","supporting"];function N(s,r,c){const n=`cardNews.${s}.${r}`,t=c(n);return t===n?r:t}function z({field:s,locked:r,selected:c=!1,onSelect:n,onChange:t,onRemove:p}){const{t:m}=u(),x=s.text.length,o=typeof s.maxChars=="number"&&x>s.maxChars,w=s.maxChars===null||s.maxChars>80,d=h.useMemo(()=>K.map(i=>({value:i,label:N("textKinds",i,m)})),[m]),a=h.useMemo(()=>Y.map(i=>({value:i,label:y(i,m)})),[m]),g=h.useMemo(()=>A.map(i=>({value:i,label:N("renderModes",i,m)})),[m]),f=h.useMemo(()=>H.map(i=>({value:i,label:N("hierarchy",i,m)})),[m]);return e.jsxs("div",{className:`card-news-text-field-card${c?" selected":""}`,onClick:n,children:[e.jsxs("div",{className:"card-news-text-field-card__header",children:[e.jsx("span",{children:N("textKinds",s.kind,m)}),e.jsx(q,{placement:s.placement})]}),e.jsxs("label",{className:"card-news-field",children:[e.jsx("span",{children:m("cardNews.textFieldText")}),w?e.jsx("textarea",{value:s.text,disabled:r,onChange:i=>t({text:i.target.value,source:"user"})}):e.jsx("input",{value:s.text,disabled:r,onChange:i=>t({text:i.target.value,source:"user"})})]}),e.jsxs("div",{className:"card-news-text-field-card__grid",children:[e.jsxs("label",{className:"card-news-field",children:[e.jsx("span",{children:m("cardNews.textKind")}),e.jsx(j,{items:d,value:s.kind,disabled:r,onChange:i=>t({kind:i,source:"user"})})]}),e.jsxs("label",{className:"card-news-field",children:[e.jsx("span",{children:m("cardNews.placement")}),e.jsx(j,{items:a,value:s.placement,disabled:r,onChange:i=>t({placement:i,source:"user"})})]}),e.jsxs("label",{className:"card-news-field",children:[e.jsx("span",{children:m("cardNews.renderMode")}),e.jsx(j,{items:g,value:s.renderMode,disabled:r,onChange:i=>t({renderMode:i,source:"user"})})]}),e.jsxs("label",{className:"card-news-field",children:[e.jsx("span",{children:m("cardNews.hierarchyLabel")}),e.jsx(j,{items:f,value:s.hierarchy,disabled:r,onChange:i=>t({hierarchy:i,source:"user"})})]})]}),e.jsxs("div",{className:`card-news-text-field-card__meta${o?" over":""}`,children:[e.jsx("span",{children:s.maxChars===null?x:`${x}/${s.maxChars}`}),o?e.jsx("span",{children:m("cardNews.textTooLong")}):null,p?e.jsx("button",{type:"button",disabled:r,onClick:p,children:m("cardNews.removeTextField")}):null]})]})}function O(){return{id:`tf_${Date.now().toString(36)}`,kind:"body",text:"",renderMode:"in-image",placement:"center",slotId:null,hierarchy:"supporting",maxChars:null,language:null,source:"user"}}function W(){const{t:s}=u(),r=l(a=>a.activePlan),c=l(a=>a.selectedCardId),n=l(a=>a.selectedTextFieldId),t=l(a=>a.updateCard),p=l(a=>a.updateTextField),m=l(a=>a.addTextField),x=l(a=>a.removeTextField),o=l(a=>a.selectTextField),w=l(a=>a.retryCard),d=r?.cards.find(a=>a.id===c)||r?.cards[0];return d?e.jsxs("aside",{className:"card-news-inspector",children:[e.jsx("div",{className:"section-title",children:s("cardNews.inspector")}),e.jsxs("div",{className:"card-news-inspector-group",children:[e.jsx("span",{className:"card-news-inspector-label",children:s("cardNews.cardTitle")}),e.jsxs("label",{className:"card-news-field",children:[e.jsx("span",{children:s("cardNews.headline")}),e.jsx("input",{value:d.headline,disabled:d.locked,onChange:a=>t(d.id,{headline:a.target.value})})]})]}),e.jsxs("div",{className:"card-news-inspector-group",children:[e.jsxs("div",{className:"card-news-inspector-row",children:[e.jsx("span",{className:"card-news-inspector-label",children:s("cardNews.textFields")}),e.jsx("button",{type:"button",className:"secondary-btn",disabled:d.locked,onClick:()=>m(d.id,O()),children:s("cardNews.addTextField")})]}),d.textFields.length?d.textFields.map(a=>e.jsx(z,{field:a,locked:d.locked,selected:n===a.id,onSelect:()=>o(a.id),onChange:g=>p(d.id,a.id,g),onRemove:()=>x(d.id,a.id)},a.id)):e.jsx("p",{className:"card-news-muted",children:s("cardNews.noTextFields")})]}),e.jsxs("details",{className:"card-news-inspector-group card-news-advanced-prompt",children:[e.jsx("summary",{children:s("cardNews.designPrompt")}),e.jsxs("label",{className:"card-news-field",children:[e.jsx("span",{children:s("cardNews.visualPrompt")}),e.jsx("textarea",{value:d.visualPrompt,disabled:d.locked,onChange:a=>t(d.id,{visualPrompt:a.target.value})})]})]}),d.imageFilename?e.jsxs("div",{className:"card-news-generated-meta",children:[e.jsx("span",{children:s("cardNews.generatedMeta")}),e.jsx("code",{children:d.imageFilename}),e.jsx("span",{children:d.status})]}):null,d.locked?e.jsx("p",{className:"card-news-locked-help",children:s("cardNews.lockedHelp")}):null,e.jsx("button",{type:"button",className:`secondary-btn${d.locked?" active":""}`,onClick:()=>t(d.id,{locked:!d.locked}),children:d.locked?s("cardNews.locked"):s("cardNews.unlocked")}),e.jsx("button",{type:"button",className:"secondary-btn",disabled:d.locked||!["draft","error"].includes(d.status),onClick:()=>{w(d.id)},children:s("cardNews.retryCard")})]}):e.jsxs("aside",{className:"card-news-inspector card-news-inspector-empty",children:[e.jsx("div",{className:"section-title",children:s("cardNews.inspector")}),e.jsxs("div",{className:"card-news-inspector-empty__mock","aria-hidden":"true",children:[e.jsx("span",{}),e.jsx("strong",{}),e.jsx("i",{}),e.jsx("i",{})]}),e.jsx("p",{children:s("cardNews.noCard")})]})}const v="ima2:cardNewsMobileNoticeShown";function X(){const{t:s}=u(),r=_(),[c,n]=h.useState(()=>{if(typeof window>"u")return!0;try{return localStorage.getItem(v)==="1"}catch{return!1}});if(!r||c)return null;const t=()=>{try{localStorage.setItem(v,"1")}catch{}n(!0)};return e.jsxs("div",{className:"card-news-mobile-notice",role:"status",children:[e.jsx("span",{children:s("mobile.cardNewsBanner")}),e.jsx("button",{type:"button",onClick:t,children:s("mobile.dismiss")})]})}function U(){const{t:s}=u(),r=l(n=>n.hydrate),c=l(n=>n.error);return h.useEffect(()=>{r()},[r]),e.jsxs("main",{className:"card-news-workspace","aria-label":s("cardNews.workspace"),children:[e.jsx(X,{}),e.jsxs("div",{className:"card-news-setup",children:[e.jsx(T,{}),e.jsx(I,{})]}),e.jsxs("div",{className:"card-news-main",children:[c?e.jsx("div",{className:"card-news-error",role:"alert",children:c}):null,e.jsx(D,{}),e.jsx(S,{})]}),e.jsx(W,{})]})}export{U as CardNewsWorkspace};
|
|
1
|
+
import{u,Z as l,j as e,_,a as h,v as j,t as k}from"./index-DTEhasVd.js";function C(s){const r=s.slots.filter(n=>n.kind==="text"||n.textKind).length,c=s.slots.filter(n=>n.kind==="image").length;return`${r} text / ${c} image`}function T(){const{t:s}=u(),r=l(t=>t.templates),c=l(t=>t.imageTemplateId),n=l(t=>t.setImageTemplate);return e.jsxs("section",{className:"card-news-panel",children:[e.jsxs("div",{className:"card-news-panel__head",children:[e.jsx("span",{children:s("cardNews.imageTemplate")}),e.jsx("button",{type:"button",disabled:!0,title:s("cardNews.newTemplateLater"),children:"+"})]}),e.jsx("div",{className:"card-news-template-grid",children:r.map(t=>e.jsxs("button",{type:"button",className:`card-news-template${c===t.id?" selected":""}`,onClick:()=>n(t.id),children:[e.jsx("img",{src:t.previewUrl,alt:""}),e.jsxs("span",{className:"card-news-template__body",children:[e.jsx("span",{className:"card-news-template__name",children:t.name}),e.jsx("span",{className:"card-news-template__meta",children:C(t)}),e.jsx("span",{className:"card-news-template__sizes",children:t.recommendedOutputSizes.join(" · ")})]})]},t.id))})]})}function I(){const{t:s}=u(),r=l(t=>t.roleTemplates),c=l(t=>t.roleTemplateId),n=l(t=>t.setRoleTemplate);return e.jsxs("section",{className:"card-news-panel",children:[e.jsx("div",{className:"card-news-panel__head",children:e.jsx("span",{children:s("cardNews.roleTemplate")})}),e.jsx("div",{className:"card-news-role-row",children:r.map(t=>e.jsx("button",{type:"button",className:c===t.id?"selected":"",onClick:()=>n(t.id),children:t.name},t.id))})]})}function F({status:s,locked:r}){const{t:c}=u(),n=r?"locked":s,t=n==="queued"||n==="generating";return e.jsxs("span",{className:`card-news-status-badge card-news-status-badge--${n}`,children:[t?e.jsx("span",{className:"card-news-spinner","aria-hidden":"true"}):null,c(`cardNews.status.${n}`)]})}function M(s,r){const c=`cardNews.roles.${s}`,n=r(c);return n===c?s:n}function S(){const{t:s}=u(),r=l(t=>t.activePlan),c=l(t=>t.selectedCardId),n=l(t=>t.selectCard);return r?e.jsx("div",{className:"card-news-deck","aria-label":s("common.cardDeck"),onWheel:_,children:r.cards.map(t=>e.jsxs("button",{type:"button",className:`card-news-deck-card${c===t.id?" selected":""}`,onClick:()=>n(t.id),children:[e.jsx("span",{children:String(t.order).padStart(2,"0")}),t.url?e.jsx("img",{src:t.url,alt:"",className:"card-news-deck-card__thumb"}):null,e.jsx("strong",{children:M(t.role,s)}),e.jsx("small",{children:t.headline||t.textFields.find(p=>p.renderMode==="in-image")?.text}),e.jsx(F,{status:t.status,locked:t.locked})]},t.id))}):null}const $=[];function E(){const{t:s}=u(),r=l(t=>t.activePlan?.cards??$),c=l(t=>t.generating),n={total:r.length,done:r.filter(t=>t.status==="generated").length,queued:r.filter(t=>t.status==="queued").length,errors:r.filter(t=>t.status==="error").length,skipped:r.filter(t=>t.locked||t.status==="skipped").length};return n.total?e.jsxs("div",{className:"card-news-batch-bar","aria-live":"polite",children:[e.jsx("span",{children:c?s("cardNews.progress.generating",{done:n.done,total:n.total}):s("cardNews.progress.summary",{done:n.done,total:n.total})}),e.jsx("span",{children:s("cardNews.progress.detail",{queued:n.queued,errors:n.errors,skipped:n.skipped})})]}):null}function P({meta:s}){const{t:r}=u();if(!s)return null;const c=s.mode==="structured-output"?r("cardNews.planner.structured"):s.mode==="json-mode"?r("cardNews.planner.jsonMode"):r("cardNews.planner.fallback");return e.jsxs("span",{className:"card-news-planner-badge",children:[c," · ",s.model,s.repaired?` · ${r("cardNews.planner.repaired")}`:""]})}function L(s){const r=s.textFields.filter(c=>c.renderMode==="in-image"&&c.text).map(c=>`[${c.placement}] ${c.text}`);return[s.headline,...r].filter(Boolean).join(`
|
|
2
|
+
`)}function R(s,r){const c=s.slotId?r?.slots.find(n=>n.id===s.slotId):null;return c?{left:`${c.x/20.48}%`,top:`${c.y/20.48}%`,width:`${c.w/20.48}%`,minHeight:`${c.h/20.48}%`}:B(s)}const b={"top-left":{left:"10%",top:"10%",width:"34%"},"top-center":{left:"50%",top:"10%",width:"42%",transform:"translateX(-50%)"},"top-right":{right:"10%",top:"10%",width:"34%"},"center-left":{left:"10%",top:"50%",width:"34%",transform:"translateY(-50%)"},center:{left:"50%",top:"50%",width:"44%",transform:"translate(-50%, -50%)"},"center-right":{right:"10%",top:"50%",width:"34%",transform:"translateY(-50%)"},"bottom-left":{left:"10%",bottom:"10%",width:"34%"},"bottom-center":{left:"50%",bottom:"10%",width:"42%",transform:"translateX(-50%)"},"bottom-right":{right:"10%",bottom:"10%",width:"34%"},free:{left:"50%",top:"50%",width:"44%",transform:"translate(-50%, -50%)"}};function B(s){return b[s.placement]||b.center}function D(){const{t:s}=u(),r=l(a=>a.activePlan),c=l(a=>a.selectedCardId),n=l(a=>a.selectedTextFieldId),t=l(a=>a.templates),p=l(a=>a.plannerMeta),m=l(a=>a.retryCard),x=l(a=>a.selectTextField),o=r?.cards.find(a=>a.id===c)||r?.cards[0],w=r?t.find(a=>a.id===r.imageTemplateId):void 0,d=o?.textFields.filter(a=>a.renderMode==="in-image")||[];return!r||!o?e.jsxs("section",{className:"card-news-empty",children:[e.jsxs("div",{className:"card-news-empty__deck","aria-hidden":"true",children:[e.jsx("div",{className:"card-news-empty__card card-news-empty__card--back"}),e.jsx("div",{className:"card-news-empty__card card-news-empty__card--mid"}),e.jsxs("div",{className:"card-news-empty__card",children:[e.jsx("span",{}),e.jsx("strong",{}),e.jsx("em",{})]})]}),e.jsxs("div",{className:"card-news-empty__copy",children:[e.jsx("span",{children:s("uiMode.cardNews")}),e.jsx("h2",{children:s("cardNews.emptyTitle")}),e.jsx("p",{children:s("cardNews.emptyBody")})]})]}):e.jsxs("section",{className:"card-news-stage",children:[e.jsxs("div",{className:"card-news-stage__header",children:[e.jsxs("div",{children:[e.jsx("h2",{children:r.title}),e.jsx("p",{children:r.generationStrategy}),e.jsx(P,{meta:p})]}),e.jsxs("span",{children:[o.order," / ",r.cards.length]})]}),e.jsx(E,{}),e.jsxs("div",{className:"card-news-preview",children:[o.status==="queued"||o.status==="generating"?e.jsx("div",{className:"card-news-preview__loading",children:s("cardNews.progress.cardGenerating")}):o.status==="error"?e.jsxs("div",{className:"card-news-preview__error",children:[e.jsx("span",{children:o.error||s("cardNews.error")}),o.locked?null:e.jsx("button",{type:"button",onClick:()=>{m(o.id)},children:s("cardNews.retryCard")})]}):o.url?e.jsx("img",{src:o.url,alt:o.headline}):e.jsx("div",{className:"card-news-preview__slot"}),d.length?e.jsx("div",{className:"card-news-stage-overlay",children:d.map(a=>e.jsx("button",{type:"button",className:`card-news-stage-overlay__field card-news-stage-overlay__field--${a.placement}${n===a.id?" selected":""}`,style:R(a,w),onClick:()=>x(a.id),"aria-label":s("cardNews.selectTextField",{text:a.text||a.kind}),children:e.jsx("span",{children:a.text||a.kind})},a.id))}):null]}),o.url?e.jsxs("div",{className:"card-news-result-actions",children:[e.jsx("button",{type:"button",onClick:()=>navigator.clipboard?.writeText(o.visualPrompt),children:s("cardNews.actions.copyPrompt")}),e.jsx("button",{type:"button",onClick:()=>navigator.clipboard?.writeText(L(o)),children:s("cardNews.actions.copyCopy")}),e.jsx("a",{href:o.url,target:"_blank",rel:"noreferrer",children:s("cardNews.actions.openImage")}),e.jsx("a",{href:o.url,download:!0,children:s("cardNews.actions.downloadCard")})]}):null]})}function y(s,r){const c=`cardNews.placements.${s}`,n=r(c);return n===c?s:n}function q({placement:s}){const{t:r}=u();return e.jsx("span",{className:"card-news-placement-chip",children:y(s,r)})}const K=["headline","body","caption","cta","badge","number"],A=["top-left","top-center","top-right","center-left","center","center-right","bottom-left","bottom-center","bottom-right","free"],H=["in-image","ui-only"],Y=["primary","secondary","supporting"];function N(s,r,c){const n=`cardNews.${s}.${r}`,t=c(n);return t===n?r:t}function z({field:s,locked:r,selected:c=!1,onSelect:n,onChange:t,onRemove:p}){const{t:m}=u(),x=s.text.length,o=typeof s.maxChars=="number"&&x>s.maxChars,w=s.maxChars===null||s.maxChars>80,d=h.useMemo(()=>K.map(i=>({value:i,label:N("textKinds",i,m)})),[m]),a=h.useMemo(()=>A.map(i=>({value:i,label:y(i,m)})),[m]),g=h.useMemo(()=>H.map(i=>({value:i,label:N("renderModes",i,m)})),[m]),f=h.useMemo(()=>Y.map(i=>({value:i,label:N("hierarchy",i,m)})),[m]);return e.jsxs("div",{className:`card-news-text-field-card${c?" selected":""}`,onClick:n,children:[e.jsxs("div",{className:"card-news-text-field-card__header",children:[e.jsx("span",{children:N("textKinds",s.kind,m)}),e.jsx(q,{placement:s.placement})]}),e.jsxs("label",{className:"card-news-field",children:[e.jsx("span",{children:m("cardNews.textFieldText")}),w?e.jsx("textarea",{value:s.text,disabled:r,onChange:i=>t({text:i.target.value,source:"user"})}):e.jsx("input",{value:s.text,disabled:r,onChange:i=>t({text:i.target.value,source:"user"})})]}),e.jsxs("div",{className:"card-news-text-field-card__grid",children:[e.jsxs("label",{className:"card-news-field",children:[e.jsx("span",{children:m("cardNews.textKind")}),e.jsx(j,{items:d,value:s.kind,disabled:r,onChange:i=>t({kind:i,source:"user"})})]}),e.jsxs("label",{className:"card-news-field",children:[e.jsx("span",{children:m("cardNews.placement")}),e.jsx(j,{items:a,value:s.placement,disabled:r,onChange:i=>t({placement:i,source:"user"})})]}),e.jsxs("label",{className:"card-news-field",children:[e.jsx("span",{children:m("cardNews.renderMode")}),e.jsx(j,{items:g,value:s.renderMode,disabled:r,onChange:i=>t({renderMode:i,source:"user"})})]}),e.jsxs("label",{className:"card-news-field",children:[e.jsx("span",{children:m("cardNews.hierarchyLabel")}),e.jsx(j,{items:f,value:s.hierarchy,disabled:r,onChange:i=>t({hierarchy:i,source:"user"})})]})]}),e.jsxs("div",{className:`card-news-text-field-card__meta${o?" over":""}`,children:[e.jsx("span",{children:s.maxChars===null?x:`${x}/${s.maxChars}`}),o?e.jsx("span",{children:m("cardNews.textTooLong")}):null,p?e.jsx("button",{type:"button",disabled:r,onClick:p,children:m("cardNews.removeTextField")}):null]})]})}function O(){return{id:`tf_${Date.now().toString(36)}`,kind:"body",text:"",renderMode:"in-image",placement:"center",slotId:null,hierarchy:"supporting",maxChars:null,language:null,source:"user"}}function W(){const{t:s}=u(),r=l(a=>a.activePlan),c=l(a=>a.selectedCardId),n=l(a=>a.selectedTextFieldId),t=l(a=>a.updateCard),p=l(a=>a.updateTextField),m=l(a=>a.addTextField),x=l(a=>a.removeTextField),o=l(a=>a.selectTextField),w=l(a=>a.retryCard),d=r?.cards.find(a=>a.id===c)||r?.cards[0];return d?e.jsxs("aside",{className:"card-news-inspector",children:[e.jsx("div",{className:"section-title",children:s("cardNews.inspector")}),e.jsxs("div",{className:"card-news-inspector-group",children:[e.jsx("span",{className:"card-news-inspector-label",children:s("cardNews.cardTitle")}),e.jsxs("label",{className:"card-news-field",children:[e.jsx("span",{children:s("cardNews.headline")}),e.jsx("input",{value:d.headline,disabled:d.locked,onChange:a=>t(d.id,{headline:a.target.value})})]})]}),e.jsxs("div",{className:"card-news-inspector-group",children:[e.jsxs("div",{className:"card-news-inspector-row",children:[e.jsx("span",{className:"card-news-inspector-label",children:s("cardNews.textFields")}),e.jsx("button",{type:"button",className:"secondary-btn",disabled:d.locked,onClick:()=>m(d.id,O()),children:s("cardNews.addTextField")})]}),d.textFields.length?d.textFields.map(a=>e.jsx(z,{field:a,locked:d.locked,selected:n===a.id,onSelect:()=>o(a.id),onChange:g=>p(d.id,a.id,g),onRemove:()=>x(d.id,a.id)},a.id)):e.jsx("p",{className:"card-news-muted",children:s("cardNews.noTextFields")})]}),e.jsxs("details",{className:"card-news-inspector-group card-news-advanced-prompt",children:[e.jsx("summary",{children:s("cardNews.designPrompt")}),e.jsxs("label",{className:"card-news-field",children:[e.jsx("span",{children:s("cardNews.visualPrompt")}),e.jsx("textarea",{value:d.visualPrompt,disabled:d.locked,onChange:a=>t(d.id,{visualPrompt:a.target.value})})]})]}),d.imageFilename?e.jsxs("div",{className:"card-news-generated-meta",children:[e.jsx("span",{children:s("cardNews.generatedMeta")}),e.jsx("code",{children:d.imageFilename}),e.jsx("span",{children:d.status})]}):null,d.locked?e.jsx("p",{className:"card-news-locked-help",children:s("cardNews.lockedHelp")}):null,e.jsx("button",{type:"button",className:`secondary-btn${d.locked?" active":""}`,onClick:()=>t(d.id,{locked:!d.locked}),children:d.locked?s("cardNews.locked"):s("cardNews.unlocked")}),e.jsx("button",{type:"button",className:"secondary-btn",disabled:d.locked||!["draft","error"].includes(d.status),onClick:()=>{w(d.id)},children:s("cardNews.retryCard")})]}):e.jsxs("aside",{className:"card-news-inspector card-news-inspector-empty",children:[e.jsx("div",{className:"section-title",children:s("cardNews.inspector")}),e.jsxs("div",{className:"card-news-inspector-empty__mock","aria-hidden":"true",children:[e.jsx("span",{}),e.jsx("strong",{}),e.jsx("i",{}),e.jsx("i",{})]}),e.jsx("p",{children:s("cardNews.noCard")})]})}const v="ima2:cardNewsMobileNoticeShown";function X(){const{t:s}=u(),r=k(),[c,n]=h.useState(()=>{if(typeof window>"u")return!0;try{return localStorage.getItem(v)==="1"}catch{return!1}});if(!r||c)return null;const t=()=>{try{localStorage.setItem(v,"1")}catch{}n(!0)};return e.jsxs("div",{className:"card-news-mobile-notice",role:"status",children:[e.jsx("span",{children:s("mobile.cardNewsBanner")}),e.jsx("button",{type:"button",onClick:t,children:s("mobile.dismiss")})]})}function U(){const{t:s}=u(),r=l(n=>n.hydrate),c=l(n=>n.error);return h.useEffect(()=>{r()},[r]),e.jsxs("main",{className:"card-news-workspace","aria-label":s("cardNews.workspace"),children:[e.jsx(X,{}),e.jsxs("div",{className:"card-news-setup",children:[e.jsx(T,{}),e.jsx(I,{})]}),e.jsxs("div",{className:"card-news-main",children:[c?e.jsx("div",{className:"card-news-error",role:"alert",children:c}):null,e.jsx(D,{}),e.jsx(S,{})]}),e.jsx(W,{})]})}export{U as CardNewsWorkspace};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as j,u as _,p as b,D as N,j as e,b as p,a as n}from"./index-DTEhasVd.js";async function f(){return j("/api/generation-requests")}async function v(a){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(a);return}const o=document.createElement("textarea");o.value=a,o.style.position="fixed",o.style.opacity="0",document.body.appendChild(o),o.select();try{document.execCommand("copy")}finally{document.body.removeChild(o)}}function y({entry:a,onClose:o,onCopyPrompt:i}){const{t:s}=_(),l=b(!0,o),r=a.succeeded===0;return N.createPortal(e.jsxs("div",{className:"generation-log-detail",role:"presentation",children:[e.jsx("div",{className:"generation-log-detail__backdrop",onClick:o}),e.jsxs("div",{ref:l,className:"generation-log-detail__content",role:"dialog","aria-modal":"true","aria-labelledby":"generation-log-detail-title",tabIndex:-1,children:[e.jsxs("div",{className:"generation-log-detail__header",children:[e.jsxs("h2",{id:"generation-log-detail-title",className:"generation-log-detail__title",children:[s("generationLog.detailTitle"),e.jsxs("span",{className:`generation-log-detail__badge${r?" is-error":" is-success"}`,children:[a.succeeded,"/",a.requested]})]}),e.jsx("button",{type:"button",className:"generation-log-detail__close",onClick:o,"aria-label":s("common.close"),children:"×"})]}),e.jsxs("div",{className:"generation-log-detail__grid",children:[e.jsx("span",{className:"generation-log-detail__label",children:s("generationLog.detailTime")}),e.jsx("span",{children:new Date(a.createdAt).toLocaleString()}),e.jsx("span",{className:"generation-log-detail__label",children:s("generationLog.detailRequestId")}),e.jsx("span",{className:"generation-log-detail__mono",children:a.requestId}),e.jsx("span",{className:"generation-log-detail__label",children:s("generationLog.detailCounts")}),e.jsxs("span",{children:[a.succeeded," / ",a.requested]}),a.error?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"generation-log-detail__label",children:s("generationLog.detailError")}),e.jsx("span",{className:"generation-log-detail__mono is-error",children:a.error})]}):null,a.errorMessage?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"generation-log-detail__label",children:s("generationLog.detailErrorMessage")}),e.jsx("span",{className:"generation-log-detail__reason",children:a.errorMessage})]}):null]}),e.jsxs("div",{className:"generation-log-detail__section",children:[e.jsx("div",{className:"generation-log-detail__label",children:s("generationLog.detailPrompt")}),e.jsx("div",{className:"generation-log-detail__prompt",children:a.prompt||s("generationLog.detailPromptEmpty")})]}),e.jsx("div",{className:"generation-log-detail__footer",children:e.jsx("button",{type:"button",className:"generation-log-detail__copy",onClick:()=>i(a),"data-modal-initial-focus":!0,children:s("generationLog.copy")})})]})]}),document.body)}function q(){const{t:a}=_(),o=p(t=>t.showToast),i=p(t=>t.activeGenerations),[s,l]=n.useState([]),[r,d]=n.useState(!0),[x,g]=n.useState(!1),[u,m]=n.useState(null),c=n.useCallback(async()=>{d(!0),g(!1);try{const t=await f();l(t.items)}catch{l([]),g(!0)}finally{d(!1)}},[]);n.useEffect(()=>{c()},[c,i]);const h=async t=>{try{await v(t.prompt),o(a("generationLog.copied"))}catch{o(a("toast.copyFailed"),!0)}};return r?e.jsx("div",{className:"generation-request-log__empty",children:a("common.loading")}):x?e.jsxs("div",{className:"generation-request-log__empty",role:"alert",children:[e.jsx("span",{children:a("generationLog.loadFailed")}),e.jsx("button",{type:"button",onClick:()=>{c()},children:a("generationLog.retry")})]}):e.jsxs("div",{className:"generation-request-log",role:"list",children:[s.length===0?e.jsx("div",{className:"generation-request-log__empty",children:a("generationLog.empty")}):s.map(t=>e.jsxs("button",{type:"button",role:"listitem",className:"generation-request-log__item",onClick:()=>m(t),title:a("generationLog.detailOpen"),children:[e.jsx("span",{className:"generation-request-log__prompt",children:t.prompt}),e.jsxs("span",{className:`generation-request-log__count${t.succeeded===0?" is-error":" is-success"}`,children:[t.succeeded,"/",t.requested]})]},t.id)),u?e.jsx(y,{entry:u,onClose:()=>m(null),onCopyPrompt:t=>{h(t)}}):null]})}export{q as GenerationRequestLogPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as i,u as m,
|
|
1
|
+
import{b as i,u as m,al as I,j as e,am as A,an as k,ao as P,v as E,ap as M,a as x,aq as w,ar as R,as as T,at as C,au as L,av as O,aw as H,ax as S}from"./index-DTEhasVd.js";const G={oauth:"GPT OAuth",api:"GPT API",grok:"Grok OAuth","grok-api":"Grok API",agy:"Antigravity","gemini-api":"Gemini API",atlascloud:"Atlas Cloud",minimax:"MiniMax",nai:"NovelAI",comfy:"ComfyUI"};function U(s){if(s.kind==="attachment")return s.source.dataUrl;if(s.source.thumbnailUrl)return s.source.thumbnailUrl;const t=s.source.referenceFilenames[0];if(t)return t.startsWith("/generated/")?t:`/generated/${t.split("/").map(encodeURIComponent).join("/")}`}function D({providerAvailability:s}){const t=i(o=>o.prompt),r=i(o=>o.setPrompt),n=i(o=>o.provider),a=i(o=>o.setProvider),c=i(o=>o.selectedPresetIds),p=i(o=>o.removePreset),d=i(o=>o.generate),v=i(o=>o.activeGenerations),h=i(o=>o.trayItems),{t:l}=m(),f=new Set(c),j=I().filter(o=>f.has(o.id)),b=v>0,y=Object.entries(G).map(([o,u])=>{const g=o,_=s[g];return{value:g,label:u,sub:_.ok?l("readiness.ready"):_.reason,disabled:!_.ok}});return e.jsxs("div",{className:"home-prompt",children:[j.length>0?e.jsx(A,{className:"home-prompt__chips",ariaLabel:l("home.selectedPresets"),children:j.map(o=>e.jsx(k,{selected:!0,onRemove:()=>p(o.id),removeLabel:l("common.removeNamed",{name:o.name}),title:o.category,children:o.name},o.id))}):null,h.length>0?e.jsxs("div",{className:"home-prompt__reference-strip",role:"group","aria-label":l("home.referenceTrayAria",{count:h.length}),children:[e.jsx("span",{className:"home-prompt__reference-thumbs","aria-hidden":"true",children:h.map(o=>{const u=U(o);return e.jsx("span",{className:"home-prompt__reference-thumb",children:u?e.jsx("img",{src:u,alt:"",loading:"lazy",decoding:"async"}):"@"},o.tokenId)})}),e.jsx("span",{className:"home-prompt__reference-count",children:l("home.referenceTrayCount",{count:h.length})})]}):null,e.jsx("label",{className:"home-prompt__label",htmlFor:"home-prompt-input",children:l("prompt.label")}),e.jsx("textarea",{id:"home-prompt-input",className:"home-prompt__textarea",rows:5,value:t,placeholder:l("prompt.placeholder"),onChange:o=>r(o.target.value)}),e.jsx(P,{variant:"home"}),e.jsxs("div",{className:"home-prompt__footer",children:[e.jsx(E,{className:"home-prompt__provider",items:y,value:n,onChange:a,ariaLabel:l("readiness.provider")}),e.jsx("button",{type:"button",className:"home-prompt__generate",disabled:b||t.trim().length===0,onClick:()=>{d();const o=i.getState().setUIMode;o("classic")},children:b?l("generate.buttonLoading",{n:v}):l("generate.button")})]})]})}const N=/\.(mp4|webm|mov)(?:$|[?#])/i;function V(s){return s.mediaType==="video"||N.test(s.filename??"")||N.test(s.url??s.image)?s.thumb:s.thumb||s.url||s.image||void 0}function B({item:s,featured:t}){const{t:r}=m(),[n,a]=x.useState(!1),c=V(s),p=(s.userPrompt?.trim()||s.prompt?.trim()||r("home.untitledResult")).slice(0,60),d=r("home.recentResultAlt",{prompt:p});return!c||n?e.jsx("div",{className:"home-recent-card__fallback",role:"img","aria-label":d,children:r("home.mediaUnavailable")}):e.jsx("img",{src:c,alt:d,loading:t?"eager":"lazy",decoding:"async",onError:()=>a(!0)})}function F(){const s=i(n=>n.history),{t}=m(),r=s.slice(0,5);return r.length===0?e.jsx("p",{className:"home-recent-empty",role:"status",children:t("history.emptyRecent")}):e.jsx("div",{className:"home-recent-row",role:"list","aria-label":t("home.recentTitle"),children:r.map((n,a)=>{const c=a===0;return e.jsx("figure",{className:`home-recent-card${c?" is-featured":""}`,role:"listitem",children:e.jsx(B,{item:n,featured:c})},M(n))})})}function $(){return e.jsxs("svg",{className:"home-hero__mode-arrow",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M5 12h14"}),e.jsx("path",{d:"m12 5 7 7-7 7"})]})}function W(){const{t:s}=m(),t=w(),r=x.useMemo(()=>Object.values(t).filter(a=>a?.ok).length,[t]),n=x.useMemo(()=>Object.keys(t).length,[t]);return e.jsxs("div",{className:"home-hero",children:[e.jsx("div",{className:"home-hero__mark","aria-hidden":"true",children:"IMA2"}),e.jsxs("header",{className:"home-hero__intro",children:[e.jsx("h1",{className:"home-hero__title",children:s("home.heroTitle")}),e.jsx("p",{className:"home-hero__lede",children:s("home.heroLede")})]}),e.jsxs("p",{className:"home-hero__readiness",role:"status",children:[e.jsx("span",{className:`home-hero__dot${r>0?" is-ready":""}`,"aria-hidden":"true"}),r>0?s("home.lanesReady",{ready:r,total:n}):s("home.lanesNone")]}),e.jsx("div",{className:"home-workspace__composer",children:e.jsx(D,{providerAvailability:t})}),e.jsxs("section",{className:"home-workspace__recent","aria-labelledby":"home-recent-title",children:[e.jsx("h2",{id:"home-recent-title",children:s("home.recentTitle")}),e.jsx(F,{})]}),e.jsx(z,{})]})}function z(){const{t:s}=m(),t=i(a=>a.setUIMode),r=[{mode:"classic",label:s("nav.create"),hint:s("home.modeCreateHint"),enabled:!0,icon:R},{mode:"node",label:s("nav.node"),hint:s("home.modeNodeHint"),enabled:C,icon:T},{mode:"agent",label:s("nav.agent"),hint:s("home.modeAgentHint"),enabled:O,icon:L},{mode:"assets",label:s("nav.assets"),hint:s("home.modeAssetsHint"),enabled:!0,icon:H}];function n(a){t(a),history.replaceState(null,"",S[a]??"#create")}return e.jsxs("nav",{className:"home-modes","aria-label":s("home.modesTitle"),children:[e.jsx("h2",{className:"home-modes__title",children:s("home.modesTitle")}),r.filter(a=>a.enabled).map(a=>e.jsxs("button",{type:"button",className:"home-modes__item",onClick:()=>n(a.mode),children:[e.jsx("span",{className:"home-modes__icon",children:e.jsx(a.icon,{})}),e.jsx("span",{className:"home-modes__label",children:a.label}),e.jsx("span",{className:"home-modes__hint",children:a.hint}),e.jsx($,{})]},a.mode))]})}function K(){const{t:s}=m();return e.jsx("section",{className:"home-workspace","aria-label":s("nav.home"),children:e.jsx("div",{className:"home-workspace__inner",children:e.jsx(W,{})})})}export{K as HomeWorkspace};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as re,a as v,b as Y,q as fe,j as a,p as ge,ai as me,aj as pe,ak as ye}from"./index-DTEhasVd.js";import{u as xe}from"./useAgentDialogFocus-Dyj_bA5Q.js";function ke(){return a.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18","aria-hidden":"true",children:a.jsx("path",{d:"M6 6l12 12M18 6 6 18",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"})})}function be({zoomed:e}){return a.jsxs("svg",{viewBox:"0 0 24 24",width:"18",height:"18","aria-hidden":"true",children:[a.jsx("circle",{cx:"10.5",cy:"10.5",r:"6.5",fill:"none",stroke:"currentColor",strokeWidth:"1.7"}),a.jsx("path",{d:"M15.5 15.5 21 21M7.5 10.5h6",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"}),e?null:a.jsx("path",{d:"M10.5 7.5v6",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})]})}function Pe({item:e,onClose:t}){const{t:n}=re(),[o,s]=v.useState(!1),l=e.metadata??null,[g,c]=v.useState(l),u=v.useId(),f=Y(C=>C.setKeyingTarget),h=Y(C=>C.setCuratorTarget),i=v.useCallback(()=>t(),[t]),p=xe(!0,i),r=e.mediaType==="video",m=e.kind!=="edit"&&!!e.filename&&e.backgroundPreset!=="transparent",b=l??g,_=typeof b?.spriteRunId=="string"?b.spriteRunId:null,w=typeof b?.manifestPath=="string"?b.manifestPath:null,G=!!(_&&w&&e.filename),K=n(r?"assetGen.videoFallback":"assetGen.imageFallback"),T=e.prompt?.trim()||K,j=v.useCallback(()=>{f(e),t()},[e,t,f]),L=v.useCallback(()=>{!_||!w||!e.filename||(h({runId:_,atlasFile:e.filename,manifestFile:w}),t())},[e.filename,w,t,h,_]);return v.useEffect(()=>{c(l);const C=e.requestId?.startsWith("asset:")?e.requestId.slice(6):null;if(!C||l)return;let P=!0;return fe(C).then(({asset:S})=>{P&&c(S.metadata)}).catch(()=>{P&&c(null)}),()=>{P=!1}},[l,e.requestId]),v.useEffect(()=>{const C=document.body.style.overflow,P=document.documentElement.style.overflow;return document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",()=>{document.body.style.overflow=C,document.documentElement.style.overflow=P}},[]),a.jsxs("div",{className:"assetgen-lightbox",role:"presentation",children:[a.jsx("button",{type:"button",className:"assetgen-lightbox__backdrop","aria-label":n("assetGen.closePreview"),onClick:i}),a.jsxs("section",{ref:p,className:"assetgen-lightbox__panel",role:"dialog","aria-modal":"true","aria-labelledby":u,children:[a.jsxs("header",{className:"assetgen-lightbox__header",children:[a.jsx("h2",{id:u,children:n("assetGen.previewDialogTitle",{prompt:T})}),a.jsx("button",{type:"button",className:"assetgen-lightbox__control","aria-label":n("assetGen.closePreview"),onClick:i,children:a.jsx(ke,{})})]}),a.jsx("div",{className:["assetgen-lightbox__stage",e.kind==="edit"?"is-keyed":"",o?"is-zoomed":""].filter(Boolean).join(" "),tabIndex:o?0:void 0,children:r?a.jsx("video",{src:e.url||e.image,poster:e.thumb||void 0,controls:!0,autoPlay:!0,muted:!0,playsInline:!0,preload:"metadata","aria-label":T}):a.jsx("img",{src:e.url||e.image,alt:T})}),!r||m||G?a.jsxs("footer",{className:"assetgen-lightbox__footer",children:[G?a.jsx("button",{type:"button",className:"assetgen-lightbox__zoom assetgen-lightbox__curate",onClick:L,children:n("spriteCurator.open")}):null,m?a.jsx("button",{type:"button",className:"assetgen-lightbox__zoom assetgen-lightbox__keybtn",onClick:j,children:n("keying.open")}):null,r?null:a.jsxs("button",{type:"button",className:"assetgen-lightbox__zoom","aria-pressed":o,"aria-label":n(o?"assetGen.zoomOut":"assetGen.zoomIn"),onClick:()=>s(C=>!C),children:[a.jsx(be,{zoomed:o}),a.jsx("span",{children:n(o?"assetGen.zoomOut":"assetGen.zoomIn")})]})]}):null]})]})}const H={tolerance:40,softness:10,spill:50};function te(e,t,n){const o=128-.168736*e-.331264*t+.5*n,s=128+.5*e-.418688*t-.081312*n;return[o,s]}function ne(e,t,n){return .299*e+.587*t+.114*n}function _e(e,t,n,o){const s=t*n,l=new Uint8Array(s);for(let i=0;i<s;i++)e[i]<o&&(l[i]=1);const g=new Uint8Array(s),c=new Int32Array(s);let u=0,f=0;const h=i=>{l[i]&&!g[i]&&(g[i]=1,c[f++]=i)};for(let i=0;i<t;i++)h(i),h((n-1)*t+i);for(let i=0;i<n;i++)h(i*t),h(i*t+t-1);for(;u<f;){const i=c[u++],p=i%t,r=(i-p)/t;p>0&&h(i-1),p<t-1&&h(i+1),r>0&&h(i-t),r<n-1&&h(i+t)}for(let i=0;i<s;i++)l[i]&&!g[i]&&(e[i]=o)}function oe(e){const{width:t,height:n,data:o}=e;if(t<2||n<2||o.length<t*n*4)throw new Error("colorKey: image too small or malformed pixel buffer");const s=4,l=[0,Math.max(0,t-s)],g=[0,Math.max(0,n-s)],c=[],u=[],f=[];for(const i of l)for(const p of g)for(let r=p;r<Math.min(p+s,n);r++)for(let m=i;m<Math.min(i+s,t);m++){const b=(r*t+m)*4;c.push(o[b]),u.push(o[b+1]),f.push(o[b+2])}const h=i=>{const p=[...i].sort((r,m)=>r-m);return p[Math.floor(p.length/2)]};return{r:h(c),g:h(u),b:h(f)}}function Me(e,t){const{width:n,height:o,data:s}=e;if(!n||!o||s.length!==n*o*4)throw new Error("colorKey: empty or malformed pixel buffer");const l=Math.max(0,Math.min(100,t.tolerance)),g=Math.max(0,Math.min(50,t.softness)),c=Math.max(0,Math.min(100,t.spill))/100,u=l/100*120,f=u+g/100*120,[h,i]=te(t.keyColor.r,t.keyColor.g,t.keyColor.b),p=t.keyColor.r,r=t.keyColor.g,m=t.keyColor.b,b=r>p+20&&r>m+20&&r>60,w=Math.max(p,r,m)-Math.min(p,r,m)<40,G=ne(p,r,m),K=10+l/100*15,T=400,j=n*o,L=new Float32Array(j);for(let k=0;k<j;k++){const x=k*4,N=s[x],R=s[x+1],E=s[x+2],[D,U]=te(N,R,E),M=Math.hypot(D-h,U-i);if(w)if(M>K)L[k]=T;else{const A=Math.abs(ne(N,R,E)-G)*.8;L[k]=Math.hypot(M,A)}else L[k]=M}const C=new Float32Array(j);for(let k=0;k<o;k++)for(let x=0;x<n;x++){const N=k*n+x;if(L[N]>=T){C[N]=T;continue}let R=0,E=0;for(let D=-1;D<=1;D++){const U=k+D;if(!(U<0||U>=o))for(let M=-1;M<=1;M++){const A=x+M;if(A<0||A>=n)continue;const B=L[U*n+A];B>=T||(R+=B,E++)}}C[N]=E>0?R/E:T}w&&_e(C,n,o,f);const P=f+c*120,S=new Uint8ClampedArray(s.length);for(let k=0;k<j;k++){const x=k*4,N=s[x],R=s[x+1],E=s[x+2],D=s[x+3],U=C[k];let M;U<=u?M=0:U<f?M=Math.pow((U-u)/(f-u),1.5)*255:M=255;let A=N,B=R,O=E;if(b&&c>0&&M>0){const W=P>u?Math.max(0,1-(U-u)/(P-u)):0;if(W>0){const X=(N+E)/2,d=Math.max(0,R-X)*W*c;B=Math.round(R-d);const y=d*.3;A=Math.min(255,Math.round(N+y)),O=Math.min(255,Math.round(E+y))}}S[x]=A,S[x+1]=B,S[x+2]=O,S[x+3]=Math.min(D,Math.round(M))}if(b&&c>0){let k=new Uint8Array(j);for(let x=0;x<o;x++)for(let N=0;N<n;N++){const R=x*n+N;if(S[R*4+3]===0)continue;let E=!1;e:for(let D=-1;D<=1;D++){const U=x+D;if(!(U<0||U>=o))for(let M=-1;M<=1;M++){const A=N+M;if(!(A<0||A>=n)&&S[(U*n+A)*4+3]===0){E=!0;break e}}}E&&(k[R]=1)}for(let x=0;x<3;x++){const N=new Uint8Array(j);for(let R=0;R<o;R++)for(let E=0;E<n;E++){const D=R*n+E;if(k[D]){N[D]=1;continue}if(S[D*4+3]===0)continue;let U=!1;for(let M=-1;M<=1&&!U;M++){const A=R+M;if(!(A<0||A>=o))for(let B=-1;B<=1&&!U;B++){const O=E+B;O<0||O>=n||k[A*n+O]&&(U=!0)}}U&&(N[D]=1)}k=N}for(let x=0;x<j;x++){if(!k[x])continue;const N=x*4,R=S[N],E=S[N+1],D=S[N+2],U=Math.max(R,D);if(E>U-8){const M=Math.max(0,U-4),A=Math.max(0,E-M);S[N+1]=Math.max(0,E-A),S[N]=Math.min(255,R+Math.round(A*.25)),S[N+2]=Math.min(255,D+Math.round(A*.25))}}}return{width:n,height:o,data:S}}function ve(e){return Math.round(Math.max(0,Math.min(100,e))*.7)}function ae(e,t,n){const o=Math.max(0,Math.min(t-1,Math.round(e.x*(t-1))));return Math.max(0,Math.min(n-1,Math.round(e.y*(n-1))))*t+o}function we(e,t,n,o){for(const s of n)if(Math.max(Math.abs(e[t]-s.r),Math.abs(e[t+1]-s.g),Math.abs(e[t+2]-s.b))<=o)return!0;return!1}function je(e,t,n){const{width:o,height:s,data:l}=e,g=o*s,c=new Uint8Array(g),u=new Uint8Array(g),f=new Int32Array(g),h=t.map(r=>{const m=ae(r,o,s)*4;return{r:l[m],g:l[m+1],b:l[m+2]}});let i=0;const p=r=>{u[r]||(u[r]=1,l[r*4+3]!==0&&we(l,r*4,h,n)&&(f[i++]=r))};for(const r of t)p(ae(r,o,s));for(;i>0;){const r=f[--i];c[r]=1;const m=r%o;m>0&&p(r-1),m<o-1&&p(r+1),r>=o&&p(r-o),r<g-o&&p(r+o)}return c}function Ce(e,t,n,o){if(n.length===0)return;if(e.width!==t.width||e.height!==t.height||e.data.length!==t.data.length)throw new Error("wandErase: target/source buffer size mismatch");const s=je(t,n,ve(o));for(let l=0;l<s.length;l++)s[l]&&(e.data[l*4+3]=0)}const Ne={reach:4,spillMaxFraction:.005},ie=18,Se=180,Ee=40,Ae=2,J=0,Ie=1,le=2,ce=3;function Q(e){const t=[e.r,e.g,e.b],n=[],o=[];for(let s=0;s<3;s++)if(t[s]>=192)n.push(s);else if(t[s]<64)o.push(s);else return null;return n.length===0||o.length===0?null:{keyed:n,unkeyed:o}}function V(e,t,n,o){const s=[e,t,n];let l=0;for(const c of o.keyed)l+=s[c];let g=0;for(const c of o.unkeyed)g+=s[c];return l/o.keyed.length-g/o.unkeyed.length}function Re(e,t,n,o){return Math.hypot(e-o.r,t-o.g,n-o.b)}function ue(e,t,n,o,s,l){const g=Math.min(l/s,1),c=1-g;if(c<=0)return[0,0,0,0];const u=(f,h)=>Math.min(255,Math.max(0,Math.round((f-g*h)/c)));return[c,u(e,o.r),u(t,o.g),u(n,o.b)]}function Ue(e,t,n,o){const s=t*n,l=255,g=new Uint8Array(s).fill(l);let c=[];for(let f=0;f<s;f++)e[f]&&(g[f]=0,c.push(f));let u=0;for(;c.length>0&&u<o;){u++;const f=[];for(const h of c){const i=h%t,p=(h-i)/t;for(let r=-1;r<=1;r++){const m=p+r;if(!(m<0||m>=n))for(let b=-1;b<=1;b++){const _=i+b;if(_<0||_>=t)continue;const w=m*t+_;g[w]===l&&(g[w]=u,f.push(w))}}}c=f}return g}function Te(e,t,n,o){const s=e.width*e.height,l=new Uint8Array(s),g=new Uint8Array(s);for(let c=0;c<s;c++){const u=c*4;if(t.data[u+3]===0){l[c]=J,g[c]=1;continue}const f=e.data[u],h=e.data[u+1],i=e.data[u+2];V(f,h,i,o)<ie?l[c]=Ie:Re(f,h,i,n)<=Se?l[c]=le:l[c]=ce}return{classes:l,keyedMask:g}}function Fe(e,t,n,o,s,l,g,c){const u=t.width*t.height,f=new Uint8Array(u);for(let h=0;h<u;h++){const i=l[h];if(!(i>0&&i<=c))continue;const p=g[h];if(p===le){if(i>Ae)continue}else if(p!==ce)continue;const r=h*4,m=t.data[r],b=t.data[r+1],_=t.data[r+2],w=V(m,b,_,o),[G,K,T,j]=ue(m,b,_,n,s,w),L=Math.round(t.data[r+3]*G);L<=0?(e.data[r]=0,e.data[r+1]=0,e.data[r+2]=0,e.data[r+3]=0):(e.data[r]=K,e.data[r+1]=T,e.data[r+2]=j,e.data[r+3]=L),f[h]=1}return f}function De(e,t,n,o,s,l,g,c){const{width:u,height:f}=t,h=u*f;let i=0;for(let _=0;_<h;_++)l[_]!==J&&i++;const p=Math.max(32,Math.round(i*c)),r=new Float32Array(h).fill(-1);for(let _=0;_<h;_++){if(g[_]||l[_]===J)continue;const w=_*4;if(e.data[w+3]===0)continue;const G=V(t.data[w],t.data[w+1],t.data[w+2],o);G>=ie&&(r[_]=G)}const m=new Uint8Array(h),b=[];for(let _=0;_<h;_++){if(r[_]<0||m[_])continue;m[_]=1,b.length=0,b.push(_);const w=[];let G=-1;for(;b.length>0;){const K=b.pop();w.push(K),r[K]>G&&(G=r[K]);const T=K%u,j=(K-T)/u;for(let L=-1;L<=1;L++){const C=j+L;if(!(C<0||C>=f))for(let P=-1;P<=1;P++){const S=T+P;if(S<0||S>=u)continue;const k=C*u+S;r[k]>=0&&!m[k]&&(m[k]=1,b.push(k))}}}if(!(w.length>p)&&!(G<=Ee))for(const K of w){const T=K*4,j=t.data[T],L=t.data[T+1],C=t.data[T+2],[P,S,k,x]=ue(j,L,C,n,s,r[K]);P<=0||(e.data[T]=S,e.data[T+1]=k,e.data[T+2]=x)}}}function Ke(e,t,n){if(!e.width||!e.height||e.width!==t.width||e.height!==t.height||e.data.length!==t.data.length||e.data.length!==e.width*e.height*4)throw new Error("softUnmix: empty or mismatched pixel buffers");const o=Q(n.keyColor);if(!o)return;const s=V(n.keyColor.r,n.keyColor.g,n.keyColor.b,o);if(s<=0)return;const l=Math.max(0,Math.min(254,Math.round(n.reach))),{classes:g,keyedMask:c}=Te(t,e,n.keyColor,o);let u;if(l>0){const f=Ue(c,t.width,t.height,l);u=Fe(e,t,n.keyColor,o,s,f,g,l)}else u=new Uint8Array(t.width*t.height);n.spillMaxFraction>0&&De(e,t,n.keyColor,o,s,g,u,n.spillMaxFraction)}function se(e,t,n){const o=`/generated/${encodeURIComponent(t)}`;return{...e,image:o,url:o,filename:t,mediaType:n,kind:"edit",requestId:`derived:${t}`,createdAt:Date.now(),providerUrl:null}}function Ge(){const{t:e}=re(),t=Y(d=>d.keyingTarget),n=Y(d=>d.setKeyingTarget),o=ge(!!t,()=>n(null)),s=Y(d=>d.addAssetGenDerivedItem),l=Y(d=>d.selectedProjectId),g=Y(d=>d.showToast),[c,u]=v.useState("loading"),[f,h]=v.useState(!1),[i,p]=v.useState(null),[r,m]=v.useState(null),[b,_]=v.useState(H.tolerance),[w,G]=v.useState(H.softness),[K,T]=v.useState(H.spill),[j,L]=v.useState(null),[C,P]=v.useState("erase"),[S,k]=v.useState([]),[x,N]=v.useState(!0),R=v.useRef(null),E=v.useRef(null),D=v.useRef(0),U=v.useRef(null),M=v.useRef(null),A=v.useCallback(()=>{U.current?.(),U.current=null},[]),B=t?.mediaType==="video",O=t?B&&t.filename?`/api/video/frame?file=${encodeURIComponent(t.filename)}&position=0`:t.url||t.image:null;v.useEffect(()=>{if(!O)return;let d=!0;u("loading"),R.current=null,L(null),k([]),P("erase");const y=new Image;return y.onload=()=>{if(d)try{const I=document.createElement("canvas");I.width=y.naturalWidth,I.height=y.naturalHeight;const F=I.getContext("2d");if(!F)throw new Error("no 2d context");F.drawImage(y,0,0);const z=F.getImageData(0,0,I.width,I.height);R.current=z,L(oe(z)),u("ready")}catch{d&&u("error")}},y.onerror=()=>{d&&u("error")},y.src=O,()=>{d=!1,y.onload=null,y.onerror=null}},[O]),v.useEffect(()=>(M.current=t?.filename??null,A(),h(!1),m(null),p(null),A),[A,t?.filename]),v.useEffect(()=>{if(!(c!=="ready"||!j))return cancelAnimationFrame(D.current),D.current=requestAnimationFrame(()=>{const d=R.current,y=E.current;if(!(!d||!y))try{const I=Me({width:d.width,height:d.height,data:d.data},{keyColor:j,tolerance:b,softness:w,spill:K});x&&Q(j)&&Ke(I,{width:d.width,height:d.height,data:d.data},{keyColor:j,...Ne}),S.length>0&&Ce(I,{width:d.width,height:d.height,data:d.data},S,b),y.width=I.width,y.height=I.height;const F=y.getContext("2d");if(!F)return;const z=F.createImageData(I.width,I.height);z.data.set(I.data),F.putImageData(z,0,0)}catch{u("error")}}),()=>cancelAnimationFrame(D.current)},[c,j,b,w,K,S,x]);const W=v.useCallback(d=>{const y=R.current,I=E.current;if(!y||!I)return;const F=I.getBoundingClientRect(),z=Math.max(0,Math.min(1,(d.clientX-F.left)/F.width)),q=Math.max(0,Math.min(1,(d.clientY-F.top)/F.height));if(C==="erase"&&!B){k(he=>[...he,{x:z,y:q}]);return}const $=Math.floor((d.clientX-F.left)/F.width*y.width),de=Math.floor((d.clientY-F.top)/F.height*y.height),Z=(Math.max(0,Math.min(y.height-1,de))*y.width+Math.max(0,Math.min(y.width-1,$)))*4;L({r:y.data[Z],g:y.data[Z+1],b:y.data[Z+2]})},[C,B]),X=v.useCallback(()=>{const d=E.current;d&&d.toBlob(y=>{if(!y)return;const I=URL.createObjectURL(y),F=document.createElement("a");F.href=I,F.download=`${(t?.filename||"asset").replace(/\.[a-z]+$/i,"")}-keyed.png`,F.click(),URL.revokeObjectURL(I)},"image/png")},[t]),ee=v.useCallback(()=>{const d=E.current;if(!(!d||!t?.filename||f)){if(h(!0),p(null),B){me({source:t.filename,keyParams:{tolerance:b,softness:w,keyColor:j??void 0},projectId:l,name:`${(t.prompt||"asset").trim().slice(0,60)} (keyed)`}).then(({requestId:y})=>{if(M.current!==t.filename)return;m(0),A();const I=pe(y,null,(F,z)=>{const q=z&&typeof z=="object"?z:{};if(F==="keying-progress"){const $=q.outTimeMs;m(typeof $=="number"&&Number.isFinite($)?$:0)}else if(F==="keying-done"){A();const $=q.filePath;if(typeof $=="string"&&$.trim()){s(se(t,$.trim(),"video")),h(!1),m(null),g(e("keying.videoSaved")),n(null);return}h(!1),m(null),p(e("keying.saveError"))}else F==="keying-error"&&(A(),h(!1),m(null),p(typeof q.error=="string"&&q.error?q.error:e("keying.saveError")))});U.current=I}).catch(y=>{M.current===t.filename&&(h(!1),p(y instanceof Error?y.message:e("keying.saveError")))});return}d.toBlob(y=>{if(M.current===t.filename){if(!y){h(!1),p(e("keying.saveError"));return}ye(y,{source:t.filename,projectId:l,name:`${(t.prompt||"asset").trim().slice(0,60)} (keyed)`,meta:{keyParams:{tolerance:b,softness:w,spill:K},prompt:t.prompt}}).then(({filePath:I})=>{if(M.current===t.filename){if(typeof I!="string"||!I.trim())throw new Error(e("keying.saveError"));s(se(t,I.trim(),"image")),g(e("keying.saved")),n(null)}}).catch(I=>{M.current===t.filename&&p(I instanceof Error?I.message:e("keying.saveError"))}).finally(()=>{M.current===t.filename&&h(!1)})}},"image/png")}},[t,f,B,j,l,b,w,K,A,s,g,n,e]);return t?a.jsx("div",{className:"assetgen-popup-backdrop",onClick:()=>n(null),children:a.jsxs("div",{ref:o,className:"keying-panel",role:"dialog","aria-modal":"true","aria-label":e("keying.title"),onClick:d=>d.stopPropagation(),children:[a.jsxs("header",{className:"keying-panel__head",children:[a.jsx("h2",{children:e("keying.title")}),j?a.jsxs("span",{className:"keying-panel__key",title:e("keying.keyColor"),children:[B?null:a.jsxs("span",{className:"keying-panel__modes",role:"group","aria-label":e("keying.clickMode"),children:[a.jsx("button",{type:"button",className:C==="erase"?"is-active":"","aria-pressed":C==="erase",onClick:()=>P("erase"),children:e("keying.modeErase")}),a.jsx("button",{type:"button",className:C==="pick"?"is-active":"","aria-pressed":C==="pick",onClick:()=>P("pick"),children:e("keying.modePick")})]}),S.length>0?a.jsx("button",{type:"button",className:"keying-panel__undo",onClick:()=>k(d=>d.slice(0,-1)),children:e("keying.undoClick",{count:String(S.length)})}):null,a.jsx("span",{className:"assetgen-bg-picker__swatch",style:{background:`rgb(${j.r},${j.g},${j.b})`},"aria-hidden":"true"}),a.jsx("span",{className:"keying-panel__hint",children:e(C==="erase"&&!B?"keying.eraseHint":"keying.pickHint")})]}):null]}),a.jsx("div",{className:"keying-panel__compare","aria-busy":c==="loading",children:c==="error"?a.jsxs("div",{className:"keying-panel__error",role:"alert",children:[a.jsx("p",{children:e("keying.loadError")}),a.jsx("button",{type:"button",onClick:()=>n(null),children:e("project.close")})]}):a.jsxs(a.Fragment,{children:[a.jsxs("figure",{className:"keying-panel__preview",children:[a.jsx("figcaption",{className:"keying-panel__preview-label",children:e("keying.original")}),a.jsx("div",{className:"keying-panel__stage keying-panel__stage--original",children:a.jsx("img",{src:O??"",alt:e("keying.originalAlt")})})]}),a.jsxs("figure",{className:"keying-panel__preview",children:[a.jsx("figcaption",{className:"keying-panel__preview-label",children:e("keying.removed")}),a.jsxs("div",{className:"keying-panel__stage",children:[a.jsx("canvas",{ref:E,className:"keying-panel__canvas",onClick:W,"aria-label":e("keying.previewAlt")}),c==="loading"?a.jsx("span",{className:"keying-panel__loading",role:"status",children:e("keying.previewLoading")}):null]})]})]})}),a.jsxs("details",{className:"keying-panel__advanced",children:[a.jsx("summary",{children:e("keying.advanced")}),a.jsxs("div",{className:"keying-panel__controls",children:[a.jsxs("label",{children:[e("keying.tolerance")," ",a.jsx("output",{children:b}),a.jsx("input",{type:"range",min:0,max:100,value:b,onChange:d=>_(Number(d.target.value))})]}),a.jsxs("label",{children:[e("keying.softness")," ",a.jsx("output",{children:w}),a.jsx("input",{type:"range",min:0,max:50,value:w,onChange:d=>G(Number(d.target.value))})]}),a.jsxs("label",{children:[e("keying.spill")," ",a.jsx("output",{children:K}),a.jsx("input",{type:"range",min:0,max:100,value:K,onChange:d=>T(Number(d.target.value))})]}),a.jsxs("label",{className:"keying-panel__unmix",children:[a.jsx("input",{type:"checkbox",checked:x,disabled:!j||!Q(j),onChange:d=>N(d.target.checked)}),e("keying.unmix"),a.jsx("span",{className:"keying-panel__hint",children:e("keying.unmixHint")})]}),a.jsx("button",{type:"button",className:"keying-panel__reset",onClick:()=>{_(H.tolerance),G(H.softness),T(H.spill),k([]),N(!0),R.current&&L(oe(R.current))},children:e("keying.reset")})]})]}),a.jsxs("footer",{className:"keying-panel__actions",children:[i?a.jsx("span",{className:"keying-panel__save-error",role:"alert",children:i}):null,a.jsx("button",{type:"button",className:"assetgen-generate",disabled:c!=="ready"||f||!t.filename,onClick:ee,children:f?r!==null?e("keying.videoKeying",{seconds:String(Math.round(r/1e3))}):e("keying.saving"):e(B?"keying.videoSave":"keying.save")}),B?null:a.jsx("button",{type:"button",className:"assetgen-popup__close",disabled:c!=="ready",onClick:X,children:e("keying.download")}),a.jsx("button",{type:"button",className:"assetgen-popup__close",onClick:()=>n(null),children:e("project.close")})]})]})}):null}export{Pe as A,Ge as K};
|