1import{u as le,r as o,t as de,p as G,j as e}from"./app-Da1gua_E.js";const f={driver_lead:0,driver_inspire:0,driver_care:0,driver_empower:0,driver_build:0,driver_collaborate:0},he=({selectedInitiativeId:g,onSelectInitiative:X})=>{const{org:x,initiatives:u,supabase:E}=le(),[c,w]=o.useState(f),[F,B]=o.useState(g||""),[b,$]=o.useState(!1),[D,P]=o.useState(!1),[J,k]=o.useState(!1),[y,R]=o.useState(""),[L,N]=o.useState(""),[K,Q]=o.useState(0),[M,Z]=o.useState(!1),_=[{key:"driver_lead",title:"LEAD",question:"Is there visible, self-aware leadership?",benchmark:"52% high-performing vs 31% low-performing said leaders made decisions for whole org",descriptions:["","No visible sponsor","Named sponsor, limited engagement","Sponsor actively involved","Active sponsor with courage, curiosity and care","Leaders make the decisions, remove blockers and model the new work"]},{key:"driver_inspire",title:"INSPIRE",question:"Is there a clear, compelling vision?",benchmark:"47% vs 26% said vision was clear and compelling",descriptions:["","No vision articulated","Vision on paper, not communicated","Vision communicated, partial adoption","The case is understood and linked to the work people do","People can explain the case, their role and the result being measured"]},{key:"driver_care",title:"CARE",question:"Are emotional and human dimensions addressed?",benchmark:"52% vs 27% received emotional support, 136% spike in negative emotions in underperformers",descriptions:["","No acknowledgement of emotional impact","One-directional communications","Two-way dialogue emerging","Two-way dialogue is routine and concerns change the plan","People receive practical support and can raise risks without penalty"]},{key:"driver_empower",title:"EMPOWER",question:"Are responsibilities clear, experimentation supported?",benchmark:"48% vs 29% said failure would not impact career",descriptions:["","No clarity, no experimentation support","Rigid roles and processes","Clarity exists, limited experimentation","Clear accountability with bounded room to experiment","Decision rights, capacity and safe-to-test boundaries are in place"]},{key:"driver_build",title:"BUILD",question:"Is technology an enabler, not the objective?",benchmark:"Leading tech practices improve success by 25%",descriptions:["","Technology-first approach","Technology and training co-exist","Technology supports mindset development","Technology supports the redesigned workflow and capability plan","The workflow, roles, skills and technology have been tested together"]},{key:"driver_collaborate",title:"COLLABORATE",question:"Are new ways of working co-created?",benchmark:"44% vs 28% said culture encouraged new working",descriptions:["","Top-down approach","Consultation but pre-made decisions","Co-creation in progress","Affected teams help design the new work and measures","Cross-functional owners run the work and resolve hand-offs together"]}],d=g||F,p=u.find(s=>s.id===d),O=de(p),a=O?.change_plan,S=G(p?.budget),ee=G(p?.cm_budget),q=S>0?ee/S*100:0,z=S>0&&q<10,C=Object.values(c).filter(s=>s>0).length,l=C===Object.keys(f).length,h=Object.values(c).reduce((s,i)=>s+(i||0),0),I=l?(h-6)/24*100:0;let H=I;z&&(H=Math.min(40,I));const se=l?h<15?"Critical":h<23?"At risk":"Strong":C===0?"Not scored":"In progress",ie=l?h<15?"#B42318":h<23?"#9A551D":"#237A4C":"#60748A",ae=l?h<15?28:h<23?50:73:null,te=[{title:"Deliver today AND transform today",icon:"â¡"},{title:"Clarity of vision AND place of not knowing",icon:"ð¯"},{title:"Create alignment AND learn from dissent",icon:"ð¤"},{title:"Disciplined delivery AND freedom to create",icon:"ð¨"}];o.useEffect(()=>{g&&B(g)},[g]),o.useEffect(()=>{!g&&!F&&u.length>0&&B(u[0].id)},[F,u,g]),o.useEffect(()=>{let s=!1;return(async()=>{if(!d||!x?.id){w(f),R("");return}try{$(!0),k(!1),w(f),R(""),N("");const{data:n,error:A}=await E.from("initiative_driver_scores").select("*").eq("org_id",x.id).eq("initiative_id",d).single();if(A&&A.code!=="PGRST116")throw A;s||w(n?{driver_lead:n.driver_lead||0,driver_inspire:n.driver_inspire||0,driver_care:n.driver_care||0,driver_empower:n.driver_empower||0,driver_build:n.driver_build||0,driver_collaborate:n.driver_collaborate||0}:f)}catch(n){console.error("Error fetching driver scores:",n),s||R("The change assessment could not be loaded. Your saved scores have not been changed.")}finally{s||$(!1)}})(),()=>{s=!0}},[d,K,x?.id,E]);const Y=(s,i)=>{w(n=>({...n,[s]:i})),k(!1),N("")},U=async()=>
1{if(!(!d||!x?.id||!l))try{P(!0),N("");const s={org_id:x.id,initiative_id:d,...c},{error:i}=await E.from("initiative_driver_scores").upsert(s,{onConflict:"org_id,initiative_id"});if(i)throw i;k(!0),setTimeout(()=>k(!1),3e3)}catch(s){console.error("Error saving driver scores:",s),N("The change assessment was not saved, please try again.")}finally{P(!1)}},ne=()=>{const re=(t,r)=>{const m=(t*60-90)*(Math.PI/180),v=r/5*80;return{x:125+v*Math.cos(m),y:125+v*Math.sin(m)}},V=_.map((t,r)=>re(r,c[t.key]||0)),oe=V.map(t=>`${t.x},${t.y}`).join(" "),ce=Array.from({length:5}).map((t,r)=>{const m=(r+1)/5*80;return _.map((j,T)=>{const W=(T*60-90)*(Math.PI/180);return[125+m*Math.cos(W),125+m*Math.sin(W)]}).map(j=>`${j[0]},${j[1]}`).join(" ")});return e.jsxs("svg",{width:250,height:250,viewBox:"0 0 250 250",className:"radar-chart",children:[ce.map((t,r)=>e.jsx("polygon",{points:t,className:"grid-line"},`grid-${r}`)),_.map((t,r)=>{const m=(r*60-90)*(Math.PI/180),v=105,j=125+v*Math.cos(m),T=125+v*Math.sin(m);return e.jsx("text",{x:j,y:T,className:"radar-label",textAnchor:"middle",children:t.title},`label-${r}`)}),e.jsx("polygon",{points:oe,className:"data-polygon"}),V.map((t,r)=>e.jsx("circle",{cx:t.x,cy:t.y,r:4,className:"data-point"},`point-${r}`))]})};return e.jsxs("div",{className:"change-enablement-container",children:[e.jsxs("div",{className:"ce-header",children:[e.jsx("h2",{children:"Change plan"}),e.jsx("p",{className:"ce-subtitle",children:"Start with the action carried from the decision, then use the six drivers only when you need to test delivery capacity."})]}),e.jsxs("div",{className:"ce-initiative-selector",children:[e.jsx("label",{htmlFor:"change-enablement-initiative",children:"Initiative decision"}),u.length>0?e.jsx("select",{id:"change-enablement-initiative",value:d,onChange:s=>{B(s.target.value),X?.(s.target.value)},children:u.map(s=>e.jsx("option",{value:s.id,children:s.name||"Untitled initiative"},s.id))}):e.jsx("p",{children:"Add an initiative in Decisions before scoring the change plan."}),p&&e.jsxs("p",{children:[C," of 6 drivers scored, ",S>0?`change funding is ${q.toFixed(1)}% of the initiative budget`:"the initiative budget has not been modelled","."]})]}),p&&a?e.jsxs("section",{style:{margin:"18px 0 20px",padding:"22px 24px",background:"#FFFFFF",border:"1px solid #D2DBE5",borderLeft:"4px solid #B87333",color:"#172C4B"},children:[e.jsxs("div",{style:{color:"#9A5C21",fontSize:11,fontWeight:700,marginBottom:6},children:[O.classification," decision, action carried into the plan"]}),e.jsx("h3",{style:{margin:"0 0 9px",fontSize:20},children:"Start with the binding constraint"}),e.jsx("p",{style:{margin:"0 0 15px",color:"#40536C",lineHeight:1.6},children:a.binding_constraint}),a.plays?.[0]&&e.jsxs("article",{style:{padding:"15px 16px",background:"#F7F9FB",border:"1px solid #DCE4EC"},children:[e.jsx("strong",{style:{display:"block",marginBottom:6},children:a.plays[0].org_move?.method||"First action"}),e.jsx("p",{style:{margin:"0 0 8px",color:"#40536C",lineHeight:1.55},children:a.plays[0].org_move?.action}),e.jsxs("small",{style:{color:"#66788F"},children:["Owner: ",a.plays[0].owner||"Name the accountable owner",a.plays[0].timeline_weeks?`, weeks ${a.plays[0].timeline_weeks[0]} to ${a.plays[0].timeline_weeks[1]}`:""]}),a.plays[0].stop_condition&&e.jsxs("p",{style:{margin:"9px 0 0",color:"#8F2119",fontSize:12},children:[e.jsx("strong",{children:"Stop condition:"})," ",a.plays[0].stop_condition]})]}),a.rescore_gate?.clears_when&&e.jsxs("p",{style:{margin:"14px 0 0",padding:"11px 13px",background:"#F0F8F4",borderLeft:"3px solid #237A4C",color:"#285844",lineHeight:1.5},children:[e.jsx("strong",{children:"Return for a decision when:"})," ",a.rescore_gate.clears_when,a.rescore_gate.deadline_weeks?`, within ${a.rescore_gate.deadline_weeks} weeks`:"","."]})]}):p?e.jsx("section",{style:{margin:"18px 0 20px",padding:"17px 20px",background:"#FFFFFF",border:"1px solid #D2DBE5",color:"#40536C"},children:"This initiative has no imported decision plan yet, return to Decisions and assess it before building the delivery plan."}):null,e.jsx("button",{type:"button",className:"save-btn",onClick:()=>Z(s=>!s),disabled:!p,style:{marginBottom:18},children:M?"Hide the six-driver diagnostic":"Open the six-driver delivery diagnostic"}),y&&e.jsxs("div",{className:"tab-recovery",role:"alert",children:[e.jsx("span",{children:y}),e.jsx("button",{type:"button",onClick:()=>Q(s=>s+1),disabled:b,children:"Retry loading"})]}),M&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"ce-composite-card",children:[e.jsxs("div",{className:"composite-content",children:[e.jsxs("div",{className:"composite-score",children:[e.jsx("div",{className:"score-number",children:h}),e.jsx("div",{className:"score-range",children:"/30"})]}),e.jsxs("div",{className:"composite-details",children:[e.jsxs("div",{className:"composite-status",style:{borderLeft:`4px solid ${ie}`},children:[e.jsx("div",{className:"status-label",children:se}),e.jsx("div",{className:"status-probability",children:l?`${ae}% research comparison`:`${C} of 6 drivers scored`})]}),e.jsxs("div",{className:"composite-percentage",children:[e.jsx("div",{className:"percentage-value",children:l?`${H.toFixed(1)}%`:"â"}),e.jsx("div",{className:"percentage-label",children:"Change enablement score"}),z&&e.jsx("div",{className:"budget-warning",children:"Budget < 10% cap applied"})]})]})]}),e.jsxs("div",{className:"multiplier-highlight",children:[e.jsx("span",{className:"multiplier-icon",children:"Ã2.6"}),e.jsx("span",{className:"multiplier-text",children:"Organisations excelling across all six drivers are 2.6 times more likely to succeed"}),e.jsx("span",{className:"multiplier-source",children:"EY/Oxford Said Business Sc
1hool, 2022"})]})]}),e.jsx("div",{className:"ce-drivers-grid",children:_.map(s=>e.jsxs("div",{className:"driver-card",children:[e.jsx("h3",{children:s.title}),e.jsx("p",{className:"driver-question",children:s.question}),e.jsxs("div",{className:"driver-benchmark",children:[e.jsx("span",{className:"benchmark-label",children:"Benchmark:"}),e.jsx("span",{className:"benchmark-stat",children:s.benchmark})]}),e.jsxs("div",{className:"slider-group",children:[e.jsx("div",{className:"score-buttons",children:[1,2,3,4,5].map(i=>e.jsx("button",{type:"button",className:`score-btn ${c[s.key]===i?"active":""}`,onClick:()=>Y(s.key,i),disabled:b||!!y,"aria-pressed":c[s.key]===i,children:i},i))}),e.jsx("input",{type:"range",min:"0",max:"5",value:c[s.key],onChange:i=>Y(s.key,parseInt(i.target.value)),className:"driver-slider",disabled:b||!!y})]}),c[s.key]>0&&e.jsx("p",{className:"score-description",children:s.descriptions[c[s.key]]})]},s.key))}),e.jsxs("div",{className:"paradoxes-section",children:[e.jsx("h3",{children:"The four paradoxes of change"}),e.jsx("div",{className:"paradoxes-grid",children:te.map((s,i)=>e.jsxs("div",{className:"paradox-card",children:[e.jsx("span",{className:"paradox-icon",children:s.icon}),e.jsx("span",{className:"paradox-title",children:s.title})]},i))})]}),e.jsxs("div",{className:"ce-radar-section",children:[e.jsx("h3",{children:"Six drivers profile"}),e.jsx(ne,{})]}),e.jsxs("div",{className:"ce-actions",children:[e.jsx("button",{className:"save-btn",onClick:U,disabled:b||D||!!y||!d||!l,children:D?"Saving...":b?"Loading...":l?"Save assessment":"Score all six drivers to save"}),J&&e.jsxs("span",{className:"save-confirmation",children:["Saved to ",p?.name||"the initiative"]}),L&&e.jsxs("span",{className:"save-error",role:"alert",children:[L,e.jsx("button",{type:"button",onClick:U,disabled:D,children:"Retry saving"})]})]})]})]})};export{he 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.