@decidables/prospectable-elements 0.5.0 → 0.5.1
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/CHANGELOG.md +9 -0
- package/lib/prospectableElements.esm.js +4 -4
- package/lib/prospectableElements.esm.js.map +1 -1
- package/lib/prospectableElements.esm.min.js +2 -2
- package/lib/prospectableElements.esm.min.js.map +1 -1
- package/lib/prospectableElements.umd.js +4 -4
- package/lib/prospectableElements.umd.js.map +1 -1
- package/lib/prospectableElements.umd.min.js +2 -2
- package/lib/prospectableElements.umd.min.js.map +1 -1
- package/package.json +2 -2
- package/src/components/cpt-space.js +3 -3
- package/src/components/decision-space.js +3 -3
|
@@ -1568,7 +1568,7 @@ const mo=t=>t??z;customElements.define("decidables-slider",class extends Ro{stat
|
|
|
1568
1568
|
stroke: none;
|
|
1569
1569
|
}
|
|
1570
1570
|
`]}render(){return k`
|
|
1571
|
-
`}willUpdate(){this.alignState()}update(t){if(super.update(t),Number.isNaN(this.width)||Number.isNaN(this.height)||Number.isNaN(this.rem))return;const B=this.width,s=this.height,Q=Math.min(B,s),F={top:3*this.rem,bottom:5*this.rem,left:2*this.rem,right:6*this.rem},i=Q-(F.top+F.bottom),U=Q-(F.left+F.right),g=yI().domain([this.range.a.start,this.range.a.stop]).range([0,U]),e=yI().domain([this.range.g.start,this.range.g.stop]).range([0,-i]),I=yI().domain([this.range.l.start,this.range.l.stop]).range([0,-i]),l=OL(this.getComputedStyleValue("---color-element-background")).hex(),c=OL(this.getComputedStyleValue("---color-better-dark")).hex(),n=OL(this.getComputedStyleValue("---color-better")).hex(),a=OL(this.getComputedStyleValue("---color-nr")).hex(),d=OL(this.getComputedStyleValue("---color-worse")).hex(),o=OL(this.getComputedStyleValue("---color-worse-dark")).hex(),b=ln().domain([this.range.uDiff.start,0,this.range.uDiff.stop]).clamp(!0).interpolator(wF([c,n,a,d,o])),C=yI().domain([this.range.uDiff.start,this.range.uDiff.stop]).range([0,-s+4*this.rem]),r={x:F.left,y:Q-F.bottom},u={x:g((this.range.a.start+this.range.a.stop)/2),y:e((this.range.g.start+this.range.g.stop)/2),z:I((this.range.l.start+this.range.l.stop)/2)},h=-.85*Math.PI/8,x=3*Math.PI/8,G=LL().origin(r).scale(1).rotationCenter(u).rotateX(h+this.rotationX).rotateY(x+this.rotationY).rotateZ(0),y=uL().origin(r).scale(1).rotationCenter(u).rotateX(h+this.rotationX).rotateY(x+this.rotationY).rotateZ(0),A=GL().origin(r).scale(1).rotationCenter(u).rotateX(h+this.rotationX).rotateY(x+this.rotationY).rotateZ(0),L=qs().on("start",t=>{this.mx=t.x,this.my=t.y}).on("drag",t=>{this.rotationY=(t.x-this.mx+this.mouseX)*(Math.PI/230),this.rotationX=(t.y-this.my+this.mouseY)*(Math.PI/230)*-1,this.requestUpdate()}).on("end",t=>{this.mouseX=t.x-this.mx+this.mouseX,this.mouseY=t.y-this.my+this.mouseY}),R=Ys(this.renderRoot).selectAll(".main").data([{width:this.width,height:this.height,rem:this.rem}]),m=R.enter().append("svg").classed("main",!0),V=m.merge(R).attr("viewBox",`0 0 ${Q} ${Q}`).call(L),S=m.append("defs").append("linearGradient").attr("id","gradient-legend").attr("x1",0).attr("x2",0).attr("y1",1).attr("y2",0);S.append("stop").attr("offset","0%").attr("stop-color",c),S.append("stop").attr("offset","25%").attr("stop-color",n),S.append("stop").attr("offset","50%").attr("stop-color",a),S.append("stop").attr("offset","75%").attr("stop-color",d),S.append("stop").attr("offset","100%").attr("stop-color",o);const Z=[[{title:'Alpha (<tspan class="math-var">α</tspan>)',id:"max",x:g.range()[1]},{id:"min",x:g.range()[0]}]],p=[[{title:'Gamma (<tspan class="math-var">γ</tspan>)',id:"max",y:e.range()[1]},{id:"min",y:e.range()[0]}]],E=[[{title:'Lambda (<tspan class="math-var">λ</tspan>)',id:"max",z:I.range()[1]},{id:"min",z:I.range()[0]}]],N=V.selectAll(".axis-x").data(G.x(t=>t.x).y(()=>e.range()[0]).z(()=>I.range()[0])(Z)),X=V.selectAll(".axis-y").data(G.x(()=>g.range()[0]).y(t=>t.y).z(()=>I.range()[1])(p)),W=V.selectAll(".axis-z").data(G.x(()=>g.range()[0]).y(()=>e.range()[0]).z(t=>t.z)(E)),H=N.enter().append("path").attr("class","d3-3d axis axis-x"),D=X.enter().append("path").attr("class","d3-3d axis axis-y"),f=W.enter().append("path").attr("class","d3-3d axis axis-z"),w=H.merge(N).attr("d",G.draw),v=D.merge(X).attr("d",G.draw),Y=f.merge(W).attr("d",G.draw);w.exit().remove(),v.exit().remove(),Y.exit().remove();const J=V.selectAll(".title-path-x").data(G.x(t=>"min"===t.id?t.x-20*this.rem:t.x+20*this.rem).y(()=>e.range()[0]+1.75*this.rem).z(()=>I.range()[0]+1.75*this.rem)(Z)),k=V.selectAll(".title-path-y").data(G.x(()=>g.range()[0]-1.75*this.rem).y(t=>"min"===t.id?t.y+20*this.rem:t.y-20*this.rem).z(()=>I.range()[1]-1.75*this.rem)(p)),M=V.selectAll(".title-path-z").data(G.x(()=>g.range()[0]-1.75*this.rem).y(()=>e.range()[0]+1.75*this.rem).z(t=>"min"===t.id?t.z-20*this.rem:t.z+20*this.rem)(E)),T=V.selectAll(".title-x").data(Z,t=>t[0].title),z=V.selectAll(".title-y").data(p,t=>t[0].title),K=V.selectAll(".title-z").data(E,t=>t[0].title),O=J.enter().append("path").attr("class","d3-3d title-path title-path-x").attr("id","title-x"),P=k.enter().append("path").attr("class","d3-3d title-path title-path-y").attr("id","title-y"),j=M.enter().append("path").attr("class","d3-3d title-path title-path-z").attr("id","title-z"),_=T.enter().append("text").attr("class","d3-3d title title-x");_.append("textPath").attr("href","#title-x").attr("startOffset","50%");const $=z.enter().append("text").attr("class","d3-3d title title-y");$.append("textPath").attr("href","#title-y").attr("startOffset","50%");const q=K.enter().append("text").attr("class","d3-3d title title-z");q.append("textPath").attr("href","#title-z").attr("startOffset","50%");const tt=O.merge(J).attr("d",G.draw),Bt=P.merge(k).attr("d",G.draw),st=j.merge(M).attr("d",G.draw),Qt=_.merge(T).select("textPath").html(t=>t[0].title),Ft=$.merge(z).select("textPath").html(t=>t[0].title),it=q.merge(K).select("textPath").html(t=>t[0].title);tt.exit().remove(),Bt.exit().remove(),st.exit().remove(),Qt.exit().remove(),Ft.exit().remove(),it.exit().remove();const Ut=g.ticks(5).map(t=>[{id:"min",label:g.tickFormat()(t),x:g(t)},{id:"max",x:g(t)}]),gt=e.ticks(5).map(t=>[{id:"min",label:e.tickFormat()(t),y:e(t)},{id:"max",y:e(t)}]),et=I.ticks(5).map(t=>[{id:"max",label:I.tickFormat()(t),z:I(t)},{id:"min",z:I(t)}]),It=V.selectAll(".tick-x").data(G.x(t=>t.x).y(t=>"min"===t.id?e.range()[0]:e.range()[0]+.35*this.rem).z(t=>"min"===t.id?I.range()[0]:I.range()[0]+.35*this.rem)(Ut)),lt=V.selectAll(".tick-y").data(G.x(t=>"min"===t.id?g.range()[0]:g.range()[0]-.35*this.rem).y(t=>t.y).z(t=>"min"===t.id?I.range()[1]:I.range()[1]-.35*this.rem)(gt)),ct=V.selectAll(".tick-z").data(G.x(t=>"min"===t.id?g.range()[0]:g.range()[0]-.35*this.rem).y(t=>"min"===t.id?e.range()[0]:e.range()[0]+.35*this.rem).z(t=>t.z)(et)),nt=It.enter().append("path").attr("class","d3-3d tick tick-x"),at=lt.enter().append("path").attr("class","d3-3d tick tick-y"),dt=ct.enter().append("path").attr("class","d3-3d tick tick-z"),ot=nt.merge(It).attr("d",G.draw),bt=at.merge(lt).attr("d",G.draw),Ct=dt.merge(ct).attr("d",G.draw);ot.exit().remove(),bt.exit().remove(),Ct.exit().remove();const rt=V.selectAll(".label-path-x").data(G.x(t=>t.x).y(t=>"min"===t.id?e.range()[0]+4*this.rem:e.range()[0]+.5*this.rem).z(t=>"min"===t.id?I.range()[0]+4*this.rem:I.range()[0]+.5*this.rem)(Ut),t=>t[0].label),ut=V.selectAll(".label-path-y").data(G.x(t=>"min"===t.id?g.range()[0]-.5*this.rem:g.range()[0]-4*this.rem).y(t=>t.y).z(t=>"min"===t.id?I.range()[1]-.5*this.rem:I.range()[1]-4*this.rem)(gt),t=>t[0].label),ht=V.selectAll(".label-path-z").data(G.x(t=>"min"===t.id?g.range()[0]-4*this.rem:g.range()[0]-.5*this.rem).y(t=>"min"===t.id?e.range()[0]+4*this.rem:e.range()[0]+.5*this.rem).z(t=>t.z)(et),t=>t[0].label),xt=V.selectAll(".label-x").data(Ut,t=>t[0].label),Gt=V.selectAll(".label-y").data(gt,t=>t[0].label),yt=V.selectAll(".label-z").data(et,t=>t[0].label),At=rt.enter().append("path").attr("class","d3-3d label-path label-path-x").attr("id",(t,B)=>`label-x-${B}`),Lt=ut.enter().append("path").attr("class","d3-3d label-path label-path-y").attr("id",(t,B)=>`label-y-${B}`),Rt=ht.enter().append("path").attr("class","d3-3d label-path label-path-z").attr("id",(t,B)=>`label-z-${B}`),mt=xt.enter().append("text").attr("class","d3-3d label label-x");mt.append("textPath").attr("href",(t,B)=>`#label-x-${B}`).attr("startOffset","0%");const Vt=Gt.enter().append("text").attr("class","d3-3d label label-y");Vt.append("textPath").attr("href",(t,B)=>`#label-y-${B}`).attr("startOffset","100%");const St=yt.enter().append("text").attr("class","d3-3d label label-z");St.append("textPath").attr("href",(t,B)=>`#label-z-${B}`).attr("startOffset","100%");const Zt=At.merge(rt).attr("d",G.draw),pt=Lt.merge(ut).attr("d",G.draw),Et=Rt.merge(ht).attr("d",G.draw),Nt=mt.merge(xt).select("textPath").text(t=>t[0].label),Xt=Vt.merge(Gt).select("textPath").text(t=>t[0].label),Wt=St.merge(yt).select("textPath").text(t=>t[0].label);Zt.exit().remove(),pt.exit().remove(),Et.exit().remove(),Nt.exit().remove(),Xt.exit().remove(),Wt.exit().remove();const Ht=V.selectAll(".point").data(y.x(t=>g(t.a)).y(t=>e(t.g)).z(t=>I(t.l))(this.point?[{a:this.a,g:this.g,l:this.l,response:this.response}]:[]));function Dt(t,B){return{x:B.x-t.x,y:B.y-t.y,z:B.z-t.z}}function ft(t){return Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z)}function wt(t,B,s){return function(t,B){return{x:t.y*B.z-t.z*B.y,y:t.z*B.x-t.x*B.z,z:t.x*B.y-t.y*B.x}}(Dt(t,B),Dt(t,s))}function vt(t,B){return function(t,B){return t.x*B.x+t.y*B.y+t.z*B.z}(t,B)/(ft(t)*ft(B))}Ht.enter().append("circle").attr("class","d3-3d point").merge(Ht).attr("class",t=>`d3-3d point ${t.response}`).attr("cx",t=>t.projected.x).attr("cy",t=>t.projected.y),Ht.exit().remove();const Yt={x:-.5,y:1,z:-1},Jt=V.selectAll(".boundary").data(this.surface?A.rows(cB(this.range.g.start,this.range.g.stop+.01,this.range.g.step).length).x(t=>g(t.a)).y(t=>e(t.g)).z(t=>I(t.l))(this.boundary).filter(t=>t[0].a>=this.range.a.start&&t[0].a<=this.range.a.stop&&t[1].a>=this.range.a.start&&t[1].a<=this.range.a.stop&&t[2].a>=this.range.a.start&&t[2].a<=this.range.a.stop&&t[3].a>=this.range.a.start&&t[3].a<=this.range.a.stop):[]);Jt.enter().append("path").attr("class","d3-3d boundary").merge(Jt).attr("d",A.draw).each(t=>{const B=t.ccw?wt(t[0].rotated,t[1].rotated,t[2].rotated):wt(t[2].rotated,t[1].rotated,t[0].rotated);t.ratio=vt(B,Yt)-.5,t.color=rQ(l).brighter(t.ratio)}).attr("fill",t=>t.color).attr("stroke",t=>t.color),Jt.exit().remove();const kt=V.selectAll(".map-xy").data(A.rows(cB(this.range.g.start,this.range.g.stop+.01,this.range.g.step).length).x(t=>g(t.a)).y(t=>e(t.g)).z(t=>I(t.l))(this.mapXY)),Mt=V.selectAll(".map-xz").data(A.rows(cB(this.range.l.start,this.range.l.stop+.01,this.range.l.step).length).x(t=>g(t.a)).y(t=>e(t.g)).z(t=>I(t.l))(this.mapXZ)),Tt=V.selectAll(".map-yz").data(A.rows(cB(this.range.l.start,this.range.l.stop+.01,this.range.l.step).length).x(t=>g(t.a)).y(t=>e(t.g)).z(t=>I(t.l))(this.mapYZ)),zt=kt.enter().append("path").attr("class","d3-3d map map-xy"),Kt=Mt.enter().append("path").attr("class","d3-3d map map-xz"),Ot=Tt.enter().append("path").attr("class","d3-3d map map-yz");zt.merge(kt).attr("d",A.draw).each(t=>{const B=t.ccw?wt(t[0].rotated,t[1].rotated,t[2].rotated):wt(t[2].rotated,t[1].rotated,t[0].rotated);t.ratio=vt(B,Yt)-.5,t.color=rQ(b(t[0].uDiff)).brighter(t.ratio)}).attr("fill",t=>t.color).attr("stroke",t=>t.color),Kt.merge(Mt).attr("d",A.draw).each(t=>{const B=t.ccw?wt(t[0].rotated,t[1].rotated,t[2].rotated):wt(t[2].rotated,t[1].rotated,t[0].rotated);t.ratio=vt(B,Yt)-.5,t.color=rQ(b(t[0].uDiff)).brighter(t.ratio)}).attr("fill",t=>t.color).attr("stroke",t=>t.color),Ot.merge(Tt).attr("d",A.draw).each(t=>{const B=t.ccw?wt(t[0].rotated,t[1].rotated,t[2].rotated):wt(t[2].rotated,t[1].rotated,t[0].rotated);t.ratio=vt(B,Yt)-.5,t.color=rQ(b(t[0].uDiff)).brighter(t.ratio)}).attr("fill",t=>t.color).attr("stroke",t=>t.color),kt.exit().remove(),Mt.exit().remove(),Tt.exit().remove(),Ys(this.renderRoot).selectAll(".d3-3d").sort(y.sort);const Pt=V.selectAll(".legend").data([{x:Q+2*this.rem,y:Q-2*this.rem,rem:this.rem}]),jt=Pt.enter().append("g").attr("class","legend"),_t=jt.merge(Pt).attr("transform",t=>`translate(${t.x} ${t.y})`);Pt.exit().remove(),jt.append("g").attr("class","axis axis-legend"),_t.select(".axis-legend").call(yB(C).ticks(7)).attr("font-size",null).attr("font-family",null),jt.append("text").attr("class","title title-legend").html('Difference in Utility (<tspan class="math-var">U<tspan class="subscript">gamble</tspan></tspan> − <tspan class="math-var">U<tspan class="subscript">sure</tspan></tspan>)'),_t.select(".title-legend").attr("transform",`translate(${2.5*-this.rem},${(C(this.range.uDiff.start)+C(this.range.uDiff.stop))/2})rotate(-90)`),jt.append("rect").attr("class","bar bar-legend").attr("fill",'url("#gradient-legend")'),_t.select(".bar-legend").attr("x",0).attr("y",C(this.range.uDiff.stop)).attr("width",this.rem).attr("height",C(this.range.uDiff.start)-C(this.range.uDiff.stop)),this.firstUpdate=!1}}customElements.define("cpt-space",qL);class tR extends(So(po)){static get properties(){return{x:{attribute:"value",type:Number,reflect:!0},a:{attribute:"alpha",type:Number,reflect:!0},l:{attribute:"lambda",type:Number,reflect:!0},label:{attribute:"label",type:String,reflect:!0},v:{attribute:!1,type:Number,reflect:!1}}}constructor(){super(),this.firstUpdate=!0,this.drag=!1,this.a=Bb.a.DEFAULT,this.l=Bb.l.DEFAULT,this.x=null,this.label="",this.function="default",this.functions=[{name:"default",a:this.a,l:this.l}],this.values=[{name:"default",x:this.x,label:this.label,function:this.function}],this.xl=null,this.xw=null,this.pw=null,this.xs=null,this.trialCount=null,this.response=null,this.alignState()}alignState(){this.functions[0].a=this.a,this.functions[0].l=this.l,this.values[0].x=this.x,this.values[0].label=this.label,this.values[0].function=this.function,this.values.forEach(t=>{const B=this.functions.find(B=>B.name===t.function);t.v=Bb.xal2v(t.x,B.a,B.l)}),this.v=this.values[0].v}trial(t,B,s,Q,F,i){this.trialCount&&this.removeValue(`${this.trialCount}-w`),this.trialCount&&this.removeValue(`${this.trialCount}-s`),this.xl=t,this.xw=B,this.pw=s,this.xs=Q,this.trialCount=F,this.response=i,this.setValue(this.xw,`${this.trialCount}-w`,"g","default",!0),this.setValue(this.xs,`${this.trialCount}-s`,"s","default",!0)}pauseTrial(){const t=Ys(this.renderRoot).selectAll(".lines[data-animating-ease-time-1]");t.interrupt("new-1"),t.interrupt("new-2"),t.datum(t=>(t.paused=!0,t))}resumeTrial(){Ys(this.renderRoot).selectAll(".lines[data-animating-ease-time-1]").datum(t=>(t.paused=!1,t)),this.requestUpdate()}clearFunctions(){this.functions.splice(1),this.requestUpdate()}clearValues(){this.values.splice(1),this.requestUpdate()}clear(){this.clearFunctions(),this.clearValues()}removeFunction(t){this.functions=this.functions.filter(B=>B.name!==t),this.requestUpdate()}removeValue(t){this.values=this.values.filter(B=>B.name!==t),this.requestUpdate()}remove(t){this.removeFunction(t),this.removeValue(t)}getFunction(t="default"){return this.functions.find(B=>B.name===t)}getValue(t="default"){return this.values.find(B=>B.name===t)}get(t="default"){return{...this.getFunction(t),...this.getValue(t)}}setFunction(t,B,s="default"){"default"===s&&(this.a=t,this.l=B);const Q=this.functions.find(t=>t.name===s);void 0===Q?this.functions.push({name:s,a:t,l:B}):(Q.a=t,Q.l=B),this.requestUpdate()}setValue(t,B="default",s="",Q=B,F=!1){"default"===B&&(this.x=t,this.label=s);const i=this.values.find(t=>t.name===B);void 0===i?this.values.push({name:B,x:t,label:s,function:Q,trial:F,new:F}):(i.x=t,i.label=s,i.function=Q),this.requestUpdate()}set(t,B,s,Q="default",F="",i=Q){this.setFunction(B,s,i),this.setValue(t,Q,F,i)}static get styles(){return[super.styles,U`
|
|
1571
|
+
`}willUpdate(){this.alignState()}update(t){if(super.update(t),Number.isNaN(this.width)||Number.isNaN(this.height)||Number.isNaN(this.rem))return;const B=this.width,s=this.height,Q=Math.min(B,s),F={top:3*this.rem,bottom:5*this.rem,left:2*this.rem,right:6*this.rem},i=Q-(F.top+F.bottom),U=Q-(F.left+F.right),g=yI().domain([this.range.a.start,this.range.a.stop]).range([0,U]),e=yI().domain([this.range.g.start,this.range.g.stop]).range([0,-i]),I=yI().domain([this.range.l.start,this.range.l.stop]).range([0,-i]),l=OL(this.getComputedStyleValue("---color-element-background")).hex(),c=OL(this.getComputedStyleValue("---color-better-dark")).hex(),n=OL(this.getComputedStyleValue("---color-better")).hex(),a=OL(this.getComputedStyleValue("---color-nr")).hex(),d=OL(this.getComputedStyleValue("---color-worse")).hex(),o=OL(this.getComputedStyleValue("---color-worse-dark")).hex(),b=ln().domain([this.range.uDiff.start,0,this.range.uDiff.stop]).clamp(!0).interpolator(wF([c,n,a,d,o])),C=yI().domain([this.range.uDiff.start,this.range.uDiff.stop]).range([0,-s+4*this.rem]),r={x:F.left,y:Q-F.bottom},u={x:g((this.range.a.start+this.range.a.stop)/2),y:e((this.range.g.start+this.range.g.stop)/2),z:I((this.range.l.start+this.range.l.stop)/2)},h=-.85*Math.PI/8,x=3*Math.PI/8,G=LL().origin(r).scale(1).rotationCenter(u).rotateX(h+this.rotationX).rotateY(x+this.rotationY).rotateZ(0),y=uL().origin(r).scale(1).rotationCenter(u).rotateX(h+this.rotationX).rotateY(x+this.rotationY).rotateZ(0),A=GL().origin(r).scale(1).rotationCenter(u).rotateX(h+this.rotationX).rotateY(x+this.rotationY).rotateZ(0),L=qs().on("start",t=>{this.mx=t.x,this.my=t.y}).on("drag",t=>{this.rotationY=(t.x-this.mx+this.mouseX)*(Math.PI/230),this.rotationX=(t.y-this.my+this.mouseY)*(Math.PI/230)*-1,this.requestUpdate()}).on("end",t=>{this.mouseX=t.x-this.mx+this.mouseX,this.mouseY=t.y-this.my+this.mouseY}),R=Ys(this.renderRoot).selectAll(".main").data([{width:this.width,height:this.height,rem:this.rem}]),m=R.enter().append("svg").classed("main",!0).call(L),V=m.merge(R).attr("viewBox",`0 0 ${Q} ${Q}`),S=m.append("defs").append("linearGradient").attr("id","gradient-legend").attr("x1",0).attr("x2",0).attr("y1",1).attr("y2",0);S.append("stop").attr("offset","0%").attr("stop-color",c),S.append("stop").attr("offset","25%").attr("stop-color",n),S.append("stop").attr("offset","50%").attr("stop-color",a),S.append("stop").attr("offset","75%").attr("stop-color",d),S.append("stop").attr("offset","100%").attr("stop-color",o);const Z=[[{title:'Alpha (<tspan class="math-var">α</tspan>)',id:"max",x:g.range()[1]},{id:"min",x:g.range()[0]}]],p=[[{title:'Gamma (<tspan class="math-var">γ</tspan>)',id:"max",y:e.range()[1]},{id:"min",y:e.range()[0]}]],E=[[{title:'Lambda (<tspan class="math-var">λ</tspan>)',id:"max",z:I.range()[1]},{id:"min",z:I.range()[0]}]],N=V.selectAll(".axis-x").data(G.x(t=>t.x).y(()=>e.range()[0]).z(()=>I.range()[0])(Z)),X=V.selectAll(".axis-y").data(G.x(()=>g.range()[0]).y(t=>t.y).z(()=>I.range()[1])(p)),W=V.selectAll(".axis-z").data(G.x(()=>g.range()[0]).y(()=>e.range()[0]).z(t=>t.z)(E)),H=N.enter().append("path").attr("class","d3-3d axis axis-x"),D=X.enter().append("path").attr("class","d3-3d axis axis-y"),f=W.enter().append("path").attr("class","d3-3d axis axis-z"),w=H.merge(N).attr("d",G.draw),v=D.merge(X).attr("d",G.draw),Y=f.merge(W).attr("d",G.draw);w.exit().remove(),v.exit().remove(),Y.exit().remove();const J=V.selectAll(".title-path-x").data(G.x(t=>"min"===t.id?t.x-20*this.rem:t.x+20*this.rem).y(()=>e.range()[0]+1.75*this.rem).z(()=>I.range()[0]+1.75*this.rem)(Z)),k=V.selectAll(".title-path-y").data(G.x(()=>g.range()[0]-1.75*this.rem).y(t=>"min"===t.id?t.y+20*this.rem:t.y-20*this.rem).z(()=>I.range()[1]-1.75*this.rem)(p)),M=V.selectAll(".title-path-z").data(G.x(()=>g.range()[0]-1.75*this.rem).y(()=>e.range()[0]+1.75*this.rem).z(t=>"min"===t.id?t.z-20*this.rem:t.z+20*this.rem)(E)),T=V.selectAll(".title-x").data(Z,t=>t[0].title),z=V.selectAll(".title-y").data(p,t=>t[0].title),K=V.selectAll(".title-z").data(E,t=>t[0].title),O=J.enter().append("path").attr("class","d3-3d title-path title-path-x").attr("id","title-x"),P=k.enter().append("path").attr("class","d3-3d title-path title-path-y").attr("id","title-y"),j=M.enter().append("path").attr("class","d3-3d title-path title-path-z").attr("id","title-z"),_=T.enter().append("text").attr("class","d3-3d title title-x");_.append("textPath").attr("href","#title-x").attr("startOffset","50%");const $=z.enter().append("text").attr("class","d3-3d title title-y");$.append("textPath").attr("href","#title-y").attr("startOffset","50%");const q=K.enter().append("text").attr("class","d3-3d title title-z");q.append("textPath").attr("href","#title-z").attr("startOffset","50%");const tt=O.merge(J).attr("d",G.draw),Bt=P.merge(k).attr("d",G.draw),st=j.merge(M).attr("d",G.draw),Qt=_.merge(T).select("textPath").html(t=>t[0].title),Ft=$.merge(z).select("textPath").html(t=>t[0].title),it=q.merge(K).select("textPath").html(t=>t[0].title);tt.exit().remove(),Bt.exit().remove(),st.exit().remove(),Qt.exit().remove(),Ft.exit().remove(),it.exit().remove();const Ut=g.ticks(5).map(t=>[{id:"min",label:g.tickFormat()(t),x:g(t)},{id:"max",x:g(t)}]),gt=e.ticks(5).map(t=>[{id:"min",label:e.tickFormat()(t),y:e(t)},{id:"max",y:e(t)}]),et=I.ticks(5).map(t=>[{id:"max",label:I.tickFormat()(t),z:I(t)},{id:"min",z:I(t)}]),It=V.selectAll(".tick-x").data(G.x(t=>t.x).y(t=>"min"===t.id?e.range()[0]:e.range()[0]+.35*this.rem).z(t=>"min"===t.id?I.range()[0]:I.range()[0]+.35*this.rem)(Ut)),lt=V.selectAll(".tick-y").data(G.x(t=>"min"===t.id?g.range()[0]:g.range()[0]-.35*this.rem).y(t=>t.y).z(t=>"min"===t.id?I.range()[1]:I.range()[1]-.35*this.rem)(gt)),ct=V.selectAll(".tick-z").data(G.x(t=>"min"===t.id?g.range()[0]:g.range()[0]-.35*this.rem).y(t=>"min"===t.id?e.range()[0]:e.range()[0]+.35*this.rem).z(t=>t.z)(et)),nt=It.enter().append("path").attr("class","d3-3d tick tick-x"),at=lt.enter().append("path").attr("class","d3-3d tick tick-y"),dt=ct.enter().append("path").attr("class","d3-3d tick tick-z"),ot=nt.merge(It).attr("d",G.draw),bt=at.merge(lt).attr("d",G.draw),Ct=dt.merge(ct).attr("d",G.draw);ot.exit().remove(),bt.exit().remove(),Ct.exit().remove();const rt=V.selectAll(".label-path-x").data(G.x(t=>t.x).y(t=>"min"===t.id?e.range()[0]+4*this.rem:e.range()[0]+.5*this.rem).z(t=>"min"===t.id?I.range()[0]+4*this.rem:I.range()[0]+.5*this.rem)(Ut),t=>t[0].label),ut=V.selectAll(".label-path-y").data(G.x(t=>"min"===t.id?g.range()[0]-.5*this.rem:g.range()[0]-4*this.rem).y(t=>t.y).z(t=>"min"===t.id?I.range()[1]-.5*this.rem:I.range()[1]-4*this.rem)(gt),t=>t[0].label),ht=V.selectAll(".label-path-z").data(G.x(t=>"min"===t.id?g.range()[0]-4*this.rem:g.range()[0]-.5*this.rem).y(t=>"min"===t.id?e.range()[0]+4*this.rem:e.range()[0]+.5*this.rem).z(t=>t.z)(et),t=>t[0].label),xt=V.selectAll(".label-x").data(Ut,t=>t[0].label),Gt=V.selectAll(".label-y").data(gt,t=>t[0].label),yt=V.selectAll(".label-z").data(et,t=>t[0].label),At=rt.enter().append("path").attr("class","d3-3d label-path label-path-x").attr("id",(t,B)=>`label-x-${B}`),Lt=ut.enter().append("path").attr("class","d3-3d label-path label-path-y").attr("id",(t,B)=>`label-y-${B}`),Rt=ht.enter().append("path").attr("class","d3-3d label-path label-path-z").attr("id",(t,B)=>`label-z-${B}`),mt=xt.enter().append("text").attr("class","d3-3d label label-x");mt.append("textPath").attr("href",(t,B)=>`#label-x-${B}`).attr("startOffset","0%");const Vt=Gt.enter().append("text").attr("class","d3-3d label label-y");Vt.append("textPath").attr("href",(t,B)=>`#label-y-${B}`).attr("startOffset","100%");const St=yt.enter().append("text").attr("class","d3-3d label label-z");St.append("textPath").attr("href",(t,B)=>`#label-z-${B}`).attr("startOffset","100%");const Zt=At.merge(rt).attr("d",G.draw),pt=Lt.merge(ut).attr("d",G.draw),Et=Rt.merge(ht).attr("d",G.draw),Nt=mt.merge(xt).select("textPath").text(t=>t[0].label),Xt=Vt.merge(Gt).select("textPath").text(t=>t[0].label),Wt=St.merge(yt).select("textPath").text(t=>t[0].label);Zt.exit().remove(),pt.exit().remove(),Et.exit().remove(),Nt.exit().remove(),Xt.exit().remove(),Wt.exit().remove();const Ht=V.selectAll(".point").data(y.x(t=>g(t.a)).y(t=>e(t.g)).z(t=>I(t.l))(this.point?[{a:this.a,g:this.g,l:this.l,response:this.response}]:[]));function Dt(t,B){return{x:B.x-t.x,y:B.y-t.y,z:B.z-t.z}}function ft(t){return Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z)}function wt(t,B,s){return function(t,B){return{x:t.y*B.z-t.z*B.y,y:t.z*B.x-t.x*B.z,z:t.x*B.y-t.y*B.x}}(Dt(t,B),Dt(t,s))}function vt(t,B){return function(t,B){return t.x*B.x+t.y*B.y+t.z*B.z}(t,B)/(ft(t)*ft(B))}Ht.enter().append("circle").attr("class","d3-3d point").merge(Ht).attr("class",t=>`d3-3d point ${t.response}`).attr("cx",t=>t.projected.x).attr("cy",t=>t.projected.y),Ht.exit().remove();const Yt={x:-.5,y:1,z:-1},Jt=V.selectAll(".boundary").data(this.surface?A.rows(cB(this.range.g.start,this.range.g.stop+.01,this.range.g.step).length).x(t=>g(t.a)).y(t=>e(t.g)).z(t=>I(t.l))(this.boundary).filter(t=>t[0].a>=this.range.a.start&&t[0].a<=this.range.a.stop&&t[1].a>=this.range.a.start&&t[1].a<=this.range.a.stop&&t[2].a>=this.range.a.start&&t[2].a<=this.range.a.stop&&t[3].a>=this.range.a.start&&t[3].a<=this.range.a.stop):[]);Jt.enter().append("path").attr("class","d3-3d boundary").merge(Jt).attr("d",A.draw).each(t=>{const B=t.ccw?wt(t[0].rotated,t[1].rotated,t[2].rotated):wt(t[2].rotated,t[1].rotated,t[0].rotated);t.ratio=vt(B,Yt)-.5,t.color=rQ(l).brighter(t.ratio)}).attr("fill",t=>t.color).attr("stroke",t=>t.color),Jt.exit().remove();const kt=V.selectAll(".map-xy").data(A.rows(cB(this.range.g.start,this.range.g.stop+.01,this.range.g.step).length).x(t=>g(t.a)).y(t=>e(t.g)).z(t=>I(t.l))(this.mapXY)),Mt=V.selectAll(".map-xz").data(A.rows(cB(this.range.l.start,this.range.l.stop+.01,this.range.l.step).length).x(t=>g(t.a)).y(t=>e(t.g)).z(t=>I(t.l))(this.mapXZ)),Tt=V.selectAll(".map-yz").data(A.rows(cB(this.range.l.start,this.range.l.stop+.01,this.range.l.step).length).x(t=>g(t.a)).y(t=>e(t.g)).z(t=>I(t.l))(this.mapYZ)),zt=kt.enter().append("path").attr("class","d3-3d map map-xy"),Kt=Mt.enter().append("path").attr("class","d3-3d map map-xz"),Ot=Tt.enter().append("path").attr("class","d3-3d map map-yz");zt.merge(kt).attr("d",A.draw).each(t=>{const B=t.ccw?wt(t[0].rotated,t[1].rotated,t[2].rotated):wt(t[2].rotated,t[1].rotated,t[0].rotated);t.ratio=vt(B,Yt)-.5,t.color=rQ(b(t[0].uDiff)).brighter(t.ratio)}).attr("fill",t=>t.color).attr("stroke",t=>t.color),Kt.merge(Mt).attr("d",A.draw).each(t=>{const B=t.ccw?wt(t[0].rotated,t[1].rotated,t[2].rotated):wt(t[2].rotated,t[1].rotated,t[0].rotated);t.ratio=vt(B,Yt)-.5,t.color=rQ(b(t[0].uDiff)).brighter(t.ratio)}).attr("fill",t=>t.color).attr("stroke",t=>t.color),Ot.merge(Tt).attr("d",A.draw).each(t=>{const B=t.ccw?wt(t[0].rotated,t[1].rotated,t[2].rotated):wt(t[2].rotated,t[1].rotated,t[0].rotated);t.ratio=vt(B,Yt)-.5,t.color=rQ(b(t[0].uDiff)).brighter(t.ratio)}).attr("fill",t=>t.color).attr("stroke",t=>t.color),kt.exit().remove(),Mt.exit().remove(),Tt.exit().remove(),Ys(this.renderRoot).selectAll(".d3-3d").sort(y.sort);const Pt=V.selectAll(".legend").data([{x:Q+2*this.rem,y:Q-2*this.rem,rem:this.rem}]),jt=Pt.enter().append("g").attr("class","legend"),_t=jt.merge(Pt).attr("transform",t=>`translate(${t.x} ${t.y})`);Pt.exit().remove(),jt.append("g").attr("class","axis axis-legend"),_t.select(".axis-legend").call(yB(C).ticks(7)).attr("font-size",null).attr("font-family",null),jt.append("text").attr("class","title title-legend").html('Difference in Utility (<tspan class="math-var">U<tspan class="subscript">gamble</tspan></tspan> − <tspan class="math-var">U<tspan class="subscript">sure</tspan></tspan>)'),_t.select(".title-legend").attr("transform",`translate(${2.5*-this.rem},${(C(this.range.uDiff.start)+C(this.range.uDiff.stop))/2})rotate(-90)`),jt.append("rect").attr("class","bar bar-legend").attr("fill",'url("#gradient-legend")'),_t.select(".bar-legend").attr("x",0).attr("y",C(this.range.uDiff.stop)).attr("width",this.rem).attr("height",C(this.range.uDiff.start)-C(this.range.uDiff.stop)),this.firstUpdate=!1}}customElements.define("cpt-space",qL);class tR extends(So(po)){static get properties(){return{x:{attribute:"value",type:Number,reflect:!0},a:{attribute:"alpha",type:Number,reflect:!0},l:{attribute:"lambda",type:Number,reflect:!0},label:{attribute:"label",type:String,reflect:!0},v:{attribute:!1,type:Number,reflect:!1}}}constructor(){super(),this.firstUpdate=!0,this.drag=!1,this.a=Bb.a.DEFAULT,this.l=Bb.l.DEFAULT,this.x=null,this.label="",this.function="default",this.functions=[{name:"default",a:this.a,l:this.l}],this.values=[{name:"default",x:this.x,label:this.label,function:this.function}],this.xl=null,this.xw=null,this.pw=null,this.xs=null,this.trialCount=null,this.response=null,this.alignState()}alignState(){this.functions[0].a=this.a,this.functions[0].l=this.l,this.values[0].x=this.x,this.values[0].label=this.label,this.values[0].function=this.function,this.values.forEach(t=>{const B=this.functions.find(B=>B.name===t.function);t.v=Bb.xal2v(t.x,B.a,B.l)}),this.v=this.values[0].v}trial(t,B,s,Q,F,i){this.trialCount&&this.removeValue(`${this.trialCount}-w`),this.trialCount&&this.removeValue(`${this.trialCount}-s`),this.xl=t,this.xw=B,this.pw=s,this.xs=Q,this.trialCount=F,this.response=i,this.setValue(this.xw,`${this.trialCount}-w`,"g","default",!0),this.setValue(this.xs,`${this.trialCount}-s`,"s","default",!0)}pauseTrial(){const t=Ys(this.renderRoot).selectAll(".lines[data-animating-ease-time-1]");t.interrupt("new-1"),t.interrupt("new-2"),t.datum(t=>(t.paused=!0,t))}resumeTrial(){Ys(this.renderRoot).selectAll(".lines[data-animating-ease-time-1]").datum(t=>(t.paused=!1,t)),this.requestUpdate()}clearFunctions(){this.functions.splice(1),this.requestUpdate()}clearValues(){this.values.splice(1),this.requestUpdate()}clear(){this.clearFunctions(),this.clearValues()}removeFunction(t){this.functions=this.functions.filter(B=>B.name!==t),this.requestUpdate()}removeValue(t){this.values=this.values.filter(B=>B.name!==t),this.requestUpdate()}remove(t){this.removeFunction(t),this.removeValue(t)}getFunction(t="default"){return this.functions.find(B=>B.name===t)}getValue(t="default"){return this.values.find(B=>B.name===t)}get(t="default"){return{...this.getFunction(t),...this.getValue(t)}}setFunction(t,B,s="default"){"default"===s&&(this.a=t,this.l=B);const Q=this.functions.find(t=>t.name===s);void 0===Q?this.functions.push({name:s,a:t,l:B}):(Q.a=t,Q.l=B),this.requestUpdate()}setValue(t,B="default",s="",Q=B,F=!1){"default"===B&&(this.x=t,this.label=s);const i=this.values.find(t=>t.name===B);void 0===i?this.values.push({name:B,x:t,label:s,function:Q,trial:F,new:F}):(i.x=t,i.label=s,i.function=Q),this.requestUpdate()}set(t,B,s,Q="default",F="",i=Q){this.setFunction(B,s,i),this.setValue(t,Q,F,i)}static get styles(){return[super.styles,U`
|
|
1572
1572
|
:host {
|
|
1573
1573
|
display: inline-block;
|
|
1574
1574
|
|
|
@@ -1847,7 +1847,7 @@ const mo=t=>t??z;customElements.define("decidables-slider",class extends Ro{stat
|
|
|
1847
1847
|
stroke: none;
|
|
1848
1848
|
}
|
|
1849
1849
|
`]}render(){return k`
|
|
1850
|
-
`}willUpdate(){this.alignState()}update(t){if(super.update(t),Number.isNaN(this.width)||Number.isNaN(this.height)||Number.isNaN(this.rem))return;const B=this.width,s=this.height,Q=Math.min(B,s),F={top:3*this.rem,bottom:5*this.rem,left:2*this.rem,right:6*this.rem},i=Q-(F.top+F.bottom),U=Q-(F.left+F.right),g=yI().domain([this.range.xs.start,this.range.xs.stop]).range([0,U]),e=yI().domain([this.range.pw.start,this.range.pw.stop]).range([0,-i]),I=yI().domain([this.range.xw.start,this.range.xw.stop]).range([0,-i]),l=OL(this.getComputedStyleValue("---color-element-background")).hex(),c=this.getComputedStyleValue("---color-better-dark"),n=this.getComputedStyleValue("---color-better"),a=this.getComputedStyleValue("---color-nr"),d=this.getComputedStyleValue("---color-worse"),o=this.getComputedStyleValue("---color-worse-dark"),b=ln().domain([this.range.uDiff.start,0,this.range.uDiff.stop]).clamp(!0).interpolator(wF([c,n,a,d,o])),C=yI().domain([this.range.uDiff.start,this.range.uDiff.stop]).range([0,-s+4*this.rem]),r={x:F.left,y:Q-F.bottom},u={x:g((this.range.xs.start+this.range.xs.stop)/2),y:e((this.range.pw.start+this.range.pw.stop)/2),z:I((this.range.xw.start+this.range.xw.stop)/2)},h=-.85*Math.PI/8,x=3*Math.PI/8,G=LL().origin(r).scale(1).rotationCenter(u).rotateX(h+this.rotationX).rotateY(x+this.rotationY).rotateZ(0),y=uL().origin(r).scale(1).rotationCenter(u).rotateX(h+this.rotationX).rotateY(x+this.rotationY).rotateZ(0),A=GL().origin(r).scale(1).rotationCenter(u).rotateX(h+this.rotationX).rotateY(x+this.rotationY).rotateZ(0),L=qs().on("start",t=>{this.mx=t.x,this.my=t.y}).on("drag",t=>{this.rotationY=(t.x-this.mx+this.mouseX)*(Math.PI/230),this.rotationX=(t.y-this.my+this.mouseY)*(Math.PI/230)*-1,this.requestUpdate()}).on("end",t=>{this.mouseX=t.x-this.mx+this.mouseX,this.mouseY=t.y-this.my+this.mouseY}),R=Ys(this.renderRoot).selectAll(".main").data([{width:this.width,height:this.height,rem:this.rem}]),m=R.enter().append("svg").classed("main",!0),V=m.merge(R).attr("viewBox",`0 0 ${Q} ${Q}`).call(L),S=m.append("defs").append("linearGradient").attr("id","gradient-legend").attr("x1",0).attr("x2",0).attr("y1",1).attr("y2",0);S.append("stop").attr("offset","0%").attr("stop-color",c),S.append("stop").attr("offset","25%").attr("stop-color",n),S.append("stop").attr("offset","50%").attr("stop-color",a),S.append("stop").attr("offset","75%").attr("stop-color",d),S.append("stop").attr("offset","100%").attr("stop-color",o);const Z=[[{title:'Sure Value (<tspan class="math-var">x<tspan class="subscript">sure</tspan></tspan>)',id:"max",x:g.range()[1]},{id:"min",x:g.range()[0]}]],p=[[{title:'Win Probability (<tspan class="math-var">p<tspan class="subscript">win</tspan></tspan>)',id:"max",y:e.range()[1]},{id:"min",y:e.range()[0]}]],E=[[{title:'Win Value (<tspan class="math-var">x<tspan class="subscript">win</tspan></tspan>)',id:"max",z:I.range()[1]},{id:"min",z:I.range()[0]}]],N=V.selectAll(".axis-x").data(G.x(t=>t.x).y(()=>e.range()[0]).z(()=>I.range()[0])(Z)),X=V.selectAll(".axis-y").data(G.x(()=>g.range()[0]).y(t=>t.y).z(()=>I.range()[1])(p)),W=V.selectAll(".axis-z").data(G.x(()=>g.range()[0]).y(()=>e.range()[0]).z(t=>t.z)(E)),H=N.enter().append("path").attr("class","d3-3d axis axis-x"),D=X.enter().append("path").attr("class","d3-3d axis axis-y"),f=W.enter().append("path").attr("class","d3-3d axis axis-z"),w=H.merge(N).attr("d",G.draw),v=D.merge(X).attr("d",G.draw),Y=f.merge(W).attr("d",G.draw);w.exit().remove(),v.exit().remove(),Y.exit().remove();const J=V.selectAll(".title-path-x").data(G.x(t=>"min"===t.id?t.x-20*this.rem:t.x+20*this.rem).y(()=>e.range()[0]+1.75*this.rem).z(()=>I.range()[0]+1.75*this.rem)(Z)),k=V.selectAll(".title-path-y").data(G.x(()=>g.range()[0]-1.75*this.rem).y(t=>"min"===t.id?t.y+20*this.rem:t.y-20*this.rem).z(()=>I.range()[1]-1.75*this.rem)(p)),M=V.selectAll(".title-path-z").data(G.x(()=>g.range()[0]-1.75*this.rem).y(()=>e.range()[0]+1.75*this.rem).z(t=>"min"===t.id?t.z-20*this.rem:t.z+20*this.rem)(E)),T=V.selectAll(".title-x").data(Z,t=>t[0].title),z=V.selectAll(".title-y").data(p,t=>t[0].title),K=V.selectAll(".title-z").data(E,t=>t[0].title),O=J.enter().append("path").attr("class","d3-3d title-path title-path-x").attr("id","title-x"),P=k.enter().append("path").attr("class","d3-3d title-path title-path-y").attr("id","title-y"),j=M.enter().append("path").attr("class","d3-3d title-path title-path-z").attr("id","title-z"),_=T.enter().append("text").attr("class","d3-3d title title-x");_.append("textPath").attr("href","#title-x").attr("startOffset","50%");const $=z.enter().append("text").attr("class","d3-3d title title-y");$.append("textPath").attr("href","#title-y").attr("startOffset","50%");const q=K.enter().append("text").attr("class","d3-3d title title-z");q.append("textPath").attr("href","#title-z").attr("startOffset","50%");const tt=O.merge(J).attr("d",G.draw),Bt=P.merge(k).attr("d",G.draw),st=j.merge(M).attr("d",G.draw),Qt=_.merge(T).select("textPath").html(t=>t[0].title),Ft=$.merge(z).select("textPath").html(t=>t[0].title),it=q.merge(K).select("textPath").html(t=>t[0].title);tt.exit().remove(),Bt.exit().remove(),st.exit().remove(),Qt.exit().remove(),Ft.exit().remove(),it.exit().remove();const Ut=g.ticks(5).map(t=>[{id:"min",label:g.tickFormat()(t),x:g(t)},{id:"max",x:g(t)}]),gt=e.ticks(5).map(t=>[{id:"min",label:e.tickFormat()(t),y:e(t)},{id:"max",y:e(t)}]),et=I.ticks(5).map(t=>[{id:"max",label:I.tickFormat()(t),z:I(t)},{id:"min",z:I(t)}]),It=V.selectAll(".tick-x").data(G.x(t=>t.x).y(t=>"min"===t.id?e.range()[0]:e.range()[0]+.35*this.rem).z(t=>"min"===t.id?I.range()[0]:I.range()[0]+.35*this.rem)(Ut)),lt=V.selectAll(".tick-y").data(G.x(t=>"min"===t.id?g.range()[0]:g.range()[0]-.35*this.rem).y(t=>t.y).z(t=>"min"===t.id?I.range()[1]:I.range()[1]-.35*this.rem)(gt)),ct=V.selectAll(".tick-z").data(G.x(t=>"min"===t.id?g.range()[0]:g.range()[0]-.35*this.rem).y(t=>"min"===t.id?e.range()[0]:e.range()[0]+.35*this.rem).z(t=>t.z)(et)),nt=It.enter().append("path").attr("class","d3-3d tick tick-x"),at=lt.enter().append("path").attr("class","d3-3d tick tick-y"),dt=ct.enter().append("path").attr("class","d3-3d tick tick-z"),ot=nt.merge(It).attr("d",G.draw),bt=at.merge(lt).attr("d",G.draw),Ct=dt.merge(ct).attr("d",G.draw);ot.exit().remove(),bt.exit().remove(),Ct.exit().remove();const rt=V.selectAll(".label-path-x").data(G.x(t=>t.x).y(t=>"min"===t.id?e.range()[0]+4*this.rem:e.range()[0]+.5*this.rem).z(t=>"min"===t.id?I.range()[0]+4*this.rem:I.range()[0]+.5*this.rem)(Ut),t=>t[0].label),ut=V.selectAll(".label-path-y").data(G.x(t=>"min"===t.id?g.range()[0]-.5*this.rem:g.range()[0]-4*this.rem).y(t=>t.y).z(t=>"min"===t.id?I.range()[1]-.5*this.rem:I.range()[1]-4*this.rem)(gt),t=>t[0].label),ht=V.selectAll(".label-path-z").data(G.x(t=>"min"===t.id?g.range()[0]-4*this.rem:g.range()[0]-.5*this.rem).y(t=>"min"===t.id?e.range()[0]+4*this.rem:e.range()[0]+.5*this.rem).z(t=>t.z)(et),t=>t[0].label),xt=V.selectAll(".label-x").data(Ut,t=>t[0].label),Gt=V.selectAll(".label-y").data(gt,t=>t[0].label),yt=V.selectAll(".label-z").data(et,t=>t[0].label),At=rt.enter().append("path").attr("class","d3-3d label-path label-path-x").attr("id",(t,B)=>`label-x-${B}`),Lt=ut.enter().append("path").attr("class","d3-3d label-path label-path-y").attr("id",(t,B)=>`label-y-${B}`),Rt=ht.enter().append("path").attr("class","d3-3d label-path label-path-z").attr("id",(t,B)=>`label-z-${B}`),mt=xt.enter().append("text").attr("class","d3-3d label label-x");mt.append("textPath").attr("href",(t,B)=>`#label-x-${B}`).attr("startOffset","0%");const Vt=Gt.enter().append("text").attr("class","d3-3d label label-y");Vt.append("textPath").attr("href",(t,B)=>`#label-y-${B}`).attr("startOffset","100%");const St=yt.enter().append("text").attr("class","d3-3d label label-z");St.append("textPath").attr("href",(t,B)=>`#label-z-${B}`).attr("startOffset","100%");const Zt=At.merge(rt).attr("d",G.draw),pt=Lt.merge(ut).attr("d",G.draw),Et=Rt.merge(ht).attr("d",G.draw),Nt=mt.merge(xt).select("textPath").text(t=>t[0].label),Xt=Vt.merge(Gt).select("textPath").text(t=>t[0].label),Wt=St.merge(yt).select("textPath").text(t=>t[0].label);Zt.exit().remove(),pt.exit().remove(),Et.exit().remove(),Nt.exit().remove(),Xt.exit().remove(),Wt.exit().remove();const Ht=V.selectAll(".point").data(y.x(t=>g(t.xs)).y(t=>e(t.pw)).z(t=>I(t.xw))(this.choices.slice("rest"===this.point?1:0,"first"===this.point?1:void 0)),t=>t.name);function Dt(t,B){return{x:B.x-t.x,y:B.y-t.y,z:B.z-t.z}}function ft(t){return Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z)}function wt(t,B,s){return function(t,B){return{x:t.y*B.z-t.z*B.y,y:t.z*B.x-t.x*B.z,z:t.x*B.y-t.y*B.x}}(Dt(t,B),Dt(t,s))}function vt(t,B){return function(t,B){return t.x*B.x+t.y*B.y+t.z*B.z}(t,B)/(ft(t)*ft(B))}Ht.enter().append("circle").attr("class","d3-3d point").merge(Ht).attr("class",t=>`d3-3d point ${t.response}`).attr("cx",t=>t.projected.x).attr("cy",t=>t.projected.y),Ht.exit().remove();const Yt={x:-.5,y:1,z:-1},Jt=V.selectAll(".boundary").data(this.surface?A.rows(cB(this.range.xw.start,this.range.xw.stop+.01,this.range.xw.step).length).x(t=>g(t.xs)).y(t=>e(t.pw)).z(t=>I(t.xw))(this.boundary).filter(t=>t[0].pw>=this.range.pw.start&&t[0].pw<=this.range.pw.stop&&t[1].pw>=this.range.pw.start&&t[1].pw<=this.range.pw.stop&&t[2].pw>=this.range.pw.start&&t[2].pw<=this.range.pw.stop&&t[3].pw>=this.range.pw.start&&t[3].pw<=this.range.pw.stop):[]);Jt.enter().append("path").attr("class","d3-3d boundary").merge(Jt).attr("d",A.draw).each(t=>{const B=t.ccw?wt(t[0].rotated,t[1].rotated,t[2].rotated):wt(t[2].rotated,t[1].rotated,t[0].rotated);t.ratio=vt(B,Yt)-.5,t.color=rQ(l).brighter(t.ratio)}).attr("fill",t=>t.color).attr("stroke",t=>t.color),Jt.exit().remove();const kt=V.selectAll(".map-xy").data(A.rows(cB(this.range.pw.start,this.range.pw.stop+.01,this.range.pw.step).length).x(t=>g(t.xs)).y(t=>e(t.pw)).z(t=>I(t.xw))(this.mapXY)),Mt=V.selectAll(".map-xz").data(A.rows(cB(this.range.xw.start,this.range.xw.stop+.01,this.range.xw.step).length).x(t=>g(t.xs)).y(t=>e(t.pw)).z(t=>I(t.xw))(this.mapXZ)),Tt=V.selectAll(".map-yz").data(A.rows(cB(this.range.xw.start,this.range.xw.stop+.01,this.range.xw.step).length).x(t=>g(t.xs)).y(t=>e(t.pw)).z(t=>I(t.xw))(this.mapYZ)),zt=kt.enter().append("path").attr("class","d3-3d map map-xy"),Kt=Mt.enter().append("path").attr("class","d3-3d map map-xz"),Ot=Tt.enter().append("path").attr("class","d3-3d map map-yz");zt.merge(kt).attr("d",A.draw).each(t=>{const B=t.ccw?wt(t[0].rotated,t[1].rotated,t[2].rotated):wt(t[2].rotated,t[1].rotated,t[0].rotated);t.ratio=vt(B,Yt)-.5,t.color=rQ(b(t[0].uDiff)).brighter(t.ratio)}).attr("fill",t=>t.color).attr("stroke",t=>t.color),Kt.merge(Mt).attr("d",A.draw).each(t=>{const B=t.ccw?wt(t[0].rotated,t[1].rotated,t[2].rotated):wt(t[2].rotated,t[1].rotated,t[0].rotated);t.ratio=vt(B,Yt)-.5,t.color=rQ(b(t[0].uDiff)).brighter(t.ratio)}).attr("fill",t=>t.color).attr("stroke",t=>t.color),Ot.merge(Tt).attr("d",A.draw).each(t=>{const B=t.ccw?wt(t[0].rotated,t[1].rotated,t[2].rotated):wt(t[2].rotated,t[1].rotated,t[0].rotated);t.ratio=vt(B,Yt)-.5,t.color=rQ(b(t[0].uDiff)).brighter(t.ratio)}).attr("fill",t=>t.color).attr("stroke",t=>t.color),kt.exit().remove(),Mt.exit().remove(),Tt.exit().remove(),Ys(this.renderRoot).selectAll(".d3-3d").sort(y.sort);const Pt=V.selectAll(".legend").data([{x:Q+2*this.rem,y:Q-2*this.rem,rem:this.rem}]),jt=Pt.enter().append("g").attr("class","legend"),_t=jt.merge(Pt).attr("transform",t=>`translate(${t.x} ${t.y})`);Pt.exit().remove(),jt.append("g").attr("class","axis axis-legend"),_t.select(".axis-legend").call(yB(C).ticks(7)).attr("font-size",null).attr("font-family",null),jt.append("text").attr("class","title title-legend").html('Difference in Utility (<tspan class="math-var">U<tspan class="subscript">gamble</tspan></tspan> − <tspan class="math-var">U<tspan class="subscript">sure</tspan></tspan>)'),_t.select(".title-legend").attr("transform",`translate(${2.5*-this.rem},${(C(this.range.uDiff.start)+C(this.range.uDiff.stop))/2})rotate(-90)`),jt.append("rect").attr("class","bar bar-legend").attr("fill",'url("#gradient-legend")'),_t.select(".bar-legend").attr("x",0).attr("y",C(this.range.uDiff.stop)).attr("width",this.rem).attr("height",C(this.range.uDiff.start)-C(this.range.uDiff.stop)),this.firstUpdate=!1}}customElements.define("decision-space",BR);class sR extends po{static get properties(){return{trials:{attribute:"trials",type:Number,reflect:!0},duration:{attribute:"duration",type:Number,reflect:!0},run:{attribute:"run",type:Boolean,reflect:!0},pause:{attribute:"pause",type:Boolean,reflect:!0},reset:{attribute:"reset",type:Boolean,reflect:!0},state:{atribute:!1,type:String,reflect:!1}}}constructor(){super(),this.trials=void 0,this.duration=void 0,this.run=!1,this.pause=!1,this.reset=!1,this.states=["resetted","running","paused","ended"],this.state="resetted"}setTrials(t){this.trials=t.target.value,this.dispatchEvent(new CustomEvent("prospectable-control-trials",{detail:{trials:this.trials},bubbles:!0}))}setDuration(t){this.duration=t.target.value,this.dispatchEvent(new CustomEvent("prospectable-control-duration",{detail:{duration:this.duration},bubbles:!0}))}doRun(){this.state="running",this.dispatchEvent(new CustomEvent("prospectable-control-run",{detail:{},bubbles:!0}))}doPause(){this.state="paused",this.dispatchEvent(new CustomEvent("prospectable-control-pause",{detail:{},bubbles:!0}))}doReset(){this.state="resetted",this.dispatchEvent(new CustomEvent("prospectable-control-reset",{detail:{},bubbles:!0}))}complete(){this.state="ended"}static get styles(){return[super.styles,U`
|
|
1850
|
+
`}willUpdate(){this.alignState()}update(t){if(super.update(t),Number.isNaN(this.width)||Number.isNaN(this.height)||Number.isNaN(this.rem))return;const B=this.width,s=this.height,Q=Math.min(B,s),F={top:3*this.rem,bottom:5*this.rem,left:2*this.rem,right:6*this.rem},i=Q-(F.top+F.bottom),U=Q-(F.left+F.right),g=yI().domain([this.range.xs.start,this.range.xs.stop]).range([0,U]),e=yI().domain([this.range.pw.start,this.range.pw.stop]).range([0,-i]),I=yI().domain([this.range.xw.start,this.range.xw.stop]).range([0,-i]),l=OL(this.getComputedStyleValue("---color-element-background")).hex(),c=this.getComputedStyleValue("---color-better-dark"),n=this.getComputedStyleValue("---color-better"),a=this.getComputedStyleValue("---color-nr"),d=this.getComputedStyleValue("---color-worse"),o=this.getComputedStyleValue("---color-worse-dark"),b=ln().domain([this.range.uDiff.start,0,this.range.uDiff.stop]).clamp(!0).interpolator(wF([c,n,a,d,o])),C=yI().domain([this.range.uDiff.start,this.range.uDiff.stop]).range([0,-s+4*this.rem]),r={x:F.left,y:Q-F.bottom},u={x:g((this.range.xs.start+this.range.xs.stop)/2),y:e((this.range.pw.start+this.range.pw.stop)/2),z:I((this.range.xw.start+this.range.xw.stop)/2)},h=-.85*Math.PI/8,x=3*Math.PI/8,G=LL().origin(r).scale(1).rotationCenter(u).rotateX(h+this.rotationX).rotateY(x+this.rotationY).rotateZ(0),y=uL().origin(r).scale(1).rotationCenter(u).rotateX(h+this.rotationX).rotateY(x+this.rotationY).rotateZ(0),A=GL().origin(r).scale(1).rotationCenter(u).rotateX(h+this.rotationX).rotateY(x+this.rotationY).rotateZ(0),L=qs().on("start",t=>{this.mx=t.x,this.my=t.y}).on("drag",t=>{this.rotationY=(t.x-this.mx+this.mouseX)*(Math.PI/230),this.rotationX=(t.y-this.my+this.mouseY)*(Math.PI/230)*-1,this.requestUpdate()}).on("end",t=>{this.mouseX=t.x-this.mx+this.mouseX,this.mouseY=t.y-this.my+this.mouseY}),R=Ys(this.renderRoot).selectAll(".main").data([{width:this.width,height:this.height,rem:this.rem}]),m=R.enter().append("svg").classed("main",!0).call(L),V=m.merge(R).attr("viewBox",`0 0 ${Q} ${Q}`),S=m.append("defs").append("linearGradient").attr("id","gradient-legend").attr("x1",0).attr("x2",0).attr("y1",1).attr("y2",0);S.append("stop").attr("offset","0%").attr("stop-color",c),S.append("stop").attr("offset","25%").attr("stop-color",n),S.append("stop").attr("offset","50%").attr("stop-color",a),S.append("stop").attr("offset","75%").attr("stop-color",d),S.append("stop").attr("offset","100%").attr("stop-color",o);const Z=[[{title:'Sure Value (<tspan class="math-var">x<tspan class="subscript">sure</tspan></tspan>)',id:"max",x:g.range()[1]},{id:"min",x:g.range()[0]}]],p=[[{title:'Win Probability (<tspan class="math-var">p<tspan class="subscript">win</tspan></tspan>)',id:"max",y:e.range()[1]},{id:"min",y:e.range()[0]}]],E=[[{title:'Win Value (<tspan class="math-var">x<tspan class="subscript">win</tspan></tspan>)',id:"max",z:I.range()[1]},{id:"min",z:I.range()[0]}]],N=V.selectAll(".axis-x").data(G.x(t=>t.x).y(()=>e.range()[0]).z(()=>I.range()[0])(Z)),X=V.selectAll(".axis-y").data(G.x(()=>g.range()[0]).y(t=>t.y).z(()=>I.range()[1])(p)),W=V.selectAll(".axis-z").data(G.x(()=>g.range()[0]).y(()=>e.range()[0]).z(t=>t.z)(E)),H=N.enter().append("path").attr("class","d3-3d axis axis-x"),D=X.enter().append("path").attr("class","d3-3d axis axis-y"),f=W.enter().append("path").attr("class","d3-3d axis axis-z"),w=H.merge(N).attr("d",G.draw),v=D.merge(X).attr("d",G.draw),Y=f.merge(W).attr("d",G.draw);w.exit().remove(),v.exit().remove(),Y.exit().remove();const J=V.selectAll(".title-path-x").data(G.x(t=>"min"===t.id?t.x-20*this.rem:t.x+20*this.rem).y(()=>e.range()[0]+1.75*this.rem).z(()=>I.range()[0]+1.75*this.rem)(Z)),k=V.selectAll(".title-path-y").data(G.x(()=>g.range()[0]-1.75*this.rem).y(t=>"min"===t.id?t.y+20*this.rem:t.y-20*this.rem).z(()=>I.range()[1]-1.75*this.rem)(p)),M=V.selectAll(".title-path-z").data(G.x(()=>g.range()[0]-1.75*this.rem).y(()=>e.range()[0]+1.75*this.rem).z(t=>"min"===t.id?t.z-20*this.rem:t.z+20*this.rem)(E)),T=V.selectAll(".title-x").data(Z,t=>t[0].title),z=V.selectAll(".title-y").data(p,t=>t[0].title),K=V.selectAll(".title-z").data(E,t=>t[0].title),O=J.enter().append("path").attr("class","d3-3d title-path title-path-x").attr("id","title-x"),P=k.enter().append("path").attr("class","d3-3d title-path title-path-y").attr("id","title-y"),j=M.enter().append("path").attr("class","d3-3d title-path title-path-z").attr("id","title-z"),_=T.enter().append("text").attr("class","d3-3d title title-x");_.append("textPath").attr("href","#title-x").attr("startOffset","50%");const $=z.enter().append("text").attr("class","d3-3d title title-y");$.append("textPath").attr("href","#title-y").attr("startOffset","50%");const q=K.enter().append("text").attr("class","d3-3d title title-z");q.append("textPath").attr("href","#title-z").attr("startOffset","50%");const tt=O.merge(J).attr("d",G.draw),Bt=P.merge(k).attr("d",G.draw),st=j.merge(M).attr("d",G.draw),Qt=_.merge(T).select("textPath").html(t=>t[0].title),Ft=$.merge(z).select("textPath").html(t=>t[0].title),it=q.merge(K).select("textPath").html(t=>t[0].title);tt.exit().remove(),Bt.exit().remove(),st.exit().remove(),Qt.exit().remove(),Ft.exit().remove(),it.exit().remove();const Ut=g.ticks(5).map(t=>[{id:"min",label:g.tickFormat()(t),x:g(t)},{id:"max",x:g(t)}]),gt=e.ticks(5).map(t=>[{id:"min",label:e.tickFormat()(t),y:e(t)},{id:"max",y:e(t)}]),et=I.ticks(5).map(t=>[{id:"max",label:I.tickFormat()(t),z:I(t)},{id:"min",z:I(t)}]),It=V.selectAll(".tick-x").data(G.x(t=>t.x).y(t=>"min"===t.id?e.range()[0]:e.range()[0]+.35*this.rem).z(t=>"min"===t.id?I.range()[0]:I.range()[0]+.35*this.rem)(Ut)),lt=V.selectAll(".tick-y").data(G.x(t=>"min"===t.id?g.range()[0]:g.range()[0]-.35*this.rem).y(t=>t.y).z(t=>"min"===t.id?I.range()[1]:I.range()[1]-.35*this.rem)(gt)),ct=V.selectAll(".tick-z").data(G.x(t=>"min"===t.id?g.range()[0]:g.range()[0]-.35*this.rem).y(t=>"min"===t.id?e.range()[0]:e.range()[0]+.35*this.rem).z(t=>t.z)(et)),nt=It.enter().append("path").attr("class","d3-3d tick tick-x"),at=lt.enter().append("path").attr("class","d3-3d tick tick-y"),dt=ct.enter().append("path").attr("class","d3-3d tick tick-z"),ot=nt.merge(It).attr("d",G.draw),bt=at.merge(lt).attr("d",G.draw),Ct=dt.merge(ct).attr("d",G.draw);ot.exit().remove(),bt.exit().remove(),Ct.exit().remove();const rt=V.selectAll(".label-path-x").data(G.x(t=>t.x).y(t=>"min"===t.id?e.range()[0]+4*this.rem:e.range()[0]+.5*this.rem).z(t=>"min"===t.id?I.range()[0]+4*this.rem:I.range()[0]+.5*this.rem)(Ut),t=>t[0].label),ut=V.selectAll(".label-path-y").data(G.x(t=>"min"===t.id?g.range()[0]-.5*this.rem:g.range()[0]-4*this.rem).y(t=>t.y).z(t=>"min"===t.id?I.range()[1]-.5*this.rem:I.range()[1]-4*this.rem)(gt),t=>t[0].label),ht=V.selectAll(".label-path-z").data(G.x(t=>"min"===t.id?g.range()[0]-4*this.rem:g.range()[0]-.5*this.rem).y(t=>"min"===t.id?e.range()[0]+4*this.rem:e.range()[0]+.5*this.rem).z(t=>t.z)(et),t=>t[0].label),xt=V.selectAll(".label-x").data(Ut,t=>t[0].label),Gt=V.selectAll(".label-y").data(gt,t=>t[0].label),yt=V.selectAll(".label-z").data(et,t=>t[0].label),At=rt.enter().append("path").attr("class","d3-3d label-path label-path-x").attr("id",(t,B)=>`label-x-${B}`),Lt=ut.enter().append("path").attr("class","d3-3d label-path label-path-y").attr("id",(t,B)=>`label-y-${B}`),Rt=ht.enter().append("path").attr("class","d3-3d label-path label-path-z").attr("id",(t,B)=>`label-z-${B}`),mt=xt.enter().append("text").attr("class","d3-3d label label-x");mt.append("textPath").attr("href",(t,B)=>`#label-x-${B}`).attr("startOffset","0%");const Vt=Gt.enter().append("text").attr("class","d3-3d label label-y");Vt.append("textPath").attr("href",(t,B)=>`#label-y-${B}`).attr("startOffset","100%");const St=yt.enter().append("text").attr("class","d3-3d label label-z");St.append("textPath").attr("href",(t,B)=>`#label-z-${B}`).attr("startOffset","100%");const Zt=At.merge(rt).attr("d",G.draw),pt=Lt.merge(ut).attr("d",G.draw),Et=Rt.merge(ht).attr("d",G.draw),Nt=mt.merge(xt).select("textPath").text(t=>t[0].label),Xt=Vt.merge(Gt).select("textPath").text(t=>t[0].label),Wt=St.merge(yt).select("textPath").text(t=>t[0].label);Zt.exit().remove(),pt.exit().remove(),Et.exit().remove(),Nt.exit().remove(),Xt.exit().remove(),Wt.exit().remove();const Ht=V.selectAll(".point").data(y.x(t=>g(t.xs)).y(t=>e(t.pw)).z(t=>I(t.xw))(this.choices.slice("rest"===this.point?1:0,"first"===this.point?1:void 0)),t=>t.name);function Dt(t,B){return{x:B.x-t.x,y:B.y-t.y,z:B.z-t.z}}function ft(t){return Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z)}function wt(t,B,s){return function(t,B){return{x:t.y*B.z-t.z*B.y,y:t.z*B.x-t.x*B.z,z:t.x*B.y-t.y*B.x}}(Dt(t,B),Dt(t,s))}function vt(t,B){return function(t,B){return t.x*B.x+t.y*B.y+t.z*B.z}(t,B)/(ft(t)*ft(B))}Ht.enter().append("circle").attr("class","d3-3d point").merge(Ht).attr("class",t=>`d3-3d point ${t.response}`).attr("cx",t=>t.projected.x).attr("cy",t=>t.projected.y),Ht.exit().remove();const Yt={x:-.5,y:1,z:-1},Jt=V.selectAll(".boundary").data(this.surface?A.rows(cB(this.range.xw.start,this.range.xw.stop+.01,this.range.xw.step).length).x(t=>g(t.xs)).y(t=>e(t.pw)).z(t=>I(t.xw))(this.boundary).filter(t=>t[0].pw>=this.range.pw.start&&t[0].pw<=this.range.pw.stop&&t[1].pw>=this.range.pw.start&&t[1].pw<=this.range.pw.stop&&t[2].pw>=this.range.pw.start&&t[2].pw<=this.range.pw.stop&&t[3].pw>=this.range.pw.start&&t[3].pw<=this.range.pw.stop):[]);Jt.enter().append("path").attr("class","d3-3d boundary").merge(Jt).attr("d",A.draw).each(t=>{const B=t.ccw?wt(t[0].rotated,t[1].rotated,t[2].rotated):wt(t[2].rotated,t[1].rotated,t[0].rotated);t.ratio=vt(B,Yt)-.5,t.color=rQ(l).brighter(t.ratio)}).attr("fill",t=>t.color).attr("stroke",t=>t.color),Jt.exit().remove();const kt=V.selectAll(".map-xy").data(A.rows(cB(this.range.pw.start,this.range.pw.stop+.01,this.range.pw.step).length).x(t=>g(t.xs)).y(t=>e(t.pw)).z(t=>I(t.xw))(this.mapXY)),Mt=V.selectAll(".map-xz").data(A.rows(cB(this.range.xw.start,this.range.xw.stop+.01,this.range.xw.step).length).x(t=>g(t.xs)).y(t=>e(t.pw)).z(t=>I(t.xw))(this.mapXZ)),Tt=V.selectAll(".map-yz").data(A.rows(cB(this.range.xw.start,this.range.xw.stop+.01,this.range.xw.step).length).x(t=>g(t.xs)).y(t=>e(t.pw)).z(t=>I(t.xw))(this.mapYZ)),zt=kt.enter().append("path").attr("class","d3-3d map map-xy"),Kt=Mt.enter().append("path").attr("class","d3-3d map map-xz"),Ot=Tt.enter().append("path").attr("class","d3-3d map map-yz");zt.merge(kt).attr("d",A.draw).each(t=>{const B=t.ccw?wt(t[0].rotated,t[1].rotated,t[2].rotated):wt(t[2].rotated,t[1].rotated,t[0].rotated);t.ratio=vt(B,Yt)-.5,t.color=rQ(b(t[0].uDiff)).brighter(t.ratio)}).attr("fill",t=>t.color).attr("stroke",t=>t.color),Kt.merge(Mt).attr("d",A.draw).each(t=>{const B=t.ccw?wt(t[0].rotated,t[1].rotated,t[2].rotated):wt(t[2].rotated,t[1].rotated,t[0].rotated);t.ratio=vt(B,Yt)-.5,t.color=rQ(b(t[0].uDiff)).brighter(t.ratio)}).attr("fill",t=>t.color).attr("stroke",t=>t.color),Ot.merge(Tt).attr("d",A.draw).each(t=>{const B=t.ccw?wt(t[0].rotated,t[1].rotated,t[2].rotated):wt(t[2].rotated,t[1].rotated,t[0].rotated);t.ratio=vt(B,Yt)-.5,t.color=rQ(b(t[0].uDiff)).brighter(t.ratio)}).attr("fill",t=>t.color).attr("stroke",t=>t.color),kt.exit().remove(),Mt.exit().remove(),Tt.exit().remove(),Ys(this.renderRoot).selectAll(".d3-3d").sort(y.sort);const Pt=V.selectAll(".legend").data([{x:Q+2*this.rem,y:Q-2*this.rem,rem:this.rem}]),jt=Pt.enter().append("g").attr("class","legend"),_t=jt.merge(Pt).attr("transform",t=>`translate(${t.x} ${t.y})`);Pt.exit().remove(),jt.append("g").attr("class","axis axis-legend"),_t.select(".axis-legend").call(yB(C).ticks(7)).attr("font-size",null).attr("font-family",null),jt.append("text").attr("class","title title-legend").html('Difference in Utility (<tspan class="math-var">U<tspan class="subscript">gamble</tspan></tspan> − <tspan class="math-var">U<tspan class="subscript">sure</tspan></tspan>)'),_t.select(".title-legend").attr("transform",`translate(${2.5*-this.rem},${(C(this.range.uDiff.start)+C(this.range.uDiff.stop))/2})rotate(-90)`),jt.append("rect").attr("class","bar bar-legend").attr("fill",'url("#gradient-legend")'),_t.select(".bar-legend").attr("x",0).attr("y",C(this.range.uDiff.stop)).attr("width",this.rem).attr("height",C(this.range.uDiff.start)-C(this.range.uDiff.stop)),this.firstUpdate=!1}}customElements.define("decision-space",BR);class sR extends po{static get properties(){return{trials:{attribute:"trials",type:Number,reflect:!0},duration:{attribute:"duration",type:Number,reflect:!0},run:{attribute:"run",type:Boolean,reflect:!0},pause:{attribute:"pause",type:Boolean,reflect:!0},reset:{attribute:"reset",type:Boolean,reflect:!0},state:{atribute:!1,type:String,reflect:!1}}}constructor(){super(),this.trials=void 0,this.duration=void 0,this.run=!1,this.pause=!1,this.reset=!1,this.states=["resetted","running","paused","ended"],this.state="resetted"}setTrials(t){this.trials=t.target.value,this.dispatchEvent(new CustomEvent("prospectable-control-trials",{detail:{trials:this.trials},bubbles:!0}))}setDuration(t){this.duration=t.target.value,this.dispatchEvent(new CustomEvent("prospectable-control-duration",{detail:{duration:this.duration},bubbles:!0}))}doRun(){this.state="running",this.dispatchEvent(new CustomEvent("prospectable-control-run",{detail:{},bubbles:!0}))}doPause(){this.state="paused",this.dispatchEvent(new CustomEvent("prospectable-control-pause",{detail:{},bubbles:!0}))}doReset(){this.state="resetted",this.dispatchEvent(new CustomEvent("prospectable-control-reset",{detail:{},bubbles:!0}))}complete(){this.state="ended"}static get styles(){return[super.styles,U`
|
|
1851
1851
|
:host {
|
|
1852
1852
|
display: inline-block;
|
|
1853
1853
|
}
|