@engenty/wizards-runtime 0.11.12 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/runtime/dist/app.js +2 -0
- package/apps/runtime/dist/auth/index.js +14 -2
- package/apps/runtime/dist/cli/account.js +1 -1
- package/apps/runtime/dist/cli/features.js +45 -2
- package/apps/runtime/dist/docs/dev/plugins/reference.md +3 -3
- package/apps/runtime/dist/docs/dev/plugins/studio.md +1 -1
- package/apps/runtime/dist/docs/user-guide/models.md +22 -2
- package/apps/runtime/dist/docs/user-guide/server.md +15 -2
- package/apps/runtime/dist/features.js +9 -0
- package/apps/runtime/dist/index.js +7 -0
- package/apps/runtime/dist/local-models.js +192 -0
- package/apps/runtime/dist/models.js +250 -75
- package/apps/runtime/dist/plugins/install.js +120 -0
- package/apps/runtime/dist/plugins/loader.js +33 -3
- package/apps/runtime/dist/plugins/pro.js +9 -9
- package/apps/runtime/dist/prompts/tools.md +1 -1
- package/apps/runtime/dist/routes/plugins.js +110 -2
- package/apps/runtime/dist/routes/runtime-settings.js +108 -0
- package/apps/runtime/dist/routes/studio.js +64 -2
- package/apps/runtime/dist/services/project-files.js +11 -1
- package/apps/runtime/dist/services/project-index.js +47 -4
- package/apps/runtime/dist/texts.js +4 -0
- package/apps/runtime/dist/update.js +10 -2
- package/apps/web/dist/assets/AboutDialog-BOJjBIYk.js +1 -0
- package/apps/web/dist/assets/{ChangelogDialog-Dc66LqBg.js → ChangelogDialog-I9DEn_ra.js} +1 -1
- package/apps/web/dist/assets/{CodeEditor-BijLsoJX.js → CodeEditor-BgUofYLQ.js} +1 -1
- package/apps/web/dist/assets/EditorPage-DEOxHFXn.js +3 -0
- package/apps/web/dist/assets/{FlowPreview-Wjt28MdG.js → FlowPreview-C6DeATyk.js} +1 -1
- package/apps/web/dist/assets/{Marketplace-CpjRqTvn.js → Marketplace-Dt7ktvc3.js} +2 -2
- package/apps/web/dist/assets/{NewWizardChannels-g3CJzwr5.js → NewWizardChannels-BrVFc6PV.js} +1 -1
- package/apps/web/dist/assets/{NewWizardPage-DGHwvXLf.js → NewWizardPage-Dl8sMR2e.js} +1 -1
- package/apps/web/dist/assets/OnboardingPage-BN5IfLGL.js +1 -0
- package/apps/web/dist/assets/{PreviewPane-BgIEsVjy.js → PreviewPane-BDzDuTz1.js} +5 -5
- package/apps/web/dist/assets/ProjectPage-BqkkyEpP.js +1 -0
- package/apps/web/dist/assets/PublicRunner-bAakEGwv.js +1 -0
- package/apps/web/dist/assets/{ReadOnly-C3SYrBNk.js → ReadOnly-MBVPGEhw.js} +1 -1
- package/apps/web/dist/assets/SettingsPage-DDe1BC-3.js +2 -0
- package/apps/web/dist/assets/SetupPage-CmTC9K8_.js +1 -0
- package/apps/web/dist/assets/{SharePage-BDeYhYRB.js → SharePage-D9_IxO3M.js} +1 -1
- package/apps/web/dist/assets/changelog-iTu1De5h.js +1 -0
- package/apps/web/dist/assets/i18n-7CvqRUdn.js +55 -0
- package/apps/web/dist/assets/index-CNwXyMzH.js +49 -0
- package/apps/web/dist/assets/index-Dxwbli0m.css +1 -0
- package/apps/web/dist/assets/{wrench-Dr19y-10.js → lock-D1093O6-.js} +1 -1
- package/apps/web/dist/assets/{phone-JGS60FQU.js → phone-YeDiW-kN.js} +1 -1
- package/apps/web/dist/assets/{runners-CwTP03YR.js → runners-DP0vYvTF.js} +1 -1
- package/apps/web/dist/assets/session-Bio3Vaq1.js +2 -0
- package/apps/web/dist/assets/{theme-DftQJmEW.js → theme-AlaEfdLQ.js} +2 -2
- package/apps/web/dist/assets/{ui-Bhp_a_44.js → ui-CU-cIuyK.js} +2 -2
- package/apps/web/dist/assets/{upload-DPLDQsRT.js → upload-DbWtEr1f.js} +1 -1
- package/apps/web/dist/assets/{useMutation-Cmn8b7tT.js → useMutation-erJIov3t.js} +1 -1
- package/apps/web/dist/assets/{volume-2-DGqbhyPO.js → volume-2-V1P9DYWO.js} +1 -1
- package/apps/web/dist/index.html +8 -8
- package/apps/web/dist/manifest.webmanifest +1 -1
- package/apps/web/dist/mcp/flow.html +25 -25
- package/node_modules/@engenty/wizards/dist/plugin/studio.d.ts +1 -1
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +6 -0
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +6 -0
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/plugin.json +1 -1
- package/apps/web/dist/assets/AboutDialog-DKGBCS3o.js +0 -1
- package/apps/web/dist/assets/EditorPage-CWtOGKs7.js +0 -3
- package/apps/web/dist/assets/Harness-BrP-ENHg.css +0 -1
- package/apps/web/dist/assets/Harness-CdmCoeEZ.js +0 -16
- package/apps/web/dist/assets/OnboardingPage-CoCBYKvL.js +0 -1
- package/apps/web/dist/assets/ProjectPage-Cmhm9qh1.js +0 -1
- package/apps/web/dist/assets/PublicRunner-C7i0QdlT.js +0 -1
- package/apps/web/dist/assets/SettingsPage-Ctul7RLy.js +0 -2
- package/apps/web/dist/assets/SetupPage-CuuQVDH2.js +0 -1
- package/apps/web/dist/assets/changelog-BXyvVCpB.js +0 -1
- package/apps/web/dist/assets/i18n-BYeH2Dmi.js +0 -55
- package/apps/web/dist/assets/index-BYZBN0xx.css +0 -1
- package/apps/web/dist/assets/index-C0yASttP.js +0 -34
- package/apps/web/dist/assets/session-CngLvd02.js +0 -2
- package/apps/web/dist/assets/settings-menu-C0yo5q3t.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{G as r,Mn as i,Mr as a,Un as o,W as s,i as c,ir as ee,l,on as u,or as te,qn as d,sr as ne,u as f}from"./ui-Bhp_a_44.js";import{t as p}from"./useMutation-Cmn8b7tT.js";import{d as re,g as ie,i as ae,n as m,v as h,w as g,x as oe}from"./session-CngLvd02.js";import{t as se}from"./upload-DPLDQsRT.js";import{t as _}from"./logo-CGNoptDg.js";import{n as v,s as y}from"./i18n-BYeH2Dmi.js";import{tt as ce}from"./index-C0yASttP.js";var b=new Set([`gmail.com`,`googlemail.com`,`gmx.at`,`gmx.de`,`gmx.net`,`web.de`,`outlook.com`,`hotmail.com`,`live.com`,`icloud.com`,`me.com`,`yahoo.com`,`yahoo.de`,`aon.at`,`a1.net`,`chello.at`,`t-online.de`,`proton.me`,`protonmail.com`]),le={website:`Website`,blog:`Blog`,linkedin:`LinkedIn`,instagram:`Instagram`,facebook:`Facebook`,youtube:`YouTube`,x:`X`,xing:`XING`,tiktok:`TikTok`},ue=[[`linkedin`,/(^|\.)linkedin\.com$/],[`instagram`,/(^|\.)instagram\.com$/],[`facebook`,/(^|\.)(facebook|fb)\.com$/],[`youtube`,/(^|\.)(youtube\.com|youtu\.be)$/],[`x`,/(^|\.)(x|twitter)\.com$/],[`xing`,/(^|\.)xing\.com$/],[`tiktok`,/(^|\.)tiktok\.com$/]];function x(e){let t=e.trim();if(!t||/\s/.test(t))return null;try{let e=new URL(/^https?:\/\//i.test(t)?t:`https://${t}`);return e.hostname.includes(`.`)?e.href:null}catch{return null}}function de(e){let t=x(e);if(!t)return`website`;let{hostname:n,pathname:r}=new URL(t),i=n.toLowerCase().replace(/^www\./,``);for(let[e,t]of ue)if(t.test(i))return e;return/^blog\./.test(i)||/^\/blog(\/|$)/.test(r)||/(^|\.)(medium|substack)\.com$/.test(i)?`blog`:`website`}var S=[{id:`bakeries`,industry:`gastronomy`,name:{de:`Bäckereien`,en:`Bakeries`},words:[`bäckerei`,`bäcker`,`backstube`,`brot`,`gebäck`,`konditorei`,`bakery`,`bread`,`pastry`]},{id:`cafes`,industry:`gastronomy`,name:{de:`Cafés`,en:`Cafés`},words:[`café`,`cafe`,`kaffeehaus`,`kaffee`,`coffee`,`espresso`]},{id:`restaurants`,industry:`gastronomy`,name:{de:`Restaurants`,en:`Restaurants`},words:[`restaurant`,`gasthaus`,`gasthof`,`wirtshaus`,`pizzeria`,`küche`,`speisekarte`,`menu`,`bistro`]},{id:`hotels`,industry:`hospitality`,name:{de:`Hotels und Pensionen`,en:`Hotels and guesthouses`},words:[`hotel`,`pension`,`zimmer`,`übernachtung`,`ferienwohnung`,`guesthouse`,`booking`,`rooms`]},{id:`architects`,industry:`professional`,name:{de:`Architekturbüros`,en:`Architects`},words:[`architekt`,`architektur`,`planung`,`entwurf`,`architect`,`architecture`]},{id:`lawFirms`,industry:`professional`,name:{de:`Kanzleien`,en:`Law firms`},words:[`rechtsanwalt`,`anwalt`,`kanzlei`,`recht`,`notar`,`law firm`,`lawyer`,`attorney`,`legal`]},{id:`taxAdvisors`,industry:`professional`,name:{de:`Steuerberatung`,en:`Tax advisors`},words:[`steuerberatung`,`steuerberater`,`steuer`,`buchhaltung`,`lohnverrechnung`,`bilanz`,`tax`,`accounting`,`bookkeeping`]},{id:`consultants`,industry:`professional`,name:{de:`Beratung`,en:`Consultants`},words:[`beratung`,`berater`,`consulting`,`coaching`,`consultant`]},{id:`physiotherapy`,industry:`health`,name:{de:`Physiotherapie`,en:`Physiotherapy`},words:[`physiotherapie`,`physio`,`massage`,`therapie`,`physiotherapy`]},{id:`practices`,industry:`health`,name:{de:`Arztpraxen`,en:`Doctors’ practices`},words:[`arzt`,`ärztin`,`praxis`,`ordination`,`zahnarzt`,`doctor`,`clinic`,`dentist`]},{id:`hairdressers`,industry:`retail`,name:{de:`Friseur und Kosmetik`,en:`Hair and beauty`},words:[`friseur`,`frisör`,`kosmetik`,`nagelstudio`,`beauty`,`hairdresser`,`salon`]},{id:`joiners`,industry:`trades`,name:{de:`Tischlereien`,en:`Joiners`},words:[`tischlerei`,`tischler`,`schreiner`,`möbel`,`holz`,`joinery`,`carpenter`,`furniture`]},{id:`electricians`,industry:`trades`,name:{de:`Elektrotechnik`,en:`Electricians`},words:[`elektriker`,`elektro`,`elektrotechnik`,`photovoltaik`,`electrician`,`electrical`]},{id:`plumbing`,industry:`trades`,name:{de:`Installateure`,en:`Plumbing and heating`},words:[`installateur`,`sanitär`,`heizung`,`klima`,`plumber`,`plumbing`,`heating`]},{id:`windows`,industry:`trades`,name:{de:`Fensterbau`,en:`Window makers`},words:[`fenster`,`türen`,`fensterbau`,`sonnenschutz`,`windows`,`doors`]},{id:`construction`,industry:`trades`,name:{de:`Bau und Handwerk`,en:`Building and trades`},words:[`bau`,`baumeister`,`maler`,`dachdecker`,`handwerk`,`construction`,`builder`,`painter`,`roofer`]},{id:`realEstate`,industry:`realEstate`,name:{de:`Immobilien`,en:`Real estate`},words:[`immobilien`,`makler`,`wohnung`,`miete`,`hausverwaltung`,`real estate`,`property`,`estate agent`]},{id:`onlineShops`,industry:`retail`,name:{de:`Online-Shops`,en:`Online shops`},words:[`online-shop`,`onlineshop`,`shop`,`versand`,`e-commerce`,`webshop`,`online store`]},{id:`retail`,industry:`retail`,name:{de:`Handel`,en:`Retail`},words:[`geschäft`,`handel`,`laden`,`boutique`,`retail`,`store`]},{id:`agencies`,industry:`agency`,name:{de:`Agenturen`,en:`Agencies`},words:[`agentur`,`werbung`,`marketing`,`design`,`kommunikation`,`agency`,`advertising`,`branding`]},{id:`photographers`,industry:`agency`,name:{de:`Fotografie`,en:`Photographers`},words:[`fotograf`,`fotografie`,`foto`,`photographer`,`photography`]},{id:`events`,industry:`events`,name:{de:`Veranstaltungen`,en:`Events`},words:[`event`,`veranstaltung`,`hochzeit`,`catering`,`konferenz`,`wedding`,`conference`]},{id:`itServices`,industry:`professional`,name:{de:`IT-Dienstleister`,en:`IT services`},words:[`it-dienstleister`,`it-service`,`software`,`webentwicklung`,`hosting`,`netzwerk`,`development`,`web design`]},{id:`cleaning`,industry:`trades`,name:{de:`Reinigung`,en:`Cleaning`},words:[`reinigung`,`gebäudereinigung`,`putz`,`cleaning`,`janitorial`]},{id:`footballClubs`,industry:`any`,name:{de:`Fußballvereine`,en:`Football clubs`},words:[`fußball`,`fussball`,`fc`,`sv`,`kicker`,`football`,`soccer`]},{id:`sportsClubs`,industry:`any`,name:{de:`Sportvereine`,en:`Sports clubs`},words:[`sportverein`,`verein`,`turnen`,`tennis`,`laufen`,`sport`,`club`]},{id:`musicClubs`,industry:`events`,name:{de:`Musikvereine und Chöre`,en:`Music clubs and choirs`},words:[`musikverein`,`blasmusik`,`chor`,`kapelle`,`orchester`,`band`,`choir`,`music`]},{id:`fireBrigades`,industry:`publicSector`,name:{de:`Feuerwehren`,en:`Fire brigades`},words:[`feuerwehr`,`rettung`,`rotes kreuz`,`fire brigade`,`rescue`]},{id:`schools`,industry:`publicSector`,name:{de:`Schulen und Bildung`,en:`Schools and education`},words:[`schule`,`kurs`,`weiterbildung`,`akademie`,`nachhilfe`,`school`,`course`,`training`]},{id:`municipalities`,industry:`publicSector`,name:{de:`Gemeinden`,en:`Municipalities`},words:[`gemeinde`,`stadt`,`bürgerservice`,`amt`,`municipality`,`council`,`town`]},{id:`associations`,industry:`any`,name:{de:`Vereine und Initiativen`,en:`Associations`},words:[`verein`,`initiative`,`ehrenamt`,`verband`,`association`,`nonprofit`,`charity`]}],C=e=>S.find(t=>t.id===e)??null;function fe(e,t=3){let n=` ${e.toLowerCase().normalize(`NFC`).replace(/[^\p{L}\p{N}-]+/gu,` `)} `;return S.map(e=>({id:e.id,score:e.words.reduce((e,t)=>e+(n.includes(` ${t}`)?Math.min(3,t.length/4):0),0)})).filter(e=>e.score>0).sort((e,t)=>t.score-e.score).slice(0,t).map(e=>e.id)}var w=e(t(),1),T=e(n(),1),pe=`oklch(50% 0.2 262)`,E=`oklch(32% 0.15 262)`,D=`oklch(90% 0.1 80)`,me={"--on":`white`,"--dot":D,"--ink-2":`oklch(96% 0.02 262)`,"--ink-3":`oklch(90% 0.035 262)`,"--moss":`oklch(90% 0.14 150)`,"--rose":`oklch(89% 0.09 45)`},O={kind:1,organization:1,site:2,details:3,know:4,space:5},he=e=>e!==null&&Object.hasOwn(O,e),ge=`w-full rounded-[18px] border border-white/30 bg-white/15 px-6 py-5 text-[1.375rem] text-white outline-none placeholder:text-white/55 focus:border-white/60`;function _e(){return(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-2.5`,children:[(0,T.jsx)(_,{size:28}),(0,T.jsxs)(`span`,{className:`font-display font-semibold text-[1.0625rem] tracking-tight`,children:[`engenty`,(0,T.jsx)(`span`,{className:`mr-[0.09em] ml-[0.06em] text-(color:--dot)`,children:`.`}),(0,T.jsx)(`span`,{className:`font-normal text-white/70`,children:`wizards`})]})]})}function k({children:e,busy:t,onClick:n,type:r=`button`}){return(0,T.jsxs)(`button`,{type:r,disabled:t,onClick:n,className:`inline-flex h-13 cursor-pointer items-center gap-2.5 rounded-full bg-white px-7 font-semibold text-[1rem] transition hover:bg-white/90 disabled:cursor-default disabled:opacity-70`,style:{color:E},children:[e,(0,T.jsx)(d,{className:`size-[18px]`})]})}function A({children:e,onClick:t}){return(0,T.jsx)(`button`,{type:`button`,onClick:t,className:`cursor-pointer font-semibold text-[0.9375rem] text-white/85 transition hover:text-white`,children:e})}function j({step:e,total:t=4}){return(0,T.jsx)(`span`,{className:`ml-auto inline-flex gap-1.5`,role:`img`,"aria-label":y(`onboard.step`,{n:e,total:t}),children:Array.from({length:t},(e,t)=>t+1).map(t=>(0,T.jsx)(`span`,{className:u(`size-2 rounded-full`,t===e?`bg-white`:`bg-white/40`)},t))})}var ve=[{kind:`personal`,label:`onboard.kindPersonal`,sub:`onboard.kindPersonalSub`},{kind:`club`,label:`onboard.kindClub`,sub:`onboard.kindClubSub`},{kind:`small`,label:`onboard.kindSmall`,sub:`onboard.kindSmallSub`},{kind:`corp`,label:`onboard.kindCorp`,sub:`onboard.kindCorpSub`}];function ye(e){let t=(e.split(`@`)[1]??``).trim().toLowerCase();return t?b.has(t)?{kind:`personal`,domain:t}:/(verein|club|klub|^sv-|^fc-|^ff-|feuerwehr|musik|chor)/.test(t)?{kind:`club`,domain:t}:{kind:`small`,domain:t}:{kind:null,domain:t}}var be={club:[`0-50`,`50-250`,`250-1000`,`1000+`],small:[`1`,`2-9`,`10-49`],corp:[`50-249`,`250-999`,`1000+`]},M=e=>Number(e).toLocaleString(v),xe=e=>{if(e===`1`)return y(`onboard.justMe`);if(e.endsWith(`+`))return`${M(e.slice(0,-1))}+`;let[t,n]=e.split(`-`);return t===`0`?`≤ ${M(n)}`:`${M(t)}–${M(n)}`},Se=[`sport`,`culture`,`social`,`education`,`environment`,`rescue`,`other`],Ce=[`chair`,`board`,`treasurer`,`secretary`,`member`],we=[`management`,`it`,`marketing`,`sales`,`operations`,`other`],Te=`w-full rounded-[14px] border border-white/30 bg-white/15 px-4 py-3 text-[1.0625rem] text-white outline-none placeholder:text-white/55 focus:border-white/60`;function Ee({picked:e,label:t,sub:n,onClick:r}){return(0,T.jsxs)(`button`,{type:`button`,"aria-pressed":e,onClick:r,className:u(`flex cursor-pointer flex-col gap-1 rounded-[18px] border px-5 py-4 text-left transition`,e?`border-white bg-white/25`:`border-white/30 bg-white/10 hover:bg-white/15`),children:[(0,T.jsx)(`span`,{className:`font-display font-semibold text-[1.125rem]`,children:t}),(0,T.jsx)(`span`,{className:`text-[0.875rem] text-white/80`,children:n})]})}function N({label:e,options:t,value:n,text:r,onChange:i}){return(0,T.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,T.jsx)(`legend`,{className:`mb-2 text-[0.9375rem] text-white/85`,children:e}),(0,T.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>(0,T.jsx)(`button`,{type:`button`,"aria-pressed":n===e,onClick:()=>i(e),className:u(`cursor-pointer rounded-full border px-4 py-2 text-[0.9375rem] transition`,n===e?`border-white bg-white`:`border-white/30 hover:bg-white/15`),style:n===e?{color:E}:void 0,children:r(e)},e))})]})}function P(e,t,n){let r=`${De}${e}:${t}`,[i,a]=(0,w.useState)(()=>{try{let e=sessionStorage.getItem(r);return e===null?n:JSON.parse(e)}catch{return n}});return(0,w.useEffect)(()=>{try{sessionStorage.setItem(r,JSON.stringify(i))}catch{}},[r,i]),[i,a]}var De=`wizards.onboarding:`;function Oe(){try{for(let e of Object.keys(sessionStorage))e.startsWith(De)&&sessionStorage.removeItem(e)}catch{}}function F(){return g(pe),ie().data?.onboarding===`welcome`?(0,T.jsx)(Me,{}):(0,T.jsx)(I,{})}function I(){let e=ie(),t=a(),n=ee(),{project:c}=re(),l=e.data?.user.id??``,d=e.data?.onboarding===`organization`,f=d?4:5,m=e.data?.startingName?null:e.data?.tenant.name??null,[h,g]=P(l,`organization`,``),[_,b]=P(l,`line`,null),[ue,S]=P(l,`ticked`,null),[C,O]=P(l,`own`,[``]),[M,De]=(0,w.useState)(null),[F,I]=(0,w.useState)([]),Me=(0,w.useRef)(null),[Pe]=(0,w.useState)(ae),[B]=(0,w.useState)(()=>d?{kind:null,domain:``}:ye(e.data?.user.email??``)),[V,Fe]=P(l,`profile`,{kind:B.kind,size:null,sector:``,role:null,need:``,questions:``,phone:``}),[Ie,Le]=te(),H=Ie.get(`page`),U=he(H)&&(H===`kind`||V.kind)&&!(d&&H===`space`)?H:`kind`,W=e=>Le(t=>{let n=new URLSearchParams(t);return n.set(`page`,e),n}),G=e=>Fe(t=>({...t,...e})),K=V.kind===`personal`,q=m??(h.trim()||null),J=ne({queryKey:[`onboarding`,`suggest`],queryFn:()=>r.get(`/api/studio/onboarding/suggest`),enabled:!d&&!m&&!!V.kind&&!K,staleTime:1/0}).data?.site??null;(0,w.useEffect)(()=>{J&&!h&&g(J.name)},[J,h,g]);let Re=ne({queryKey:[`onboarding`,`find`,q],queryFn:()=>r.post(`/api/studio/onboarding/find`,{name:q,lang:v}),enabled:U===`site`&&!K&&!!q,staleTime:1/0}),Y=Re.data?.addresses??[],X=ue??Y.filter((e,t)=>e.kind!==`website`||!Y.slice(0,t).some(e=>e.kind===`website`)).map(e=>e.url),ze=C.map(e=>e.trim()).filter(e=>x(e)),Z=[...X,...ze],Be=!K&&Re.isSuccess&&Y.length===0,[Ve,He]=P(l,`anyway`,!1),Ue=_!==null||Be&&!ze.length&&!Ve,We=p({mutationFn:()=>r.put(`/api/studio/organization/profile`,{kind:V.kind,size:V.size,sector:V.sector.trim()||null,role:V.role,need:V.need.trim()||null,questions:(V.questions??``).trim()||null,phone:V.phone.trim()||null,website:Z.find(e=>de(e)===`website`)??null,links:Z})}),Ge=p({mutationFn:e=>r.put(`/api/studio/organization`,{name:e})}),Ke=()=>{W(`site`),t.invalidateQueries({queryKey:[`organization`]}),t.invalidateQueries({queryKey:[`me`]})},Q=p({mutationFn:e=>r.post(`/api/studio/projects/${c?.id}/website`,{urls:e,lang:v}),onSuccess:async e=>{let n=e?.sectors?.[0];n&&Fe(e=>e.sector?e:{...e,sector:n}),De(e??{name:``,about:!1,colors:0,fonts:0,logo:!1,facts:0,assets:0}),await t.invalidateQueries({queryKey:s.spaces()})}}),qe=p({mutationFn:e=>r.patch(`/api/studio/projects/${c?.id}`,{brand:{about:e}}),onSuccess:()=>t.invalidateQueries({queryKey:s.spaces()})}),$=p({mutationFn:()=>r.post(`/api/studio/onboarding/done`),onSuccess:async()=>{Oe(),await t.invalidateQueries({queryKey:[`me`]}),n(`/new`,{replace:!0})}}),Je=e.data?.user.name??``,Ye=Je.includes(`@`)?``:Je.split(` `)[0],Xe=d&&m?y(`onboard.kickerNew`,{organization:m}):Ye?y(`onboard.kicker1`,{name:Ye}):y(`onboard.kicker1Anon`),Ze=(e,t)=>q&&!K?y(e,{organization:q}):y(t),Qe=async e=>{if(e&&c){for(let t of Array.from(e)){I(e=>[...e,{name:t.name,state:`uploading`}]);try{await r.upload(`/api/studio/projects/${c.id}/files?kind=document`,t),I(e=>e.map(e=>e.name===t.name?{...e,state:`done`}:e))}catch{I(e=>e.map(e=>e.name===t.name?{...e,state:`failed`}:e))}}await t.invalidateQueries({queryKey:s.spaces()})}},$e=M?[M.about?y(`onboard.readAbout`):``,M.colors?y(`onboard.readColors`,{n:M.colors}):``,M.fonts?y(`onboard.readFonts`,{n:M.fonts}):``,M.logo?y(`onboard.readLogo`):``,M.facts?y(`onboard.readFacts`,{n:M.facts}):``,M.assets?y(`onboard.readAssets`,{n:M.assets}):``].join(``):``,et=[...new Set([...M?.sectors??[],...fe(`${q??``} ${_??``} ${V.questions??``}`,4)])].slice(0,4),tt=e=>`${window.location.host}/studio/${je(e)}`;return(0,T.jsxs)(`div`,{className:`flex min-h-dvh flex-col px-6 text-white sm:px-10`,style:{...me,background:pe},children:[(0,T.jsxs)(`header`,{className:`flex items-center justify-between pt-6 sm:pt-8`,children:[(0,T.jsx)(_e,{}),(0,T.jsx)(ce,{tone:`ground`,ink:E})]}),(0,T.jsxs)(`main`,{className:`mx-auto grid w-full max-w-6xl flex-1 items-center gap-10 py-10 lg:grid-cols-[5fr_7fr] lg:gap-12`,children:[(0,T.jsxs)(`div`,{className:`flex flex-col items-center gap-8 max-lg:order-first`,children:[(0,T.jsx)(oe,{kind:`drop`,size:240,fluffy:!0,coat:`fur`}),Pe?(0,T.jsxs)(`figure`,{className:`w-full max-w-sm rounded-[18px] bg-white/15 px-5 py-4`,children:[(0,T.jsx)(`figcaption`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:y(`onboard.wish`)}),(0,T.jsx)(`blockquote`,{className:`mt-1.5 line-clamp-6 whitespace-pre-line break-words text-[1rem] leading-relaxed`,children:Pe}),(0,T.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-white/75`,children:y(`onboard.wishNext`)})]}):null]}),(0,T.jsxs)(`div`,{className:`flex min-w-0 max-w-2xl animate-rise flex-col gap-5`,children:[U===`kind`?(0,T.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault(),V.kind&&W(V.kind===`personal`||m?`site`:`organization`)},children:[(0,T.jsx)(L,{children:Xe}),(0,T.jsx)(R,{children:y(`onboard.kind`)}),(0,T.jsx)(z,{children:d&&m?y(`onboard.kindSubOrganization`,{organization:m}):y(`onboard.kindSub`)}),B.kind?(0,T.jsx)(`p`,{className:`text-[0.9375rem] text-white/80`,children:y(`onboard.guess`,{domain:B.domain,kind:y(ve.find(e=>e.kind===B.kind)?.label??`onboard.kindSmall`)})}):null,(0,T.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:ve.map(e=>(0,T.jsx)(Ee,{picked:V.kind===e.kind,label:y(e.label),sub:y(e.sub),onClick:()=>G({kind:e.kind,size:e.kind===V.kind?V.size:null})},e.kind))}),(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,T.jsx)(k,{type:`submit`,children:y(`onboard.continue`)}),(0,T.jsx)(j,{step:1,total:f})]})]}):null,U===`organization`?(0,T.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault();let t=h.trim();t?Ge.mutate(t,{onSuccess:Ke}):W(`site`)},children:[(0,T.jsx)(L,{children:Xe}),(0,T.jsx)(R,{children:y(`onboard.organization`)}),(0,T.jsx)(z,{children:y(`onboard.organizationSub`)}),(0,T.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:y(`onboard.organizationPlaceholder`),maxLength:80,"aria-label":y(`onboard.organization`),className:ge}),h.trim()?(0,T.jsxs)(`p`,{className:`-mt-2 text-[0.9375rem] text-white/85`,children:[J&&h===J.name?`${y(`onboard.nameFrom`,{domain:new URL(J.url).host})} `:``,y(`onboard.address`),` `,(0,T.jsx)(`span`,{className:`font-mono text-[0.875rem]`,style:{color:D},children:tt(h)})]}):null,(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,T.jsx)(k,{type:`submit`,busy:Ge.isPending,children:y(`onboard.continue`)}),(0,T.jsx)(j,{step:1,total:f})]})]}):null,U===`site`?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(L,{children:K?y(`onboard.kicker2Personal`):Ze(`onboard.kicker2Named`,`onboard.kicker2`)}),(0,T.jsx)(R,{children:K?y(`onboard.linksPersonal`):Be&&!Ve&&q?y(`onboard.noneFound`,{name:q}):q?y(`onboard.siteNamed`,{organization:q}):y(`onboard.site`)}),(0,T.jsx)(z,{children:K?y(`onboard.linksPersonalSub`):Be&&!Ve&&q?y(`onboard.noneFoundSub`,{name:q}):Re.isPending?y(`onboard.searching`,{name:q??``}):y(`onboard.foundSub`)}),Ue?(0,T.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault();let t=(_??``).trim();t?qe.mutate(t,{onSuccess:()=>W(`details`)}):W(`details`)},children:[(0,T.jsx)(ke,{value:_??``,onChange:b,rows:4,label:y(`onboard.line`),placeholder:y(K?`onboard.linePlaceholderPersonal`:`onboard.linePlaceholder`)}),(0,T.jsxs)(`button`,{type:`button`,onClick:()=>{b(null),He(!0),O(e=>e.length?e:[``])},className:`-mt-1 cursor-pointer self-start font-semibold text-[0.9375rem] text-white/85 hover:text-white`,children:[`+ `,y(`onboard.addressAfterAll`)]}),(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,T.jsx)(k,{type:`submit`,busy:qe.isPending,children:y(`onboard.continue`)}),(0,T.jsx)(A,{onClick:()=>W(`details`),children:y(`onboard.skip`)}),(0,T.jsx)(j,{step:2,total:f})]})]}):(0,T.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault(),M?W(`details`):Z.length&&!Q.isPending&&Q.mutate(Z)},children:[Y.length?(0,T.jsx)(`div`,{className:`flex flex-col gap-2`,children:Y.map(e=>(0,T.jsx)(Ae,{address:e,picked:X.includes(e.url),onToggle:()=>S(X.includes(e.url)?X.filter(t=>t!==e.url):[...X,e.url])},e.url))}):null,!K&&Y.length?(0,T.jsx)(`p`,{className:`-mb-2 text-[0.9375rem] text-white/85`,children:y(`onboard.own`)}):null,C.map((e,t)=>(0,T.jsxs)(`div`,{className:`relative`,children:[(0,T.jsx)(`input`,{value:e,onChange:e=>O(n=>n.map((n,r)=>r===t?e.target.value:n)),placeholder:y(K?`onboard.linkPlaceholderPersonal`:`onboard.ownPlaceholder`),autoCapitalize:`none`,"aria-label":y(`onboard.own`),className:u(Te,`pr-28`)}),x(e)?(0,T.jsx)(`span`,{className:`-translate-y-1/2 absolute top-1/2 right-3 rounded-full bg-white/20 px-2.5 py-0.5 font-semibold text-[0.75rem]`,children:le[de(e)]}):null]},t)),C.length+Y.length<10?(0,T.jsxs)(`button`,{type:`button`,onClick:()=>O(e=>[...e,``]),className:`-mt-1 cursor-pointer self-start font-semibold text-[0.9375rem] text-white/85 hover:text-white`,children:[`+ `,y(`onboard.addAddress`)]}):null,M?(0,T.jsxs)(`p`,{className:`flex items-center gap-2 text-[0.9375rem] text-(color:--moss)`,children:[(0,T.jsx)(o,{className:`size-4`}),M.name?y(`onboard.readDone`,{name:M.name,details:$e}):y(`onboard.readKept`,{n:Z.length})]}):Q.isError?(0,T.jsx)(`p`,{className:`text-[0.9375rem] text-(color:--rose)`,children:y(`onboard.readFailed`)}):null,(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[M?(0,T.jsx)(k,{type:`submit`,children:y(`onboard.continue`)}):(0,T.jsx)(k,{type:`submit`,busy:Q.isPending,children:Q.isPending?y(`onboard.reading`):y(`onboard.read`)}),(0,T.jsx)(A,{onClick:()=>b(``),children:y(`onboard.line`)}),(0,T.jsx)(A,{onClick:()=>W(`details`),children:y(`onboard.skip`)}),(0,T.jsx)(j,{step:2,total:f})]})]})]}):null,U===`details`&&V.kind?(0,T.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault(),We.mutate(),W(`know`)},children:[(0,T.jsx)(L,{children:K||!q?Xe:q}),(0,T.jsx)(R,{small:!0,children:K?y(`onboard.personalTitle`):q?y(`onboard.aboutOrganization`,{organization:q}):y(V.kind===`club`?`onboard.clubTitle`:`onboard.businessTitle`)}),K?(0,T.jsx)(ke,{value:V.need,onChange:e=>G({need:e}),rows:4,label:y(`onboard.personalTitle`),placeholder:y(`onboard.personalPlaceholder`)}):null,V.kind===`club`?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(N,{label:y(`onboard.clubKind`),options:Se,value:V.sector,text:e=>y(`onboard.club.${e}`),onChange:e=>G({sector:e})}),(0,T.jsx)(N,{label:y(`onboard.members`),options:be.club,value:V.size,text:xe,onChange:e=>G({size:e})}),(0,T.jsx)(N,{label:y(`onboard.yourRole`),options:Ce,value:V.role,text:e=>y(`onboard.role.${e}`),onChange:e=>G({role:e})})]}):null,V.kind===`small`?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(N,{label:y(`onboard.people`),options:be.small,value:V.size,text:xe,onChange:e=>G({size:e})}),(0,T.jsx)(Ne,{value:V.sector,onChange:e=>G({sector:e}),suggested:et})]}):null,V.kind===`corp`?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(N,{label:y(`onboard.people`),options:be.corp,value:V.size,text:xe,onChange:e=>G({size:e})}),(0,T.jsx)(Ne,{value:V.sector,onChange:e=>G({sector:e}),suggested:et}),(0,T.jsx)(N,{label:y(`onboard.yourRole`),options:we,value:V.role,text:e=>y(`onboard.role.${e}`),onChange:e=>G({role:e})}),(0,T.jsxs)(`label`,{className:`flex flex-col gap-2 text-[0.9375rem] text-white/85`,children:[(0,T.jsxs)(`span`,{children:[y(`onboard.phone`),` `,(0,T.jsx)(`span`,{className:`text-white/60`,children:y(`onboard.phoneWhy`)})]}),(0,T.jsx)(`input`,{type:`tel`,value:V.phone,onChange:e=>G({phone:e.target.value.replace(/[^+0-9 ()/.-]/g,``)}),placeholder:`+43 …`,maxLength:40,autoComplete:`tel`,className:Te})]})]}):null,K?null:(0,T.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,T.jsxs)(`span`,{className:`text-[0.9375rem] text-white/85`,children:[y(`onboard.questions`),` `,(0,T.jsx)(`span`,{className:`text-white/60`,children:y(`onboard.optional`)})]}),(0,T.jsx)(ke,{value:V.questions??``,onChange:e=>G({questions:e}),rows:3,label:y(`onboard.questions`),placeholder:y(`onboard.questionsPlaceholder`)}),(0,T.jsx)(`span`,{className:`text-[0.8125rem] text-white/70`,children:y(`onboard.questionsHint`)})]}),(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,T.jsx)(k,{type:`submit`,busy:We.isPending,children:y(`onboard.continue`)}),(0,T.jsx)(A,{onClick:()=>window.history.state?.idx>0?n(-1):W(`site`),children:y(`onboard.back`)}),(0,T.jsx)(j,{step:3,total:f})]})]}):null,U===`know`?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(L,{children:Ze(`onboard.kicker3Named`,`onboard.kicker3`)}),(0,T.jsx)(R,{children:y(`onboard.know`)}),(0,T.jsx)(z,{children:y(`onboard.knowSub`)}),(0,T.jsxs)(`button`,{type:`button`,onClick:()=>Me.current?.click(),onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),Qe(e.dataTransfer.files)},className:`flex cursor-pointer flex-col items-center gap-2 rounded-[18px] border-2 border-white/45 border-dashed bg-white/10 px-6 py-7 text-center transition hover:bg-white/15`,children:[(0,T.jsx)(se,{className:`size-7`}),(0,T.jsx)(`span`,{className:`font-semibold text-[1.0625rem]`,children:y(`onboard.drop`)}),(0,T.jsx)(`span`,{className:`text-[0.875rem] text-white/80`,children:`PDF · Word · Excel · Markdown`}),(0,T.jsx)(`input`,{ref:Me,type:`file`,multiple:!0,className:`sr-only`,onChange:e=>{Qe(e.target.files),e.target.value=``}})]}),F.length?(0,T.jsx)(`ul`,{className:`flex flex-col gap-2`,children:F.map(e=>(0,T.jsxs)(`li`,{className:`flex items-center gap-2.5 rounded-xl bg-white/15 px-3.5 py-2.5 text-[0.875rem]`,children:[(0,T.jsx)(i,{className:`size-4 shrink-0`}),(0,T.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,T.jsx)(`span`,{className:u(`text-white/80`,e.state===`failed`?`text-(color:--rose)`:``),children:e.state===`uploading`?y(`onboard.uploading`):e.state===`done`?y(`onboard.uploaded`):y(`onboard.uploadFailed`)})]},e.name))}):null,(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,T.jsx)(k,{busy:F.some(e=>e.state===`uploading`)||$.isPending,onClick:()=>d?$.mutate():W(`space`),children:y(d?`onboard.buildFirst`:`onboard.continue`)}),F.length||d?null:(0,T.jsx)(A,{onClick:()=>W(`space`),children:y(`onboard.skip`)}),(0,T.jsx)(j,{step:4,total:f})]})]}):null,U===`space`&&!d?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(L,{children:Ze(`onboard.kicker4Named`,`onboard.kicker4`)}),(0,T.jsx)(R,{children:q&&!K?y(`onboard.spaceNamed`,{organization:q}):y(`onboard.space`)}),(0,T.jsx)(z,{children:y(`onboard.spaceSub`,{space:c?.name??``})}),(0,T.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[[`partInfo`,`partInfoText`,!!(M||_)],[`partKnow`,`partKnowText`,F.some(e=>e.state===`done`)],[`partData`,`partDataText`,!1],[`partResults`,`partResultsText`,!1]].map(([e,t,n])=>(0,T.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-2xl border border-white/20 bg-white/10 px-4.5 py-4`,children:[(0,T.jsxs)(`span`,{className:`flex items-center gap-2 font-semibold text-[1rem]`,children:[n?(0,T.jsx)(o,{className:`size-4 text-(color:--moss)`}):null,y(`onboard.${e}`)]}),(0,T.jsx)(`span`,{className:`text-[0.84375rem] text-white/85 leading-snug`,children:y(`onboard.${t}`)})]},e))}),(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,T.jsx)(k,{busy:$.isPending,onClick:()=>$.mutate(),children:y(`onboard.build`)}),(0,T.jsx)(j,{step:5,total:f})]})]}):null]},U)]}),(0,T.jsxs)(`footer`,{className:`mx-auto flex w-full max-w-6xl items-center justify-between pb-6 text-[0.75rem] text-white/55 sm:pb-8`,children:[(0,T.jsx)(`span`,{children:`engenty.wizards`}),(0,T.jsx)(`span`,{"aria-hidden":`true`,className:`size-[3px] bg-(color:--dot)`})]})]})}function L({children:e}){return(0,T.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:e})}function R({children:e,small:t}){return(0,T.jsx)(`h1`,{className:u(`font-display font-bold leading-[1.05] tracking-[-0.02em]`,t?`text-[2.25rem] sm:text-[2.75rem]`:`text-[2.5rem] sm:text-[3.25rem]`),children:e})}function z({children:e}){return(0,T.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:e})}function ke({value:e,onChange:t,rows:n,label:r,placeholder:i}){let[a]=f(),o=l(e,t,{deviceId:a.deviceId});return(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-[18px] border border-white/30 bg-white/15 px-4 pt-3 pb-3 focus-within:border-white/60`,children:[(0,T.jsx)(`textarea`,{value:e,onChange:e=>t(e.target.value),placeholder:o.listening?y(`editor.listening`):i,rows:n,maxLength:4e3,"aria-label":r,className:`w-full resize-none bg-transparent text-[1.0625rem] text-white leading-relaxed outline-none placeholder:text-white/55`}),o.supported?(0,T.jsx)(`div`,{className:`self-end`,style:{"--ink":`white`,"--border":`rgb(255 255 255 / 0.55)`},children:(0,T.jsx)(c,{speech:o,labelled:!0})}):null]})}function Ae({address:e,picked:t,onToggle:n}){return(0,T.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:n,className:u(`flex cursor-pointer items-center gap-3.5 rounded-[14px] border px-4 py-2.5 text-left transition`,t?`border-white bg-white/22`:`border-white/30 bg-white/8 hover:bg-white/12`),children:[(0,T.jsx)(`span`,{className:u(`flex size-5 shrink-0 items-center justify-center rounded-md border-2`,t?`border-white bg-white`:`border-white/60`),style:t?{color:E}:void 0,children:t?(0,T.jsx)(o,{className:`size-3.5`,strokeWidth:3}):null}),(0,T.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,T.jsx)(`span`,{className:`font-semibold text-[0.6875rem] text-white/70 uppercase tracking-[0.1em]`,children:le[e.kind]}),(0,T.jsx)(`span`,{className:`truncate font-mono text-[0.9375rem]`,children:e.url.replace(/^https?:\/\/(www\.)?/,``).replace(/\/$/,``)}),(0,T.jsx)(`span`,{className:`truncate text-[0.8125rem] text-white/80`,children:e.title})]}),(0,T.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-white/70 max-sm:hidden`,children:y(e.source===`email`?`onboard.fromEmail`:`onboard.fromWeb`)})]})}function je(e){return e.toLowerCase().replace(/['’]/g,``).replace(/ä/g,`ae`).replace(/ö/g,`oe`).replace(/ü/g,`ue`).replace(/ß/g,`ss`).normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,35).replace(/-+$/,``)}function Me(){let e=ie(),t=a(),n=ee(),i=h(),o=e.data?.tenant,s=ne({queryKey:[`organization`,o?.id],queryFn:()=>r.get(`/api/studio/organization`),enabled:!!o}),c=p({mutationFn:()=>r.post(`/api/studio/onboarding/done`),onSuccess:async()=>{await t.invalidateQueries({queryKey:[`me`]}),n(`/`,{replace:!0})}});if(!(e.data&&o))return null;let l=o.name??``,u=e.data.user.name,te=u.includes(`@`)?``:u.split(` `)[0],d=e.data.organizations.find(e=>e.id===o.id)?.invitedBy?.name,f=s.data?.members.find(t=>t.role===`owner`&&t.userId!==e.data?.user.id)?.name,re=o.role!==`member`,ae=o.slug?`${window.location.host}/studio/${o.slug}`:null;return(0,T.jsxs)(`div`,{className:`flex min-h-dvh flex-col px-6 text-white sm:px-10`,style:{...me,background:pe},children:[(0,T.jsxs)(`header`,{className:`flex items-center justify-between pt-6 sm:pt-8`,children:[(0,T.jsx)(_e,{}),(0,T.jsx)(ce,{tone:`ground`,ink:E})]}),(0,T.jsxs)(`main`,{className:`mx-auto grid w-full max-w-6xl flex-1 items-center gap-10 py-10 lg:grid-cols-[5fr_7fr] lg:gap-12`,children:[(0,T.jsx)(`div`,{className:`flex flex-col items-center gap-8 max-lg:order-first`,children:(0,T.jsx)(oe,{kind:`drop`,size:240,fluffy:!0,coat:`fur`})}),(0,T.jsxs)(`div`,{className:`flex min-w-0 max-w-2xl animate-rise flex-col gap-5`,children:[(0,T.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:te?y(`onboard.kicker1`,{name:te}):y(`onboard.kicker1Anon`)}),(0,T.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:y(`welcome.title`,{organization:l})}),(0,T.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:d?y(`welcome.invited`,{name:d}):f?y(`welcome.setUp`,{name:f,organization:l}):y(`welcome.plain`)}),(0,T.jsxs)(`div`,{className:`overflow-hidden rounded-[18px] bg-white/12 ring-1 ring-white/20`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-3.5 px-4.5 py-3.5`,children:[(0,T.jsx)(`span`,{className:`flex size-11 shrink-0 items-center justify-center rounded-xl font-bold font-display`,style:{background:D,color:E},children:m(l)}),(0,T.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,T.jsx)(`span`,{className:`truncate font-semibold text-[1.0625rem]`,children:l}),ae?(0,T.jsx)(`span`,{className:`truncate font-mono text-[0.8125rem] text-white/75`,children:ae}):null]}),(0,T.jsx)(`span`,{className:`rounded-full bg-white/20 px-2.5 py-1 font-semibold text-[0.75rem]`,children:y(`organization.role.${o.role}`)})]}),i.data?.some(e=>e.wizardCount>0)?i.data.map(e=>(0,T.jsxs)(`div`,{className:`flex justify-between gap-3 border-white/15 border-t px-4.5 py-2.5 text-[0.9375rem]`,children:[(0,T.jsx)(`span`,{className:`truncate`,children:e.name}),(0,T.jsx)(`span`,{className:`shrink-0 text-white/75`,children:y(`welcome.wizards`,{n:e.wizardCount})})]},e.id)):(0,T.jsx)(`p`,{className:`border-white/15 border-t px-4.5 py-3 text-[0.9375rem] text-white/80`,children:y(`welcome.noWizards`)})]}),(0,T.jsx)(`p`,{className:`text-[0.9375rem] text-white/80`,children:y(re?`welcome.canBuild`:`welcome.canMember`)}),(0,T.jsx)(`div`,{className:`flex flex-wrap items-center gap-5`,children:(0,T.jsx)(k,{busy:c.isPending,onClick:()=>c.mutate(),children:y(`welcome.go`)})})]})]})]})}function Ne({value:e,onChange:t,suggested:n}){let[r,i]=(0,w.useState)(!1),a=C(e),o=[...new Set([...a?[a.id]:[],...n])].slice(0,4),s=e=>C(e)?.name[v===`de`?`de`:`en`]??e;return(0,T.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,T.jsx)(`legend`,{className:`mb-2 text-[0.9375rem] text-white/85`,children:y(`onboard.sector`)}),(0,T.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[o.map(n=>(0,T.jsx)(`button`,{type:`button`,"aria-pressed":e===n,onClick:()=>t(n),className:u(`cursor-pointer rounded-full border px-4 py-2 text-[0.9375rem] transition`,e===n?`border-white bg-white`:`border-white/30 hover:bg-white/15`),style:e===n?{color:E}:void 0,children:s(n)},n)),(0,T.jsx)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>i(e=>!e),className:`cursor-pointer rounded-full border border-white/40 border-dashed px-4 py-2 text-[0.9375rem] hover:bg-white/15`,children:y(`onboard.sectorOther`)})]}),r?(0,T.jsxs)(`select`,{value:a?e:``,onChange:e=>{t(e.target.value),i(!1)},"aria-label":y(`onboard.sector`),className:u(Te,`[&>option]:text-black`),children:[(0,T.jsx)(`option`,{value:``,children:y(`onboard.sectorPick`)}),[...S].sort((e,t)=>s(e.id).localeCompare(s(t.id),v)).map(e=>(0,T.jsx)(`option`,{value:e.id,children:s(e.id)},e.id))]}):null,a?(0,T.jsxs)(`span`,{className:`text-[0.8125rem] text-white/75`,children:[y(`onboard.sectorHint`),` `,(0,T.jsx)(`b`,{style:{color:D},children:y(`onboard.catalog`,{sector:s(a.id)})})]}):null]})}export{F as OnboardingPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,A as i,An as a,B as o,C as s,Cn as c,D as l,Dn as u,E as d,G as f,Gt as p,H as m,I as h,In as g,Jt as _,Kn as v,Kt as y,L as b,M as x,Mn as S,Mr as C,N as w,Nn as T,O as E,On as D,P as O,Qn as k,R as ee,Rn as te,S as A,T as j,U as M,Un as N,V as P,W as ne,Wt as F,Xn as I,Xt as L,Yt as R,Zt as z,_ as B,_n as V,an as H,ar as re,b as ie,bn as U,d as W,en as ae,er as oe,f as se,g as ce,h as G,hn as le,in as ue,ir as de,j as fe,jn as pe,k as K,kn as me,m as he,nn as ge,on as q,or as _e,p as J,pn as ve,qt as ye,rn as be,rr as xe,sr as Se,tn as Ce,un as we,v as Te,w as Ee,x as De,y as Y,yn as Oe,yt as ke,z as Ae}from"./ui-Bhp_a_44.js";import{E as je,S as Me,_ as Ne,b as Pe,v as Fe,x as Ie}from"./Marketplace-CpjRqTvn.js";import{t as Le}from"./useMutation-Cmn8b7tT.js";import{I as Re,L as ze,P as Be,S as Ve,_ as He,a as Ue,b as We,c as Ge,d as Ke,f as qe,g as Je,h as Ye,i as Xe,l as Ze,m as Qe,o as $e,p as et,r as tt,s as nt,t as rt,u as it,v as at,x as ot,y as st}from"./PreviewPane-BgIEsVjy.js";import{b as ct,f as lt}from"./theme-DftQJmEW.js";import{d as ut,f as dt,g as ft,p as pt,x as mt}from"./session-CngLvd02.js";import{t as ht}from"./phone-JGS60FQU.js";import{n as gt,r as _t,t as vt}from"./ReadOnly-C3SYrBNk.js";import{t as yt}from"./upload-DPLDQsRT.js";import{lt as bt,n as xt,s as X}from"./i18n-BYeH2Dmi.js";import{At as St,Dt as Ct,Ht as wt,It as Tt,Lt as Et,Rt as Dt,bt as Ot,c as kt,d as At,f as jt,h as Mt,ht as Nt,it as Pt,jt as Ft,m as It,p as Lt,qt as Rt,rt as zt,s as Bt,u as Vt,v as Ht,y as Ut}from"./index-C0yASttP.js";import{a as Wt,c as Gt,f as Kt,i as qt,n as Jt,o as Yt,r as Xt,s as Zt,t as Qt,u as $t}from"./settings-menu-C0yo5q3t.js";var en={name:`blend`,size:24,node:[[`circle`,{cx:`15`,cy:`9`,r:`7`,key:`1i12rt`}],[`circle`,{cx:`9`,cy:`15`,r:`7`,key:`19bs8k`}]]};en.node;var tn=I(en),nn={name:`box`,size:24,node:[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]};nn.node;var rn=I(nn),an={name:`case-upper`,size:24,node:[[`path`,{d:`M15 11h4.5a1 1 0 0 1 0 5h-4a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h3a1 1 0 0 1 0 5`,key:`nxs35`}],[`path`,{d:`m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16`,key:`d5nyq2`}],[`path`,{d:`M3.304 13h6.392`,key:`1q3zxz`}]]};an.node;var on=I(an),sn={name:`folder-plus`,size:24,node:[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};sn.node;var cn=I(sn),ln={name:`grid-2x2`,size:24,node:[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]],aliases:[`grid-2-x-2`]};ln.node;var un=I(ln),dn={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]};dn.node;var fn=I(dn),pn={name:`list`,size:24,node:[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]};pn.node;var mn=I(pn),hn={name:`music`,size:24,node:[[`path`,{d:`M9 18V5l12-2v13`,key:`1jmyc2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]};hn.node;var gn=I(hn),_n={name:`tablet`,size:24,node:[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]};_n.node;var vn=I(_n),Z=e(t(),1),Q=e(n(),1),yn={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function bn({file:e,actions:t}){let[n,r]=(0,Z.useState)(e.description),i=(0,Z.useRef)(e.description),a=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{e.description!==i.current&&(r(t=>t===i.current?e.description:t),i.current=e.description)},[e.description]),(0,Z.useLayoutEffect)(()=>{let e=a.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[n]);let o=e.status===`pending`&&!n;return t.readOnly?n?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-snug`,children:n}):null:(0,Q.jsx)(`textarea`,{ref:a,rows:1,value:n,maxLength:600,placeholder:X(o?`project.describing`:`project.description`),onChange:e=>r(e.target.value),onBlur:()=>{n.trim()!==e.description&&(i.current=n.trim(),t.describe(e.id,n.trim()))},className:`-mx-1 block w-[calc(100%+0.5rem)] resize-none overflow-hidden rounded-md bg-transparent px-1 py-0.5 text-[0.8125rem] text-ink-2 leading-snug outline-none transition placeholder:text-ink-4 hover:bg-paper-2 focus:bg-card focus:text-ink focus:ring-1 focus:ring-border`})}function xn(e,t){confirm(X(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function Sn({projectId:e,file:t,small:n}){let r=Ae(e,t.id);if(t.mime.startsWith(`image/`))return(0,Q.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:q(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)});if(t.mime.startsWith(`video/`))return(0,Q.jsx)(`video`,{src:`${r}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`});if(t.mime.startsWith(`font/`))return(0,Q.jsx)(Cn,{src:r,small:n});let i=n?`size-5`:`size-7`;return(0,Q.jsxs)(`div`,{className:`flex size-full flex-col items-center justify-center gap-1.5 text-ink-3`,children:[t.mime.startsWith(`audio/`)?(0,Q.jsx)(gn,{className:i}):t.mime===`application/pdf`?(0,Q.jsx)(S,{className:i}):t.mime===`application/json`?(0,Q.jsx)(ve,{className:i}):t.mime.startsWith(`model/`)?(0,Q.jsx)(rn,{className:i}):(0,Q.jsx)(pe,{className:i}),n?null:(0,Q.jsx)(`span`,{className:`text-[0.6875rem] uppercase tracking-wide`,children:t.mime===`application/json`?`Lottie / JSON`:t.mime.split(`/`).pop()})]})}function Cn({src:e,small:t}){let[n,r]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let t=`asset-${e.split(`/`).slice(-2,-1)[0]}`;new FontFace(t,`url("${e}")`).load().then(e=>{document.fonts.add(e),r(t)}).catch(()=>r(null))},[e]),(0,Q.jsx)(`div`,{className:q(`flex size-full items-center justify-center text-ink`,t?`text-[1.25rem]`:`text-[2.75rem]`),style:n?{fontFamily:`"${n}"`}:void 0,children:`Aa`})}var wn=`application/x-wizards-logo`;function Tn({projectId:e,kind:t,files:n,actions:r,accept:i,addLabel:a,onUpload:o,onPreview:s,mainId:c,onMakeMain:l,moveTo:u,onRemove:d}){let f=e=>d?d(e):xn(e,r);return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(184px,1fr))] gap-3`,children:[n.map(n=>(0,Q.jsxs)(`div`,{draggable:u&&!r.readOnly?!0:void 0,onDragStart:e=>e.dataTransfer.setData(wn,n.id),className:`group relative flex flex-col gap-1.5 rounded-lg bg-paper p-2 pb-2.5 ring-1 ring-border-soft`,children:[n.id===c?(0,Q.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,Q.jsx)(y,{tone:`ember`,children:X(`project.logoMain`)})}):null,(0,Q.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?yn:void 0,children:[s&&n.mime.startsWith(`image/`)?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${X(`project.preview`)}: ${n.name}`,onClick:()=>s(n),className:`block size-full cursor-zoom-in`,children:(0,Q.jsx)(Sn,{projectId:e,file:n})}):(0,Q.jsx)(Sn,{projectId:e,file:n}),(0,Q.jsxs)(`div`,{className:`absolute top-1 right-1 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:[s?(0,Q.jsx)(R,{label:X(`project.preview`),onClick:()=>s(n),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(je,{className:`size-4`})}):null,l&&n.id!==c&&!r.readOnly?(0,Q.jsx)(R,{label:X(`project.logoMakeMain`),onClick:()=>l(n),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(Pe,{className:`size-4`})}):null,u&&!r.readOnly?(0,Q.jsx)(ce,{options:u.options,value:u.current(n),onChange:e=>u.onMove(n,e),className:`bg-card shadow-soft`}):null,r.readOnly?null:(0,Q.jsx)(R,{label:X(`project.remove`),onClick:()=>f(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,Q.jsx)(we,{className:`size-4`})})]})]}),t===`asset`?(0,Q.jsx)(`div`,{className:`truncate px-0.5 text-[0.75rem] text-ink-3`,title:n.name,children:n.name}):null,(0,Q.jsx)(bn,{file:n,actions:r})]},n.id)),a&&!r.readOnly?(0,Q.jsxs)(he,{accept:i,multiple:!1,onFiles:e=>o?o(e):r.upload(t,e),className:`min-h-28 flex-col p-3`,children:[r.busy?(0,Q.jsx)(Ce,{className:`size-5`}):(0,Q.jsx)(Oe,{className:`size-5`}),a]}):null]})}function En({kind:e,fetchUrl:t,onAdded:n,onClose:r}){let[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)([]),m=async()=>{s(!0),l(null);try{let a=await t(i.trim());a.file?(n([a.file]),r()):a.candidates?.length?(d(a.candidates),p([a.candidates[0].url])):l(X(e===`logo`?`project.logoNoneFound`:`project.assetNoneFound`))}catch(e){l(e.message)}s(!1)},h=async()=>{s(!0),l(null);let e=[];try{for(let n of f){let r=await t(n);r.file&&e.push(r.file)}}catch(e){l(e.message)}s(!1),e.length&&n(e),e.length===f.length&&r()};return(0,Q.jsx)(ye,{open:!0,onClose:r,wide:u?!0:void 0,title:X(u?e===`logo`?`project.logoFound`:`project.assetFound`:e===`logo`?`project.logoFromUrl`:`project.assetFromUrl`),children:u?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:X(e===`logo`?`project.logoFoundHint`:`project.assetFoundHint`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-3`,children:u.map(t=>{let n=f.includes(t.url);return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":n,title:t.hint,onClick:()=>p(e=>n?e.filter(e=>e!==t.url):[...e,t.url]),className:q(`relative h-28 overflow-hidden rounded-lg ring-1 transition`,n?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),style:yn,children:[(0,Q.jsx)(`img`,{src:t.url,alt:``,className:q(`size-full`,e===`logo`?`object-contain p-3`:`object-cover`)}),n?(0,Q.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(N,{className:`size-3.5`})}):null]},t.url)})}),c?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(F,{variant:`ghost`,onClick:()=>d(null),children:X(`run.back`)}),(0,Q.jsx)(F,{busy:o,disabled:!f.length,onClick:()=>void h(),children:f.length>1?X(`project.addMany`,{n:f.length}):X(`project.add`)})]})]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(z,{children:X(`project.logoUrl`)}),(0,Q.jsx)(L,{autoFocus:!0,value:i,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>a(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:X(e===`logo`?`project.logoUrlHint`:`project.assetUrlHint`)})]}),c?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(F,{variant:`ghost`,onClick:r,children:X(`common.cancel`)}),(0,Q.jsx)(F,{type:`submit`,busy:o,disabled:!i.trim(),children:X(`run.next`)})]})]})})}function Dn(e,t,n){return Se({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>f.get(`/api/studio/projects/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function On(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var kn=e=>[On(e),e.pages?X(`project.pages`,{n:e.pages}):null,bt(e.size)].filter(Boolean).join(` · `),An=2e5;function jn({projectId:e,fileId:t,readOnly:n,onGone:r}){let i=C(),a=M(e),o=Qe(e),s=P(e,n),c=a.data?.files.find(e=>e.id===t),l=c?c.mime===`application/pdf`||c.mime.startsWith(`image/`):!1,[u,d]=(0,Z.useState)(null);if(!c)return a.isLoading?(0,Q.jsx)(Ce,{className:`mx-auto text-ink-3`}):null;let f=u??(l?`original`:`text`),m=o.data?.items.find(e=>e.key===`f:${c.id}`),h=Ae(e,c.id),g=(e,t)=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":f===e,onClick:()=>d(e),className:q(`rounded-full px-3 py-1 text-[0.8125rem] transition`,f===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,Q.jsx)(`h2`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-lg`,children:c.name}),(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:kn(c)}),(0,Q.jsx)(`a`,{href:h,target:`_blank`,rel:`noreferrer`,"aria-label":X(`project.openOriginal`),title:X(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,Q.jsx)(T,{className:`size-4`})}),n?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(R,{label:X(`project.reindex`),onClick:async()=>{await s.reindex(c.id),await i.invalidateQueries({queryKey:ne.knowledge(e)})},children:(0,Q.jsx)(V,{className:`size-4`})}),(0,Q.jsx)(R,{label:X(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(X(`data.confirmDelete`,{title:c.name}))&&(await s.remove(c.id),await i.invalidateQueries({queryKey:ne.knowledge(e)}),r())},children:(0,Q.jsx)(we,{className:`size-4`})})]})]}),(0,Q.jsx)(qe,{projectId:e,itemKey:`f:${c.id}`,has:m?.categories??[],originLabel:m?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,Q.jsx)(`div`,{className:`px-1`,children:(0,Q.jsx)(bn,{file:c,actions:s})}),c.status===`failed`?(0,Q.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:c.error}):null,(0,Q.jsxs)(p,{className:`flex flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[l?g(`original`,X(`project.original`)):null,g(`text`,X(`project.readText`))]}),f===`original`?c.mime===`application/pdf`?(0,Q.jsx)(`iframe`,{src:h,title:c.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,Q.jsx)(`img`,{src:h,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,Q.jsx)(Mn,{projectId:e,file:c})]})]})}function Mn({projectId:e,file:t}){let n=Dn(e,t,An);return n.isLoading||t.status===`pending`?(0,Q.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,Q.jsx)(Ce,{})}):n.data?.text?(0,Q.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,Q.jsx)(ke,{text:n.data.text,className:`text-[0.875rem]`}),n.data.chars>n.data.text.length?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-3`,children:X(`project.textCut`,{shown:n.data.text.length.toLocaleString(xt),total:n.data.chars.toLocaleString(xt)})}):null]}):(0,Q.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:X(`project.noText`)})}var Nn=`image/*,video/*,audio/*,application/pdf,.pdf,.woff2,.woff,.ttf,.otf,.json,.glb,.gltf`,Pn=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),bt(e.size)].filter(Boolean).join(` · `);function Fn({projectId:e,file:t,actions:n,onClose:r}){let i=Ae(e,t.id);return(0,Q.jsxs)(ye,{open:!0,onClose:r,wide:`page`,title:t.name,children:[(0,Q.jsxs)(`div`,{className:`-mt-2 mb-4 flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:Pn(t)}),(0,Q.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":X(`project.openOriginal`),title:X(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,Q.jsx)(T,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,Q.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:yn,children:(0,Q.jsx)(`img`,{src:i,alt:``,className:`mx-auto max-h-[68dvh] object-contain`})}):t.mime.startsWith(`video/`)?(0,Q.jsx)(`video`,{src:i,controls:!0,className:`max-h-[68dvh] w-full rounded-lg bg-black`}):(0,Q.jsx)(`audio`,{src:i,controls:!0,className:`w-full`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsx)(bn,{file:t,actions:n})})]})}function In({projectId:e,file:t,actions:n,moveTo:r,onPreview:i,onRemove:a}){return(0,Q.jsxs)(`li`,{className:`group/row flex items-start gap-3 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${X(`project.preview`)}: ${t.name}`,onClick:i,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,Q.jsx)(Sn,{projectId:e,file:t,small:!0})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 py-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:i,title:t.name,className:`min-w-0 truncate font-medium text-[0.875rem] hover:underline`,children:t.name}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:Pn(t)})]}),(0,Q.jsx)(bn,{file:t,actions:n})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start opacity-0 transition focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`,children:[(0,Q.jsx)(R,{label:X(`project.preview`),onClick:i,children:(0,Q.jsx)(je,{className:`size-4`})}),r&&!n.readOnly?(0,Q.jsx)(ce,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,Q.jsx)(R,{label:X(`project.remove`),onClick:a,className:`hover:text-rose`,children:(0,Q.jsx)(we,{className:`size-4`})})]})]})}function Ln({section:e,onSave:t,onRemove:n,onClose:r}){let[i,a]=(0,Z.useState)(e?.title??``);return(0,Q.jsx)(ye,{open:!0,onClose:r,title:X(e?`project.assetSectionRename`:`project.assetSectionAdd`),children:(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&(t(i.trim()),r())},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(z,{children:X(`project.assetSectionName`)}),(0,Q.jsx)(L,{autoFocus:!0,value:i,maxLength:80,placeholder:X(`project.assetSectionTitle`),onChange:e=>a(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,Q.jsx)(F,{variant:`danger`,onClick:n,children:X(`project.sectionRemove`)}):null,(0,Q.jsx)(`span`,{className:`flex-1`}),(0,Q.jsx)(F,{variant:`ghost`,onClick:r,children:X(`common.cancel`)}),(0,Q.jsx)(F,{type:`submit`,disabled:!i.trim(),children:X(e?`settings.save`:`project.add`)})]})]})})}function Rn({projectId:e,data:t,readOnly:n,sections:r,save:a}){let s=P(e,n),[c,l]=m(`assets`,`cards`),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(r),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(!1),C=(0,Z.useRef)(null),w=o({assetSections:h},a),T=t.files.filter(e=>e.kind===`asset`),E=new Map(T.map(e=>[e.id,e])),D=new Set(h.flatMap(e=>e.assets)),O=h.find(e=>e.id===_)??null,k=O?O.assets.map(e=>E.get(e)).filter(e=>!!e):T.filter(e=>!D.has(e.id)),ee=T.find(e=>e.id===f),te=u.trim().toLowerCase(),A=te?k.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(te)):k,j=(e,t)=>g(n=>n.map(n=>{let r=n.assets.filter(t=>t!==e);return{...n,assets:n.id===t?[...r,e]:r}})),M=async e=>{let t=O?.id??null;for(let n of await s.upload(`asset`,e))j(n.id,t)},N=e=>{confirm(X(`project.removeConfirm`,{name:e.name}))&&(s.remove(e.id),j(e.id,null))},ne=h.length?{options:[{value:``,label:X(`project.assetsGeneral`)},...h.map(e=>({value:e.id,label:e.title||X(`project.sectionUntitled`)}))],current:e=>h.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>j(e.id,t||null)}:void 0,F=[{label:X(`project.assetUpload`),icon:(0,Q.jsx)(yt,{className:`size-4 shrink-0`}),onPick:()=>C.current?.click()},{label:X(`project.assetFromUrl`),icon:(0,Q.jsx)(fn,{className:`size-4 shrink-0`}),onPick:()=>S(!0)},...h.length<i.logoSections?[{label:X(`project.assetSectionAdd`),icon:(0,Q.jsx)(cn,{className:`size-4 shrink-0`}),onPick:()=>b(`new`)}]:[]],I=h.length||T.length?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`-mx-1 flex min-w-0 flex-1 items-center gap-1 overflow-x-auto px-1 pb-0.5`,children:[h.length?(0,Q.jsx)(ue,{value:_,onChange:e=>{v(e),d(``)},label:X(`project.assets`),options:[{id:``,label:X(`project.assetsGeneral`)},...h.map(e=>({id:e.id,label:e.title||X(`project.sectionUntitled`)}))]}):null,O&&!n?(0,Q.jsx)(R,{label:X(`project.assetSectionRename`),onClick:()=>b(`current`),children:(0,Q.jsx)(U,{className:`size-4`})}):null]}),k.length?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`w-56 max-w-[45%] shrink`,children:(0,Q.jsx)(Te,{value:u,onChange:d,placeholder:X(`project.assetSearch`)})}),(0,Q.jsx)(R,{label:X(c===`list`?`project.viewCards`:`project.viewList`),onClick:l,children:c===`list`?(0,Q.jsx)(Et,{className:`size-4`}):(0,Q.jsx)(mn,{className:`size-4`})})]}):null]}):null;return(0,Q.jsxs)(Y,{title:X(`project.assets`),hint:X(`project.assetsHint`),save:w,tabs:I,action:n?null:(0,Q.jsx)(W,{entries:F}),children:[(0,Q.jsx)(`input`,{ref:C,type:`file`,multiple:!0,accept:Nn,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&M(t)}}),A.length?c===`cards`?(0,Q.jsx)(Tn,{projectId:e,kind:`asset`,files:A,actions:s,moveTo:ne,onRemove:N,onPreview:e=>p(e.id)}):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:A.map(t=>(0,Q.jsx)(In,{projectId:e,file:t,actions:s,moveTo:ne,onPreview:()=>p(t.id),onRemove:()=>N(t)},t.id))}):k.length?null:n?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:X(`project.staysLocal`)}):(0,Q.jsxs)(he,{accept:Nn,onFiles:e=>void M(e),className:`h-16 w-full`,children:[s.busy?(0,Q.jsx)(Ce,{className:`size-4`}):(0,Q.jsx)(yt,{className:`size-4`}),X(`project.drop`),` `,(0,Q.jsx)(`span`,{className:`underline`,children:X(`project.assetAdd`)})]}),s.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:s.error}):null,ee?(0,Q.jsx)(Fn,{projectId:e,file:ee,actions:s,onClose:()=>p(null)}):null,y?(0,Q.jsx)(Ln,{section:y===`current`?O:null,onClose:()=>b(null),onSave:e=>{if(y===`current`&&O)g(t=>t.map(t=>t.id===O.id?{...t,title:e}:t));else{let t=De();g(n=>[...n,{id:t,title:e,assets:[]}]),v(t)}},onRemove:y===`current`&&O?()=>{(!O.assets.length||confirm(X(`project.assetSectionRemoveConfirm`,{name:O.title})))&&(g(e=>e.filter(e=>e.id!==O.id)),v(``),b(null))}:void 0}):null,x?(0,Q.jsx)(En,{kind:`asset`,onClose:()=>S(!1),fetchUrl:e=>s.fromUrl(`asset`,e),onAdded:e=>{for(let t of e)j(t.id,O?.id??null)}}):null]})}var zn=/^#[0-9a-fA-F]{6}$/;async function Bn(e,t){let[n,r]=[1920,1080],i=document.createElement(`canvas`);i.width=n,i.height=r;let a=i.getContext(`2d`);if(!a)return;let o=e.angle*Math.PI/180,s;if(e.type===`radial`)s=a.createRadialGradient(n/2,r/2,0,n/2,r/2,Math.hypot(n,r)/2);else if(e.type===`conic`)s=a.createConicGradient(o-Math.PI/2,n/2,r/2);else{let e=Math.abs(n*Math.sin(o))+Math.abs(r*Math.cos(o)),[t,i]=[Math.sin(o)*e/2,-Math.cos(o)*e/2];s=a.createLinearGradient(n/2-t,r/2-i,n/2+t,r/2+i)}for(let t of[...e.stops].sort((e,t)=>e.at-t.at))s.addColorStop(Math.min(1,Math.max(0,t.at/100)),t.color);a.fillStyle=s,a.fillRect(0,0,n,r);let c=await new Promise(e=>i.toBlob(e,`image/png`));if(c){let e=document.createElement(`a`);e.href=URL.createObjectURL(c),e.download=`${t||`gradient`}.png`,e.click(),setTimeout(()=>URL.revokeObjectURL(e.href),5e3)}}var Vn={linear:`project.gradientLinear`,radial:`project.gradientRadial`,conic:`project.gradientConic`};function Hn({projectId:e,gradient:t,isNew:n,brand:r,onSave:i,onClose:a}){let[o,s]=(0,Z.useState)(t),[c,u]=(0,Z.useState)(O(t)),[d,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(!n),S=e=>{s(e),u(O(e)),p(!1)},C=(e,t)=>S({...o,stops:o.stops.map((n,r)=>r===e?{...n,...t}:n)}),w=e=>{let t=[...o.stops].sort((e,t)=>e.at-t.at),n=50,r=-1;for(let e=0;e<t.length-1;e++)t[e+1].at-t[e].at>r&&(r=t[e+1].at-t[e].at,n=Math.round((t[e].at+t[e+1].at)/2));S({...o,stops:[...o.stops,{color:e??t[0]?.color??`#888888`,at:n}]})},T=async()=>{_(!0),y(null);try{let{gradient:t}=await f.post(`/api/studio/projects/${e}/gradients/describe`,{text:m.trim(),...b?{gradient:{name:o.name,type:o.type,angle:o.angle,stops:o.stops}}:{}});S({...o,...t,name:o.name.trim()?o.name:t.name}),h(``),x(!0)}catch(e){y(e.message)}_(!1)};return(0,Q.jsx)(ye,{open:!0,onClose:a,wide:!0,title:X(n?`project.gradientNew`:`project.gradientEdit`),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m.trim()&&!g&&T()},children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(L,{"data-autofocus":n||void 0,value:m,maxLength:1e3,"aria-label":X(`project.gradientDescribe`),placeholder:X(b?`project.gradientDescribeChange`:`project.gradientDescribeNew`),onChange:e=>h(e.target.value),className:`min-w-0 flex-1`}),(0,Q.jsxs)(F,{type:`submit`,variant:`secondary`,busy:g,disabled:!m.trim(),children:[(0,Q.jsx)(ve,{className:`size-4`}),X(b?`project.gradientDescribeApply`:`project.gradientDescribeMake`)]})]}),(0,Q.jsx)(`p`,{className:q(`mt-1.5 text-[0.8125rem]`,v?`text-rose`:`text-ink-3`),children:v??X(`project.gradientDescribeHint`)})]}),(0,Q.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:O(o)}}),(0,Q.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(z,{children:X(`project.gradientName`)}),(0,Q.jsx)(L,{value:o.name,maxLength:80,placeholder:X(`project.gradientNamePlaceholder`),onChange:e=>s({...o,name:e.target.value})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(z,{children:X(`project.fillUseLabel`)}),(0,Q.jsx)(L,{value:o.description??``,maxLength:400,placeholder:X(`project.gradientUse`),onChange:e=>s({...o,description:e.target.value})})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-6 gap-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(z,{children:X(`project.gradientType`)}),(0,Q.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:l.map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":o.type===e,onClick:()=>S({...o,type:e}),className:q(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,o.type===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:X(Vn[e])},e))})]}),o.type===`radial`?null:(0,Q.jsxs)(`div`,{className:`min-w-56`,children:[(0,Q.jsx)(z,{children:X(`project.gradientAngle`)}),(0,Q.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,Q.jsx)(`input`,{type:`range`,min:0,max:360,value:o.angle,"aria-label":X(`project.gradientAngle`),onChange:e=>S({...o,angle:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,Q.jsxs)(`span`,{className:`w-12 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(o.angle),`°`]})]})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(z,{children:X(`project.gradientStops`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.stops.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(ge,{value:zn.test(e.color)?e.color:`#888888`,onChange:e=>C(t,{color:e.target.value})}),(0,Q.jsx)(L,{value:e.color,spellCheck:!1,onChange:e=>{let n=e.target.value.trim();zn.test(n)&&C(t,{color:n.toLowerCase()})},className:`w-28 font-mono text-[0.8125rem]`}),(0,Q.jsx)(`input`,{type:`range`,min:0,max:100,value:e.at,"aria-label":X(`project.gradientAt`),onChange:e=>C(t,{at:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,Q.jsxs)(`span`,{className:`w-10 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(e.at),`%`]}),(0,Q.jsx)(R,{label:X(`project.remove`),disabled:o.stops.length<=2,onClick:()=>S({...o,stops:o.stops.filter((e,n)=>n!==t)}),className:`hover:text-rose`,children:(0,Q.jsx)(we,{className:`size-4`})})]},t))}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[o.stops.length<12?(0,Q.jsxs)(F,{variant:`secondary`,size:`sm`,onClick:()=>w(),children:[(0,Q.jsx)(Oe,{className:`size-4`}),` `,X(`project.gradientStopAdd`)]}):null,r.length&&o.stops.length<12?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`ml-2 text-[0.8125rem] text-ink-3`,children:X(`project.gradientFromBrand`)}),r.slice(0,10).map(e=>(0,Q.jsx)(`button`,{type:`button`,title:e.name||e.value,"aria-label":e.name||e.value,onClick:()=>w(e.value),className:`size-6 rounded-full ring-1 ring-border transition hover:scale-110`,style:{background:e.value}},e.value))]}):null]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(z,{children:`CSS`}),(0,Q.jsx)(L,{value:c,spellCheck:!1,onChange:e=>{u(e.target.value);let t=ee(e.target.value);p(!t),t&&s({...o,...t})},className:`font-mono text-[0.8125rem]`}),(0,Q.jsx)(`p`,{className:q(`mt-1.5 text-[0.8125rem]`,d?`text-rose`:`text-ink-3`),children:X(d?`project.gradientCssError`:`project.gradientCssHint`)})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(F,{variant:`ghost`,onClick:a,children:X(`common.cancel`)}),(0,Q.jsx)(F,{onClick:()=>{i(o),a()},children:X(`settings.save`)})]})]})})}var Un=`absolute top-1.5 right-1.5 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover/card:opacity-100 coarse:opacity-100`,Wn=`size-8 bg-card shadow-soft hover:bg-card`;function Gn({name:e,namePlaceholder:t,description:n,usePlaceholder:r,readOnly:i,onChange:a}){return i?(0,Q.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,Q.jsx)(`p`,{className:`truncate text-[0.875rem]`,children:e||t}),n?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 leading-snug`,children:n}):null]}):(0,Q.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,Q.jsx)(G,{value:e,label:X(`project.gradientName`),placeholder:t,maxLength:80,onChange:e=>a({name:e}),className:`font-medium text-[0.875rem]`}),(0,Q.jsx)(G,{value:n??``,label:X(`project.fillUseLabel`),placeholder:r,maxLength:400,onChange:e=>a({description:e}),className:`text-[0.8125rem] text-ink-3`})]})}function Kn({gradient:e,readOnly:t,onEdit:n,onChange:r,onRemove:i}){let a=O(e),[o,s]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:t,"aria-label":X(`project.gradientEdit`),onClick:n,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:{background:a}}),(0,Q.jsxs)(`div`,{className:Un,children:[(0,Q.jsx)(R,{label:X(o?`project.gradientCopied`:`project.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${a};`),s(!0),setTimeout(()=>s(!1),1500)},className:Wn,children:(0,Q.jsx)(te,{className:`size-4`})}),(0,Q.jsx)(R,{label:X(`project.download`),onClick:()=>void Bn(e,e.name),className:Wn,children:(0,Q.jsx)(g,{className:`size-4`})}),t?null:(0,Q.jsx)(R,{label:X(`project.remove`),onClick:i,className:q(Wn,`hover:text-rose`),children:(0,Q.jsx)(we,{className:`size-4`})})]})]}),(0,Q.jsx)(Gn,{name:e.name,namePlaceholder:X(`project.gradientName`),description:e.description,usePlaceholder:X(`project.gradientUse`),readOnly:t,onChange:r})]})}function qn(e,t){return{backgroundImage:`url("${e}")`,backgroundSize:t?`64px`:`cover`,backgroundRepeat:t?`repeat`:`no-repeat`,backgroundPosition:`center`}}function Jn({projectId:e,pattern:t,fileName:n,readOnly:r,onEdit:i,onChange:a,onRemove:o}){let s=Ae(e,t.file);return(0,Q.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:r,"aria-label":X(`project.patternEdit`),onClick:i,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:qn(s,t.tile)}),(0,Q.jsxs)(`div`,{className:Un,children:[(0,Q.jsx)(`a`,{href:s,download:n,"aria-label":X(`project.download`),title:X(`project.download`),className:q(`inline-flex items-center justify-center rounded-full text-ink-3 transition hover:text-ink`,Wn),children:(0,Q.jsx)(g,{className:`size-4`})}),r?null:(0,Q.jsx)(R,{label:X(`project.remove`),onClick:o,className:q(Wn,`hover:text-rose`),children:(0,Q.jsx)(we,{className:`size-4`})})]})]}),(0,Q.jsx)(Gn,{name:t.name,namePlaceholder:n,description:t.description,usePlaceholder:X(`project.patternUse`),readOnly:r,onChange:a})]})}function Yn({projectId:e,pattern:t,isNew:n,fileName:r,busy:i,error:a,upload:o,removeFile:s,onSave:c,onClose:l}){let[u,d]=(0,Z.useState)(t),[f,p]=(0,Z.useState)([]),m=async e=>{let t=e[0];if(!t)return;let n=await o(t);n&&(p(e=>[...e,n.id]),d(e=>({...e,file:n.id,name:e.name||n.name.replace(/\.[^.]+$/,``)})))},h=()=>{for(let e of f)s(e);l()};return(0,Q.jsx)(ye,{open:!0,onClose:h,wide:!0,title:X(n?`project.patternNew`:`project.patternEdit`),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[u.file?(0,Q.jsx)(`div`,{className:`relative h-40 rounded-lg ring-1 ring-border-soft`,style:qn(Ae(e,u.file),u.tile),children:(0,Q.jsxs)(he,{accept:`image/*`,multiple:!1,onFiles:e=>void m(e),className:`absolute right-2 bottom-2 h-9 border-solid bg-card px-3.5 text-ink-2 shadow-soft`,children:[i?(0,Q.jsx)(Ce,{className:`size-4`}):(0,Q.jsx)(D,{className:`size-4`}),X(`project.patternReplace`)]})}):(0,Q.jsxs)(he,{accept:`image/*`,multiple:!1,onFiles:e=>void m(e),className:`h-40 flex-col`,children:[i?(0,Q.jsx)(Ce,{className:`size-5`}):(0,Q.jsx)(D,{className:`size-5`}),X(`project.patternPick`)]}),(0,Q.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(z,{children:X(`project.patternName`)}),(0,Q.jsx)(L,{value:u.name,maxLength:80,placeholder:u.file?r(u.file):X(`project.patternNamePlaceholder`),onChange:e=>d({...u,name:e.target.value})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(z,{children:X(`project.fillUseLabel`)}),(0,Q.jsx)(L,{value:u.description??``,maxLength:400,placeholder:X(`project.patternUse`),onChange:e=>d({...u,description:e.target.value})})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(z,{children:X(`project.patternShow`)}),(0,Q.jsx)(`div`,{className:`flex w-fit gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:[!1,!0].map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!!u.tile===e,onClick:()=>d({...u,tile:e||void 0}),className:q(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,!!u.tile===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:X(e?`project.patternTile`:`project.patternFill`)},String(e)))})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[a?(0,Q.jsx)(`p`,{className:`mr-auto text-[0.8125rem] text-rose`,children:a}):null,(0,Q.jsx)(F,{variant:`ghost`,onClick:h,children:X(`common.cancel`)}),(0,Q.jsx)(F,{disabled:!u.file||i,onClick:()=>{for(let e of f.filter(e=>e!==u.file))s(e);t.file&&t.file!==u.file&&s(t.file),c({...u,name:u.name.trim(),description:u.description?.trim()||void 0}),l()},children:X(n?`project.add`:`settings.save`)})]})]})})}var Xn=/^#[0-9a-fA-F]{6}$/;function Zn({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),[d,p]=(0,Z.useState)([]),m=async()=>{o(!0),c(null);try{let{colors:t}=await f.post(`/api/studio/projects/${e}/colors/scan`,{url:r.trim()});t.length?(u(t),p([])):c(X(`project.colorsNoneFound`))}catch(e){c(e.message)}o(!1)};return(0,Q.jsx)(ye,{open:!0,onClose:n,wide:l?!0:void 0,title:X(l?`project.colorsFound`:`project.colorsFromUrl`),children:l?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:X(`project.colorsFoundHint`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-3`,children:l.map(e=>{let t=d.includes(e.value);return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>p(n=>t?n.filter(t=>t!==e.value):[...n,e.value]),className:q(`relative flex flex-col overflow-hidden rounded-lg text-left ring-1 transition`,t?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:[(0,Q.jsx)(`span`,{className:`h-16`,style:{background:e.value}}),(0,Q.jsxs)(`span`,{className:`flex flex-col px-2.5 py-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-[0.8125rem] text-ink-2`,children:e.name||`—`}),(0,Q.jsx)(`span`,{className:`font-mono text-[0.75rem] text-ink-3`,children:e.value})]}),t?(0,Q.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(N,{className:`size-3.5`})}):null]},e.value)})}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(F,{variant:`ghost`,onClick:()=>u(null),children:X(`run.back`)}),(0,Q.jsx)(F,{disabled:!d.length,onClick:()=>{t(l.filter(e=>d.includes(e.value))),n()},children:d.length>1?X(`project.addMany`,{n:d.length}):X(`project.add`)})]})]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(z,{children:X(`project.logoUrl`)}),(0,Q.jsx)(L,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>i(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:X(`project.colorsUrlHint`)})]}),s?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(F,{variant:`ghost`,onClick:n,children:X(`common.cancel`)}),(0,Q.jsx)(F,{type:`submit`,busy:a,disabled:!r.trim(),children:X(`run.next`)})]})]})})}function Qn({projectId:e,data:t,colors:n,sections:r,gradients:a,patterns:s,rules:c,sectioned:l,ruled:u,save:d,readOnly:f}){let[p,m]=(0,Z.useState)(()=>n.map(e=>({...e,id:De()}))),[h,g]=(0,Z.useState)(r),[_,b]=(0,Z.useState)(a),[x,S]=(0,Z.useState)(s),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(null),D=P(e,f),O=A(c),[k,ee]=(0,Z.useState)(null),[te,j]=(0,Z.useState)(null),[M,N]=(0,Z.useState)(!1),ne=o({colors:p.filter(e=>Xn.test(e.value)).map(({name:e,value:t,section:n})=>({name:e.trim(),value:t,...n?{section:n}:{}})),colorSections:h,gradients:_,patterns:x,colorRules:O.rules},d),F=l?h:[],I=F.filter(e=>(e.kind??`colors`)===`colors`),z=e=>I.some(t=>t.id===e.section),V=p.filter(e=>!z(e)),H=(V[0]??p[0])?.id,re=(e,t)=>m(n=>n.map(n=>n.id===e?{...n,...t}:n)),U=e=>m(t=>[...t,...e.map(e=>({...e,id:De()}))].slice(0,i.colors)),ae=[{value:``,label:X(`project.sectionStandard`)},...I.map(e=>({value:e.id,label:e.title||X(`project.sectionUntitled`)}))],oe=(e,t)=>{let n=De();ee(n),g(r=>[...r,{id:n,title:t,...e===`colors`?{}:{kind:e}}])},G=e=>({id:De(),name:``,section:e,type:`linear`,angle:90,stops:[{color:p[0]?.value&&Xn.test(p[0].value)?p[0].value:`#4b73ff`,at:0},{color:p[1]?.value&&Xn.test(p[1].value)?p[1].value:`#ff6d1b`,at:100}]}),le=e=>t.files.find(t=>t.id===e)?.name??`pattern`,ue=[...p.length<i.colors?[{label:X(`project.colorNew`),icon:(0,Q.jsx)(Oe,{className:`size-4 shrink-0`}),onPick:()=>fe()},{label:X(`project.colorsFromUrl`),icon:(0,Q.jsx)(fn,{className:`size-4 shrink-0`}),onPick:()=>N(!0)}]:[],...l&&h.length<i.logoSections?[{label:X(`project.colorSectionAdd`),icon:(0,Q.jsx)(cn,{className:`size-4 shrink-0`}),onPick:()=>oe(`colors`,``)},{label:X(`project.gradientSectionAdd`),icon:(0,Q.jsx)(tn,{className:`size-4 shrink-0`}),onPick:()=>oe(`gradients`,X(`project.gradientSectionTitle`))},{label:X(`project.patternSectionAdd`),icon:(0,Q.jsx)(un,{className:`size-4 shrink-0`}),onPick:()=>oe(`patterns`,X(`project.patternSectionTitle`))}]:[],...!u||O.full?[]:[{label:X(`project.ruleNew`),icon:(0,Q.jsx)(Me,{className:`size-4 shrink-0`}),onPick:()=>O.add()}]],de=e=>(0,Q.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,Q.jsx)(ge,{value:Xn.test(e.value)?e.value:`#888888`,onChange:t=>re(e.id,{value:t.target.value})}),(0,Q.jsx)(L,{value:e.name,autoFocus:e.id===te,placeholder:X(`project.colorName`),maxLength:120,onChange:t=>re(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,Q.jsx)(L,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>re(e.id,{value:t.target.value.trim()}),className:`w-28 font-mono text-[0.8125rem]`}),(0,Q.jsxs)(`div`,{className:`flex w-28 shrink-0 items-center justify-end max-sm:w-auto`,children:[e.id===H?(0,Q.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,Q.jsx)(y,{tone:`ember`,children:X(`project.colorAccent`)})}):f?null:(0,Q.jsx)(R,{label:X(`project.colorFirst`),onClick:()=>m(t=>[{...e,section:void 0},...t.filter(t=>t.id!==e.id)]),className:`opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`,children:(0,Q.jsx)(v,{className:`size-4`})}),f||!I.length?null:(0,Q.jsx)(ce,{options:ae,value:z(e)?e.section??``:``,onChange:t=>re(e.id,{section:t||void 0}),className:`opacity-0 focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`}),f?null:(0,Q.jsx)(R,{label:X(`project.remove`),onClick:()=>m(t=>t.filter(t=>t.id!==e.id)),className:`opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,Q.jsx)(we,{className:`size-4`})})]})]},e.id),fe=e=>{let t=De();j(t),m(n=>[...n,{id:t,name:``,value:`#888888`,...e?{section:e}:{}}])};return(0,Q.jsxs)(Y,{title:X(`project.colors`),hint:X(`project.colorsHint`),save:ne,locked:f,action:f?null:(0,Q.jsx)(W,{entries:ue}),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[V.length?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:V.map(de)}),f?null:(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:X(`project.colorUse`)})]}):p.length?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:X(`project.colorsEmpty`)}),F.map(t=>{let n=t.kind??`colors`,r=p.filter(e=>e.section===t.id),a=_.filter(e=>e.section===t.id),o=x.filter(e=>e.section===t.id),s=n===`gradients`?a.length:n===`patterns`?o.length:r.length;return(0,Q.jsxs)(`div`,{className:`group/section flex flex-col gap-3`,children:[(0,Q.jsx)(ie,{title:t.title,titlePlaceholder:X(n===`gradients`?`project.gradientSectionTitlePlaceholder`:n===`patterns`?`project.patternSectionTitlePlaceholder`:`project.colorSectionTitle`),kind:n===`gradients`?{icon:(0,Q.jsx)(tn,{}),label:X(`project.kindGradients`)}:n===`patterns`?{icon:(0,Q.jsx)(un,{}),label:X(`project.kindPatterns`)}:{icon:(0,Q.jsx)(St,{}),label:X(`project.kindColors`)},autoFocus:k===t.id,readOnly:f,onChange:e=>g(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{if(!s||confirm(X(n===`colors`?`project.colorSectionRemoveConfirm`:`project.fillSectionRemoveConfirm`,{name:t.title||X(`project.sectionUntitled`)}))){g(e=>e.filter(e=>e.id!==t.id)),m(e=>e.map(e=>e.section===t.id?{...e,section:void 0}:e)),b(e=>e.filter(e=>e.section!==t.id));for(let e of o)D.remove(e.file);S(e=>e.filter(e=>e.section!==t.id))}}}),n===`gradients`?(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[a.map(e=>(0,Q.jsx)(Kn,{gradient:e,readOnly:f,onEdit:()=>w(e),onChange:t=>b(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>b(t=>t.filter(t=>t.id!==e.id))},e.id)),f||_.length>=i.gradients?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>w(G(t.id)),className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-lg border border-input border-dashed text-[0.875rem] text-ink-3 transition hover:border-ink-4 hover:text-ink`,children:[(0,Q.jsx)(Oe,{className:`size-5`}),X(`project.gradientAdd`)]})]}):n===`patterns`?(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[o.map(t=>(0,Q.jsx)(Jn,{projectId:e,pattern:t,fileName:le(t.file),readOnly:f,onEdit:()=>E(t),onChange:e=>S(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{D.remove(t.file),S(e=>e.filter(e=>e.id!==t.id))}},t.id)),f||x.length>=i.files.pattern?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>E({id:De(),name:``,section:t.id,file:``}),className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-lg border border-input border-dashed text-[0.875rem] text-ink-3 transition hover:border-ink-4 hover:text-ink`,children:[(0,Q.jsx)(Oe,{className:`size-5`}),X(`project.patternAdd`)]})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map(de),f||p.length>=i.colors?null:(0,Q.jsx)(se,{label:X(`project.colorAdd`),onClick:()=>fe(t.id)})]})]},t.id)}),u?(0,Q.jsx)(B,{rules:O,placeholder:X(`project.colorRulePlaceholder`),readOnly:f}):null]}),D.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:D.error}):null,C?(0,Q.jsx)(Hn,{projectId:e,gradient:C,isNew:!_.some(e=>e.id===C.id),brand:p.filter(e=>Xn.test(e.value)),onClose:()=>w(null),onSave:e=>b(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,T?(0,Q.jsx)(Yn,{projectId:e,pattern:T,isNew:!x.some(e=>e.id===T.id),fileName:le,busy:D.busy,error:D.error,upload:async e=>(await D.upload(`pattern`,[e]))[0]??null,removeFile:e=>void D.remove(e),onClose:()=>E(null),onSave:e=>S(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,M?(0,Q.jsx)(Zn,{projectId:e,onClose:()=>N(!1),onAdd:U}):null]})}var $n=e=>/^(ja|yes|true)$/i.test(e.trim()),er={text:Fe,longtext:_t,number:Re,date:ze,url:u,email:Tt,phone:ht,boolean:Be};function tr({type:e,detected:t,onChange:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),s=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!r)return;let e=e=>{s.current?.contains(e.target)||i(!1)},t=e=>e.key===`Escape`&&i(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]);let c=er[e??t],l=`${X(`project.factType`)}: ${X(`project.type.${e??t}`)}`,u=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 hover:bg-accent hover:text-ink`,d=e=>{n(e),i(!1)};return(0,Q.jsxs)(`div`,{className:`relative`,ref:s,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":l,title:l,"aria-haspopup":`menu`,"aria-expanded":r,onClick:e=>{o(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),i(e=>!e)},className:q(`inline-flex size-11 items-center justify-center rounded-lg transition hover:bg-accent hover:text-ink`,r?`bg-accent text-ink`:e?`text-ink-2`:`text-ink-4`),children:(0,Q.jsx)(c,{className:`size-4`})}),r?(0,Q.jsxs)(`div`,{role:`menu`,className:q(`absolute right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,a?`bottom-12`:`top-12`),children:[(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:u,onClick:()=>d(void 0),children:[(0,Q.jsx)(Ne,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:X(`project.factAuto`)}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:X(`project.type.${t}`)}),(0,Q.jsx)(N,{className:q(`size-4 shrink-0`,e&&`invisible`)})]}),(0,Q.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),Ee.map(t=>{let n=er[t];return(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:u,onClick:()=>d(t),children:[(0,Q.jsx)(n,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:X(`project.type.${t}`)}),(0,Q.jsx)(N,{className:q(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function nr({facts:e,save:t,readOnly:n}){let r=(0,Z.useRef)(0),a=(0,Z.useRef)(null),[c,l]=(0,Z.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),u=o(c.filter(e=>e.key&&e.label.trim()).map(({key:e,label:t,value:n,type:r})=>({key:e,label:t.trim(),value:n,...r?{type:r}:{}})),t),d=(e,t)=>l(n=>n.map(n=>n.id===e?{...n,...t}:n)),f=(e,t,n=!1)=>{let i=`f${r.current++}`;a.current=`${i}:${t}`;let o={id:i,key:``,label:``,value:``,...e};l(e=>n?[o,...e]:[...e,o])},p=e=>t=>{t&&a.current===e&&(a.current=null,t.focus())},m=s.filter(e=>!c.some(t=>t.key===e));return(0,Q.jsxs)(Y,{title:X(`project.facts`),hint:X(`project.factsHint`),save:u,locked:n,action:c.length<i.facts&&!n?(0,Q.jsxs)(F,{variant:`secondary`,size:`sm`,onClick:()=>f({},`label`,!0),children:[(0,Q.jsx)(Oe,{className:`size-4`}),` `,X(`project.factAdd`)]}):null,children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:c.map(e=>{let t=fe(e.value),r=e.type??t;return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto_auto] items-start gap-x-1 gap-y-2 sm:grid-cols-[minmax(0,2fr)_minmax(0,3fr)_auto_auto]`,children:[(0,Q.jsx)(L,{ref:p(`${e.id}:label`),value:e.label,placeholder:X(`project.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>d(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&d(e.id,{key:x(e.label,c.map(e=>e.key))})},className:`max-sm:col-span-3 max-sm:font-medium sm:mr-1`}),e.type===`boolean`?(0,Q.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,Q.jsx)(be,{checked:$n(e.value),label:e.label,onChange:t=>d(e.id,{value:X(t?`project.yes`:`project.no`)})}),(0,Q.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:$n(e.value)?X(`project.yes`):X(`project.no`)})]}):(0,Q.jsx)(H,{ref:p(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:X(`project.factValue`),onChange:t=>d(e.id,{value:t.target.value}),className:`min-h-11`}),(0,Q.jsx)(tr,{type:e.type,detected:t,onChange:t=>d(e.id,{type:t})}),n?null:(0,Q.jsx)(R,{label:X(`project.remove`),onClick:()=>l(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,Q.jsx)(we,{className:`size-4`})})]},e.id)})}),c.length<i.facts&&!n?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${c.length?`mt-4`:``}`,children:[(0,Q.jsxs)(F,{variant:`secondary`,size:`sm`,onClick:()=>f({},`label`),children:[(0,Q.jsx)(Oe,{className:`size-4`}),` `,X(`project.factAdd`)]}),m.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>f({key:e,label:X(`fact.${e}`)},`value`),className:`inline-flex h-8 items-center gap-1 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,Q.jsx)(Oe,{className:`size-3.5`}),` `,X(`fact.${e}`)]},e))]}):null]})}function rr({onLogo:e,children:t,className:n}){let[r,i]=(0,Z.useState)(!1);return e?(0,Q.jsx)(`div`,{onDragOver:e=>{e.dataTransfer.types.includes(`application/x-wizards-logo`)&&(e.preventDefault(),i(!0))},onDragLeave:()=>i(!1),onDrop:t=>{let n=t.dataTransfer.getData(wn);i(!1),n&&(t.preventDefault(),e(n))},className:q(`-m-2 rounded-xl p-2 transition`,r&&`bg-paper-2 ring-1 ring-focus`,n),children:t}):(0,Q.jsx)(`div`,{className:n,children:t})}function ir({projectId:e,data:t,readOnly:n,sections:r,rules:a,sectioned:s,ruled:c,save:l}){let u=P(e,n),[d,f]=(0,Z.useState)(r),p=A(a),[m,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),y=(0,Z.useRef)(null),b=o({logoSections:d,logoRules:p.rules},l),x=t.files.filter(e=>e.kind===`logo`),S=new Map(x.map(e=>[e.id,e])),C=s?d:[],w=new Set(C.flatMap(e=>e.logos)),T=x.filter(e=>!w.has(e.id)),E=h(x,d)?.id,D=(e,t)=>f(n=>n.map(n=>{let r=n.logos.filter(t=>t!==e);return{...n,logos:n.id===t?[...r,e]:r}})),O=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,...t}:n)),k=async(e,t)=>{let n=await u.upload(`logo`,e);for(let e of n)D(e.id,t)},ee=C.length?{options:[{value:``,label:X(`project.sectionStandard`)},...C.map(e=>({value:e.id,label:e.title||X(`project.sectionUntitled`)}))],current:e=>C.find(t=>t.logos.includes(e.id))?.id??``,onMove:(e,t)=>D(e.id,t||null)}:void 0,te=(t,n,r)=>(0,Q.jsx)(Tn,{projectId:e,kind:`logo`,files:t,actions:u,accept:`image/*`,addLabel:r?X(`project.logoAdd`):void 0,onUpload:e=>void k(e,n),mainId:E,onMakeMain:e=>{D(e.id,null),u.order(`logo`,[e.id,...x.filter(t=>t.id!==e.id).map(e=>e.id)])},moveTo:ee,onRemove:e=>{confirm(X(`project.removeConfirm`,{name:e.name}))&&(u.remove(e.id),D(e.id,null))}}),j=n?void 0:e=>t=>D(t,e),M=[{label:X(`project.logoUpload`),icon:(0,Q.jsx)(yt,{className:`size-4 shrink-0`}),onPick:()=>y.current?.click()},{label:X(`project.logoFromUrl`),icon:(0,Q.jsx)(fn,{className:`size-4 shrink-0`}),onPick:()=>v(!0)},...s&&d.length<i.logoSections?[{label:X(`project.logoSectionAdd`),icon:(0,Q.jsx)(cn,{className:`size-4 shrink-0`}),onPick:()=>{let e=De();g(e),f(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...!c||p.full?[]:[{label:X(`project.ruleNew`),icon:(0,Q.jsx)(Me,{className:`size-4 shrink-0`}),onPick:()=>p.add()}]];return(0,Q.jsxs)(Y,{title:X(`project.logos`),hint:X(`project.logosHint`),save:b,action:n?null:(0,Q.jsx)(W,{entries:M}),children:[(0,Q.jsx)(`input`,{ref:y,type:`file`,accept:`image/*`,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&k(t,null)}}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,Q.jsx)(rr,{onLogo:j?.(null),children:te(T,null,!0)}),C.map(e=>(0,Q.jsx)(`div`,{className:`group/section`,children:(0,Q.jsxs)(rr,{onLogo:j?.(e.id),className:`flex flex-col gap-3`,children:[(0,Q.jsx)(ie,{title:e.title,description:e.description,titlePlaceholder:X(`project.logoSectionTitle`),descriptionPlaceholder:X(`project.logoSectionUse`),autoFocus:m===e.id,readOnly:n,onChange:t=>O(e.id,t),onRemove:()=>{(!e.logos.length||confirm(X(`project.logoSectionRemoveConfirm`,{name:e.title||X(`project.sectionUntitled`)})))&&f(t=>t.filter(t=>t.id!==e.id))}}),te(e.logos.map(e=>S.get(e)).filter(e=>!!e),e.id,!0)]})},e.id)),c?(0,Q.jsx)(B,{rules:p,placeholder:X(`project.logoRulePlaceholder`),readOnly:n}):null]}),u.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:u.error}):null,_?(0,Q.jsx)(En,{kind:`logo`,onClose:()=>v(!1),fetchUrl:e=>u.fromUrl(`logo`,e),onAdded:e=>{for(let t of e)D(t.id,null)}}):null]})}var ar=e=>URL.canParse(e)?new URL(e).host:e;async function or(e,t){let n=w({family:t,source:{url:e}});if(!n)return`down`;if(n.stylesheet)return await sr(e,t);let r=await fetch(e,{mode:`cors`}).catch(()=>null);return r?r.ok?await new FontFace(`engenty-check-${Date.now()}`,await r.arrayBuffer()).load().then(()=>`ok`,()=>`noFont`):`down`:await fetch(e,{mode:`no-cors`}).then(()=>!0,()=>!1)?`cors`:`down`}function sr(e,t){let n=new Set(document.fonts),r=document.createElement(`link`);return r.rel=`stylesheet`,r.href=e,new Promise(e=>{r.onerror=()=>e(`down`),r.onload=async()=>{let r=[...document.fonts].filter(e=>!n.has(e)&&e.family.replace(/^["']|["']$/g,``)===t),i=await Promise.allSettled(r.map(e=>e.load()));e(r.length===0?`missing`:i.some(e=>e.status===`fulfilled`)?`ok`:`cors`)},document.head.append(r)}).finally(()=>r.remove())}function cr(e,t){let n=e.source;if(!n)return X(`project.fontSourceNone`);if(`file`in n){let e=t.find(e=>e.id===n.file)?.name??``;return X(`project.fontSourceFile`,{name:e})}return X(`project.fontSourceUrl`,{host:ar(n.url)})}function lr({projectId:e,font:t,onSave:n,onClose:i}){let a=(M(e).data?.files??[]).filter(e=>e.mime.startsWith(`font/`)),o=P(e),s=(0,Z.useRef)(null),[c,l]=(0,Z.useState)(t.source&&`url`in t.source?`url`:`file`),[u,d]=(0,Z.useState)(t.source&&`file`in t.source?t.source.file:``),[f,p]=(0,Z.useState)(t.source&&`url`in t.source?t.source.url:``),[m,h]=(0,Z.useState)(t.source&&`url`in t.source?{url:t.source.url,result:`ok`}:null),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(t.license??``),[b,x]=(0,Z.useState)(!1),S=f.trim(),C=async()=>{_(!0),h({url:S,result:await or(S,t.family.trim())}),_(!1)},w=c===`file`?u?{file:u}:null:m?.url===S&&m.result===`ok`?{url:S}:null,T=m?.url===S?m.result:null;return(0,Q.jsx)(ye,{open:!0,onClose:i,title:X(`project.fontSourceTitle`,{family:t.family}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:X(`project.fontSourceHint`)}),(0,Q.jsx)(r,{value:c,options:[`file`,`url`],label:e=>X(`project.fontSourceKind.${e}`),onChange:e=>l(e)}),c===`file`?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(z,{children:X(`project.fontSourceFiles`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-1`,children:a.map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":u===e.id,onClick:()=>d(e.id),className:q(`rounded-lg px-3 py-2 text-left text-[0.875rem] ring-1 transition`,u===e.id?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:e.name},e.id))}),(0,Q.jsx)(`input`,{ref:s,type:`file`,accept:`.woff2,.woff,.ttf,.otf`,className:`hidden`,onChange:async e=>{let t=[...e.target.files??[]];e.target.value=``;let[n]=await o.upload(`asset`,t);n&&d(n.id)}}),(0,Q.jsxs)(F,{variant:`ghost`,className:`mt-2`,busy:o.busy,onClick:()=>s.current?.click(),children:[(0,Q.jsx)(yt,{className:`size-4`}),X(`project.fontSourceUpload`)]}),o.error?(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-rose`,children:o.error}):null]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),C()},children:[(0,Q.jsx)(z,{children:X(`project.fontSourceUrlLabel`)}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(L,{value:f,inputMode:`url`,placeholder:X(`project.fontSourceUrlPlaceholder`),onChange:e=>p(e.target.value)}),(0,Q.jsx)(F,{type:`submit`,variant:`ghost`,busy:g,disabled:!S.startsWith(`https://`),children:X(`project.fontSourceCheck`)})]}),T?(0,Q.jsx)(`p`,{className:q(`mt-1.5 text-[0.875rem]`,T===`ok`?`text-ink-3`:`text-rose`),children:X(`project.fontCheck.${T}`,{host:ar(S),family:t.family})}):null,T===`ok`?(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-ink-3`,children:X(`project.fontPrivacy`,{host:ar(S)})}):null]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(z,{hint:X(`project.fontLicenseHint`),children:X(`project.fontLicense`)}),(0,Q.jsx)(L,{value:v,maxLength:200,placeholder:X(`project.fontLicensePlaceholder`),onChange:e=>y(e.target.value)}),(0,Q.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-[0.875rem]`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 accent-ember`,checked:b,onChange:e=>x(e.target.checked)}),X(`project.fontLicenseConfirm`,{family:t.family})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[t.source?(0,Q.jsx)(F,{variant:`ghost`,className:`mr-auto`,onClick:()=>{n({source:void 0,license:t.license}),i()},children:X(`project.fontSourceRemove`)}):null,(0,Q.jsx)(F,{variant:`ghost`,onClick:i,children:X(`common.cancel`)}),(0,Q.jsx)(F,{disabled:!(w&&b),onClick:()=>{w&&(n({source:w,license:v.trim()||void 0}),i())},children:X(`project.fontSourceSave`)})]})]})})}var ur=new Set;function dr(e){(0,Z.useEffect)(()=>{let t=e.trim().toLowerCase().replace(/\s+/g,`-`);if(!t||ur.has(t))return;ur.add(t);let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=`https://fonts.bunny.net/css?family=${encodeURIComponent(t)}:${d.join(`,`)}&display=swap`,document.head.append(n)},[e])}var fr=e=>e?`"${e}", system-ui, sans-serif`:`system-ui, sans-serif`;function pr({unit:e,label:t,...n}){return(0,Q.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3`,title:t,children:[(0,Q.jsx)(`input`,{type:`number`,"aria-label":t,className:`h-8 w-14 rounded-md border border-input bg-card px-1.5 text-right text-[0.8125rem] text-ink tabular-nums outline-none transition focus:border-focus focus:ring-2 focus:ring-focus-glow`,...n}),e]})}var mr=`h-8 rounded-md border border-input bg-card px-1.5 text-[0.8125rem] text-ink outline-none transition focus:border-focus focus:ring-2 focus:ring-focus-glow`,hr={web:`project.fontUseWeb`,documents:`project.fontUseDocuments`,print:`project.fontUsePrint`,images:`project.fontUseImages`,video:`project.fontUseVideo`};function gr({projectId:e,font:t,first:n,readOnly:r,autoFocus:i,onChange:a,onRemove:o}){dr(t.family);let s=M(e).data?.files??[],[c,l]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{className:`group/font relative flex flex-col gap-2 rounded-lg bg-paper p-3 ring-1 ring-border-soft`,children:[(0,Q.jsxs)(`div`,{className:`flex h-28 items-end justify-between overflow-hidden rounded-md bg-card px-4 pb-3 ring-1 ring-border-soft`,style:{fontFamily:fr(t.family)},children:[(0,Q.jsx)(`span`,{className:`text-[3.5rem] text-ink leading-none`,children:`Aa`}),(0,Q.jsx)(`span`,{className:`truncate pl-3 text-[0.875rem] text-ink-3`,children:`ABCDEFG abcdefg 0123456789`})]}),r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:t.family}),t.role?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:t.role}):null]}):(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(G,{value:t.family,label:X(`project.fontFamily`),placeholder:X(`project.fontFamily`),maxLength:80,autoFocus:i,onChange:e=>a({family:e}),className:`font-medium text-[0.9375rem]`}),(0,Q.jsx)(G,{value:t.role,label:X(`project.fontRole`),placeholder:X(n?`project.fontRoleFirst`:`project.fontRole`),maxLength:200,onChange:e=>a({role:e}),className:`text-[0.875rem] text-ink-3`})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:d.map(e=>{let n=t.weights.includes(e);return(0,Q.jsx)(`button`,{type:`button`,disabled:r,"aria-pressed":n,onClick:()=>a({weights:n?t.weights.filter(t=>t!==e):[...t.weights,e].sort((e,t)=>e-t)}),style:{fontFamily:fr(t.family),fontWeight:e},className:q(`h-7 rounded-full px-2.5 text-[0.8125rem] tabular-nums transition`,n?`bg-ink text-paper`:`bg-paper-2 text-ink-3 hover:text-ink`,r&&!n&&`hidden`),children:e},e)})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[r?t.license?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:t.license}):null:(0,Q.jsx)(G,{value:t.license??``,label:X(`project.fontLicense`),placeholder:X(`project.fontLicensePlaceholder`),maxLength:200,onChange:e=>a({license:e}),className:`text-[0.8125rem] text-ink-3`}),r&&!t.uses?.length?null:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`mr-1 text-[0.8125rem] text-ink-3`,children:X(`project.fontUses`)}),j.map(e=>{let n=!!t.uses?.includes(e);return(0,Q.jsxs)(`button`,{type:`button`,disabled:r,"aria-pressed":n,onClick:()=>{let r=n?(t.uses??[]).filter(t=>t!==e):j.filter(n=>n===e||t.uses?.includes(n));a({uses:r.length?r:void 0})},className:q(`inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-[0.8125rem] transition`,n?`bg-card text-ink ring-1 ring-border`:`bg-paper-2 text-ink-3 hover:text-ink`,r&&!n&&`hidden`),children:[n?(0,Q.jsx)(N,{className:`size-3.5`}):null,X(hr[e])]},e)})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[0.8125rem] text-ink-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:cr(t,s)}),r||!t.family.trim()?null:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>l(!0),className:`text-ink underline decoration-border underline-offset-2 hover:decoration-ink`,children:X(t.source?`project.fontSourceChange`:`project.fontSourceSet`)})]}),c?(0,Q.jsx)(lr,{projectId:e,font:t,onSave:a,onClose:()=>l(!1)}):null,r?null:(0,Q.jsx)(R,{label:X(`project.remove`),onClick:o,className:`absolute top-4 right-4 size-8 bg-card opacity-0 shadow-soft transition focus:opacity-100 group-hover/font:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,Q.jsx)(we,{className:`size-4`})})]})}function _r({style:e,fonts:t,sample:n,readOnly:r,autoFocus:i,onChange:a,onRemove:o}){let s=t.find(t=>t.id===e.font)??t[0],c={fontFamily:fr(s?.family),fontWeight:e.weight,fontSize:`${Math.min(e.size,56)}px`,lineHeight:`${e.lineHeight}%`,letterSpacing:`${e.tracking/100}em`,textTransform:e.uppercase?`uppercase`:void 0};return(0,Q.jsxs)(`li`,{className:`group/row flex flex-col gap-2 border-border-soft border-b py-4 first:pt-1 last:border-b-0`,children:[(0,Q.jsx)(`div`,{className:`truncate text-ink`,style:c,children:n}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[r?(0,Q.jsx)(`span`,{className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`,children:e.name}):(0,Q.jsx)(`div`,{className:`w-40`,children:(0,Q.jsx)(G,{value:e.name,label:X(`project.styleName`),placeholder:X(`project.styleName`),maxLength:60,autoFocus:i,onChange:e=>a({name:e}),className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`})}),(0,Q.jsxs)(`fieldset`,{disabled:r,className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[t.length>1?(0,Q.jsx)(`select`,{"aria-label":X(`project.styleFont`),value:s?.id??``,onChange:e=>a({font:e.target.value}),className:q(mr,`max-w-40`),children:t.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.family||X(`project.fontFamily`)},e.id))}):null,(0,Q.jsx)(`select`,{"aria-label":X(`project.styleWeight`),value:e.weight,onChange:e=>a({weight:Number(e.target.value)}),className:mr,children:[...new Set([...d,e.weight])].sort().map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))}),(0,Q.jsx)(pr,{unit:`px`,label:X(`project.styleSize`),min:6,max:400,value:e.size,onChange:e=>a({size:Number(e.target.value)||16})}),(0,Q.jsx)(pr,{unit:X(`project.styleLine`),label:X(`project.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>a({lineHeight:Number(e.target.value)||100})}),(0,Q.jsx)(pr,{unit:X(`project.styleTracking`),label:X(`project.styleTrackingLabel`),min:-20,max:50,step:.5,value:e.tracking,onChange:e=>a({tracking:Number(e.target.value)||0})}),(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!!e.uppercase,title:X(`project.styleUpper`),"aria-label":X(`project.styleUpper`),onClick:()=>a({uppercase:!e.uppercase}),className:q(`grid size-8 place-items-center rounded-md transition`,e.uppercase?`bg-ink text-paper`:`text-ink-3 hover:bg-paper-2 hover:text-ink`),children:(0,Q.jsx)(on,{className:`size-4`})})]}),r?null:(0,Q.jsx)(R,{label:X(`project.remove`),onClick:o,className:`ml-auto size-8 opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,Q.jsx)(we,{className:`size-4`})})]})]})}function vr({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),[d,p]=(0,Z.useState)([]),m=async()=>{o(!0),c(null);try{let{fonts:t}=await f.post(`/api/studio/projects/${e}/fonts/scan`,{url:r.trim()});t.length?(u(t),p(t.slice(0,2).map(e=>e.family))):c(X(`project.fontsNoneFound`))}catch(e){c(e.message)}o(!1)};return(0,Q.jsx)(ye,{open:!0,onClose:n,wide:l?!0:void 0,title:X(l?`project.fontsFound`:`project.fontsFromUrl`),children:l?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:X(`project.fontsFoundHint`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:l.map(e=>(0,Q.jsx)(yr,{font:e,on:d.includes(e.family),onToggle:()=>p(t=>t.includes(e.family)?t.filter(t=>t!==e.family):[...t,e.family])},e.family))}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(F,{variant:`ghost`,onClick:()=>u(null),children:X(`run.back`)}),(0,Q.jsx)(F,{disabled:!d.length,onClick:()=>{t(l.filter(e=>d.includes(e.family))),n()},children:d.length>1?X(`project.addMany`,{n:d.length}):X(`project.add`)})]})]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(z,{children:X(`project.logoUrl`)}),(0,Q.jsx)(L,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>i(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:X(`project.fontsUrlHint`)})]}),s?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(F,{variant:`ghost`,onClick:n,children:X(`common.cancel`)}),(0,Q.jsx)(F,{type:`submit`,busy:a,disabled:!r.trim(),children:X(`run.next`)})]})]})})}function yr({font:e,on:t,onToggle:n}){return dr(e.family),(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:n,className:q(`flex items-center gap-4 rounded-lg px-4 py-3 text-left ring-1 transition`,t?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:[(0,Q.jsx)(`span`,{className:`text-[2rem] text-ink leading-none`,style:{fontFamily:fr(e.family)},children:`Aa`}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e.family}),(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:e.weights.length?e.weights.join(` · `):X(`project.fontWeightsUnknown`)})]}),t?(0,Q.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(N,{className:`size-3.5`})}):null]})}function br({projectId:e,fonts:t,styles:n,rules:r,ruled:a,sample:s,save:c,readOnly:l}){let[u,d]=(0,Z.useState)(t),[f,p]=(0,Z.useState)(n),m=A(r),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),y=o({fonts:u,textStyles:f,typeRules:m.rules},c),b=(e,t=!1)=>{let n=e.map(e=>({id:De(),family:e.family,role:``,weights:e.weights}));t&&n[0]&&g(n[0].id),d(e=>[...e,...n].slice(0,i.fonts))},x=()=>{let e=De();g(e),p(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},S=[...u.length<i.fonts?[{label:X(`project.fontNew`),icon:(0,Q.jsx)(Oe,{className:`size-4 shrink-0`}),onPick:()=>b([{family:``,weights:[400,700]}],!0)},{label:X(`project.fontsFromUrl`),icon:(0,Q.jsx)(fn,{className:`size-4 shrink-0`}),onPick:()=>v(!0)}]:[],...f.length<i.textStyles?[{label:X(`project.styleNew`),icon:(0,Q.jsx)(Ct,{className:`size-4 shrink-0`}),onPick:x}]:[],...!a||m.full?[]:[{label:X(`project.ruleNew`),icon:(0,Q.jsx)(Me,{className:`size-4 shrink-0`}),onPick:()=>m.add()}]];return(0,Q.jsxs)(Y,{title:X(`project.typography`),hint:X(`project.typographyHint`),save:y,action:l?null:(0,Q.jsx)(W,{entries:S}),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[u.length?(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-3`,children:u.map((t,n)=>(0,Q.jsx)(gr,{projectId:e,font:t,first:n===0,readOnly:l,autoFocus:h===t.id,onChange:e=>d(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>d(e=>e.filter(e=>e.id!==t.id))},t.id))}):(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:X(`project.fontsEmpty`)}),f.length?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:X(`project.styles`)}),l?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:X(`project.stylesHint`)}),(0,Q.jsx)(`ul`,{className:`mt-2 flex flex-col`,children:f.map(e=>(0,Q.jsx)(_r,{style:e,fonts:u,sample:s,readOnly:l,autoFocus:h===e.id,onChange:t=>p(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>p(t=>t.filter(t=>t.id!==e.id))},e.id))})]}):null,a?(0,Q.jsx)(B,{rules:m,placeholder:X(`project.typeRulePlaceholder`),readOnly:l}):null]}),_?(0,Q.jsx)(vr,{projectId:e,onClose:()=>v(!1),onAdd:e=>b(e)}):null]})}function xr({projectId:e,logo:t}){let n=X(t?`project.logoPeek`:`project.logoPeekAdd`);return(0,Q.jsxs)(`div`,{className:`shrink-0`,children:[(0,Q.jsx)(z,{children:X(`project.logo`)}),(0,Q.jsx)(k,{to:{pathname:`/space/brand`,hash:`logos`},title:n,"aria-label":n,className:q(`grid size-[4.5rem] place-items-center overflow-hidden rounded-xl transition`,t?`bg-card ring-1 ring-border-soft hover:ring-border`:`text-ink-4 ring-1 ring-border ring-dashed hover:text-ink-2`),children:t?(0,Q.jsx)(Sn,{projectId:e,file:t,small:!0}):(0,Q.jsx)(me,{className:`size-5`})})]})}function Sr({project:e,logo:t,save:n}){let[r,i]=(0,Z.useState)(e.brand.name??``),[a,s]=(0,Z.useState)(e.brand.about??``),c=o({name:r.trim(),about:a.trim()},e=>n({brand:e}));return(0,Q.jsx)(Y,{title:X(`project.base`),hint:X(`project.baseHint`),save:c,locked:e.readOnly,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(z,{children:X(`project.title`)}),(0,Q.jsx)(L,{value:r,maxLength:120,onChange:e=>i(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:X(`project.titleHint`)})]}),(0,Q.jsx)(xr,{projectId:e.id,logo:t})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(z,{children:X(`project.about`)}),(0,Q.jsx)(H,{minRows:4,value:a,onChange:e=>s(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:X(`project.aboutHint`)})]})]})})}function Cr({project:e,group:t,top:n=!1,children:r}){let i=C(),a=M(e.id),[o,s]=(0,Z.useState)(0),[c,l]=(0,Z.useState)(!1),u=async t=>{await f.patch(`/api/studio/projects/${e.id}`,t),await i.invalidateQueries({queryKey:ne.spaces()})},d=Le({mutationFn:()=>f.del(`/api/studio/projects/${e.id}`),onSuccess:()=>i.invalidateQueries({queryKey:ne.spaces()})}),p=pt(),m=dt(),g=a.data??{files:[],embeddings:!0},_=`${e.id}:${o}`,v=e.readOnly,y=t===`knowledge`,b=Ot(`brandSections`),x=Ot(`brandRules`),S=Ot(`typography`);return Pt(v?{}:{title:X(y?`project.assistantTitleKnowledge`:`project.assistantTitle`),hello:X(y?`project.assistantHelloKnowledge`:`project.assistantHello`),about:X(y?`project.assistantAboutKnowledge`:`project.assistantAbout`),placeholder:X(y?`project.assistantComposerKnowledge`:`project.assistantComposer`),suggestions:y?[{label:X(`assistant.suggest.knowledgeHow`)},{label:X(`assistant.suggest.knowledgeSite`),fill:!0},{label:X(`assistant.suggest.knowledgeCategories`)}]:[{label:X(`assistant.suggest.readSite`),fill:!0},{label:X(`assistant.suggest.missing`)},...t===`info`?[{label:X(`assistant.suggest.facts`)}]:[]],summary:y?void 0:[e.brand.name?`title "${e.brand.name}"`:`no title`,`${e.facts.length} facts`,`${e.brand.colors?.length??0} colours`,`${g.files.filter(e=>e.kind===`logo`).length} logos`].join(` · `),onChanged:()=>s(e=>e+1)}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[v?(0,Q.jsx)(vt,{children:gt(e)}):n?(0,Q.jsx)(zt,{}):null,t===`info`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(J,{id:`base`,children:(0,Q.jsx)(Sr,{project:e,logo:h(g.files.filter(e=>e.kind===`logo`),e.brand.logoSections),save:u},`base:${_}`)}),(0,Q.jsx)(J,{id:`facts`,children:(0,Q.jsx)(nr,{facts:e.facts,save:e=>u({facts:e}),readOnly:v},`facts:${_}`)})]}):null,t===`brand`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(J,{id:`logos`,children:(0,Q.jsx)(ir,{projectId:e.id,data:g,readOnly:v,sections:e.brand.logoSections??[],rules:e.brand.logoRules??[],sectioned:b,ruled:x,save:e=>u({brand:e})},`logos:${_}`)}),(0,Q.jsx)(J,{id:`colors`,children:(0,Q.jsx)(Qn,{projectId:e.id,data:g,colors:e.brand.colors??[],sections:e.brand.colorSections??[],gradients:e.brand.gradients??[],patterns:e.brand.patterns??[],rules:e.brand.colorRules??[],sectioned:b,ruled:x,save:e=>u({brand:e}),readOnly:v},`colors:${_}`)}),S?(0,Q.jsx)(J,{id:`typography`,children:(0,Q.jsx)(br,{projectId:e.id,fonts:e.brand.fonts??[],styles:e.brand.textStyles??[],rules:e.brand.typeRules??[],ruled:x,sample:e.brand.name||X(`project.typeSample`),save:e=>u({brand:e}),readOnly:v},`typography:${_}`)}):null,(0,Q.jsx)(J,{id:`assets`,children:(0,Q.jsx)(Rn,{projectId:e.id,data:g,readOnly:v,sections:e.brand.assetSections??[],save:e=>u({brand:e})},`assets:${_}`)})]}):null,r,t===`info`&&p&&!v&&m?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(F,{variant:`danger`,onClick:()=>l(!0),children:X(`settings.delete`)}),(0,Q.jsxs)(ye,{open:c,onClose:()=>l(!1),title:X(`settings.deleteTitle`,{name:e.name}),children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:X(`settings.deleteBody`)}),d.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:d.error.message}):null,(0,Q.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Q.jsx)(F,{variant:`ghost`,onClick:()=>l(!1),children:X(`common.cancel`)}),(0,Q.jsx)(F,{variant:`danger`,busy:d.isPending,onClick:()=>d.mutate(),children:X(`common.delete`)})]})]})]}):null]})}var wr=[{value:`de-du`,label:`page.lang.deDu`},{value:`de-sie`,label:`page.lang.deSie`},{value:`en`,label:`page.lang.en`}],$=`text-[0.8125rem] text-ink-3 leading-snug`,Tr=`font-mono text-[0.875rem]`,Er=e=>e.slice(e.indexOf(`.`)+1);function Dr(){let[e,t]=(0,Z.useState)(!1),n=(0,Z.useRef)(void 0);return(0,Z.useEffect)(()=>()=>clearTimeout(n.current),[]),{copied:e,copy:e=>navigator.clipboard.writeText(e).then(()=>{t(!0),clearTimeout(n.current),n.current=setTimeout(()=>t(!1),1500)}).catch(()=>t(!1))}}function Or(){let e=X(`page.sources`).split(/(\{brand\}|\{facts\})/);return(0,Q.jsxs)(`p`,{className:$,children:[e.map((e,t)=>e===`{brand}`?(0,Q.jsx)(k,{to:`/space/brand`,className:`text-ink underline-offset-2 hover:underline`,children:X(`space.brand`)},t):e===`{facts}`?(0,Q.jsx)(k,{to:`/space/info#facts`,className:`text-ink underline-offset-2 hover:underline`,children:X(`project.facts`)},t):e),` `,X(`page.onlyShared`)]})}function kr({host:e,value:t,onChange:n,disabled:r}){let i=K.test(t);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex h-11 items-stretch overflow-hidden rounded-lg border border-input bg-card focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow`,children:[(0,Q.jsxs)(`span`,{title:`${e}/`,className:`flex max-w-[55%] items-center truncate bg-paper-2 px-3 font-mono text-[0.75rem] text-ink-3`,children:[`…`,Er(e),`/`]}),(0,Q.jsx)(`input`,{value:t,disabled:r,"aria-label":X(`page.address`),maxLength:E.slug,onChange:e=>n(e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,`-`)),className:q(`min-w-0 flex-1 bg-transparent px-3 outline-none`,Tr)})]}),(0,Q.jsx)(`p`,{className:q(`mt-1.5`,$,!i&&t&&`text-rose`),children:X(`page.addressRules`)})]})}function Ar({host:e,words:t,onChange:n,disabled:r}){return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] gap-5 sm:grid-cols-[repeat(2,minmax(0,1fr))]`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(z,{children:X(`page.title`)}),(0,Q.jsx)(L,{value:t.title,disabled:r,maxLength:E.title,onChange:e=>n({title:e.target.value})}),(0,Q.jsx)(`p`,{className:q(`mt-1.5`,$),children:X(`page.titleHint`)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(z,{children:X(`page.address`)}),(0,Q.jsx)(kr,{host:e,value:t.slug,disabled:r,onChange:e=>n({slug:e})}),(0,Q.jsx)(`p`,{className:q(`mt-1`,$),children:X(`page.addressChange`)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,Q.jsx)(z,{children:X(`page.headline`)}),(0,Q.jsx)(L,{value:t.headline??``,disabled:r,maxLength:E.headline,onChange:e=>n({headline:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,Q.jsx)(z,{children:X(`page.words`)}),(0,Q.jsx)(H,{value:t.intro??``,disabled:r,minRows:3,maxLength:E.intro,onChange:e=>n({intro:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(z,{children:X(`page.lang`)}),(0,Q.jsx)(ae,{value:t.voice,onChange:e=>n({voice:e}),options:wr.map(e=>({value:e.value,label:X(e.label)}))}),(0,Q.jsx)(`p`,{className:q(`mt-1.5`,$),children:X(`page.langHint`)})]})]})}function jr(e,t){if(!e.published)return X(`page.draftNote`);if(!e.shareEnabled)return X(`page.notSharedNote`);let n=e.description.trim();return t?[n,X(`page.first`)].filter(Boolean).join(` · `):n}function Mr({wizard:e,first:t,on:n,disabled:r,onToggle:i,drag:o}){return(0,Q.jsxs)(`li`,{draggable:o?!0:void 0,onDragStart:o?.onDragStart,onDragOver:o?.onDragOver,onDrop:o?.onDrop,className:q(`flex items-center gap-3 border-border-soft border-t py-2.5 first:border-t-0`,!e.published&&`opacity-60`),children:[o?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${X(`page.moveUp`)} / ${X(`page.moveDown`)}`,onKeyDown:o.onKeyDown,className:`grid size-7 shrink-0 cursor-grab place-items-center rounded-md text-ink-4 hover:text-ink focus:text-ink`,children:(0,Q.jsx)(a,{className:`size-4`})}):(0,Q.jsx)(`span`,{className:`size-7 shrink-0`}),(0,Q.jsx)(mt,{kind:e.avatar,costume:e.costume,size:36,interactive:!1}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate font-medium text-[0.9375rem]`,children:e.title}),(0,Q.jsx)(`p`,{className:q(`truncate`,$),children:jr(e,t)})]}),(0,Q.jsx)(be,{checked:n,disabled:r||!e.published,label:X(`page.showOnPage`),onChange:i})]})}function Nr({title:e,text:t,picked:n,disabled:r,later:i,onPick:a}){return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:r||i,onClick:a,className:q(`flex min-h-20 flex-col items-start gap-1 rounded-xl px-4 py-3 text-left transition`,n?`bg-accent ring-2 ring-primary`:i?`border border-border border-dashed opacity-60`:`ring-1 ring-border-soft hover:bg-paper-2`,(r||i)&&`cursor-not-allowed`),children:[(0,Q.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e}),(0,Q.jsx)(`span`,{className:$,children:t})]})}var Pr={desktop:1280,tablet:768,mobile:390},Fr=`wizards.pagePreviewDevice`,Ir=`wizards.pagePreviewHeight`,Lr=360,Rr=e=>e?640:480,zr=()=>Math.max(Lr,window.innerHeight-140);function Br(){try{let e=Number(localStorage.getItem(Ir));return e>=Lr?e:null}catch{return null}}function Vr(e){try{e===null?localStorage.removeItem(Ir):localStorage.setItem(Ir,String(Math.round(e)))}catch{}}function Hr(){try{let e=localStorage.getItem(Fr);return e&&e in Pr?e:`desktop`}catch{return`desktop`}}function Ur(e){try{localStorage.setItem(Fr,e)}catch{}}function Wr({url:e,version:t,device:n}){let r=(0,Z.useRef)(null),[i,a]=(0,Z.useState)({width:0,tall:!0});(0,Z.useEffect)(()=>{let e=r.current;if(!e)return;let t=()=>a({width:e.clientWidth,tall:e.clientWidth>=640});t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let o=Pr[n],[s,c]=(0,Z.useState)(Br),[l,u]=(0,Z.useState)(!1),d=(0,Z.useRef)(null),f=Math.min(s??Rr(i.tall),i.width?zr():9999),p=e=>{let t=Math.round(Math.min(zr(),Math.max(Lr,e)));return c(t),t},m=n===`mobile`,h=m?12:0,g=i.width?Math.min(1,(i.width-2*h)/o):1,_=(0,Q.jsxs)(`div`,{className:q(`relative overflow-hidden bg-paper-2`,m?`rounded-[1.5rem]`:`rounded-lg ring-1 ring-border-soft`),style:{width:Math.round(o*g),height:f},children:[i.width?(0,Q.jsx)(`iframe`,{title:X(`page.previewTitle`),src:`${e}${e.includes(`?`)?`&`:`?`}v=${t}`,tabIndex:-1,className:q(`absolute top-0 left-0 border-0`,l&&`pointer-events-none`),style:{width:o,height:Math.ceil(f/g),transform:`scale(${g})`,transformOrigin:`top left`}},t):null,(0,Q.jsx)(`button`,{type:`button`,"aria-label":X(`page.resize`),title:X(`page.resize`),onPointerDown:e=>{e.preventDefault();try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}d.current={y:e.clientY,height:f},u(!0)},onPointerMove:e=>{d.current&&p(d.current.height+e.clientY-d.current.y)},onPointerUp:e=>{d.current&&=(Vr(p(d.current.height+e.clientY-d.current.y)),null),u(!1)},onPointerCancel:()=>{d.current=null,u(!1)},onDoubleClick:()=>{c(null),Vr(null)},onKeyDown:e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),Vr(p(f+(e.key===`ArrowDown`?24:-24))))},className:`absolute right-1 bottom-1 z-10 grid size-7 cursor-ns-resize touch-none place-items-center rounded-md bg-card/90 text-ink-3 shadow-soft ring-1 ring-border-soft hover:text-ink coarse:size-9`,children:(0,Q.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,"aria-hidden":`true`,children:(0,Q.jsx)(`path`,{d:`M11 1 1 11M11 5 5 11M11 9 9 11`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})})})]});return(0,Q.jsx)(`div`,{ref:r,className:`flex w-full justify-center`,children:m?(0,Q.jsx)(`div`,{className:`rounded-[2.25rem] bg-ink p-3 shadow-soft`,children:_}):_})}function Gr({host:e,page:t,disabled:n,save:r,onState:i}){let a=(0,Z.useRef)(t);a.current=t;let[s,c]=(0,Z.useState)(()=>({slug:t.slug,title:t.title,headline:t.headline??``,intro:t.intro??``,voice:Ve(t)})),l=o(s,async e=>{if(!(K.test(e.slug)&&e.title.trim()))return;let{lang:t,form:n}=st(e.voice);await r({...a.current,slug:e.slug,title:e.title.trim(),headline:e.headline?.trim()||void 0,intro:e.intro?.trim()||void 0,lang:t,form:n})}),{state:u,error:d}=l;return(0,Z.useEffect)(()=>i(l),[u,d]),(0,Q.jsx)(Ar,{host:e,words:s,disabled:n,onChange:e=>c(t=>({...t,...e}))})}function Kr({project:e}){let t=C(),n=ft(),r=n.data?.tenant.pagesHost??null,i=n.data?.manageUrl??null,a=e.readOnly,o=e.page,s=!!o?.on,c=Se({queryKey:ne.projectWizards(e.id),queryFn:()=>f.get(`/api/studio/projects/${e.id}/wizards`)}),[l,u]=(0,Z.useState)(1),[d,m]=(0,Z.useState)(Hr),h=(0,Z.useRef)(o);h.current=o;let g=async n=>{await f.patch(`/api/studio/projects/${e.id}`,{page:n}),await t.invalidateQueries({queryKey:ne.spaces()}),u(e=>e+1)},_=Le({mutationFn:e=>{let t=h.current;return t?g({...t,...e}):Promise.resolve()}}),[v,y]=(0,Z.useState)({state:`idle`,error:null}),{copied:x,copy:S}=Dr(),w=c.data??[],T=(o?.wizards??[]).map(e=>w.find(t=>t.id===e)).filter(e=>e!==void 0),E=w.filter(e=>!o?.wizards.includes(e.id)),[D,O]=(0,Z.useState)(null),k=(e,t)=>{let n=[...o?.wizards??[]];if(t<0||t>=n.length||e===t)return;let[r]=n.splice(e,1);n.splice(t,0,r),_.mutate({wizards:n})},ee=(e,t)=>_.mutate({wizards:t?[...o?.wizards??[],e]:(o?.wizards??[]).filter(t=>t!==e)}),A=e.brand.name?.trim()||e.name,j=Le({mutationFn:()=>g({on:!0,slug:b(A)||`page`,title:A,...st(xt===`de`?`de-du`:`en`),wizards:w.filter(e=>e.published&&e.shareEnabled).map(e=>e.id),examples:{}})}),M=e=>{o?_.mutate({on:e}):e&&j.mutate()},P=_.isPending||j.isPending,I=_.error??j.error;if(!r)return(0,Q.jsx)(J,{id:`page`,children:(0,Q.jsx)(Y,{title:X(`space.page`),hint:X(`page.intro`),children:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:X(`page.cloudOnly`)})})});let L=o?.slug||b(A)||`…`,R=We(r,L),z=ot(r,L,i),B=(0,Q.jsxs)(`span`,{className:q(Tr,`min-w-0 truncate`),children:[(0,Q.jsxs)(`span`,{className:`text-ink-3`,children:[r,`/`]}),(0,Q.jsx)(`b`,{className:`text-ink`,children:L})]}),V=a||!o,H=(0,Q.jsxs)(p,{className:`flex flex-col gap-2.5 p-4`,children:[(0,Q.jsxs)(`div`,{className:`@container flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:X(`page.previewTitle`)}),s?(0,Q.jsx)(rt,{named:!0,label:X(`editor.device`),value:d,onChange:e=>{m(e),Ur(e)},options:[{id:`desktop`,label:X(`editor.deviceDesk`),icon:(0,Q.jsx)(Ft,{className:`size-3.5`})},{id:`tablet`,label:X(`page.deviceTablet`),icon:(0,Q.jsx)(vn,{className:`size-3.5`})},{id:`mobile`,label:X(`editor.devicePhone`),icon:(0,Q.jsx)(ct,{className:`size-3.5`})}]}):null]}),s?(0,Q.jsx)(Wr,{url:z,version:l,device:d}):(0,Q.jsx)(`p`,{className:$,children:X(`page.previewOff`)}),s?(0,Q.jsx)(`p`,{className:$,children:X(`page.previewHint`)}):null]}),re=(0,Q.jsxs)(p,{className:`flex flex-col gap-3 p-4`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:X(`page.inShare`)}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-paper-2 px-3 py-2.5`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block truncate font-medium text-[0.875rem]`,children:X(`share.onPage`,{space:o?.title||A})}),(0,Q.jsx)(`span`,{className:q(`block truncate font-mono`,$),children:R})]}),(0,Q.jsx)(be,{checked:!0,disabled:!0,label:X(`page.showOnPage`),onChange:()=>{}})]}),(0,Q.jsx)(`p`,{className:$,children:X(`page.inShareHint`)})]});return(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-9`,children:[(0,Q.jsxs)(`div`,{className:`contents`,children:[(0,Q.jsx)(J,{id:`page`,children:(0,Q.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`px-1`,children:[(0,Q.jsx)(`h2`,{className:`font-display font-semibold text-lg leading-tight`,children:X(`space.page`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-snug`,children:X(`page.intro`)})]}),(0,Q.jsxs)(p,{className:`flex flex-wrap items-center gap-3 p-3 sm:pl-4`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:q(`size-2 shrink-0 rounded-full`,s?`bg-moss`:`bg-ink-4`),"aria-hidden":!0}),B]}),(0,Q.jsxs)(`span`,{className:`flex w-full items-center gap-2 sm:w-auto sm:shrink-0`,children:[(0,Q.jsxs)(F,{variant:`secondary`,size:`sm`,className:`max-sm:flex-1`,disabled:!s,onClick:()=>S(z),children:[x?(0,Q.jsx)(N,{className:`size-3.5`}):(0,Q.jsx)(te,{className:`size-3.5`}),X(x?`share.copied`:`share.copyMain`)]}),(0,Q.jsxs)(F,{size:`sm`,className:`max-sm:flex-1`,disabled:!s,onClick:()=>window.open(z,`_blank`,`noopener`),children:[X(`page.open`),` `,(0,Q.jsx)(Rt,{className:`size-3.5`})]})]})]}),(0,Q.jsxs)(Y,{title:X(`page.sectionPage`),locked:a,children:[(0,Q.jsxs)(`fieldset`,{"aria-label":X(`page.sectionPage`),className:`grid min-w-0 gap-3 sm:grid-cols-[repeat(3,minmax(0,1fr))]`,children:[(0,Q.jsx)(Nr,{title:X(`page.whoOff`),text:X(`page.whoOffHint`),picked:!s,disabled:a||P,onPick:()=>M(!1)}),(0,Q.jsx)(Nr,{title:X(`page.whoPublic`),text:X(`page.whoPublicHint`),picked:s,disabled:a||P,onPick:()=>M(!0)}),(0,Q.jsx)(Nr,{title:X(`page.whoMembers`),text:X(`page.whoMembersHint`),picked:!1,later:!0,onPick:()=>{}})]}),I?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:I.message}):null]})]})}),H,(0,Q.jsx)(J,{id:`page-words`,children:(0,Q.jsx)(Y,{title:X(`page.sectionWords`),hint:o?void 0:X(`page.notYet`),save:o?v:void 0,locked:V,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[o?(0,Q.jsx)(Gr,{host:r,page:o,disabled:a,save:g,onState:y},`${e.id}:${o.slug}`):(0,Q.jsx)(Ar,{host:r,disabled:!0,words:{slug:L,title:A,headline:``,intro:``,voice:xt===`de`?`de-du`:`en`},onChange:()=>{}}),(0,Q.jsxs)(`div`,{id:`page-wizards`,className:`scroll-mt-6 border-border-soft border-t pt-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:X(`page.sectionWizards`)}),(0,Q.jsx)(`span`,{className:$,children:X(`page.wizardsHint`)})]}),(0,Q.jsxs)(`ul`,{className:`mt-2 flex flex-col`,children:[T.map((e,t)=>(0,Q.jsx)(Mr,{wizard:e,first:t===0,on:!0,disabled:V,onToggle:t=>ee(e.id,t),drag:{onDragStart:()=>O(t),onDragOver:e=>e.preventDefault(),onDrop:()=>{D!==null&&k(D,t),O(null)},onKeyDown:e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),k(t,e.key===`ArrowUp`?t-1:t+1))}}},e.id)),E.map(e=>(0,Q.jsx)(Mr,{wizard:e,first:!1,on:!1,disabled:V,onToggle:t=>ee(e.id,t)},e.id))]}),w.length?null:(0,Q.jsx)(`p`,{className:q(`mt-2`,$),children:X(`page.noWizards`)}),(0,Q.jsx)(`p`,{className:q(`mt-4`,$),children:X(`page.wizardsNote`)})]}),(0,Q.jsx)(Or,{})]})})})]}),re]})}var qr=`results-search`,Jr={q:``,mode:``,days:0};function Yr(e,t,n){let r=new URLSearchParams;t&&r.set(`wizard`,t),n.q.trim()&&r.set(`q`,n.q.trim()),n.mode&&r.set(`mode`,n.mode),n.days&&r.set(`days`,String(n.days));let i=r.toString();return Se({queryKey:[`results`,e,i],queryFn:()=>f.get(`/api/studio/projects/${e}/results${i&&`?${i}`}`),enabled:!!e,placeholderData:e=>e,refetchInterval:15e3})}function Xr({data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}){let[a,o]=(0,Z.useState)(r.q);return Nt({icon:le,label:X(`space.resultsSearch`),run:()=>{let e=document.getElementById(qr);e?.scrollIntoView({block:`center`,behavior:`smooth`}),e?.focus()}}),(0,Z.useEffect)(()=>{if(a===r.q)return;let e=setTimeout(()=>i({...r,q:a}),250);return()=>clearTimeout(e)},[a,r,i]),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(ae,{value:t??``,onChange:e=>n(e||null),options:[{value:``,label:X(`space.resultsAllWizards`)},...e.wizards.filter(e=>e.results||e.id===t).map(e=>({value:e.id,label:`${e.title} (${e.results})`}))],className:`w-56 max-sm:w-full`}),(0,Q.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-56`,children:[(0,Q.jsx)(le,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,Q.jsx)(L,{type:`search`,value:a,onChange:e=>o(e.target.value),id:qr,placeholder:X(`space.resultsSearch`),"aria-label":X(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,Q.jsx)(ae,{value:r.mode,onChange:e=>i({...r,mode:e}),options:[{value:``,label:X(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,Q.jsx)(ae,{value:String(r.days),onChange:e=>i({...r,days:Number(e)}),options:[{value:`0`,label:X(`space.resultsAnyTime`)},{value:`1`,label:X(`space.resultsDay`)},{value:`7`,label:X(`space.resultsDays`,{n:7})},{value:`30`,label:X(`space.resultsDays`,{n:30})}],className:`w-44`})]})}function Zr({data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}){let[a,o]=(0,Z.useState)(null),s=t=>e.wizards.find(e=>e.id===t)?.title??``,l=new Intl.DateTimeFormat(xt,{dateStyle:`medium`,timeStyle:`short`});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(Y,{title:t?s(t):X(`space.resultsAll`),hint:X(`space.resultsHint`),plain:!0,children:[(0,Q.jsx)(Xr,{data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}),e.runs.length?(0,Q.jsx)(p,{className:`flex flex-col p-1.5`,children:e.runs.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>o(e),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate text-[0.875rem]`,children:t?l.format(new Date(e.doneAt)):s(e.wizardId)}),(0,Q.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t?null:`${l.format(new Date(e.doneAt))} · `,X(`space.resultCredits`,{n:e.credits})]})]}),e.assets?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3 tabular-nums`,title:X(`space.resultFiles`,{n:e.assets}),children:[(0,Q.jsx)(c,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,Q.jsx)(y,{children:X(`run.testChip`)}):(0,Q.jsxs)(y,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,Q.jsx)(p,{children:(0,Q.jsx)(_,{children:r.q.trim()||r.mode||r.days?X(`space.resultsNone`):X(`space.resultsEmpty`)})})]}),a?(0,Q.jsx)(tt,{header:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem]`,children:s(a.wizardId)}),a.mode===`test`?(0,Q.jsx)(y,{children:X(`run.testChip`)}):(0,Q.jsxs)(y,{tone:`live`,children:[`Live v`,a.version]})]}),onClose:()=>o(null),children:(0,Q.jsx)(lt,{runId:a.id,compact:!0,studio:!0},a.id)}):null]})}function Qr(e){let t=e.join(` `),[n,r]=(0,Z.useState)(e[0]);return(0,Z.useEffect)(()=>{let e=t.split(` `),n=0,i=()=>{n=0;let t=Ht(),i=t.scrollTop>0&&t.clientHeight+t.scrollTop>=t.scrollHeight-4,a=(t===document.documentElement?0:t.getBoundingClientRect().top)+Math.max(120,t.clientHeight/3),o=e[0];for(let t of e){let e=document.getElementById(t)?.getBoundingClientRect().top;e!==void 0&&e<=a&&(o=t)}r(i?e.at(-1):o)},a=()=>{n||=requestAnimationFrame(i)};return i(),window.addEventListener(`scroll`,a,{passive:!0,capture:!0}),window.addEventListener(`resize`,a),()=>{cancelAnimationFrame(n),window.removeEventListener(`scroll`,a,{capture:!0}),window.removeEventListener(`resize`,a)}},[t]),n}function $r(){let[e,t]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let e=Ht(),n=()=>t(e.clientHeight);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[]),e}function ei(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function ti({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,Q.jsx)(Wt,{icon:e.icon??Ie,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,Q.jsx)(qt,{label:e.label,children:r},e.plugin):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},`own`)})}function ni(){let{group:e}=re(),[t,n]=_e(),r=de(),i=xe(),{hash:a}=i,{project:o,loading:s}=ut(),c=Vt(),l=$t(),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),g=jt(e)?e:void 0,v=g?void 0:c.spaceParts.find(t=>t.id===e),y=g??v?.id,b=i.state?.parts===!0,x=Ot(`pages`),S=It().filter(e=>x||e.id!==`page`),C=Mt(S,c).map(e=>({...e,to:`/space/${e.id}`})),w={id:`results`,label:X(`space.results`),icon:wt,to:`/space/results`},T=g===`results`?w:C.find(e=>e.id===y),E=t.get(`show`),D=g===`results`?2:y?E?2:1:0,O=g===`results`?1:l?Math.min(D,1):y&&m!==y&&!b?1:0,k=Kt(O),ee=Kt(D),te=(0,Z.useMemo)(()=>({slot:u,narrow:l,setDetail:p}),[u,l]),A=o?o.brand.name?.trim()||o.name:X(`nav.space`),j=Ot(`typography`)?[]:[`typography`],M=v?c.spaceMenus[v.id]??[]:[],N=v?[{plugin:null,label:null,sections:M}]:g&&g!==`results`?Lt(g,c,j):[],P=g?Lt(g,c).filter(e=>e.plugin):[],ne=Qr([...N,...g===`results`?P:[]].flatMap(e=>e.sections.map(e=>e.id))),F=g===`results`&&E&&E!==`all`?E:null,[I,L]=(0,Z.useState)(Jr),R=Yr(g===`results`?o?.id:void 0,F,I),z=R.data?.wizards.find(e=>e.id===F)?.title,B=g===`data`&&E&&E!==`all`||g===`knowledge`&&E&&/^[ptfcvs]:/.test(E)?E:null,V=B?.startsWith(`s:`)?c.spaceSections.find(e=>e.id===B.slice(2)):void 0,H=g===`knowledge`&&B&&/^[ptf]:/.test(B)?B:null,ie=Ge(g===`data`?o?.id:void 0),U=Qe(g===`knowledge`?o?.id:void 0),W=at(B?.startsWith(`v:`)?B.slice(2):``),ae=U.data?.categories.find(e=>e.id===(B?.startsWith(`c:`)?B.slice(2):W.data?.category.id)),se=g===`knowledge`?V?V.label():B?.startsWith(`v:`)?W.data&&`${W.data.category.name}: ${W.data.value}`:B?.startsWith(`c:`)?ae?.name:U.data?.items.find(e=>e.key===B)?.title:ie.data?nt(ie.data).flatMap(e=>e.items).find(e=>e.key===B)?.title:void 0;Ut([...g===`results`?[]:[{label:X(`nav.sources`),to:`/space`}],...T?[{label:T.label,to:`/space/${T.id}`}]:[],...T&&(f??z??se)?[{label:f??z??se}]:[]]);let ce={p:`page`,t:`table`,f:`file`,c:`category`,v:`category value`,s:`plugin section`};Pt({...g===`data`||g===`results`?{compact:!0}:{},...g===`data`?{suggestions:[{label:X(`assistant.suggest.dataWhat`)},{label:X(`assistant.suggest.dataWho`)},{label:X(`assistant.suggest.dataEdit`)}]}:g===`results`?{suggestions:[{label:X(`assistant.suggest.resultsFailed`)},{label:X(`assistant.suggest.resultsCost`)},{label:X(`assistant.suggest.resultsShare`)}]}:{},...B&&se?{open:{kind:ce[B[0]]??`item`,id:B.slice(2),label:se}}:F&&z?{open:{kind:`wizard`,id:F,label:z}}:{}});let G=g===`results`||g===`data`||B?a.slice(1):E||a.slice(1),le=(0,Z.useRef)(``);(0,Z.useEffect)(()=>{let e=`${y}#${G}`;G&&le.current!==e&&document.getElementById(G)&&(le.current=e,requestAnimationFrame(()=>ei(G,!1)))},[y,G,o?.id,c.spaceSections,M.length]),(0,Z.useEffect)(()=>{!l&&(y===`knowledge`||y===`data`)&&Ht().scrollTo({top:0})},[l,y,B]);let ue=$r();if(!y){let t=a.slice(1),n=t?At(t,c):null;if(n===`knowledge`&&c.spaceSections.some(e=>e.id===t))return(0,Q.jsx)(oe,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,Q.jsx)(oe,{to:l?`/space/${n}?show=${t}`:{pathname:`/space/${n}`,hash:t},replace:!0});if((t||e)&&c.status!==`ready`)return null;if(e!==void 0||!l)return(0,Q.jsx)(oe,{to:`/space/info`,replace:!0,state:{parts:!0}})}let fe=g===`info`?E??a.slice(1):``;if(fe&&At(fe,c)===`brand`)return(0,Q.jsx)(oe,{to:l?`/space/brand?show=${fe}`:{pathname:`/space/brand`,hash:fe},replace:!0});if(g===`knowledge`&&!E&&c.spaceSections.some(e=>e.id===a.slice(1)))return(0,Q.jsx)(oe,{to:`/space/knowledge?show=s:${a.slice(1)}`,replace:!0});let pe=e=>{if(l){r({search:`?show=${e}`});return}le.current=`${y}#${e}`,ei(e,!0),r({search:``,hash:e},{replace:!0})},K=e=>l?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),me=e=>e.flatMap(e=>e.sections).map(e=>c.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,Q.jsx)(J,{id:e.id,children:(0,Q.jsx)(Y,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,Q.jsx)(Bt,{of:e,children:(0,Q.jsx)(e.component,{})})})},e.serial)),he=l?void 0:ne,ge=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Jt,{title:A,open:O===1?T??null:null,onBack:g===`results`?void 0:()=>l?r(`/space`):h(y??null),root:{icon:Dt,label:X(`nav.sources`),backLabel:X(`nav.wizards`),onBack:()=>r(`/`)}}),(0,Q.jsx)(`div`,{className:q(Gt(k)),children:O===0?(0,Q.jsx)(Xt,{entries:C,current:l?void 0:T,onPick:()=>h(null)}):(0,Q.jsx)(`div`,{ref:d})},O)]});return(0,Q.jsx)(Yt.Provider,{value:te,children:(0,Q.jsx)(`div`,{className:`animate-rise`,children:(0,Q.jsxs)(`div`,{className:q(`grid gap-6`,g!==`results`&&`md:grid-cols-[10.5rem_minmax(0,1fr)] md:gap-5 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`),children:[g===`results`?null:(0,Q.jsx)(`aside`,{className:q(`min-w-0 md:sticky md:top-6 md:self-start md:overflow-y-auto md:overscroll-contain`,l&&D===2&&`hidden`,l&&ee===`back`&&Gt(`back`)),style:!l&&ue?{maxHeight:ue-48,paddingBottom:`var(--assistant-dock, 0px)`}:void 0,children:ge}),y?(0,Q.jsxs)(`div`,{className:q(`min-w-0`,l&&D<2&&`hidden`,l&&ee===`deeper`&&Gt(`deeper`)),children:[l&&g!==`results`?(0,Q.jsx)(`div`,{className:`mb-3`,children:(0,Q.jsx)(Qt,{label:T?.label??A,onBack:()=>r(`/space/${y}`)})}):null,g===`data`?(0,Q.jsxs)(Zt,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(Wt,{icon:Et,label:X(`data.all`),selected:!l&&!B,onPick:()=>K(`all`)})}),ie.data?nt(ie.data).map(e=>(0,Q.jsx)(qt,{label:e.label,children:e.items.map(e=>(0,Q.jsx)(Wt,{icon:Ue[e.kind],label:e.title,selected:!l&&e.key===B,onPick:()=>K(e.key)},e.key))},e.key)):null,(0,Q.jsx)(ti,{groups:P,current:he,onPick:pe})]}):g===`knowledge`?(0,Q.jsxs)(Zt,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(Wt,{icon:Et,label:X(`know.all`),selected:!(l||B),onPick:()=>K(`all`)})}),U.data?.categories.length?(0,Q.jsx)(qt,{label:X(`know.categories`),children:U.data.categories.map(e=>(0,Q.jsx)(Wt,{icon:Ye[e.type],label:e.name,badge:(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.proposed?`·`:e.count}),selected:!l&&(B===`c:${e.id}`||W.data?.category.id===e.id),onPick:()=>K(`c:${e.id}`)},e.id))}):null,(0,Q.jsx)(ti,{groups:P,current:l?void 0:V?.id,onPick:e=>K(`s:${e}`)})]}):(0,Q.jsx)(Zt,{children:(0,Q.jsx)(ti,{groups:N,current:he,onPick:pe})}),o&&(g===`info`||g===`brand`||g===`knowledge`)?(0,Q.jsxs)(Cr,{project:o,group:g,top:!B||!!V,children:[g===`knowledge`?H?H.startsWith(`p:`)?(0,Q.jsx)(Ze,{pageId:H.slice(2),onGone:()=>K(`all`),onOpen:K},H):H.startsWith(`t:`)?(0,Q.jsx)(Xe,{tableId:H.slice(2),onGone:()=>K(`all`)},H):(0,Q.jsx)(jn,{projectId:o.id,fileId:H.slice(2),readOnly:o.readOnly,onGone:()=>K(`all`)},H):U.data?V?(0,Q.jsx)(Y,{title:V.label(),hint:V.hint?.(),plain:!0,children:(0,Q.jsx)(Bt,{of:V,children:(0,Q.jsx)(V.component,{})})},B):B?.startsWith(`c:`)?ae?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(Je,{projectId:o.id,category:ae,readOnly:o.readOnly,onOpen:K,onGone:()=>K(`all`)}),ae.type===`choice`?null:(0,Q.jsx)(it,{projectId:o.id,category:ae,categories:U.data.categories,onOpen:K})]},B):null:B?.startsWith(`v:`)?W.data?(0,Q.jsx)(He,{value:W.data,readOnly:o.readOnly,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[W.data.items.length?(0,Q.jsx)(`div`,{className:`flex flex-col rounded-xl bg-card p-1.5 shadow-soft ring-1 ring-border-soft`,children:W.data.items.map(e=>(0,Q.jsx)(Ke,{item:e,categories:U.data.categories.filter(e=>e.id!==W.data?.category.id),onOpen:K},e.key))}):null,W.data.rows.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>K(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:X(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},B):null:(0,Q.jsx)(J,{id:`documents`,children:(0,Q.jsx)(et,{projectId:o.id,data:U.data,readOnly:o.readOnly,onOpen:K})}):null:null,g===`info`||g===`brand`?me(P):null]},o.id):null,o&&g===`page`&&x?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,Q.jsx)(Kr,{project:o},o.id),me(P)]}):null,o&&v?(0,Q.jsx)(Bt,{of:v,children:(0,Q.jsx)(kt,{part:v.id,children:(0,Q.jsx)(v.component,{})},o.id)}):null,o&&g===`data`?(0,Q.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:B?.startsWith(`t:`)?(0,Q.jsx)(Xe,{tableId:B.slice(2),onGone:()=>K(`all`)},B):B?.startsWith(`p:`)?(0,Q.jsx)(Ze,{pageId:B.slice(2),onGone:()=>K(`all`)},B):(0,Q.jsxs)(Q.Fragment,{children:[ie.data?(0,Q.jsx)($e,{projectId:o.id,data:ie.data,readOnly:o.readOnly,onOpen:K}):null,me(P)]})}):null,o&&g===`results`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[R.data?(0,Q.jsx)(Zr,{data:R.data,wizardId:F,onWizard:e=>K(e??`all`),filter:I,onFilter:L}):null,R.isError?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:R.error.message}):null,me(P)]}):null,o||s?null:(0,Q.jsx)(_,{children:X(`settings.noProject`)})]}):null]})})})}export{ni as ProjectPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{G as r,Q as i,Rt as a,Wt as o,Xn as s,Yt as c,ar as l,dt as u,er as d,ft as f,ir as p,on as m,ot as h,qn as g,rr as _,sn as v,sr as y,st as b,tn as x}from"./ui-Bhp_a_44.js";import{_ as S,b as C,d as w,f as ee,g as T,h as E,m as D,n as te,p as ne,v as O,y as k}from"./theme-DftQJmEW.js";import{O as re,S as A,b as j,x as M}from"./session-CngLvd02.js";import{V as N,a as P,l as F,s as I}from"./i18n-BYeH2Dmi.js";import{St as L,et as R}from"./index-C0yASttP.js";var ie={name:`bookmark`,size:24,node:[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]};ie.node;var ae=s(ie),oe={name:`square-plus`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]],aliases:[`plus-square`]};oe.node;var se=s(oe),z=e(t(),1);function ce(){if(window.self===window.top)return null;let e=new URLSearchParams(window.location.search).get(`embed`);return e===`inline`||e===`modal`||e===`popout`?e:null}var B=ce(),le=B?new URLSearchParams(window.location.search).get(`page`):null,V=new URLSearchParams(window.location.search).get(`theme`),H=V?`?theme=${encodeURIComponent(V)}`:``,U=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`),ue=()=>U(`close`);function de(e){(0,z.useEffect)(()=>{if(B===`inline`&&!e){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>U(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(B===`modal`||B===`popout`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&U(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[e])}var W=e(n(),1),G=`wizards.runner.translate`,K=new Set;function fe(){try{return localStorage.getItem(G)===`on`}catch{return!1}}function pe(e){try{localStorage.setItem(G,e?`on`:`off`)}catch{}for(let e of K)e()}function me(){return(0,z.useSyncExternalStore)(e=>(K.add(e),()=>K.delete(e)),fe)}function he(e){let t=me(),[n]=(0,z.useState)(()=>F()),i=e?.lang??`en`,a=e?.translatable&&n&&n!==i?n:null,o=a&&t?a:i,s=e?.token,c=y({queryKey:[`public-translation`,s,o],enabled:!!(s&&o!==i),queryFn:()=>r.post(`/api/public/wizards/${s}/translation${H}`,{lang:o}),staleTime:1/0,retry:!1}),l=y({queryKey:[`public-texts`,s,o],enabled:!(!s||N(o)),queryFn:()=>r.get(`/api/public/wizards/${s}/texts/${o}`),staleTime:1/0,retry:!1}),u=!N(o),d=o===i||c.data&&(!u||l.data),f=o!==i&&(c.isError||u&&l.isError),p=d&&!f?o:i,m=(0,z.useMemo)(()=>!N(p)&&l.data?.lang===p?{lang:l.data.lang,runner:l.data.runner,notes:l.data.notes}:null,[p,l.data]);if((0,z.useEffect)(()=>{e&&P(p,m)},[e,p,m]),(0,z.useEffect)(()=>()=>P(null),[]),!e)return null;let h=p!==i&&c.data?c.data:null;return{own:i,other:a,shown:p,wizard:h??e,translating:o!==i&&!d&&!f,failed:!!f,translated:!!h,machine:h?.translation?.machine??!1,pick:e=>pe(e!==i)}}function q({page:e,tone:t=`ground`}){if(!e?.other)return null;let n=e.translating?e.other:e.shown;return(0,W.jsx)(R,{langs:[e.own,e.other],value:n,onPick:e.pick,tone:t})}function J({page:e,small:t}){if(!e)return null;let n=t?`truncate text-[0.75rem]`:`text-[0.8125rem]`;return e.failed?(0,W.jsx)(`p`,{className:m(`text-ink-3`,n),children:I(`translation.failed`)}):e.translated?(0,W.jsxs)(`p`,{className:m(`text-ink-3`,n),children:[e.machine?(0,W.jsxs)(W.Fragment,{children:[I(`translation.machine`),` · `]}):null,(0,W.jsx)(`button`,{type:`button`,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,onClick:()=>e.pick(e.own),children:I(`translation.showOriginal`)})]}):null}function ge(e,t){let n=(0,z.useRef)(null),i=t&&!t.translating?t.translated?t.shown:null:void 0;(0,z.useEffect)(()=>{if(!e||i===void 0)return;let t=`${e}:${i}`;n.current!==t&&(n.current=t,r.post(`/api/runs/${e}/lang`,{lang:i}).catch(()=>void 0))},[e,i])}function _e(e,t){(0,z.useEffect)(()=>{if(!e||!t)return;let n=h(`/api/public/wizards/${e}`),r=[{rel:`manifest`,href:`${n}/manifest.webmanifest`},{rel:`apple-touch-icon`,href:`${n}/icons/apple-touch-icon.png`},{rel:`icon`,href:`${n}/icons/favicon.png`,type:`image/png`}].flatMap(({rel:e,href:t,type:n})=>{let r=document.querySelector(`link[rel="${e}"]`);if(!r)return[];let i={href:r.getAttribute(`href`),type:r.getAttribute(`type`)};return r.setAttribute(`href`,t),n&&r.setAttribute(`type`,n),[{link:r,before:i}]}),i=document.createElement(`meta`);return i.name=`apple-mobile-web-app-title`,i.content=t,document.head.appendChild(i),()=>{for(let{link:e,before:t}of r)for(let[n,r]of Object.entries(t))r===null?e.removeAttribute(n):e.setAttribute(n,r);i.remove()}},[e,t])}var ve=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,Y=ve||/Android/.test(navigator.userAgent);function ye(){let[e,t]=(0,z.useState)(()=>window.wizardInstall??null),[n,r]=(0,z.useState)(!1);if((0,z.useEffect)(()=>{let e=()=>t(window.wizardInstall??null);return window.addEventListener(`wizard-install`,e),()=>window.removeEventListener(`wizard-install`,e)},[]),window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0||Y&&!e&&!ve)return null;let i=/Mac/.test(navigator.platform),a=I(Y?`install.ios`:i?`install.bookmark.mac`:`install.bookmark.pc`);return(0,W.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>{Y&&e?(e.prompt(),window.wizardInstall=null,t(null)):r(e=>!e)},className:`inline-flex items-center gap-1.5 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[Y?(0,W.jsx)(se,{className:`size-4`}):(0,W.jsx)(ae,{className:`size-4`}),I(Y?`install.add`:`install.bookmark`)]}),n?(0,W.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:a}):null]})}function be({brand:e,toggle:t=!0,start:n}){return(0,W.jsx)(`header`,{className:`safe-top`,children:(0,W.jsxs)(`div`,{className:`relative flex h-14 items-center justify-center px-5`,children:[n?(0,W.jsx)(`div`,{className:`absolute left-3`,children:n}):null,e.logoUrl?(0,W.jsx)(`img`,{src:h(e.logoUrl),alt:e.name,className:`h-7 max-w-[160px] object-contain`}):e.name?(0,W.jsx)(`span`,{className:`max-w-[60%] truncate font-display font-semibold text-[0.9375rem] text-ink-2 tracking-tight`,children:e.name}):null,t?(0,W.jsx)(`div`,{className:`absolute right-3`,children:(0,W.jsx)(A,{})}):null]})})}function xe({siteKey:e,onToken:t}){let n=(0,z.useRef)(null);return(0,z.useEffect)(()=>{let r=()=>{n.current&&window.turnstile&&!n.current.childElementCount&&window.turnstile.render(n.current,{sitekey:e,callback:t,appearance:`interaction-only`})};if(window.turnstile){r();return}let i=document.createElement(`script`);i.src=`https://challenges.cloudflare.com/turnstile/v0/api.js`,i.async=!0,i.onload=r,document.head.appendChild(i)},[e,t]),(0,W.jsx)(`div`,{ref:n,className:`mt-4 flex justify-center`})}function Se({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||b||B?null:(0,W.jsxs)(`a`,{href:u(`${window.location.origin}${i}/w/${e}`),className:`mt-3 inline-flex items-center gap-1.5 text-[0.8125rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[(0,W.jsx)(C,{className:`size-4`}),` `,I(`install.app`)]})}var X=e=>`wz.run.${e}`,Z=()=>_().state?.elsewhere===!0,Ce=b&&new URLSearchParams(window.location.search).get(`start`)===`1`,Q=B===`inline`?`min-h-80`:`min-h-dvh`;function $(e,t,n){let i=p(),[a,o]=(0,z.useState)(!1),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(null),d=(()=>{try{return localStorage.getItem(X(e.token))}catch{return null}})();return{busy:a,error:s,captcha:l,setCaptcha:u,start:async()=>{o(!0),c(null);try{let{runId:a}=await r.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:l??void 0,embedded:B!==null,origin:le??void 0,lang:n??void 0});try{localStorage.setItem(X(e.token),a)}catch{}i(`${t}/${a}`,{replace:Ce})}catch(e){c(e.message),o(!1)}},resume:d?()=>i(`${t}/${d}`):null}}function we({wizard:e,page:t}){let{busy:n,error:r,captcha:i,setCaptcha:a,start:s,resume:c}=$(e,`/w/${e.token}`,t?.translated?t.shown:null),l=Z(),u=Ce&&e.available&&!e.turnstileSiteKey,d=(0,z.useRef)(!1);return(0,z.useEffect)(()=>{u&&!d.current&&(d.current=!0,s())},[u]),u&&!r?(0,W.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,W.jsx)(x,{})}):(0,W.jsxs)(`div`,{className:`mx-auto flex max-w-lg animate-rise flex-col items-center px-6 pt-6 pb-12 text-center sm:pt-16 sm:pb-16`,children:[l?(0,W.jsx)(`p`,{className:`mb-6 rounded-xl bg-paper-2 px-5 py-3 text-[0.875rem] text-ink-2`,children:I(`run.elsewhere`)}):null,(0,W.jsx)(M,{kind:e.avatar,costume:e.costume,size:190,fluffy:!0}),(0,W.jsx)(`h1`,{className:`wizard-title mt-2 text-balance font-display font-semibold text-[1.875rem] leading-[1.1] tracking-tight sm:text-[2.125rem]`,children:e.title}),e.description?(0,W.jsx)(`p`,{className:`mt-3 text-[1rem] text-ink-2 leading-relaxed`,children:e.description}):null,(0,W.jsx)(`div`,{className:`mt-3`,children:(0,W.jsx)(J,{page:t})}),e.available?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(o,{size:`lg`,className:`mt-10 min-w-48`,busy:n,disabled:!!e.turnstileSiteKey&&!i,onClick:s,children:[I(`run.start`),` `,(0,W.jsx)(g,{className:`size-4`})]}),e.turnstileSiteKey?(0,W.jsx)(xe,{siteKey:e.turnstileSiteKey,onToken:a}):null,c?(0,W.jsx)(`button`,{type:`button`,onClick:c,className:`mt-4 text-[0.875rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:I(`run.resume`)}):null,(0,W.jsx)(Te,{wizard:e,current:`steps`}),B||b?null:(0,W.jsx)(ye,{}),(0,W.jsx)(Se,{token:e.token})]}):(0,W.jsx)(`p`,{className:`mt-10 rounded-xl bg-paper-2 px-5 py-4 text-[0.9375rem] text-ink-2`,children:e.unavailableReason??I(`run.unavailable`)}),r?(0,W.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:r}):null]})}function Te({wizard:e,current:t}){let n=e.runners.filter(e=>e.id!==t&&e.kind===`page`&&e.url);return n.length?(0,W.jsx)(`p`,{className:`mt-4 flex flex-wrap justify-center gap-x-4 text-[0.875rem] text-ink-3`,children:n.map(e=>(0,W.jsx)(`a`,{href:e.url??void 0,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:I(`run.orAs`,{label:e.label})},e.id))}):null}function Ee({wizard:e,page:t}){let n=k();return(0,W.jsx)(`header`,{className:`safe-top shrink-0 border-border-soft border-b`,children:(0,W.jsxs)(`div`,{className:`mx-auto flex h-16 w-full max-w-[760px] items-center gap-3 pr-2 pl-4 sm:pr-4 sm:pl-6`,children:[(0,W.jsx)(`span`,{className:m(n?.speaking&&`animate-breathe`),children:(0,W.jsx)(M,{kind:e.avatar,costume:e.costume,size:38})}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`truncate font-display font-semibold text-[1rem] leading-tight tracking-tight`,children:e.title}),e.brand.name?(0,W.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:e.brand.name}):null,(0,W.jsx)(J,{page:t,small:!0})]}),e.brand.logoUrl&&B!==`popout`?(0,W.jsx)(`img`,{src:h(e.brand.logoUrl),alt:e.brand.name,className:`h-6 max-w-[120px] object-contain max-sm:hidden`}):null,(0,W.jsx)(q,{page:t,tone:`surface`}),B?null:(0,W.jsx)(A,{}),B===`popout`?(0,W.jsx)(c,{label:I(`common.close`),onClick:ue,children:(0,W.jsx)(v,{className:`size-5`})}):null]})})}function De({door:e,wizard:t,page:n,header:r,footer:i}){let{busy:a,error:o,captcha:s,setCaptcha:c,start:l,resume:u}=$(t,`/w/${t.token}/${e}`,n?.translated?n.shown:null),d=Z(),f=[];return d&&f.push({key:`elsewhere`,who:`bot`,node:I(`run.elsewhere`)}),f.push({key:`hello`,who:`bot`,node:t.description||t.title}),e!==`chat`&&f.push({key:e,who:`bot`,node:I(e===`video`?`video.hint`:`talk.joinHint`)}),t.available||f.push({key:`unavailable`,who:`bot`,node:t.unavailableReason??I(`run.unavailable`)}),o&&f.push({key:`error`,who:`bot`,node:o,tone:`error`}),t.available&&f.push(O(`start`,(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(T,{primary:!0,busy:a,disabled:!!t.turnstileSiteKey&&!s,onClick:()=>void l(),children:[I(`run.start`),` `,(0,W.jsx)(g,{className:`size-4`})]}),u?(0,W.jsx)(T,{onClick:u,children:I(`run.resume`)}):null,t.turnstileSiteKey?(0,W.jsx)(xe,{siteKey:t.turnstileSiteKey,onToken:c}):null]}))),(0,W.jsxs)(D,{header:r,footer:i,children:[(0,W.jsx)(S,{avatar:t.avatar,costume:t.costume,lines:f}),(0,W.jsx)(E,{})]})}function Oe({className:e}){return(0,W.jsx)(`footer`,{className:m(`text-center text-ink-4`,e),children:(0,W.jsx)(`a`,{href:`${i}/`,target:B?`_blank`:void 0,rel:`noreferrer`,className:`inline-block hover:text-ink-2`,children:I(`run.madeWith`).replace(`engenty wizards`,j.name)})})}function ke({chat:e=!1,steps:t=!1,talk:n=!1,video:s=!1}){let{token:c,runId:u}=l(),h=p(),g=y({queryKey:[`public`,c,H],queryFn:()=>r.get(`/api/public/wizards/${c}${H}`),retry:(e,t)=>a(t)&&e<3}),_=g.data?.runners??[],v=!g.data||_.some(e=>e.id===`talk`),S=!g.data||_.some(e=>e.id===`video`),C=!g.data||_.some(e=>e.id===`chat`)||n&&v||s&&S,T=_[0]?.id,E=e||B===`popout`||!t&&!u&&C&&(T===`chat`||T===`talk`||T===`video`),D=s&&S||!t&&!e&&!n&&T===`video`,O=!D&&(n&&v||!t&&!e&&T===`talk`),k=D?`video`:O?`talk`:`chat`,A=he(g.data);ge(u,A),te(g.data?.brand.theme),re(g.data?.avatar),_e(c,g.data?.title),de(E);let N=A?.wizard.title??g.data?.title;(0,z.useEffect)(()=>{N&&(document.title=N)},[N]);let P=(0,z.useCallback)(e=>{try{c&&localStorage.getItem(X(c))===u&&localStorage.removeItem(X(c))}catch{}h(e,{replace:!0,state:{elsewhere:!0}})},[h,c,u]);if((0,z.useEffect)(()=>{c&&u&&f(`run`,{token:c,runId:u})},[c,u]),g.isLoading)return(0,W.jsx)(`div`,{className:m(`flex items-center justify-center text-ink-4`,Q),children:(0,W.jsx)(x,{})});if(e&&g.data&&!C||n&&g.data&&!v||s&&g.data&&!S)return(0,W.jsx)(d,{to:`/w/${c}`,replace:!0});if(!g.data){let e=a(g.error);return(0,W.jsxs)(`div`,{className:m(`flex flex-col items-center justify-center gap-4 px-6 text-center`,Q),children:[(0,W.jsx)(M,{kind:`pebble`,size:80}),(0,W.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:I(e?`common.offline`:`run.notFound`)}),e?(0,W.jsx)(o,{variant:`secondary`,onClick:()=>void g.refetch(),children:I(`common.retry`)}):null]})}let F=A?.wizard??g.data,R=A?.translating?(0,W.jsxs)(`div`,{className:m(`flex flex-col items-center justify-center gap-3 text-ink-3`,Q),children:[(0,W.jsx)(x,{}),(0,W.jsx)(`p`,{className:`text-[0.875rem]`,children:I(`translation.working`)})]}):null;if(E){let e=(0,W.jsx)(Ee,{wizard:F,page:A}),t=b?(0,W.jsx)(`div`,{className:`safe-bottom`}):(0,W.jsx)(Oe,{className:`pb-[max(0.375rem,env(safe-area-inset-bottom))] text-[0.6875rem]`});return(0,W.jsxs)(`div`,{className:`wizard-page flex h-dvh flex-col`,children:[(0,W.jsx)(w,{effects:g.data.brand.theme.effects}),B||b?null:(0,W.jsx)(L,{}),R??(u?(0,W.jsx)(ne,{runId:u,talk:O,call:D?`video`:O?`audio`:!1,onRestart:()=>h(`/w/${c}/${k}`),onNotFound:()=>P(`/w/${c}/${k}`),header:D||O?void 0:e,footer:t}):(0,W.jsx)(De,{wizard:F,page:A,header:e,footer:t,door:k}))]})}return(0,W.jsxs)(`div`,{className:m(`wizard-page flex flex-col`,Q),children:[(0,W.jsx)(w,{effects:g.data.brand.theme.effects}),B||b?null:(0,W.jsx)(L,{}),B===`inline`||b?null:(0,W.jsx)(be,{brand:g.data.brand,toggle:!B,start:(0,W.jsx)(q,{page:A})}),B===`inline`||b?(0,W.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,W.jsx)(q,{page:A,tone:`surface`})}):null,u&&(A?.translated||A?.failed)?(0,W.jsx)(`div`,{className:`flex justify-center px-5`,children:(0,W.jsx)(J,{page:A})}):null,(0,W.jsx)(`div`,{className:`flex-1`,children:R??(u?(0,W.jsx)(ee,{runId:u,onRestart:()=>h(`/w/${c}`),onNotFound:()=>P(`/w/${c}`)}):(0,W.jsx)(we,{wizard:F,page:A}))}),b?(0,W.jsx)(`div`,{className:`safe-bottom`}):(0,W.jsx)(`footer`,{className:`safe-bottom pt-6 text-center text-[0.75rem] text-ink-4`,children:(0,W.jsx)(`a`,{href:`${i}/`,target:B?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:I(`run.madeWith`).replace(`engenty wizards`,j.name)})})]})}export{be as BrandHeader,ke as PublicRunner};
|