PageSourceSearch

https://noxi.ai/assets/TemplateBuilderPage-Cyf3W4wl.js

js noxi.ai collected 2026-10-05 12:20:03 UTC 69,102 bytes, 26 lines download raw bytes

1import{j as e,r as c}from"./vendor-react-BePqIK_N.js";import{c as oe,L as D,ci as Ve,X as ma,l as Pa,ay as je,d as Ia,m as $a,F as Fa}from"./gemini-config-CzObe-G-.js";import{u as K}from"./vendor-i18n-w4qX2dm-.js";import{R as we,ai as L,A as ge}from"./WorkspaceShell-BoqBm6sD.js";import{b as Re,aa as va,av as ue}from"./rtl-CqvAm1Lj.js";import{bj as Da,P as La,U as Ua,bi as Ja,ck as _e,bK as Ma,cl as Ba,cm as sa,cn as ia,co as ra,cp as Oa,cq as za,cr as Ae,cs as na,ct as Ha,cu as Le,cv as la,cw as Wa,cx as Ga,cy as Ka,cz as Ya,cA as Qa}from"./designExemplarMetadata-CBYEQNue.js";import{m as ke,A as me,L as De}from"./main-DbAiAVOu.js";import{I as da}from"./SlideThumbnail-DGrjOelh.js";import{T as Xa}from"./UserTemplates-CCbvVXjR.js";import{C as Za}from"./chevron-left-DgjzVk0O.js";import{S as et}from"./save-ZEDMqgq7.js";import"./vendor-radix-mJlUMr-8.js";import"./vendor-shared-CaA14SRz.js";import"./vendor-supabase-BApm0Gf0.js";import"./authStorage-COucfPVJ.js";import"./vendor-sentry-BPKSlpKX.js";import"./modulepreload-polyfill-CsbzyCjx.js";import"./app-DB6QS2JT.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};a.SENTRY_RELEASE={id:"noxi@4bfab6c"};var l=new a.Error().stack;l&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[l]="5427a66b-efe5-432e-9011-2945119e376d",a._sentryDebugIdIdentifier="sentry-dbid-5427a66b-efe5-432e-9011-2945119e376d")}catch{}})();/**
2 * @license lucide-react v0.487.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const at=[["rect",{width:"6",height:"10",x:"9",y:"7",rx:"2",key:"yn7j0q"}],["path",{d:"M4 22V2",key:"tsjzd3"}],["path",{d:"M20 22V2",key:"1bnhr8"}]],tt=oe("align-horizontal-space-around",at);/**
7 * @license lucide-react v0.487.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const st=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],it=oe("columns-2",st);/**
12 * @license lucide-react v0.487.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const rt=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3 15 2 2 4-4",key:"1lhrkk"}]],nt=oe("file-check-2",rt);/**
17 * @license lucide-react v0.487.0 - ISC
18 *
19 * This source code is licensed under the ISC license.
20 * See the LICENSE file in the root directory of this source tree.
21 */const lt=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]],ua=oe("file-image",lt);/**
22 * @license lucide-react v0.487.0 - ISC
23 *
24 * This source code is licensed under the ISC license.
25 * See the LICENSE file in the root directory of this source tree.
26 */const dt=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]],ut=oe("file-up",dt),oa={upload:"Secure upload",render:"Render source slides",native_extract:"Extract native objects",brand_analysis:"Analyze brand system",background_reconstruction:"Reconstruct clean backgrounds",layout_compile:"Compile layout families",rtl_validate:"Validate Arabic and RTL",raster_qa:"Check visual consistency",semantic_qa:"Check content and languages",review:"Prepare findings"};function ot({job:a,busy:l=!1,onCancel:m,onRetry:f,onResume:r}){const{t:n}=K("templates"),o=Math.min(100,Math.max(0,a.progress)),d=a.status==="failed",x=a.status==="cancelled";return e.jsxs("section",{className:"ut-analysis","aria-labelledby":"ut-analysis-title","aria-busy":a.status==="running",children:[e.jsxs("div",{className:"ut-analysis__header",children:[e.jsxs("div",{children:[e.jsx("p",{className:"ut-eyebrow",children:n("builder.analysis.eyebrow",{defaultValue:"AI template analysis"})}),e.jsx("h2",{id:"ut-analysis-title",children:d?n("builder.analysis.failedTitle",{defaultValue:"Analysis needs attention"}):x?n("builder.analysis.pausedTitle",{defaultValue:"Analysis is paused"}):n("builder.analysis.title",{defaultValue:"Learning your presentation system"})}),e.jsx("p",{children:n("builder.analysis.description",{defaultValue:"We separate repeatable design rules from slide content, preserve artwork direction, and verify English and Arabic outputs."})})]}),e.jsxs("strong",{className:"ut-analysis__percentage",children:[Math.round(o),"%"]})]}),e.jsx("progress",{className:"ut-progress",value:o,max:100,"aria-label":n("builder.analysis.overallProgress",{defaultValue:"Overall analysis progress"})}),e.jsx("p",{className:"ut-sr-only","aria-live":"polite",children:n("builder.analysis.progressAnnouncement",{defaultValue:"{{stage}}, {{progress}} percent complete",stage:n(`builder.analysis.stages.${a.currentStage}`,{defaultValue:oa[a.currentStage]??a.currentStage}),progress:Math.round(o)})}),a.currentStage==="background_reconstruction"&&(a.correctionCount??0)>0&&e.jsxs("p",{className:"ut-analysis__repair-note",role:"status",children:[e.jsx(we,{"aria-hidden":"true"}),n("builder.analysis.backgroundRepair",{defaultValue:"Visual QA found remaining foreground content. Re-cleaning the affected background automatically."})]}),a.stages.length>0&&e.jsx("ol",{className:"ut-analysis__stages",children:a.stages.map(h=>{const p=h.status==="succeeded"?Re:h.status==="running"?D:h.status==="failed"?L:va;return e.jsxs("li",{"data-status":h.status,children:[e.jsx(p,{className:h.status==="running"?"ut-spin":void 0,"aria-hidden":"true"}),e.jsx("span",{children:n(`builder.analysis.stages.${h.stage}`,{defaultValue:oa[h.stage]??h.stage})})]},h.stage)})}),d&&e.jsxs("div",{className:"ut-alert ut-alert--danger",role:"alert",children:[e.jsx(L,{"aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("strong",{children:n("builder.analysis.errorLabel",{defaultValue:"Analysis 
26stopped"})}),e.jsx("p",{children:n(`errors.${a.errorCode||"request_failed"}`,{defaultValue:a.errorMessage||n("errors.request_failed",{defaultValue:"The request could not be completed. Try again."})})})]})]}),e.jsxs("div",{className:"ut-actions ut-actions--start",children:[a.canCancel&&e.jsxs("button",{type:"button",className:"ut-button ut-button--secondary",disabled:l,onClick:m,children:[e.jsx(Da,{"aria-hidden":"true"}),n("actions.cancelAnalysis",{defaultValue:"Cancel analysis"})]}),a.canRetry&&e.jsxs("button",{type:"button",className:"ut-button ut-button--primary",disabled:l,onClick:f,children:[e.jsx(we,{"aria-hidden":"true"}),n("actions.retry",{defaultValue:"Retry"})]}),a.canResume&&a.status!=="running"&&e.jsxs("button",{type:"button",className:"ut-button ut-button--primary",disabled:l,onClick:r,children:[e.jsx(we,{"aria-hidden":"true"}),n("actions.resumeAnalysis",{defaultValue:"Resume analysis"})]})]})]})}const ct=["cover","content"];function ft(a){return a==="en"?["en"]:a==="ar"?["ar"]:["en","ar"]}function ht({previews:a,languageCoverage:l="en_ar",verificationPhase:m="preparing_previews"}){const{t:f,i18n:r}=K("templates"),n=c.useId(),o=c.useMemo(()=>ft(l),[l]),[d,x]=c.useState(()=>o.includes(r.resolvedLanguage==="ar"?"ar":"en")?r.resolvedLanguage==="ar"?"ar":"en":o[0]),[h,p]=c.useState(()=>new Set);c.useEffect(()=>{o.includes(d)||x(o[0])},[d,o]);const v=c.useMemo(()=>a.filter(b=>b.locale===d&&b.imageUrl.trim().length>0),[d,a]),S=c.useMemo(()=>v.filter(b=>!h.has(`${b.id}:${b.imageUrl}`)),[h,v]),s=v.length-S.length,P=m!=="blocked"&&m!=="ready",V=S.length||!P?[]:ct,k=(b,i)=>{const R=o.indexOf(i);let C=null;if(b.key==="Home"&&(C=0),b.key==="End"&&(C=o.length-1),b.key==="ArrowRight"||b.key==="ArrowLeft"){const X=r.dir?.()==="rtl",I=b.key==="ArrowRight"?1:-1,Z=X?-I:I;C=(R+Z+o.length)%o.length}if(C===null)return;b.preventDefault();const F=o[C];x(F),document.getElementById(`${n}-tab-${F}`)?.focus()};return e.jsxs("section",{className:"ut-preview","aria-labelledby":`${n}-title`,children:[e.jsxs("header",{className:"ut-section-heading",children:[e.jsxs("div",{children:[e.jsx("p",{className:"ut-eyebrow",children:f("builder.preview.eyebrow",{defaultValue:"Rendered proof"})}),e.jsx("h2",{id:`${n}-title`,children:f("builder.preview.title",{defaultValue:"Preview the system, not one slide"})}),e.jsx("p",{children:l==="en_ar"?f("builder.preview.description",{defaultValue:"Review representative learned layout families in both languages."}):l==="ar"?f("builder.preview.descriptionArabic",{defaultValue:"Review representative learned layout families in Arabic."}):f("builder.preview.descriptionEnglish",{defaultValue:"Review representative learned layout families in English."})})]}),l!=="en"&&e.jsxs("span",{className:"ut-preview__direction-note",children:[e.jsx(ke,{"aria-hidden":"true"}),f("builder.preview.directionNote",{defaultValue:"Arabic text reflows; artwork is not blindly mirrored"})]})]}),e.jsx("div",{className:"ut-tabs ut-tabs--compact",role:"tablist","aria-label":f("builder.preview.language",{defaultValue:"Preview language"}),children:o.map(b=>e.jsx("button",{id:`${n}-tab-${b}`,type:"button",role:"tab","aria-selected":d===b,"aria-controls":`${n}-panel`,tabIndex:d===b?0:-1,onClick:()=>x(b),onKeyDown:i=>k(i,b),children:b==="ar"?e.jsx("span",{lang:"ar",children:f("languages.arabic",{defaultValue:"العربية"})}):f("languages.english",{defaultValue:"English"})},b))}),e.jsxs("div",{id:`${n}-panel`,role:"tabpanel","aria-labelledby":`${n}-tab-${d}`,className:"ut-preview__grid","aria-busy":V.length>0&&s===0,children:[S.map((b,i)=>e.jsxs("figure",{className:"ut-preview-slide",children:[e.jsx("div",{className:"ut-preview-slide__canvas",dir:d==="ar"?"rtl":"ltr",lang:d,children:e.jsx("img",{src:b.imageUrl,alt:b.alt||f("builder.preview.slideAlt",{defaultValue:"{{language}} {{slideClass}} slide preview",language:d==="ar"?f("languages.arabic",{defaultValue:"Arabic"}):f("languages.english",{defaultValue:"English"}),slideClass:b.slideClass}),onError:()=>p(R=>{const C=new Set(R);return C.add(`${b.id}:${b.imageUrl}`),C})})}),e.jsxs("figcaption",{children:[e.jsx("span",{children:f(`builder.preview.slideClasses.${b.slideClass}`,{defaultValue:b.slideClass})}),e.jsxs("span",{children:[e.jsx(Ve,{"aria-hidden":"true"}),f("common.rendered",{defaultValue:"Rendered"})]}),e.jsx("span",{children:i+1})]})]},b.id)),V.map(b=>e.jsxs("figure",{className:"ut-preview-slide ut-preview-slide--pending",children:[e.jsxs("div",{className:"ut-preview-slide__canvas","aria-hidden":"true",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}),e.jsxs("figcaption",{children:[e.jsx("span",{children:f(`builder.preview.slideClasses.${b}`,{defaultValue:b})}),e.jsxs("span",{children:[e.jsx(D,{className:"ut-spin","aria-hidden":"true"}),f("builder.preview.pendingPreview",{defaultValue:"Preview pending"})]})]})]},`pending-${d}-${b}`)),!S.length&&e.jsxs("div",{className:"ut-preview-empty",role:s?"alert":"status",children:[s?e.jsx(L,{"aria-hidden":"true"}):P?e.jsx(D,{className:"ut-spin","aria-hidden":"true"}):e.jsx(L,{"aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("h3",{children:s?f("builder.preview.loadFailedTitle",{defaultValue:"Rendered preview could not be loaded"}):P?f("builder.preview.pendingTitle",{defaultValue:"Preview is still being prepared"}):f("builder.preview.unavailableTitle",{defaultValue:"Rendered previews are not available yet"})}),e.jsx("p",{children:s?f("builder.preview.loadFailedDescription",{defaultValue:"The private preview may have expired. Reopen this template or try again before approving it."}):P?f("builder.preview.pendingDescription",{defaultValue:"This area will show the actual rendered slides. Placeholder artwork is never presented as proof."}):f("builder.preview.unavailableDescription",{defaultValue:"No placeholder is shown as proof. Automatic verification must produce a real rendered preview before publishing."})})]})]}),S.length>0&&s>0&&e.jsxs("div",{className:"ut-alert ut-alert--danger ut-preview-partial-error",role:"alert",children:[e.jsx(L,{"aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("strong",{children:f("builder.preview.partialLoadFailedTitle",{defaultValue:"Some rendered previews are unavailable"})}),e.jsx("p",{children:f("builder.preview.loadFailedDescription",{defaultValue:"The private preview may have expired. Reopen this template or try again before approving it."})})]})]})]})]})}function pt(a,l){return new Intl.NumberFormat(l,{style:"unit",unit:a>=1024*1024?"megabyte":"kilobyte",unitDisplay:"short",maximumFractionDigits:1}).format(a>=1024*1024?a/(1024*1024):Math.max(1,a/1024))}function ca({id:a,role:l,accept:m,multiple:f=!1,files:r,disabled:n=!1,onFiles:o,onRemove:d,onPause:x,onResume:h}){const{t:p,i18n:v}=K("templates"),S=c.useRef(null),s=c.useRef(0),[P,V]=c.useState(!1),k=l==="logo_original",b=i=>{!i?.length||n||(o(Array.from(i)),S.current&&(S.current.value=""))};return e.jsxs("section",{className:"ut-upload","data-dragging":P?"true":"false",children:[e.jsxs("div",{className:"ut-upload__dropzone",onDragEnter:i=>{i.dataTransfer.types.includes("Files")&&(i.preventDefault(),s.current+=1,V(!0))},onDragOver:i=>{i.dataTransfer.types.includes("Files")&&(i.preventDefault(),i.dataTransfer.dropEffect=n?"none":"copy")},onDragLeave:i=>{i.preventDefault(),s.current=Math.max(0,s.current-1),s.current===0&&V(!1)},onDrop:i=>{i.dataTransfer.types.includes("Files")&&(i.preventDefault(),s.current=0,V(!1),b(i.dataTransfer.files))},children:[e.jsx("span",{className:"ut-upload__icon","aria-hidden":"true",children:k?e.jsx(ua,{}):e.jsx(ut,{})}),e.jsxs("div",{children:[e.jsx("h3",{children:k?p("builder.sources.logoTitle",{defaultValue:"Original logo (recommended)"}):p("builder.sources.filesTitle",{defaultValue:"Reference presentations"})}),e.jsx("p",{children:k?p("builder.sources.logoHelp",{defaultValue:"Upload the original SVG or transparent PNG. We will not rely on a low-resolution crop from a slide."}):p("builder.sources.filesHelp",{defaultValue:"PDF, PPTX, PNG, JPG or WebP. Include varied slide types for a stronger result."})})]}),e.jsxs("button",{type:"button",className:"ut-button ut-button--secondary",disabled:n||k&&r.length>0,onClick:()=>S.current?.click(),children:[e.jsx(La,{"aria-hidden":"true"}
26),k?p("builder.sources.chooseLogo",{defaultValue:"Choose logo"}):p("builder.sources.chooseFiles",{defaultValue:"Choose files"})]}),e.jsx("input",{ref:S,id:a,className:"ut-sr-only",type:"file",accept:m,multiple:f,disabled:n,onChange:i=>b(i.currentTarget.files)})]}),r.length>0&&e.jsx("ul",{className:"ut-upload__files","aria-label":p("builder.sources.selectedFiles",{defaultValue:"Selected files"}),children:r.map(i=>e.jsxs("li",{"data-status":i.status,children:[e.jsx("span",{className:"ut-file-icon","aria-hidden":"true",children:e.jsx(ua,{})}),e.jsxs("span",{className:"ut-file-copy",children:[e.jsx("strong",{children:e.jsx("bdi",{children:i.file.name})}),e.jsx("span",{children:pt(i.file.size,v.language)})]}),i.status==="uploading"&&e.jsxs("div",{className:"ut-file-progress",children:[e.jsx("progress",{value:i.progress,max:100,"aria-label":p("builder.sources.uploadProgress",{defaultValue:"Upload progress for {{fileName}}",fileName:i.file.name})}),e.jsxs("span",{children:[Math.round(i.progress),"%"]})]}),e.jsxs("span",{className:"ut-file-state","aria-live":"polite",children:[i.status==="queued"&&p("upload.queued",{defaultValue:"Waiting"}),i.status==="uploading"&&p("upload.uploading",{defaultValue:"Uploading"}),i.status==="paused"&&p("upload.paused",{defaultValue:"Paused"}),i.status==="ready"&&p("upload.ready",{defaultValue:"Uploaded"}),i.status==="failed"&&p("upload.failed",{defaultValue:"Upload failed"})]}),i.status==="uploading"&&x&&e.jsx("button",{type:"button",className:"ut-text-button",disabled:n,onClick:()=>x(i.localId),children:p("actions.pause",{defaultValue:"Pause"})}),i.status==="paused"&&h&&e.jsx("button",{type:"button",className:"ut-text-button",disabled:n,onClick:()=>h(i.localId),children:p("actions.resume",{defaultValue:"Resume"})}),e.jsx("button",{type:"button",className:"ut-icon-button",disabled:n,onClick:()=>d(i.localId),"aria-label":p("builder.sources.removeFile",{defaultValue:"Remove {{fileName}}",fileName:i.file.name}),children:e.jsx(ma,{"aria-hidden":"true"})})]},i.localId))})]})}const fa=["brand","backgrounds","layouts","arabic"],bt={brand:"Brand",backgrounds:"Backgrounds",layouts:"Layouts",arabic:"Arabic"};function gt(a){return Math.min(1,Math.max(0,Number.isFinite(a)?a:0))}function se({provenance:a}){const{t:l,i18n:m}=K("templates"),f=gt(a?.confidence??0),r=a?.sourceFileName,n=a?.sourcePageOrSlide??a?.pageOrSlide,o=a?.origin??"inferred";return e.jsxs("span",{className:"ut-evidence",children:[e.jsx("span",{"data-origin":o,children:l(`findings.origin.${o}`,{defaultValue:o==="observed"?"Observed":o==="user_confirmed"?"Confirmed":"Inferred"})}),e.jsx("span",{children:new Intl.NumberFormat(m.language,{style:"percent"}).format(f)}),r&&e.jsxs("span",{children:[e.jsx("bdi",{children:r}),n?l("findings.sourceSlide",{defaultValue:" · slide {{slide}}",slide:n}):null]})]})}function ha(a,l){const m={title:"Title",vertical_stack:"Vertical stack",two_columns:"Two columns",three_columns:"Three columns",split_visual:"Visual split",grid:"Grid",timeline:"Timeline",data_focus:"Data focus",quote:"Quote",closing:"Closing",custom:"Custom"};return l(`findings.layouts.kinds.${a.kind}`,{defaultValue:m[a.kind]})}function mt({findings:a,languageCoverage:l="en_ar",hasOriginalLogo:m,onChange:f,onRequestLogoUpload:r}){const{t:n,i18n:o}=K("templates"),d=c.useId(),[x,h]=c.useState("brand"),p=c.useMemo(()=>l==="en"?fa.filter(i=>i!=="arabic"):fa,[l]),v=a.brand??{colors:[],fonts:[],logo:null,logoPlacements:[]},S=a.backgrounds??[],s=a.layouts??[],P=a.arabic;c.useEffect(()=>{p.includes(x)||h(p[0])},[x,p]);const V=i=>{v.logo&&f({...a,brand:{...v,logo:{...v.logo,userDecision:i}}})},k=a.substitutions??[],b=!!a.substitutionsAcceptedAt;return e.jsxs("section",{className:"ut-findings","aria-labelledby":`${d}-title`,children:[k.length>0&&e.jsxs("div",{className:"ut-alert ut-alert--warning ut-findings__substitutions",role:"alert",children:[e.jsx(L,{"aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("strong",{children:n("builder.review.substitutionsTitle",{defaultValue:"Some values could not be read and were substituted"})}),e.jsx("p",{children:n("builder.review.substitutionsDescription",{defaultValue:"The
26se were not measured from your files. Later checks cannot see them, so confirm they are acceptable before continuing."})}),e.jsx("ul",{children:k.map(i=>e.jsx("li",{children:e.jsx("bdi",{children:i.note})},`${i.section}:${i.note}`))}),e.jsxs("label",{className:"ut-check","data-review-requirement":"substitutions_acceptance_required",htmlFor:`${d}-substitutions-accepted`,children:[e.jsx("input",{id:`${d}-substitutions-accepted`,type:"checkbox",checked:b,onChange:i=>f({...a,substitutionsAcceptedAt:i.target.checked?new Date().toISOString():null})}),n("builder.review.substitutionsAccept",{defaultValue:"I understand these values were substituted, not measured."})]})]})]}),e.jsxs("header",{className:"ut-section-heading",children:[e.jsxs("div",{children:[e.jsx("p",{className:"ut-eyebrow",children:n("builder.review.eyebrow",{defaultValue:"Human review"})}),e.jsx("h2",{id:`${d}-title`,children:n("builder.review.title",{defaultValue:"Check what AI learned"})}),e.jsx("p",{children:n("builder.review.description",{defaultValue:"Observed details come directly from your files. Inferred rules are marked with confidence and source evidence."})})]}),e.jsxs("span",{className:"ut-review-shield",children:[e.jsx(ue,{"aria-hidden":"true"}),n("builder.review.notPublished",{defaultValue:"Nothing is published yet"})]})]}),e.jsx("div",{className:"ut-tabs",role:"tablist","aria-label":n("builder.review.categories",{defaultValue:"Finding categories"}),children:p.map(i=>e.jsx("button",{id:`${d}-tab-${i}`,type:"button",role:"tab","aria-selected":x===i,"aria-controls":`${d}-panel-${i}`,tabIndex:x===i?0:-1,onClick:()=>h(i),onKeyDown:R=>{let C=null;if(R.key==="Home"&&(C=0),R.key==="End"&&(C=p.length-1),R.key==="ArrowRight"||R.key==="ArrowLeft"){const X=o.dir?.()==="rtl",I=R.key==="ArrowRight"?1:-1,Z=X?-I:I;C=(p.indexOf(i)+Z+p.length)%p.length}if(C===null)return;R.preventDefault();const F=p[C];h(F),document.getElementById(`${d}-tab-${F}`)?.focus()},children:n(`builder.review.tabs.${i}`,{defaultValue:bt[i]})},i))}),e.jsxs("div",{id:`${d}-panel-brand`,role:"tabpanel","aria-labelledby":`${d}-tab-brand`,hidden:x!=="brand",className:"ut-tab-panel",children:[v.logo?.detected&&!m&&e.jsxs("div",{className:"ut-logo-confirmation",children:[v.logo.previewUrl?e.jsx("img",{src:v.logo.previewUrl,alt:n("findings.logo.detectedPreview",{defaultValue:"Logo detected in the reference slides"})}):e.jsx("span",{className:"ut-logo-confirmation__placeholder",children:e.jsx(da,{"aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("h3",{children:n("findings.logo.detectedTitle",{defaultValue:"We found a logo in your slides"})}),e.jsx("p",{children:n("findings.logo.detectedDescription",{defaultValue:"For crisp, reproducible exports, upload the original SVG or transparent PNG. The mark detected in the slide is used only as placement evidence."})}),e.jsx(se,{provenance:v.logo.provenance}),e.jsxs("fieldset",{className:"ut-choice-group",children:[e.jsx("legend",{children:n("findings.logo.decision",{defaultValue:"What should we use?"})}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",name:`${d}-logo-decision`,value:"upload_original",checked:v.logo.userDecision==="upload_original",onChange:()=>V("upload_original")}),n("findings.logo.uploadOriginal",{defaultValue:"I will upload the original"})]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",name:`${d}-logo-decision`,value:"not_a_logo",checked:v.logo.userDecision==="not_a_logo",onChange:()=>V("not_a_logo")}),n("findings.logo.notLogo",{defaultValue:"This is not our logo"})]})]}),v.logo.userDecision==="upload_original"&&e.jsxs("button",{type:"button",className:"ut-button ut-button--secondary",onClick:r,children:[e.jsx(Ua,{"aria-hidden":"true"}),n("findings.logo.goToUpload",{defaultValue:"Upload original logo"})]})]})]}),e.jsxs("div",{className:"ut-finding-grid",children:[e.jsxs("article",{className:"ut-finding-card",children:[e.jsxs("h3",{children:[e.jsx(Pa,{"aria-hidden":"true"}),n("findings.brand.colors",{defaultValue:"Color roles"})]}),v.colors.length?e.jsx("ul",{className:"ut-color-list",children:v.colors.map((i,R)=>e.jsxs("li",{children:[e.jsx("span",{className:"ut-color-swatch",style:{backgroundColor:i.hex},"aria-hidden":"true"}),e.jsxs("span",{children:[e.jsx("strong",{children:i.hex}),e.jsx("small",{children:n(`findings.colors.${i.role}`,{defaultValue:i.role})})]}),e.jsx(se,{provenance:i.provenance})]},`${i.hex}-${i.role}-${R}`))}):e.jsx("p",{className:"ut-empty-inline",children:n("findings.none.colors",{defaultValue:"No stable color roles detected."})})]}),e.jsxs("article",{className:"ut-finding-card",children:[e.jsxs("h3",{children:[e.jsx(Ja,{"aria-hidden":"true"}),n("findings.brand.typography",{defaultValue:"Typography"})]}),v.fonts.length?e.jsx("ul",{className:"ut-font-list",children:v.fonts.map((i,R)=>e.jsxs("li",{children:[e.jsxs("span",{children:[e.jsx("strong",{children:e.jsx("bdi",{children:i.family})}),e.jsx("small",{children:n(`findings.fonts.${i.role}`,{defaultValue:i.role})})]}),e.jsx(se,{provenance:i.provenance})]},`${i.family}-${i.role}-${R}`))}):e.jsx("p",{className:"ut-empty-inline",children:n("findings.none.fonts",{defaultValue:"No consistent font family detected."})})]})]})]}),e.jsx("div",{id:`${d}-panel-backgrounds`,role:"tabpanel","aria-labelledby":`${d}-tab-backgrounds`,hidden:x!=="backgrounds",className:"ut-tab-panel",children:e.jsxs("div",{className:"ut-card-grid",children:[S.map(i=>e.jsxs("article",{className:"ut-visual-card",children:[e.jsx("div",{className:"ut-visual-card__preview",children:i.thumbnailUrl?e.jsx("img",{src:i.thumbnailUrl,alt:""}):e.jsx(da,{"aria-hidden":"true"})}),e.jsxs("div",{className:"ut-visual-card__copy",children:[e.jsx("h3",{children:e.jsx("bdi",{children:i.name})}),e.jsx("p",{children:n(`findings.backgrounds.kind.${i.kind}`,{defaultValue:i.kind})}),e.jsx(se,{provenance:i.provenance}),e.jsxs("span",{className:"ut-automatic-proof",children:[e.jsx(ue,{"aria-hidden":"true"}),n("findings.backgrounds.automaticVerification",{defaultValue:"Backgroun
26d cleanup is verified automatically before publishing"})]})]})]},i.id)),!S.length&&e.jsx("p",{className:"ut-empty-inline",children:n("findings.none.backgrounds",{defaultValue:"No reusable backgrounds were found."})})]})}),e.jsx("div",{id:`${d}-panel-layouts`,role:"tabpanel","aria-labelledby":`${d}-tab-layouts`,hidden:x!=="layouts",className:"ut-tab-panel",children:e.jsxs("div",{className:"ut-card-grid",children:[s.map(i=>e.jsxs("article",{className:"ut-visual-card",children:[e.jsx("div",{className:"ut-visual-card__preview ut-layout-sketch","data-kind":i.kind,children:i.thumbnailUrl?e.jsx("img",{src:i.thumbnailUrl,alt:""}):e.jsxs(e.Fragment,{children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]})}),e.jsxs("div",{className:"ut-visual-card__copy",children:[e.jsxs("h3",{children:[e.jsx(it,{"aria-hidden":"true"}),e.jsx("bdi",{children:i.name||ha(i,n)})]}),e.jsxs("p",{children:[ha(i,n)," · ",n("findings.layouts.observedCount",{defaultValue:"seen on {{count}} slides",count:i.slideCountObserved})]}),e.jsxs("span",{className:"ut-direction-rule",children:[e.jsx(tt,{"aria-hidden":"true"}),i.contentDirection==="logical"?n("findings.layouts.logical",{defaultValue:"Content follows reading direction"}):n("findings.layouts.fixedArtwork",{defaultValue:"Artwork keeps its physical position"})]}),e.jsx(se,{provenance:i.provenance})]})]},i.id)),!s.length&&e.jsx("p",{className:"ut-empty-inline",children:n("findings.none.layouts",{defaultValue:"No repeatable layout family was found."})})]})}),l!=="en"&&e.jsx("div",{id:`${d}-panel-arabic`,role:"tabpanel","aria-labelledby":`${d}-tab-arabic`,hidden:x!=="arabic",className:"ut-tab-panel",children:e.jsxs("div",{className:"ut-arabic-review",children:[e.jsxs("div",{className:"ut-arabic-sample",dir:"rtl",lang:"ar",children:[e.jsx("p",{children:n("findings.arabic.sampleEyebrow",{defaultValue:"نموذج العرض التقديمي"})}),e.jsx("h3",{children:n("findings.arabic.sampleTitle",{defaultValue:"نحو مستقبل أكثر ابتكاراً"})}),e.jsx("p",{children:n("findings.arabic.sampleBody",{defaultValue:"نحوّل الأفكار المعقدة إلى قصة واضحة ومؤثرة تدعم اتخاذ القرار."})}),e.jsx("span",{children:n("findings.arabic.sampleMetric",{defaultValue:"نمو بنسبة ٤٢٪"})})]}),e.jsxs("div",{className:"ut-arabic-rules",children:[e.jsxs("h3",{children:[e.jsx(ke,{"aria-hidden":"true"}),n("findings.arabic.title",{defaultValue:"Arabic behavior"})]}),e.jsxs("dl",{children:[e.jsxs("div",{children:[e.jsx("dt",{children:n("findings.arabic.rtl",{defaultValue:"Text direction"})}),e.jsx("dd",{children:P.rtlReady?n("common.verified",{defaultValue:"Verified"}):n("common.needsReview",{defaultValue:"Needs review"})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("findings.arabic.artwork",{defaultValue:"Artwork"})}),e.jsx("dd",{children:n("findings.arabic.noBlindMirror",{defaultValue:"Never mirrored blindly"})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("findings.arabic.font",{defaultValue:"Arabic font"})}),e.jsx("dd",{children:e.jsx("bdi",{children:P.arabicFontFamily||n("findings.arabic.fallbackFont",{defaultValue:"Compatible fallback"})})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("findings.arabic.numerals",{defaultValue:"Numerals"})}),e.jsx("dd",{children:n(`findings.arabic.numeralStyle.${P.numeralStyle}`,{defaultValue:P.numeralStyle})})]})]}),e.jsx(se,{provenance:P.provenance}),e.jsxs("span",{className:"ut-automatic-proof",children:[e.jsx(ue,{"aria-hidden":"true"}),n("findings.arabic.automaticVerification",{defaultValue:"Arabic text flow is verified automatically before publishing"})]})]})]})})]})}const vt={preparing_previews:{title:"Preparing slide previews",description:"We are rendering representative slides in every selected language."},visual_check:{title:"Checking visual consistency",description:"Layout, spacing, contrast, backgrounds and logo placement are being verified."},language_check:{title:"Checking content and languages",description:"We are validating text flow and reading direction before publishing."},repairing:{title:"Improving the template",description:"We found something that can be improved and are checking the corrected result again."},ready:{title:"Template verified and ready",description:"The current draft passed its final checks and can be published."},blocked:{title:"Verification needs more time",description:"We could not finish the final verification. Your private draft is safe and remains unpublished."}},xt={request_failed:{title:"Verification could not be reached",description:"The last request did not get through. Your draft is safe — try again."}
26,job_failed:{title:"Analysis stopped before verification",description:"The analysis did not finish, so there is nothing to verify yet. Start it again."},cancelled:{title:"Analysis was cancelled",description:"Verification never started. Run the analysis again when you are ready."},pending_changes:{title:"Save your changes first",description:"The brief has unsaved edits, so the checked draft is not the current one."},qa_failed:{title:"The checks found problems",description:"Review the findings, then run the checks again. Your draft stays unpublished."},not_attested:{title:"Checks passed, but the draft is not attested yet",description:"The compiled design changed after it was checked. Run the checks again."},review_required:{title:"Review the findings first",description:"Verification starts once you have confirmed what the analysis learned."},unknown:{title:"Verification needs more time",description:"We could not finish the final verification. Your private draft is safe and remains unpublished."}},yt={preparing_previews:0,visual_check:1,repairing:1,language_check:2,ready:3,blocked:-1};function jt({state:a}){const{t:l}=K("templates"),m=a.phase==="blocked"?a.blockedReason??"unknown":null,f=m?xt[m]:vt[a.phase],r=m?`builder.verification.blocked.${m}`:`builder.verification.phases.${a.phase}`,n=yt[a.phase],o=[l("builder.verification.steps.previews",{defaultValue:"Render slide previews"}),l("builder.verification.steps.visual",{defaultValue:"Check visual consistency"}),l("builder.verification.steps.language",{defaultValue:"Check content and languages"})];return e.jsxs("section",{className:"ut-verification","data-phase":a.phase,"aria-labelledby":"ut-verification-title","aria-live":"polite","aria-busy":!a.publishReady&&a.phase!=="blocked",children:[e.jsxs("div",{className:"ut-verification__hero",children:[e.jsx("span",{className:"ut-verification__icon","aria-hidden":"true",children:a.phase==="ready"?e.jsx(ue,{}):a.phase==="blocked"?e.jsx(L,{}):a.phase==="repairing"?e.jsx(je,{}):e.jsx(D,{className:"ut-spin"})}),e.jsxs("div",{children:[e.jsx("p",{className:"ut-eyebrow",children:l("builder.verification.eyebrow",{defaultValue:"Automatic final verification"})}),e.jsx("h2",{id:"ut-verification-title",children:l(`${r}.title`,{defaultValue:f.title})}),e.jsx("p",{children:l(`${r}.description`,{defaultValue:f.description})})]}),e.jsx("span",{className:"ut-verification__status",children:a.phase==="ready"?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{"aria-hidden":"true"}),l("builder.verification.ready",{defaultValue:"Ready"})]}):a.phase==="blocked"?l("builder.verification.paused",{defaultValue:"Not ready yet"}):l("builder.verification.working",{defaultValue:"Working automatically"})})]}),a.progress!==null&&e.jsx("div",{className:"ut-verification__progress",role:"progressbar","aria-label":l("builder.verification.progressLabel",{defaultValue:"Final verification progress"}),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":a.progress,children:e.jsx("span",{style:{width:`${a.progress}%`}})}),e.jsx("ol",{className:"ut-verification__steps",children:o.map((d,x)=>{const h=a.phase==="ready"||n>=0&&x<n,p=a.phase!=="blocked"&&a.phase!=="ready"&&x===n;return e.jsxs("li",{"data-state":h?"complete":p?"active":"pending",children:[e.jsx("span",{"aria-hidden":"true",children:h?e.jsx(Re,{}):p?e.jsx(D,{className:"ut-spin"}):e.jsx(va,{})}),d]},d)})}),a.readyPreviewCount>0&&e.jsx("p",{className:"ut-verification__preview-count",children:a.expectedPreviewCount!==null?l("builder.verification.previewCount",{defaultValue:"{{ready}} of {{total}} preview slides ready",ready:a.readyPreviewCount,total:a.expectedPreviewCount}):l("builder.verification.availablePreviewCount",{defaultValue:"{{count}} rendered previews available",count:a.readyPreviewCount})})]})}const wt={brief:"Describe",sources:"Sources & logo",analysis:"Analyze",review:"Review findings",preview:"Preview & verify",publish:"Publish"};function _t({currentStep:a,furthestStep:l,onStepChange:m}){const{t:f}=K("templates"),r=_e.indexOf(a),n=_e.indexOf(l),o=c.useRef(null);return c.useEffect(()=>{const d=typeof window<"u"&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;o.current?.scrollIntoView?.({behavior:d?"auto":"smooth",block:"nearest",inline:"center"})}
26,[a]),e.jsx("nav",{className:"ut-stepper","aria-label":f("builder.stepper.label",{defaultValue:"Template creation progress"}),children:e.jsx("ol",{children:_e.map((d,x)=>{const h=x<r,p=x<=n;return e.jsx("li",{"data-completed":h?"true":"false",children:e.jsxs("button",{ref:d===a?o:void 0,type:"button",className:"ut-stepper__button","aria-current":d===a?"step":void 0,disabled:!p,onClick:()=>m(d),children:[e.jsx("span",{className:"ut-stepper__marker","aria-hidden":"true",children:h?e.jsx(Re,{}):x+1}),e.jsx("span",{children:f(`builder.steps.${d}`,{defaultValue:wt[d]})})]})},d)})})})}const xa=new Set(["qa_render_required","raster_verification_required","semantic_verification_required","semantic_evidence_required","semantic_background_evidence_required"]);function ya(a){return a.qa?.status==="failed"&&(a.qa.issues??[]).some(l=>(l.status==="open"||l.status==="fixing")&&xa.has(l.code))}function Vt(a){const l=a.languageCoverage==="en_ar"?new Set(["en","ar"]):new Set([a.languageCoverage]);return new Set(a.previews.filter(m=>l.has(m.locale)&&m.imageUrl.trim()).map(m=>m.id)).size}function kt(a){return a==="semantic_qa"||a==="rtl_validate"?"language_check":a==="raster_qa"?"visual_check":a==="background_reconstruction"||a==="layout_compile"?"repairing":"preparing_previews"}function Nt(a,l,m){return a==="blocked"?null:a==="ready"?100:a==="repairing"?64:a==="language_check"?82:a==="visual_check"?58:m?Math.max(15,Math.min(42,Math.round(l/m*42))):15}function Rt(a,l){const m=Vt(a),f=Number(a.previewExpectedCount??0),r=Number.isSafeInteger(f)&&f>0?Math.max(f,m):l.publishReady&&m>0?m:null,n=a.activeJob,o=n?.status==="queued"||n?.status==="running",d=!!(a.findings?.reviewedAt&&n&&(n.status==="awaiting_review"||n.status==="succeeded")&&(!a.qa||a.qa.status==="not_run"));let x=null,h;return l.publishReady?h="ready":l.localActivity==="repairing"?h="repairing":l.localActivity==="previews"?h="preparing_previews":l.localActivity==="qa"?h=n?.currentStage==="semantic_qa"?"language_check":"visual_check":l.requestFailed&&(!o||n?.canResume===!0)?(h="blocked",x="request_failed"):o&&a.findings?.reviewedAt?h=kt(n.currentStage):l.requestFailed?(h="blocked",x="request_failed"):n?.status==="failed"||n?.status==="cancelled"?(h="blocked",x=n.status==="cancelled"?"cancelled":"job_failed"):a.qa?.status==="running"?h=n?.currentStage==="semantic_qa"?"language_check":"visual_check":l.hasPendingChanges?(h="blocked",x="pending_changes"):a.qa?.status==="failed"?(h="blocked",x="qa_failed"):a.qa?.status==="passed"?(h="blocked",x="not_attested"):d?h=m===0?"preparing_previews":"visual_check":(h="blocked",x=a.findings?.reviewedAt?"unknown":"review_required"),{phase:h,progress:Nt(h,m,r),automatic:!0,publishReady:l.publishReady,readyPreviewCount:m,expectedPreviewCount:r,draftRevision:a.draftRevision,verificationRevision:a.qa?.revision??null,checkedAt:a.qa?.checkedAt,blockedReason:x}}const At={brief:"Describe your template",sources:"Add reference files and your logo",analysis:"Analyze your design system",review:"Review the findings",preview:"Preview and verify",publish:"Publish an immutable version"},ie=3,Tt=2;function pa(a){return a instanceof Ae?a.status===408||a.status===429||a.status>=500:!(a instanceof DOMException&&a.name==="AbortError")}function ba(a){return!(a instanceof Ae)||a.status!==409?!1:a.code==="job_lease_active"||a.code==="job_not_resumable"}function ve(a,l){return a instanceof Ae&&a.retryAfterMs!==null?Math.max(100,Math.min(5e3,a.retryAfterMs)):l===0?350:1200}function xe(a){return new Promise(l=>window.setTimeout(l,a))}function Ne(a){return _e.indexOf(a)}function W(a,l){return Ne(a)>=Ne(l)?a:l}function ga(a){return a?a.status==="published"?"publish":a.findings?.reviewedAt?"preview":a.activeJob&&["queued","running","failed","cancelled"].includes(a.activeJob.status)?"analysis":a.findings&&!a.findings.reviewedAt?"review":a.qa?.status==="passed"||a.status==="ready_to_publish"||a.qa||a.previews.length||a.status==="qa_required"?"preview":a.findings||a.status==="review_required"?"review":["queued","analyzing","failed","cancelled"].includes(a.status)?"analysis":"sources":"brief"}function G(a){return a instanceof Ae?a.code||"request_failed":a instanceof DOMException&&a.name==="AbortError"?"cancelled":"request_failed"}function ye(a){return a.status==="published"||!a.findings?.reviewedAt||!a.activeJob||!["awaiting_review","succeeded"].includes(a.activeJob.status)?!1:!a.qa||a.qa.status==="not_run"?!0:a.verificationRefreshRequired===!0||ya(a)||a.qa.status==="passed"&&!a.publicationReady}function Ct(a){return a.verificationRefreshRequired?"policy-attestation-refresh":a.qa?.status==="passed"&&!a.publicationReady?"publication-attestation":a.qa?.status==="failed"?a.qa.issues.filter(l=>
26(l.status==="open"||l.status==="fixing")&&xa.has(l.code)).map(l=>`${l.code}:${l.id}`).sort().join(","):"initial"}function ja(a){return["qa",a.id,a.activeJob?.id??"no-job",a.activeJob?.attempt??0,a.draftRevision,Ct(a)].join(":")}function St(a){return`${ja(a)}:revision:${a.qa?.revision??0}`}function qt(a,l){return{localId:Le("upload"),file:a,role:l,status:"queued",progress:0,asset:null,error:null}}function Qt({templateId:a=null,onBack:l,onTemplateCreated:m,onPublished:f}){const{t:r,i18n:n}=K("templates"),{accessToken:o}=Ia(),d=Ma(),{enabled:x,getTemplate:h,refreshTemplate:p}=d,[v,S]=c.useState(a),s=v?d.getTemplate(v):null,P=ga(s),[V,k]=c.useState(a?P:"brief"),[b,i]=c.useState(a?P:"brief"),[R,C]=c.useState(s?.name??""),[F,X]=c.useState(s?.instructions||s?.description||""),[I,Z]=c.useState(s?.languageCoverage??"en_ar"),[re,Te]=c.useState([]),[Ue,wa]=c.useState([]),[ne,ce]=c.useState("unsure"),[U,Je]=c.useState(s?.findings??null),[w,q]=c.useState(null),[_a,le]=c.useState(null),[Va,E]=c.useState(!1),[$,j]=c.useState(null),[Ce,ka]=c.useState(!1),[ee,fe]=c.useState(!1),J=c.useRef(new Map),Se=c.useRef(new Map),qe=c.useRef(null),Me=c.useRef(null),Be=c.useRef(null),Oe=c.useRef(null),Ee=c.useRef(null),ze=c.useRef(null),Pe=c.useRef(new Set),O=c.useRef(new Set),He=c.useRef(new Map),We=c.useRef(new Set),Ge=new Set(re.flatMap(t=>t.asset?.id??[])),he=s?.assets.filter(t=>t.role==="source"&&!Ge.has(t.id))??[],de=s?.assets.filter(t=>t.role==="logo_original"&&!Ge.has(t.id))??[],pe=re.filter(t=>t.role==="source"),ae=re.filter(t=>t.role==="logo_original"),Y=de.length>0||ae.some(t=>t.status==="ready"),Ke=s?.activeJob?.status==="awaiting_review"&&s.findings?.brand?.logo?.detected===!0;c.useEffect(()=>{!a||!x||Ee.current===a||(Ee.current=a,fe(!1),S(a),h(a)||p(a).then(t=>{t||fe(!0)}))},[h,x,p,a]),c.useEffect(()=>{if(!s)return;const t=`${s.id}:${s.draftRevision}`;if(Be.current===t)return;Be.current=t,C(s.name),X(s.instructions||s.description),Z(s.languageCoverage),s.assets.some(y=>y.role==="logo_original")||s.logoIntakeStatus==="provided"||s.logoIntakeStatus==="confirmed"?ce("yes"):s.logoIntakeStatus==="none"&&ce("no");const u=ga(s);if(a&&ze.current!==s.id){ze.current=s.id,k(u),i(u);return}i(y=>W(y,u))},[s,a]),c.useEffect(()=>{if(!s?.findings)return;const t=JSON.stringify(s.findings);Oe.current!==t&&(Oe.current=t,Je(s.findings))},[s?.findings]),c.useEffect(()=>{const t=s?.activeJob;V==="analysis"&&s?.findings&&(t?.status==="awaiting_review"||t?.status==="succeeded")&&(i(u=>W(u,"review")),k("review"))},[V,s?.activeJob,s?.findings]),c.useEffect(()=>{const t=typeof window<"u"&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;qe.current?.focus({preventScroll:!0}),qe.current?.scrollIntoView?.({behavior:t?"auto":"smooth",block:"start"})},[V]),c.useEffect(()=>{$&&Me.current?.focus({preventScroll:!0})},[$]),c.useEffect(()=>()=>{for(const t of J.current.values())t.pause()},[]);const M=c.useCallback((t,u)=>{Te(y=>y.map(_=>_.localId===t?{..._,...u}:_))},[]),Ye=c.useCallback(t=>{const u=Se.current.get(t.localId);if(u)return u;if(!o||!v)return Promise.resolve(!1);const y=(async()=>{M(t.localId,{status:"uploading",error:null});try{const _=await Ba(o,v,t.file,{clientUploadId:t.localId,role:t.role,...t.role==="logo_original"&&s?.activeJob?.status==="awaiting_review"?{reviewContext:{jobId:s.activeJob.id,expectedJobUpdatedAt:s.activeJob.updatedAt,sourceDigest:s.activeJob.sourceDigest}}:{}},({percentage:N})=>M(t.localId,{progress:N}));J.current.set(t.localId,_);const g=await _.result;return J.current.delete(t.localId),M(t.localId,{status:"ready",progress:100,asset:g}),await d.refreshTemplate(v),!0}catch(_){return J.current.delete(t.localId),_ instanceof DOMException&&_.name==="AbortError"||M(t.localId,{status:"failed",error:G(_)}),!1}})().finally(()=>Se.current.delete(t.localId));return Se.current.set(t.localId,y),y},[o,d,v,M,s?.activeJob]),Qe=(t,u)=>{const y=re.filter(N=>N.role===u),_=u==="source"?he.length+y.length:de.length+y.length,g=Wa(t,u,_);wa(g.issues),g.accepted.length&&(u==="logo_original"&&ce("yes"),Te(N=>[...N,...g.accepted.map(Q=>
26qt(Q,u))]))},Xe=async t=>{if(!(!o||!v||w)){q(`remove-asset:${t}`),j(null);try{const u=await la(o,v,t);d.upsertTemplate(u)}catch{j("asset_delete_failed")}finally{q(null)}}},Ze=async t=>{const u=re.find(_=>_.localId===t);if(!u||!o||!v)return;const y=J.current.get(t);if(y&&await y.cancel(),Te(_=>_.filter(g=>g.localId!==t)),u.asset)try{const _=await la(o,v,u.asset.id);d.upsertTemplate(_)}catch{j("asset_delete_failed")}},ea=async t=>{const u=J.current.get(t);u&&(await u.pause(),M(t,{status:"paused"}))},aa=t=>{const u=J.current.get(t);u&&(M(t,{status:"uploading"}),u.resume())},z=t=>{if((t==="preview"||t==="publish")&&s?.status!=="published"){if(!s?.findings?.reviewedAt){j("findings_review_required"),k("review");return}if(t==="publish"&&!s.previews.length){j("preview_batch_required"),k("preview");return}}Ne(t)<=Ne(b)&&(j(null),k(t))},Na=async()=>{if(!(!o||w)){if(!R.trim()||F.trim().length<20){j("brief_incomplete");return}q("save-brief"),j(null);try{const t=s?await na(o,s.id,{name:R.trim(),instructions:F.trim(),languageCoverage:I,expectedDraftRevision:s.draftRevision}):await Ha(o,{name:R.trim(),instructions:F.trim(),languageCoverage:I,idempotencyKey:Le("create")});d.upsertTemplate(t),v||(S(t.id),m?.(t.id)),i(u=>W(u,"sources")),k("sources")}catch(t){j(G(t))}finally{q(null)}}},Ra=async()=>{if(!o||!v||w)return;if(!Ce){j("processor_consent_required");return}if(Ke){const u=ae.filter(y=>y.status!=="ready");if(!Y&&u.length===0){j("logo_required");return}q("upload-analyze"),j(null);try{for(const g of u)g.status==="paused"&&(J.current.get(g.localId)?.resume(),M(g.localId,{status:"uploading"}));if((await Promise.all(u.map(Ye))).some(g=>!g)){j("upload_failed");return}const _=await d.refreshTemplate(v);_&&d.upsertTemplate(_),i(g=>W(g,"review")),k("review")}catch(y){j(G(y))}finally{q(null)}return}if(ne==="yes"&&!Y&&ae.length===0){j("logo_required");return}const t=pe.filter(u=>u.status!=="ready");if(he.length===0&&pe.length===0){j("source_required");return}q("upload-analyze"),j(null);try{const u=await na(o,v,{logoIntakeStatus:ne==="yes"?Y?"provided":"requested":ne==="no"?"none":"requested",expectedDraftRevision:s?.draftRevision??0});d.upsertTemplate(u);const y=[...t,...ae.filter(T=>T.status!=="ready")];for(const T of y)T.status==="paused"&&(J.current.get(T.localId)?.resume(),M(T.localId,{status:"uploading"}));if((await Promise.all(y.map(Ye))).some(T=>!T)){j("upload_failed");return}const g=await d.refreshTemplate(v);if(!!!(g?.assets.some(T=>T.role==="source")||pe.length>0)){j("source_required");return}const Q=await Ga(o,v,{processorConsent:!0}),A=g??s;A&&d.upsertTemplate({...A,status:"analyzing",activeJob:Q}),i(T=>W(T,"analysis")),k("analysis")}catch(u){j(G(u))}finally{q(null)}},Ie=async t=>{if(!(!o||!s?.activeJob||w)){q(`job-${t}`),j(null);try{const y=await(t==="cancel"?Ka:t==="retry"?ia:ra)(o,s.id,s.activeJob.id);d.upsertTemplate({...s,status:y.status==="cancelled"?"cancelled":"analyzing",activeJob:y})}catch(u){j(G(u))}finally{q(null)}}},$e=c.useCallback(async t=>{if(!o||!t.activeJob||!ye(t))return t;const u=St(t);if(Pe.current.has(u)||O.current.has(u))return t;const y=ja(t);if(t.verificationRefreshRequired===!0||ya(t)||t.qa?.status==="passed"&&!t.publicationReady){const g=He.current.get(y)??0;if(g>=Tt)return O.current.add(u),E(!0),t;He.current.set(y,g+1)}Pe.current.add(u);try{E(!1),j(null),le(t.previews.length?"qa":"previews");let g=t;for(let N=0;N<ie;N+=1){const Q=g.activeJob;if(!Q||!ye(g))return O.current.add(u),g;try{const A=await sa(o,g.id,Q);return d.upsertTemplate(A),E(!1),O.current.add(u),A}catch(A){const T=await p(g.id);if(T&&(g=T,!ye(T)))return E(!1),O.current.add(u),T;if(ba(A)){if(E(!1),N+1>=ie)return E(!0),O.current.add(u),g;await xe(ve(A,N));continue}if(N+1>=ie||!pa(A))return E(!0),O.current.add(u),g;await xe(ve(A,N))}}return E(!0),O.current.add(u),g}finally{Pe.current.delete(u),le(null)}},[o,d,p]);c.useEffect(()=>{!s||!ye(s)||(i(t=>W(t,"preview")),$e(s))},[$e,s]),c.useEffect(()=>{const t=s?.activeJob;if(!o||!s?.findings?.reviewedAt||!t)return;const u=t.status==="failed"&&t.canRetry?"retry":(t.status==="queued"||t.status==="running")&&t.canResume?"resume":null;if(!u)return;const y=`${s.id}:${t.id}:${u}:${t.attempt}`;if(We.current.has(y))return;We.current.add(y),E(!1),le(t.currentStage==="background_reconstruction"||t.currentStage==="layout_compile"?"repairing":"qa");const _=u==="retry"?ia:ra;(async()=>{for(let g=0;g<ie;g+=1)try{const N=await _(o,s.id,t.id);d.upsertTemplate({...s,status:N.status==="queued"||N.status==="running"?"anal
26yzing":s.status,activeJob:N}),E(!1);return}catch(N){const A=(await p(s.id))?.activeJob,T=!!(A&&(A.id!==t.id||A.status!==t.status||A.updatedAt!==t.updatedAt||(A.status==="queued"||A.status==="running")&&!A.canResume));if(A&&(A.status==="awaiting_review"||A.status==="succeeded"||T)){E(!1);return}if(ba(N)){if(g+1>=ie){E(!0);return}await xe(ve(N,g));continue}if(g+1>=ie||!pa(N)){E(!0);return}await xe(ve(N,g))}})().finally(()=>{le(null)})},[o,d,p,s]),c.useEffect(()=>{if(!s?.findings?.reviewedAt)return;const t=s.activeJob?.status;(t==="queued"||t==="running"||s.qa?.status==="running"||s.qa?.status==="passed")&&E(!1)},[s?.activeJob?.status,s?.activeJob?.updatedAt,s?.findings?.reviewedAt,s?.qa?.status]);const Fe=c.useMemo(()=>{if(!U)return"findings_missing";const t=U.brand?.logo;return t?.detected&&!Y&&!t.userDecision?"logo_decision_required":t?.detected&&!Y&&t.userDecision!=="not_a_logo"?"logo_required":U.substitutions?.length&&!U.substitutionsAcceptedAt?"substitutions_acceptance_required":null},[U,Y]),Aa=async()=>{if(!(!o||!s||!s.activeJob||!U||w)){if(Fe){j(Fe),window.requestAnimationFrame(()=>{const t=document.querySelector(`[data-review-requirement="${Fe}"]`);t?.scrollIntoView?.({behavior:"smooth",block:"center"}),t?.querySelector("input, button, select, textarea")?.focus()});return}q("review"),j(null);try{const t=await Ya(o,s.id,{jobId:s.activeJob.id,expectedJobUpdatedAt:s.activeJob.updatedAt,sourceDigest:s.activeJob.sourceDigest,expectedRevision:U.revision,findings:U});if(d.upsertTemplate(t),!t.activeJob)throw new Error("Reviewed template is missing its analysis job.");i(u=>W(u,"preview")),k("preview"),await $e(t)}catch(t){j(G(t))}finally{q(null)}}},be=!!(s&&(R.trim()!==s.name||F.trim()!==(s.instructions||s.description)||I!==s.languageCoverage)),B=s?.publicationReady===!0&&s?.qa?.status==="passed"&&s.activeJob?.currentStage==="review"&&(s.activeJob.status==="awaiting_review"||s.activeJob.status==="succeeded")&&!be&&!(s.qa.issues??[]).some(t=>(t.status==="open"||t.status==="fixing")&&(t.severity==="blocker"||t.severity==="major")),ta=!!(s?.qa?.status==="failed"&&s.activeJob&&["awaiting_review","succeeded"].includes(s.activeJob.status)&&!be),te=s?Rt(s,{localActivity:_a,publishReady:B,requestFailed:Va,hasPendingChanges:be}):null,Ta=async()=>{if(!(!o||!s?.activeJob||w||!ta)){q("retry-verification"),j(null),E(!1),le("qa");try{const t=await sa(o,s.id,s.activeJob);d.upsertTemplate(t)}catch(t){E(!0),j(G(t))}finally{q(null)}}};c.useEffect(()=>{V==="publish"&&s?.status!=="published"&&!B&&s?.findings?.reviewedAt&&k("preview")},[B,V,s?.findings?.reviewedAt,s?.status]);const Ca=async()=>{if(!(!o||!s||!s.qa||!s.activeJob||w)){if(!B){j("verification_not_ready");return}q("publish"),j(null);try{const t=await Qa(o,s.id,{jobId:s.activeJob.id,expectedJobUpdatedAt:s.activeJob.updatedAt,sourceDigest:s.activeJob.sourceDigest,expectedDraftRevision:s.draftRevision,expectedQa
26Revision:s.qa.revision,idempotencyKey:Le("publish")});d.upsertTemplate(t.template),f?.(t.version)}catch(t){j(G(t))}finally{q(null)}}},Sa=r(`builder.stepTitles.${V}`,{defaultValue:At[V]}),H=!!(a&&!s);return e.jsxs("main",{className:"ut-page ut-builder-page",children:[e.jsxs("header",{className:"ut-builder-header",children:[e.jsxs("button",{type:"button",className:"ut-back-button",onClick:l,children:[e.jsx(Za,{"aria-hidden":"true"}),r("actions.backToTemplates",{defaultValue:"Back to templates"})]}),e.jsxs("div",{className:"ut-builder-header__identity",children:[e.jsx("span",{className:"ut-builder-header__mark","aria-hidden":"true",children:e.jsx(je,{})}),e.jsxs("div",{children:[e.jsx("strong",{children:e.jsx("bdi",{children:s?.name||R||r("builder.untitled",{defaultValue:"New template"})})}),e.jsx("span",{children:r("builder.autoSave",{defaultValue:"Saved securely to your account"})})]})]}),s&&e.jsx(Xa,{status:s.status})]}),e.jsx(_t,{currentStep:V,furthestStep:b,onStepChange:z}),e.jsxs("div",{className:"ut-builder-shell",children:[e.jsx("h1",{ref:qe,className:"ut-sr-only",tabIndex:-1,"data-step-heading":!0,children:Sa}),H&&e.jsxs("section",{className:"ut-empty-state ut-empty-state--compact","aria-busy":!ee,role:ee?"alert":"status",children:[ee?e.jsx(L,{"aria-hidden":"true"}):e.jsx(D,{className:"ut-spin","aria-hidden":"true"}),e.jsx("h2",{children:ee?r("builder.loadFailedTitle",{defaultValue:"Could not load this template"}):r("builder.loadingTitle",{defaultValue:"Loading template"})}),e.jsx("p",{children:ee?r("builder.loadFailedDescription",{defaultValue:"Check your connection, then restore the latest private draft."}):r("builder.loadingDescription",{defaultValue:"Restoring the latest private draft and job state."})}),ee&&e.jsx("button",{type:"button",className:"ut-button ut-button--secondary",onClick:()=>{Ee.current=null,fe(!1),d.refreshTemplate(a).then(t=>{t||fe(!0)})},children:r("actions.tryAgain",{defaultValue:"Try again"})})]}),!H&&$&&e.jsxs("div",{ref:Me,className:"ut-alert ut-alert--danger ut-page-error",role:"alert",tabIndex:-1,children:[e.jsx(L,{"aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("strong",{children:r("errors.title",{defaultValue:"Please check this step"})}),e.jsx("p",{children:r(`errors.${$}`,{defaultValue:$==="brief_incomplete"?"Add a name and at least 20 characters describing the style.":$==="logo_question_required"?"Tell us whether you have an original logo.":$==="logo_required"?"Upload the original SVG or PNG logo, or choose that no original is available.":$==="source_required"?"Add at least one reference presentation or image.":$==="processor_consent_required"?"Confirm the disclosed processing before analysis.":$==="logo_decision_required"?"Confirm whether the logo detected in the slides should be used.":$==="substitutions_acceptance_required"?"Review and confirm the values that were substituted instead of measured.":$==="qa_not_passed"||$==="verification_not_ready"?"Final verification is not ready yet. Publishing remains safely locked.":$==="findings_review_required"?"Review and confirm the current findings before final verification.":$==="preview_batch_required"?"The current slide previews are still being prepared.":"The request could not be completed. Try again."})})]})]}),!H&&V==="brief"&&e.jsxs("section",{className:"ut-step-card ut-brief","aria-labelledby":"ut-brief-title",children:[e.jsx("header",{className:"ut-section-heading ut-section-heading--centered",children:e.jsxs("div",{children:[e.jsx("p",{className:"ut-eyebrow",children:r("builder.brief.eyebrow",{defaultValue:"Step 1 · Intent"})}),e.jsx("h2",{id:"ut-brief-title",children:r("builder.brief.title",{defaultValue:"Describe the system behind your slides"})}),e.jsx("p",{children:r("builder.brief.description",{defaultValue:"Explain what should remain consistent: tone, density, brand feel, preferred layouts and any rules the source files may not reveal."})})]})}),e.jsxs("div",{className:"ut-form-grid",children:[e.jsxs("label",{className:"ut-field",children:[e.jsx("span",{children:r("builder.brief.nameLabel",{defaultValue:"Template name"})}),e.jsx("input",{type:"text",value:R,maxLength:80,autoComplete:"off",placeholder:r("builder.brief.namePlaceholder",{defaultValue:"e.g. Acme executive brief"}),onChange:t=>C(t.currentTarget.value)}),e.jsx("small",{children:r("builder.brief.nameHelp",{defaultValue:"Only visible to you until published."})})]}),e.jsxs("label",{className:"ut-field",children:[e.jsx("span",{children:r("builder.brief.descriptionLabel",{defaultValue:"How should presentations feel and work?"})}),e.jsx("textarea",{value:F,maxLength:2e3,rows:7,placeholder:r("builder.brief.descriptionPlaceholder",{defaultValue:"Executive and calm. Use short headlines, generous whitespace, data-first content slides, and the logo only in approved corners…"}),onChange:t=>X(t.currentTarget.value)}),e.jsx("small",{children:r("builder.brief.descriptionCount",{defaultValue:"{{count}} of {{max}} characters",count:F.length,max:2e3})})]}),e.jsxs("fieldset",{className:"ut-language-choice",children:[e.jsx("legend",{children:r("builder.brief.languagesLabel",{defaultValue:"Language coverage"})}),[["en_ar","English + Arabic","Recommended: validates both LTR and RTL behavior."],["en","English","English layouts only."],["ar","Arabic","Arabic-first RTL layouts."]].map(([t,u,y])=>e.jsxs("label",{children:[e.jsx("input",{type:"radio",name:"template-language-coverage",value:t,checked:I===t,onChange:()=>Z(t)}),e.jsxs("span",{children:[e.jsx("strong",{children:r(`builder.brief.languages.${t}.label`,{defaultValue:u})}),e.jsx("small",{children:r(`builder.brief.languages.${t}.help`,{defaultValue:y})})]}),t==="en_ar"&&e.jsx(ke,{"aria-hidden":"true"})]},t))]})]}),e.jsx("div",{className:"ut-actions",children:e.jsxs("button",{type:"button",className:"ut-button ut-button--primary ut-button--large",disabled:!!w,onClick:()=>void Na(),children:[w==="save-brief"?e.jsx(D,{className:"ut-spin","aria-hidden":"true"}):e.jsx(et,{"aria-hidden":"true"}),s?r("actions.saveContinue",{defaultValue:"Save and continue"}):r("actions.createContinue",{defaultValue:"Create and continue"}),e.jsx(me,{"aria-hidden":"true"})]})})]}),!H&&V==="sources"&&e.jsxs("section",{className:"ut-step-card","aria-labelledby":"ut-sources-title",children:[e.jsxs("header",{className:"ut-section-heading",children:[e.jsxs("div",{children:[e.jsx("p",{className:"ut-eyebrow",children:r("builder.sources.eyebrow",{defaultValue:"Step 2 · Evidence"})}),e.jsx("h2",{id:"ut-sources-title",children:r("builder.sources.title",{defaultValue:"Add representative slides and the best logo file"})}),e.jsx("p",{children:r("builder.sources.description",{defaultValue:"Use several slide types if possible. Files are stored privately in your account and securely processed by OpenAI, Google Gemini, ConvertAPI, and Browserless only to compile and verify this template."})})]}),e.jsxs("span",{className:"ut-private-note",children:[e.jsx(De,{"aria-hidden":"true"}),r("builder.sources.private",{defaultValue:"Private storage · approved processors used"})]})]}),he.length>0&&e.jsxs("div",{className:"ut-existing-files",children:[e.jsx("h3",{children:r("builder.sources.alreadyUploaded",{defaultValue:"Already uploaded"})}),e.jsx("ul",{children:he.map(t=>e.jsxs("li",{children:[e.jsx(nt,{"aria-hidden":"true"}),e.jsx("bdi",{children:t.fileName}),e.jsx("span",{children:r("upload.ready",{defaultValue:"Uploaded"})}),e.jsx("button",{type:"button",className:"ut-icon-button",disabled:!!w,onClick:()=>void Xe(t.id),"aria-label":r("builder.sources.removeFile",{defaultValue:"Remove {{fileName}}",fileName:t.fileName}),children:e.jsx(ma,{"aria-hidden":"true"})})]},t.id))})]}),e.jsx(ca,{id:"ut-source-files",role:"source",accept:Oa,multiple:!0,files:pe,disabled:!!w,onFiles:t=>Qe(t,"source"),onRemove:t=>void Ze(t),onPause:t=>void ea(t),onResume:aa}),e.jsxs("fieldset",{className:"ut-logo-question",children:[e.jsx("legend",{children:r("builder.sources.logoQuestion",{defaultValue:"Do you have the original company or organization logo?"})}),e.jsx("p",{children:r("builder.sources.logoQuestionHelp",{defaultValue:"If a logo appears in the references, an original file produces sharper placement and prevents AI from treating it as slide content."})}),e.jsx("div",{children:["yes","no","unsure"].map(t=>e.jsxs("label",{children:[e.jsx("input",{type:"radio",name:"logo-availability",value:t,checked:ne===t,onChange:()=>ce(t)}),r(`builder.sources.logoAnswers.${t}`,{defaultValue:t==="yes"?"Yes, I have it":t==="no"?"No original available":"Not sure"})]},t))})]}),(ne==="yes"||ae.length>0||de.length>0)&&e.jsxs(e.Fragment,{children:[de.map(t=>e.jsxs("div",{className:"ut-existing-logo",children:[e.jsx(Ve,{"aria-hidden":"true"}),e.jsxs("span",{children:[r("builder.sources.logoOnFile",{defaultValue:"Original logo on file"}),": ",e.jsx("bdi",{children:t.fileName})]}),e.jsx("button",{type:"button",className:"ut-button ut-button--secondary",disabled:!!w,onClick:()=>void Xe(t.id),children:r("builder.sources.replaceLogo",{defaultValue:"Remove and replace"})})]},t.id)),e.jsx(ca,{id:"ut-logo-file",role:"logo_original",accept:za,files:ae,disabled:!!w||de.length>0,onFiles:t=>Qe(t,"logo_original"),onRemove:t=>void Ze(t),onPause:t=>void ea(t),onResume:aa})]}),Ue.length>0&&e.jsxs("div",{className:"ut-alert ut-alert--danger",role:"alert",children:[e.jsx(L,{"aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("strong",{children:r("builder.sources.someFilesRejected",{defaultValue:"Some files were not added"})}),e.jsx("ul",{children:Ue.map((t,u)=>e.jsxs("li",{children:[e.jsx("bdi",{children:t.fileName}),": ",r(`upload.validation.${t.code}`,{defaultValue:t.code==="unsupported_type"?"unsupported file type":t.code==="empty"?"empty file":t.code==="too_large"?"file is too large":"file limit reached"})]},`${t.fileName}-${u}`))})]})]}),e.jsxs("label",{className:"ut-processor-consent",children:[e.jsx("input",{type:"checkbox",checked:Ce,onChange:t=>ka(t.currentTarget.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:r("builder.sources.processorConsentTitle",{defaultValue:"I authorize the disclosed processing for this compilation"})}),e.jsx("small",{children:r("builder.sources.processorConsentHelp",{defaultValue:"OpenAI, Google Gemini, ConvertAPI, and Browserless receive only the bounded data needed for their compilation or verification stage."})})]})]}),e.jsx("p",{className:"ut-processor-privacy",children:e.jsx("a",{href:$a(n.language,"/privacy-policy"),target:"_blank",rel:"noreferrer",children:r("builder.sources.processorPrivacyLink",{defaultValue:"Review how these processors handle your files"})})}),e.jsxs("div",{className:"ut-actions ut-actions--between",children:[e.jsxs("button",{type:"button",className:"ut-button ut-button--secondary",onClick:()=>z("brief"),children:[e.jsx(ge,{"aria-hidden":"true"}),r("actions.back",{defaultValue:"Back"})]}),e.jsxs("button",{type:"button",className:"ut-button ut-button--primary ut-button--large",disabled:!!w||!Ce,onClick:()=>void Ra(),children:[w==="upload-analyze"?e.jsx(D,{className:"ut-spin","aria-hidden":"true"}):e.jsx(je,{"aria-hidden":"true"}),w==="upload-analyze"?r("actions.uploading",{defaultValue:"Uploading securely…"}):Ke?r("actions.attachLogoReturn",{defaultValue:"Attach logo and return to review"}):r("actions.uploadAnalyze",{defaultValue:"Upload and analyze"}),e.jsx(me,{"aria-hidden":"true"})]})]})]}),!H&&V==="analysis"&&e.jsx("div",{className:"ut-step-card",children:s?.activeJob?e.jsx(ot,{job:s.activeJob,busy:!!w,onCancel:()=>void Ie("cancel"),onRetry:()=>void Ie("retry"),onResume:()=>void Ie("resume")}):e.jsxs("section",{className:"ut-empty-state ut-empty-state--compact",children:[e.jsx(je,{"aria-hidden":"true"}),e.jsx("h2",{children:r("builder.analysis.notStartedTitle",{defaultValue:"Analysis has not started"})}),e.jsx("p",{children:r("builder.analysis.notStartedDescription",{defaultValue:"Return to 
26sources and start the analysis."})}),e.jsx("button",{type:"button",className:"ut-button ut-button--secondary",onClick:()=>z("sources"),children:r("actions.backToSources",{defaultValue:"Back to sources"})})]})}),!H&&V==="review"&&e.jsx("div",{className:"ut-step-card",children:U?e.jsxs(e.Fragment,{children:[e.jsx(mt,{findings:U,languageCoverage:I,hasOriginalLogo:Y,onChange:t=>{Je(t),j(null)},onRequestLogoUpload:()=>z("sources")}),e.jsxs("div",{className:"ut-actions ut-actions--between",children:[e.jsxs("button",{type:"button",className:"ut-button ut-button--secondary",onClick:()=>z("analysis"),children:[e.jsx(ge,{"aria-hidden":"true"}),r("actions.back",{defaultValue:"Back"})]}),e.jsxs("button",{type:"button",className:"ut-button ut-button--primary ut-button--large",disabled:!!w,onClick:()=>void Aa(),children:[w==="review"?e.jsx(D,{className:"ut-spin","aria-hidden":"true"}):e.jsx(Re,{"aria-hidden":"true"}),r("actions.confirmGeneratePreviews",{defaultValue:"Confirm and generate previews"}),e.jsx(me,{"aria-hidden":"true"})]})]})]}):e.jsxs("section",{className:"ut-empty-state ut-empty-state--compact",children:[e.jsx(Fa,{"aria-hidden":"true"}),e.jsx("h2",{children:r("builder.review.notReadyTitle",{defaultValue:"Findings are not ready yet"})}),e.jsx("p",{children:r("builder.review.notReadyDescription",{defaultValue:"Analysis must finish before review."})})]})}),!H&&V==="preview"&&e.jsxs("div",{className:"ut-step-stack",children:[te&&e.jsx("div",{className:"ut-step-card",children:e.jsx(jt,{state:te})}),e.jsx("div",{className:"ut-step-card",children:e.jsx(ht,{previews:s?.previews??[],languageCoverage:I,verificationPhase:te?.phase??"preparing_previews"})}),e.jsxs("div",{className:"ut-actions ut-actions--between",children:[e.jsxs("button",{type:"button",className:"ut-button ut-button--secondary",onClick:()=>z("review"),children:[e.jsx(ge,{"aria-hidden":"true"}),r("actions.back",{defaultValue:"Back"})]}),te?.phase==="blocked"&&ta?e.jsxs("button",{type:"button",className:"ut-button ut-button--primary ut-button--large",disabled:w!==null,onClick:Ta,children:[w==="retry-verification"?e.jsx(D,{className:"ut-spin","aria-hidden":"true"}):e.jsx(we,{"aria-hidden":"true"}),r("actions.runChecksAgain",{defaultValue:"Run checks again"})]}):e.jsxs("button",{type:"button",className:"ut-button ut-button--primary ut-button--large",disabled:!B,onClick:()=>{i(t=>W(t,"publish")),k("publish")},children:[B?r("actions.continueToPublish",{defaultValue:"Continue to publish"}):te?.phase==="blocked"?r("actions.verificationNotReady",{defaultValue:"Not ready yet"}):r("actions.verificationInProgress",{defaultValue:"Verification in progress"}),!B&&te?.phase!=="blocked"&&e.jsx(D,{className:"ut-spin","aria-hidden":"true"}),B&&e.jsx(me,{"aria-hidden":"true"})]})]})]}),!H&&V==="publish"&&e.jsx("section",{className:"ut-step-card ut-publish","aria-labelledby":"ut-publish-title",children:s?.status==="published"&&s.publishedVersion?e.jsxs("div",{className:"ut-published-success",children:[e.jsx("span",{className:"ut-published-success__icon",children:e.jsx(Ve,{"aria-hidden":"true"})}),e.jsx("p",{className:"ut-eyebrow",children:r("builder.publish.successEyebrow",{defaultValue:"Published"})}),e.jsx("h2",{id:"ut-publish-title",children:r("builder.publish.successTitle",{defaultValue:"Your template is ready to generate presentations"})}),e.jsx("p",{children:r("builder.publish.successDescription",{defaultValue:"This version is immutable, so presentations using it remain visually reproducible."})}),e.jsxs("dl",{className:"ut-version-details",children:[e.jsxs("div",{children:[e.jsx("dt",{children:r("builder.publish.version",{defaultValue:"Version"})}),e.jsx("dd",{children:s.publishedVersion.version})]}),e.jsxs("div",{children:[e.jsx("dt",{children:r("builder.publish.rendererId",{defaultValue:"Renderer template"})}),e.jsx("dd",{children:e.jsx("bdi",{children:d.getRendererTemplateForVersion(s.publishedVersion.versionId)?.templateId??"—"})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:r("builder.publish.publishedAt",{defaultValue:"Published"})}),e.jsx("dd",{children:new Intl.DateTimeFormat(n.language,{dateStyle:"medium",timeStyle:"short"}).format(new Date(s.publishedVersion.publishedAt))})]})]}),e.jsx("button",{type:"button",className:"ut-button ut-button--secondary",onClick:l,children:r("actions.done",{defaultValue:"Done"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("header",{className:"ut-section-heading ut-section-heading--centered",children:e.jsxs("div",{children:[e.jsx("p",{className:"ut-eyebrow",children:r("builder.publish.eyebrow",{defaultValue:"Final step"})}),e.jsx("h2",{id:"ut-publish-title",children:r("builder.publish.title",{defaultValue:"Publish a stable, immutable version"})}),e.jsx("p",{children:r("builder.publish.description",{defaultValue:"Future edits create a new version. Existing presentations keep the exact renderer manifest they started with."})})]})}),e.jsxs("div",{className:"ut-publish-summary",children:[e.jsxs("div",{children:[e.jsx(ue,{"aria-hidden":"true"}),e.jsxs("span",{children:[e.jsx("strong",{children:r("builder.publish.qaPassed",{defaultValue:"Verification complete"})}),e.jsx("small",{children:I==="en"?r("builder.publish.qaPassedHelpEnglish",{defaultValue:"Pixel and semantic checks completed"}):r("builder.publish.qaPassedHelp",{defaultValue:"Pixel, semantic and RTL checks completed"})})]})]}),e.jsxs("div",{children:[e.jsx(ke,{"aria-hidden":"true"}),e.jsxs("span",{children:[e.jsx("strong",{children:r("builder.publish.languageCoverage",{defaultValue:"Language coverage"})}),e.jsx("small",{children:I==="en_ar"?r("languages.englishArabicFull",{defaultValue:"English and Arabic"}):I.toLocaleUpperCase()})]})]}),e.jsxs("div",{children:[e.jsx(De,{"aria-hidden":"true"}),e.jsxs("span",{children:[e.jsx("strong",{children:r("builder.publish.immutable",{defaultValue:"Immutable version"})}),e.jsx("small",{children:r("builder.publish.immutableHelp",{defaultValue:"Reproducible renderer manifest with a content hash"})})]})]})]}),be&&e.jsxs("div",{className:"ut-alert ut-alert--danger ut-publish-dirty",role:"alert",children:[e.jsx(L,{"aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("strong",{children:r("builder.publish.unsavedTitle",{defaultValue:"Save your latest template changes first"})}),e.jsx("p",{children:r("builder.publish.unsavedDescription",{defaultValue:"Publishing is paused because the name, instructions, or language coverage changed after final verification."})}),e.jsx("button",{type:"button",className:"ut-button ut-button--secondary",onClick:()=>z("brief"),children:r("builder.publish.reviewChanges",{defaultValue:"Review and save changes"})})]})]}),e.jsxs("div",{className:"ut-actions ut-actions--between",children:[e.jsxs("button",{type:"button",className:"ut-button ut-button--secondary",onClick:()=>z("preview"),children:[e.jsx(ge,{"aria-hidden":"true"}),r("actions.back",{defaultValue:"Back"})]}),e.jsxs("button",{type:"button",className:"ut-button ut-button--primary ut-button--large",disabled:!!w||!B,onClick:()=>void Ca(),children:[w==="publish"?e.jsx(D,{className:"ut-spin","aria-hidden":"true"}):e.jsx(De,{"aria-hidden":"true"}),w==="publish"?r("actions.publishing",{defaultValue:"Publishing…"}):r("actions.publishTemplate",{defaultValue:"Publish template"})]})]})]})}),e.jsx("p",{className:"ut-sr-only","aria-live":"polite",children:w?r("builder.working",{defaultValue:"Working…"}):""})]})]})}export{Qt as TemplateBuilderPage};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.