PageSourceSearch

https://personaresearch.ai/assets/StudyWizard-DL17QlYb.js

js personaresearch.ai collected 2026-10-05 16:14:37 UTC 19,723 bytes, 3 lines download raw bytes

1import{r as j,j as s,M as g,L as T,u as q}from"./index-DRqqyXod.js";const y=20,x=(e,t)=>({field:e,message:t,severity:"error"}),v=(e,t)=>({field:e,message:t,severity:"warning"});function E(e){var i,d,h,r,c,p,w,u,S,C;const t=[];(i=e.objective)!=null&&i.trim()||t.push(x("objective","Say what you are trying to learn.")),(d=e.studyName)!=null&&d.trim()||t.push(x("studyName","The study needs a name.")),(r=(h=e.targetAudience)==null?void 0:h.plainEnglish)!=null&&r.trim()||t.push(x("targetAudience.plainEnglish","Describe who you want to ask."));const n=e.questions??[],a=n.filter(b=>{var k;return(k=b==null?void 0:b.text)==null?void 0:k.trim()});a.length===0&&t.push(x("questions","Add at least one question.")),n.length!==a.length&&t.push(v("questions","Blank questions will be dropped at handoff."));const l=e.respondentCount;!Number.isFinite(l)||!Number.isInteger(l)?t.push(x("respondentCount","Respondent count must be a whole number.")):l<1?t.push(x("respondentCount","A study needs at least one respondent.")):l>y&&t.push(x("respondentCount",`A single study can include at most ${y} personas.`));const o=e.personaSourceRecommendation;
1return o?((c=o.rationale)!=null&&c.trim()||t.push(v("personaSourceRecommendation.rationale","No rationale recorded.")),o.mode==="existing_collection"&&!((p=o.collectionIds)!=null&&p.length)&&t.push(x("personaSourceRecommendation.collectionIds","Pick at least one collection.")),o.mode==="create_new"&&!((w=o.newPersonaPrompts)!=null&&w.length)&&t.push(x("personaSourceRecommendation.newPersonaPrompts","Describe the personas that would need creating.")),(((u=o.personaIds)==null?void 0:u.length)??0)>y&&t.push(x("personaSourceRecommendation.personaIds",`At most ${y} personas.`)),(o.mode==="create_new"||o.mode==="mixed")&&t.push(v("personaSourceRecommendation.mode","New personas are a recommendation only — the wizard will not create them."))):t.push(x("personaSourceRecommendation","Choose where respondents come from.")),(S=e.projectRecommendation)!=null&&S.createNewProjectName&&t.push(v("projectRecommendation.createNewProjectName","New projects are a recommendation only — the wizard will not create one.")),(C=e.missingInputs)!=null&&C.length&&t.push(v("missingInputs",`${e.missingInputs.length} open question(s).`)),{valid:t.every(b=>b.severity!=="error"),errors:t.filter(b=>b.severity==="error"),warnings:t.filter(b=>b.severity==="warning")}}const O={objective:"",audience:"",existingQuestions:"",respondentCount:8,personaSource:"public_library",projectId:null,newProjectName:"",studyName:""},z=[{build:e=>({text:`How would you describe your experience with ${e}?`,type:"screening",rationale:"Establishes context and lets you segment answers by familiarity."})},{build:e=>({text:`When you think about ${e}, what matters most to you and why?`,type:"open_ended",rationale:"Unprompted priorities, before any option is put in front of them."})},{build:e=>({text:`What would stop you from choosing ${e}?`,type:"open_ended",rationale:"Surfaces objections, which are usually more actionable than praise."})},{build:e=>({text:`If you had to pick one improvement to ${e}, what would it be?`,type:"preference",rationale:"Forces a trade-off rather than a wish list."})}],W=["i'm trying to understand","i am trying to understand","i'm trying to learn","i am trying to learn","i'd like to understand","i'd like to learn","i'd like to know","i would like to know","i want to understand","i want to find out","i want to learn","i want to know","we're trying to understand","we are trying to understand","we want to understand","we want to learn","we want to know","i'm studying","i am studying","we're studying","we are studying","find out","figure out","work out","understand","investigate","determine","research","validate","discover","explore","learn","know","test"],D=["whether or not","whether","how much","how many","how often","how likely","how","why","what","when","where","which","who","if","that","do","does","did"],R=[{match:"pay for",label:(e,t)=>`${m(e)} willingness to pay for ${t}`},{match:"switch to",label:(e,t)=>`${m(e)} willingness to switch to ${t}`},{match:"recommend",label:(e,t)=>`${m(e)} likelihood of recommending ${t}`},{match:"subscribe to",label:(e,t)=>`${m(e)} willingness to subscribe to ${t}`},{match:"buy",label:(e,t)=>`${m(e)} willingness to buy ${t}`},{match:"use",label:(e,t)=>`${m(e)} likelihood of using ${t}`},{match:"prefer",label:(e,t)=>`${m(e)} preferences for ${t}`},{match:"choose",label:(e,t)=>`${m(e)} preferences for ${t}`},{match:"want",label:(e,t)=>`${m(e)} interest in ${t}`},{match:"need",label:(e,t)=>`${m(e)} interest in ${t}`}],A=R.map(e=>e.match).join("|"),I="would|will|do|does|did|are|is|can|might",_={prefers:"prefer",chooses:"choose",wants:"want",needs:"need",uses:"use",buys:"buy",recommends:"recommend","pays for":"pay for","subscribes to":"subscribe to","switches to":"switch to"},M=[...R.map(e=>e.match),...Object.keys(_)].sort((e,t)=>t.length-e.length).join("|");function Q(e){const t=e.trim().toLowerCase(),n=_[t]??t;return R.find(a=>a.match===n)}function m(e){const t=e.trim();return/s$/i.test(t)?`${t}’`:`${t}’s`}function $(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}function B(e){let t=e.trim().replace(/\s+/g," ").replace(/[.?!]+$/,"").trim(),n=!0;for(;n;){n=!1;for(const a of[...W,...D]){const l=new RegExp(`^${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b[,:\\s]+`,"i");if(l.test(t)){t=t.replace(l,"").trim(),n=!0;break}}}return t}function L(e){const t=B(e??"");if(!t)return{subject:"this",label:"Untitled study"};const n=new RegExp(`^(.+?)\\s+(?:${I})\\s+(?:be\\s+willing\\s+to\\s+)?(${A})\\s+(.+)$`,"i").exec(t),a=new RegExp(`^(?:${I})\\s+(.+?)\\s+(?:be\\s+willing\\s+to\\s+)?(${A})\\s+(.+)$`,"i").exec(t),l=new RegExp(`^(.+?)\\s+(${M})\\s+(.+)$`,"i").exec(t),o=n??a??l;if(o){const[,h,r,c]=o,p=Q(r);if(p)return{subject:c.trim(),label:$(p.label(h.trim(),c.trim()))}}const i=/^(.+?)\s+(?:think|thinks|feel|feels)\s+about\s+(.+)$/i.exec(t);if(i)return{subject:i[2].trim(),label:$(`${m(i[1].trim())} views on ${i[2].trim()}`)};const d=/^(.+?)\s+(?:react|reacts|respond|responds)\s+to\s+(.+)$/i.exec(t);return d?{subject:d[2].trim(),label:$(`${m(d[1].trim())} reactions to ${d[2].trim()}`)}:{subject:t,label:$(t)}}function U(e){const t=e.trim().replace(/\s+/g," ");
1if(!t)return"";const n=/[.?!]$/.test(t)?t:`${t}.`;return $(n)}function V(e){return e.split(`
2`).map(t=>t.replace(/^\s*[-*\d.)\s]+/,"").trim()).filter(t=>t.length>0).map(t=>({text:t,type:"open_ended",rationale:"Supplied by you."}))}const P=60;function F(e,t){var i;if((i=e.studyName)!=null&&i.trim())return e.studyName.trim();const{label:n}=t;if(!n||n==="Untitled study")return"Untitled study";if(n.length<=P)return n;const a=n.slice(0,P-1),l=a.lastIndexOf(" ");return`${(l>20?a.slice(0,l):a).replace(/[\s,;:]+$/,"")}…`}function H(e){const t=e.split(/[,;]|\band\b/i).map(o=>o.trim()).filter(Boolean),n=t.filter(o=>/manager|engineer|designer|founder|director|owner|student|nurse|teacher|developer|analyst/i.test(o)),a=t.filter(o=>/\d{2}\s*[-–]\s*\d{2}|aged?\s*\d|male|female|men|women|urban|rural|income/i.test(o)),l=t.filter(o=>!n.includes(o)&&!a.includes(o));return{plainEnglish:e.trim(),...a.length?{demographics:a}:{},...n.length?{roles:n}:{},...l.length?{interests:l}:{}}}function Y(e){switch(e){case"public_library":return"The library already covers this audience, so no persona creation is needed.";case"existing_collection":return"You have a saved panel that matches this audience.";case"create_new":return"The audience is specific enough that existing personas are unlikely to fit.";case"mixed":return"Part of the audience exists already; the rest would need creating."}}function G(e){var d,h,r;const t=L(e.objective),n=V(e.existingQuestions),a=n.length>0?n:z.map(c=>c.build(t.subject)),l=[],o=[];n.length>0?l.push(`Using your ${n.length} question(s) as written.`):l.push("Questions were drafted from your objective — edit them before running."),e.objective.trim()||o.push("What you are trying to learn."),e.audience.trim()||o.push("Who you want to ask."),e.respondentCount>y&&o.push(`A respondent count of ${y} or fewer.`),(e.personaSource==="create_new"||e.personaSource==="mixed")&&o.push("New personas must be created by you before the study can run."),!e.projectId&&!((d=e.newProjectName)!=null&&d.trim())&&l.push("No project selected — results will not be filed under one.");const i=e.personaSource==="create_new"||e.personaSource==="mixed"?[`A persona matching: ${e.audience.trim()||"your target audience"}`]:void 0;return{objective:e.objective.trim(),studyName:F(e,t),studyDescription:U(e.objective),targetAudience:H(e.audience),respondentCount:e.respondentCount,questions:a,personaSourceRecommendation:{mode:e.personaSource,...i?{newPersonaPrompts:i}:{},rationale:Y(e.personaSource)},...e.projectId||(h=e.newProjectName)!=null&&h.trim()?{projectRecommendation:{...e.projectId?{projectId:e.projectId}:{},...(r=e.newProjectName)!=null&&r.trim()?{createNewProjectName:e.newProjectName.trim()}:{}}}:{},confidenceNotes:l,missingInputs:o}}function X(e,t={}){var i;const n=E(e);if(!n.valid)throw new Error(`Cannot apply an invalid study draft: ${n.errors.map(d=>d.field).join(", ")}`);const a=e.questions.map(d=>d.text.trim()).filter(d=>d.length>0),l=(t.personaIds??e.personaSourceRecommendation.personaIds??[]).slice(0,y),o=((i=e.projectRecommendation)==null?void 0:i.projectId)??null;return{name:e.studyName.trim(),description:(e.studyDescription??"").trim(),questions:a,surveyQuestions:a.map(d=>({text:d})),selectedPersonas:l,selectedProjectId:o}}function K(e,t={}){var o,i;const n=[],a=e.personaSourceRecommendation;return(o=a.newPersonaPrompts)!=null&&o.length&&n.push({kind:"create_personas",detail:`${a.newPersonaPrompts.length} suggested persona(s) to create yourself`,to:"/persona-creator"}),(i=e.projectRecommendation)!=null&&i.createNewProjectName&&n.push({kind:"create_project",detail:`Create the project "${e.projectRecommendation.createNewProjectName}" yourself`,to:"/projects"}),(t.personaIds??a.personaIds??[]).length===0&&n.push({kind:"pick_personas",detail:`Choose up to ${e.respondentCount} respondents in the study composer`,to:"/studies/new"}),n}const J=[{value:"public_library",label:"The public library",hint:"Thousands of ready-made personas"},{value:"existing_collection",label:"One of my collections",hint:"A panel you saved earlier"},{value:"create_new",label:"New personas I create",hint:"You create them; the wizard will not"},{value:"mixed",label:"A mix",hint:"Some existing, some to create"}];function Z({onApply:e,onCancel:t}){const[n,a]=j.useState("intake"),[l,o]=j.useState(O),[i,d]=j.useState(null),h=(u,S)=>o(C=>({...C,[u]:S})),r=j.useMemo(()=>
2i?E(i):null,[i]),c=j.useMemo(()=>i?K(i):[],[i]),p=()=>{d(G(l)),a("review")},w=()=>{!i||!(r!=null&&r.valid)||e(X(i),i)};return n==="review"&&i?s.jsx(ee,{draft:i,onDraftChange:d,validation:r,followUps:c,onBack:()=>a("intake"),onApply:w}):s.jsxs("div",{className:"mx-auto max-w-3xl px-6 py-10",children:[s.jsxs("header",{className:"mb-8",children:[s.jsx(g,{as:"div",className:"mb-2",children:"Study wizard · Step 1 of 2"}),s.jsx("h1",{className:"font-shell-serif text-4xl leading-tight tracking-tight text-shell-fg",children:"Describe the study you want."}),s.jsx("p",{className:"mt-3 max-w-2xl text-[15px] text-shell-dim",children:"Answer in plain English. The wizard turns it into an editable draft — nothing runs, and nothing is created, until you review it and launch from the composer yourself."})]}),s.jsxs("div",{className:"space-y-8",children:[s.jsx(N,{label:"What are you trying to learn?",hint:"One or two sentences. This drives the questions.",children:s.jsx("textarea",{value:l.objective,onChange:u=>h("objective",u.target.value),rows:3,placeholder:"Whether busy parents would pay for a weekly meal-kit subscription",className:"w-full rounded border bg-transparent p-3 text-[14px] text-shell-fg placeholder:text-shell-dim focus:outline-none",style:{borderColor:"var(--shell-rule)"}})}),s.jsx(N,{label:"Who do you want to ask?",hint:"Roles, demographics, interests — anything.",children:s.jsx("textarea",{value:l.audience,onChange:u=>h("audience",u.target.value),rows:2,placeholder:"Parents aged 30-45, urban, working full time",className:"w-full rounded border bg-transparent p-3 text-[14px] text-shell-fg placeholder:text-shell-dim focus:outline-none",style:{borderColor:"var(--shell-rule)"}})}),s.jsx(N,{label:"Do you already have questions?",hint:"One per line. Leave blank and the wizard drafts them for you.",children:s.jsx("textarea",{value:l.existingQuestions,onChange:u=>h("existingQuestions",u.target.value),rows:4,placeholder:`How do you plan meals today?
3What would make you cancel?`,className:"w-full rounded border bg-transparent p-3 text-[14px] text-shell-fg placeholder:text-shell-dim focus:outline-none",style:{borderColor:"var(--shell-rule)"}})}),s.jsx(N,{label:"How many respondents?",hint:`A single study can include at most ${y} personas.`,children:s.jsx("input",{type:"number",min:1,max:y,value:l.respondentCount,onChange:u=>h("respondentCount",Number(u.target.value)),className:"w-28 rounded border bg-transparent p-2 text-[14px] text-shell-fg focus:outline-none",style:{borderColor:"var(--shell-rule)"}})}),s.jsx(N,{label:"Where should respondents come from?",children:s.jsx("div",{className:"space-y-2",children:J.map(u=>s.jsxs("label",{className:"flex cursor-pointer items-start gap-3 rounded border p-3 transition-colors hover:border-shell-fg",style:{borderColor:l.personaSource===u.value?"var(--shell-fg)":"var(--shell-rule)"},children:[s.jsx("input",{type:"radio",name:"personaSource",className:"mt-1",checked:l.personaSource===u.value,onChange:()=>h("personaSource",u.value)}),s.jsxs("span",{children:[s.jsx("span",{className:"block text-[14px] text-shell-fg",children:u.label}),s.jsx("span",{className:"block text-[12px] text-shell-dim",children:u.hint})]})]},u.value))})})]}),s.jsxs("div",{className:"mt-10 flex items-center gap-3",children:[s.jsx("button",{type:"button",onClick:p,className:"rounded border px-5 py-2 font-shell-mono text-[11px] uppercase tracking-mono text-shell-fg transition-colors hover:border-shell-fg",style:{borderColor:"var(--shell-rule-strong)"},children:"Draft the study →"}),t&&s.jsx("button",{type:"button",onClick:t,className:"rounded px-3 py-2 font-shell-mono text-[11px] uppercase tracking-mono text-shell-dim hover:text-shell-fg",children:"Cancel"})]})]})}function ee({draft:e,onDraftChange:t,validation:n,followUps:a,onBack:l,onApply:o}){const i=(r,c)=>t({...e,questions:e.questions.map((p,w)=>w===r?{...p,text:c}:p)}),d=r=>t({...e,questions:e.questions.filter((c,p)=>p!==r)}),h=()=>t({...e,questions:[...e.questions,{text:""}]});return s.jsxs("div",{className:"mx-auto max-w-3xl px-6 py-10",children:[s.jsxs("header",{className:"mb-8",children:[s.jsx(g,{as:"div",className:"mb-2",children:"Study wizard · Step 2 of 2 · Review"}),s.jsx("h1",{className:"font-shell-serif text-4xl leading-tight tracking-tight text-shell-fg",children:"Check the draft before it goes anywhere."}),s.jsx("p",{className:"mt-3 max-w-2xl text-[15px] text-shell-dim",children:"Everything here is editable. Applying it fills in the study composer — it does not launch a study, spend credits, or create anything."})]}),s.jsx(f,{label:"Study name",children:s.jsx("input",{value:e.studyName,onChange:r=>t({...e,studyName:r.target.value}),className:"w-full rounded border bg-transparent p-3 text-[14px] text-shell-fg focus:outline-none",style:{borderColor:"var(--shell-rule)"}})}),s.jsx(f,{label:`Questions · ${e.questions.length}`,children:s.jsxs("div",{className:"space-y-3",children:[e.questions.map((r,c)=>s.jsxs("div",{className:"rounded border p-3",style:{borderColor:"var(--shell-rule)"},children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(g,{className:"mt-2.5 flex-shrink-0",children:c+1}),s.jsx("textarea",{value:r.text,onChange:p=>i(c,p.target.value),rows:2,className:"flex-1 bg-transparent text-[14px] text-shell-fg focus:outline-none"}),s.jsx("button",{type:"button",onClick:()=>d(c),className:"flex-shrink-0 font-shell-mono text-[10px] uppercase tracking-mono text-shell-dim hover:text-shell-fg",children:"Remove"})]}),(r.rationale||r.type)&&s.jsxs("p",{className:"mt-2 border-t pt-2 text-[12px] text-shell-dim",style:{borderColor:"var(--shell-rule)"},children:[s.jsx(g,{children:"Wizard note"})," ",r.type&&s.jsxs("span",{className:"uppercase",children:["[",r.type,"] "]}),r.rationale," — not saved with the study."]})]},c)),s.jsx("button",{type:"button",onClick:h,className:"rounded border px-3 py-1.5 font-shell-mono text-[10px] uppercase tracking-mono text-shell-dim hover:text-shell-fg",style:{borderColor:"var(--shell-rule)"},children:"+ Add question"})]})}),s.jsx(f,{label:"Planning context — stays in the wizard",children:s.jsxs("div",{className:"rounded border p-4 text-[13px] text-shell-dim",style:{borderColor:"var(--shell-rule)"},children:[s.jsxs("p",{className:"mb-2",children:[s.jsx(g,{children:"Objective"})," ",e.objective||"—"]}),s.jsxs("p",{className:"mb-2",children:[s.jsx(g,{children:"Audience"})," ",e.targetAudience.plainEnglish||"—"]}
3),s.jsxs("p",{className:"mb-2",children:[s.jsx(g,{children:"Respondents"})," ",e.respondentCount]}),s.jsxs("p",{children:[s.jsx(g,{children:"Personas"})," ",e.personaSourceRecommendation.mode," —"," ",e.personaSourceRecommendation.rationale]}),s.jsx("p",{className:"mt-3 text-[12px]",children:"This context is not saved to the study record in V1. It shapes the questions above and then stays here."})]})}),e.confidenceNotes.length>0&&s.jsx(f,{label:"Notes",children:s.jsx("ul",{className:"space-y-1 text-[13px] text-shell-dim",children:e.confidenceNotes.map((r,c)=>s.jsxs("li",{children:["· ",r]},c))})}),e.missingInputs.length>0&&s.jsx(f,{label:"Still missing",children:s.jsx("ul",{className:"space-y-1 text-[13px] text-shell-dim",children:e.missingInputs.map((r,c)=>s.jsxs("li",{children:["· ",r]},c))})}),a.length>0&&s.jsx(f,{label:"You will need to do these yourself",children:s.jsx("ul",{className:"space-y-2 text-[13px]",children:a.map((r,c)=>s.jsx("li",{children:s.jsx(T,{to:r.to,className:"text-shell-fg underline underline-offset-2",children:r.detail})},c))})}),n.errors.length>0&&s.jsx(f,{label:"Fix before applying",children:s.jsx("ul",{className:"space-y-1 text-[13px]",style:{color:"var(--shell-live)"},children:n.errors.map((r,c)=>s.jsxs("li",{children:["· ",r.message]},c))})}),s.jsxs("div",{className:"mt-10 flex flex-wrap items-center gap-3",children:[s.jsx("button",{type:"button",onClick:o,disabled:!n.valid,className:"rounded border px-5 py-2 font-shell-mono text-[11px] uppercase tracking-mono transition-colors disabled:opacity-40",style:{borderColor:"var(--shell-rule-strong)",color:"var(--shell-fg)"},children:"Apply to study setup →"}),s.jsx("button",{type:"button",onClick:l,className:"rounded px-3 py-2 font-shell-mono text-[11px] uppercase tracking-mono text-shell-dim hover:text-shell-fg",children:"← Back to questions"}),s.jsx("p",{className:"text-[12px] text-shell-dim",children:"Applying only fills in the composer. You still review, select personas, and launch there."})]})]})}function N({label:e,hint:t,children:n}){return s.jsxs("div",{children:[s.jsx("label",{className:"mb-2 block font-shell-serif text-[17px] leading-tight tracking-tight text-shell-fg",children:e}),t&&s.jsx("p",{className:"mb-2 text-[12px] text-shell-dim",children:t}),n]})}function f({label:e,children:t}){return s.jsxs("section",{className:"mb-8",children:[s.jsx(g,{as:"div",className:"mb-3",children:e}),t]})}function se(){const e=q(),t=n=>{e("/studies/new",{state:{studyDraft:n}})};return s.jsx(Z,{onApply:t,onCancel:()=>e("/studies")})}export{se as default};

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