import{a as st,s as rt,b as at,c as lt,n as ot,o as ct,l as tt,g as et,a6 as ht,A as ut,T as pt,e as yt,i as ft,q as mt,P as gt,H as J}from"./layers.BfHNcLbu-DoBpzOGI.js";import"./layers.B6AgvWr7-Bq9IA4iY.js";import{v as Z}from"./layers.DxRkHDxc-DU-c-Pfl.js";import{h as dt}from"./layers.b0h5ZBmD-D7tiw6cE.js";import{t as _t}from"./layers.CqVTtuYm-C3YJfAyO.js";import{P as M}from"./layers.DLwuMfdd-B0oSrkCJ.js";import"./index-DTC0Ed21.js";import"./TaskPanel-DL-lNNa-.js";import"./tasks-ClycqzjK.js";import"./IconUser-Bh9n--nN.js";import"./tasks-R9G1-k7v.js";import"./IconChevronLeft-DwnMQlxZ.js";import"./use-resize-observer-B2T5TxF-.js";import"./useTaskTypesData-DEDxUwkB.js";import"./PillsInput-BQBRVlfT.js";import"./SegmentedControl-CI2D3wRP.js";import"./get-base-value-JqT_q0U7.js";import"./ColorSwatch-DyLoUEeW.js";import"./TypographyStylesProvider-B4wTcLh8.js";import"./clamp-Bw9v46PI.js";import"./IconGripVertical-A4WphpSm.js";import"./Accordion-BmslGzqa.js";import"./layers.DjUOC4st-DHuO7-vr.js";function bt(e,h){return h<e?-1:h>e?1:h>=e?0:NaN}function kt(e){return e}function vt(){var e=kt,h=bt,y=null,$=M(0),x=M(J),S=M(0);function u(r){var l,g=(r=_t(r)).length,b,I,T=0,d=new Array(g),k=new Array(g),o=+$.apply(this,arguments),A=Math.min(J,Math.max(-J,x.apply(this,arguments)-o)),N,E=Math.min(Math.abs(A)/g,S.apply(this,arguments)),m=E*(A<0?-1:1),t;for(l=0;l<g;++l)(t=k[d[l]=l]=+e(r[l],l,r))>0&&(T+=t);for(h!=null?d.sort(function(i,s){return h(k[i],k[s])}):y!=null&&d.sort(function(i,s){return y(r[i],r[s])}),l=0,I=T?(A-g*m)/T:0;l<g;++l,o=N)b=d[l],t=k[b],N=o+(t>0?t*I:0)+m,k[b]={data:r[b],index:l,value:t,startAngle:o,endAngle:N,padAngle:E};return k}return u.value=function(r){return arguments.length?(e=typeof r=="function"?r:M(+r),u):e},u.sortValues=function(r){return arguments.length?(h=r,y=null,u):h},u.sort=function(r){return arguments.length?(y=r,h=null,u):y},u.startAngle=function(r){return arguments.length?($=typeof r=="function"?r:M(+r),u):$},u.endAngle=function(r){return arguments.length?(x=typeof r=="function"?r:M(+r),u):x},u.padAngle=function(r){return arguments.length?(S=typeof r=="function"?r:M(+r),u):S},u}var H=(function(){var e=function(m,t,i,s){for(i=i||{},s=m.length;s--;i[m[s]]=t);return i},h=[1,3],y=[1,4],$=[1,5],x=[1,6],S=[1,10,12,14,16,18,19,20,21,22],u=[2,4],r=[1,5,10,12,14,16,18,19,20,21,22],l=[20,21,22],g=[2,7],b=[1,12],I=[1,13],T=[1,14],d=[1,15],k=[1,16],o=[1,17],A={trace:function(){},yy:{},symbols_:{error:2,start:3,eol:4,PIE:5,document:6,showData:7,line:8,statement:9,txt:10,value:11,title:12,title_value:13,acc_title:14,acc_title_value:15,acc_descr:16,acc_descr_value:17,acc_descr_multiline_value:18,section:19,NEWLINE:20,";":21,EOF:22,$accept:0,$end:1},terminals_:{2:"error",5:"PIE",7:"showData",10:"txt",11:"value",12:"title",13:"title_value",14:"acc_title",15:"acc_title_value",16:"acc_descr",17:"acc_descr_value",18:"acc_descr_multiline_value",19:"section",20:"NEWLINE",21:";",22:"EOF"},productions_:[0,[3,2],[3,2],[3,3],[6,0],[6,2],[8,2],[9,0],[9,2],[9,2],[9,2],[9,2],[9,1],[9,1],[4,1],[4,1],[4,1]],performAction:function(m,t,i,s,a,n,p){var v=n.length-1;switch(a){case 3:s.setShowData(!0);break;case 6:this.$=n[v-1];break;case 8:s.addSection(n[v-1],s.cleanupValue(n[v]));break;case 9:this.$=n[v].trim(),s.setDiagramTitle(this.$);break;case 10:this.$=n[v].trim(),s.setAccTitle(this.$);break;case 11:case 12:this.$=n[v].trim(),s.setAccDescription(this.$);break;case 13:s.addSection(n[v].substr(8)),this.$=n[v].substr(8);break}},table:[{3:1,4:2,5:h,20:y,21:$,22:x},{1:[3]},{3:7,4:2,5:h,20:y,21:$,22:x},e(S,u,{6:8,7:[1,9]}),e(r,[2,14]),e(r,[2,15]),e(r,[2,16]),{1:[2,1]},e(l,g,{8:10,9:11,1:[2,2],10:b,12:I,14:T,16:d,18:k,19:o}),e(S,u,{6:18}),e(S,[2,5]),{4:19,20:y,21:$,22:x},{11:[1,20]},{13:[1,21]},{15:[1,22]},{17:[1,23]},e(l,[2,12]),e(l,[2,13]),e(l,g,{8:10,9:11,1:[2,3],10:b,12:I,14:T,16:d,18:k,19:o}),e(S,[2,6]),e(l,[2,8]),e(l,[2,9]),e(l,[2,10]),e(l,[2,11])],defaultActions:{7:[2,1]},parseError:function(m,t){if(t.recoverable)this.trace(m);else{var i=new Error(m);throw i.hash=t,i}},parse:function(m){var t=this,i=[0],s=[],a=[null],n=[],p=this.table,v="",D=0,f=0,V=2,R=1,z=n.slice.call(arguments,1),c=Object.create(this.lexer),C={yy:{}};for(var q in this.yy)Object.prototype.hasOwnProperty.call(this.yy,q)&&(C.yy[q]=this.yy[q]);c.setInput(m,C.yy),C.yy.lexer=c,C.yy.parser=this,typeof c.yylloc>"u"&&(c.yylloc={});var G=c.yylloc;n.push(G);var it=c.options&&c.options.ranges;typeof C.yy.parseError=="function"?this.parseError=C.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function nt(){var P;return P=s.pop()||c.lex()||R,typeof P!="number"&&(P instanceof Array&&(s=P,P=s.pop()),P=t.symbols_[P]||P),P}for(var _,F,w,K,j={},B,O,Y,L;;){if(F=i[i.length-1],this.defaultActions[F]?w=this.defaultActions[F]:((_===null||typeof _>"u")&&(_=nt()),w=p[F]&&p[F][_]),typeof w>"u"||!w.length||!w[0]){var Q="";L=[];for(B in p[F])this.terminals_[B]&&B>V&&L.push("'"+this.terminals_[B]+"'");c.showPosition?Q="Parse error on line "+(D+1)+`:
`+c.showPosition()+`
Expecting `+L.join(", ")+", got '"+(this.terminals_[_]||_)+"'":Q="Parse error on line "+(D+1)+": Unexpected "+(_==R?"end of input":"'"+(this.terminals_[_]||_)+"'"),this.parseError(Q,{text:c.match,token:this.terminals_[_]||_,line:c.yylineno,loc:G,expected:L})}if(w[0]instanceof Array&&w.length>1)throw new Error("Parse Error: multiple actions possible at state: "+F+", token: "+_);switch(w[0]){case 1:i.push(_),a.push(c.yytext),n.push(c.yylloc),i.push(w[1]),_=null,f=c.yyleng,v=c.yytext,D=c.yylineno,G=c.yylloc;break;case 2:if(O=this.productions_[w[1]][1],j.$=a[a.length-O],j._$={first_line:n[n.length-(O||1)].first_line,last_line:n[n.length-1].last_line,first_column:n[n.length-(O||1)].first_column,last_column:n[n.length-1].last_column},it&&(j._$.range=[n[n.length-(O||1)].range[0],n[n.length-1].range[1]]),K=this.performAction.apply(j,[v,f,D,C.yy,w[1],a,n].concat(z)),typeof K<"u")return K;O&&(i=i.slice(0,-1*O*2),a=a.slice(0,-1*O),n=n.slice(0,-1*O)),i.push(this.productions_[w[1]][0]),a.push(j.$),n.push(j._$),Y=p[i[i.length-2]][i[i.length-1]],i.push(Y);break;case 3:return!0}}return!0}},N=(function(){var m={EOF:1,parseError:function(t,i){if(this.yy.parser)this.yy.parser.parseError(t,i);else throw new Error(t)},setInput:function(t,i){return this.yy=i||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t;var i=t.match(/(?:\r\n?|\n).*/g);return i?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var i=t.length,s=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-i),this.offset-=i;var a=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),s.length-1&&(this.yylineno-=s.length-1);var n=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:s?(s.length===a.length?this.yylloc.first_column:0)+a[a.length-s.length].length-s[0].length:this.yylloc.first_column-i},this.options.ranges&&(this.yylloc.range=[n[0],n[0]+this.yyleng-i]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),i=new Array(t.length+1).join("-");return t+this.upcomingInput()+`
`+i+"^"},test_match:function(t,i){var s,a,n;if(this.options.backtrack_lexer&&(n={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(n.yylloc.range=this.yylloc.range.slice(0))),a=t[0].match(/(?:\r\n?|\n).*/g),a&&(this.yylineno+=a.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:a?a[a.length-1].length-a[a.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],s=this.performAction.call(this,this.yy,this,i,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),s)return s;if(this._backtrack){for(var p in n)this[p]=n[p];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var t,i,s,a;this._more||(this.yytext="",this.match="");for(var n=this._currentRules(),p=0;p<n.length;p++)if(s=this._input.match(this.rules[n[p]]),s&&(!i||s[0].length>i[0].length)){if(i=s,a=p,this.options.backtrack_lexer){if(t=this.test_match(s,n[p]),t!==!1)return t;if(this._backtrack){i=!1;continue}else return!1}else if(!this.options.flex)break}return i?(t=this.test_match(i,n[a]),t!==!1?t:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
`+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return t||this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){var t=this.conditionStack.length-1;return t>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return t=this.conditionStack.length-1-Math.abs(t||0),t>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(t,i,s,a){switch(s){case 0:break;case 1:break;case 2:return 20;case 3:break;case 4:break;case 5:return this.begin("title"),12;case 6:return this.popState(),"title_value";case 7:return this.begin("acc_title"),14;case 8:return this.popState(),"acc_title_value";case 9:return this.begin("acc_descr"),16;case 10:return this.popState(),"acc_descr_value";case 11:this.begin("acc_descr_multiline");break;case 12:this.popState();break;case 13:return"acc_descr_multiline_value";case 14:this.begin("string");break;case 15:this.popState();break;case 16:return"txt";case 17:return 5;case 18:return 7;case 19:return"value";case 20:return 22}},rules:[/^(?:%%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:[\n\r]+)/i,/^(?:%%[^\n]*)/i,/^(?:[\s]+)/i,/^(?:title\b)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:["])/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:pie\b)/i,/^(?:showData\b)/i,/^(?::[\s]*[\d]+(?:\.[\d]+)?)/i,/^(?:$)/i],conditions:{acc_descr_multiline:{rules:[12,13],inclusive:!1},acc_descr:{rules:[10],inclusive:!1},acc_title:{rules:[8],inclusive:!1},title:{rules:[6],inclusive:!1},string:{rules:[15,16],inclusive:!1},INITIAL:{rules:[0,1,2,3,4,5,7,9,11,14,17,18,19,20],inclusive:!0}}};return m})();A.lexer=N;function E(){this.yy={}}return E.prototype=A,A.Parser=E,new E})();H.parser=H;const xt=H,wt=gt.pie,U={sections:{},showData:!1};let W=U.sections,X=U.showData;const $t=structuredClone(wt),St=()=>structuredClone($t),At=()=>{W=structuredClone(U.sections),X=U.showData,mt()},Et=(e,h)=>{e=ft(e,et()),W[e]===void 0&&(W[e]=h,tt.debug(`added new section: ${e}, with value: ${h}`))},Tt=()=>W,It=e=>(e.substring(0,1)===":"&&(e=e.substring(1).trim()),Number(e.trim())),Ct=e=>{X=e},Ot=()=>X,Pt={getConfig:St,clear:At,setDiagramTitle:ct,getDiagramTitle:ot,setAccTitle:lt,getAccTitle:at,setAccDescription:rt,getAccDescription:st,addSection:Et,getSections:Tt,cleanupValue:It,setShowData:Ct,getShowData:Ot},Nt=e=>`
  .pieCircle{
    stroke: ${e.pieStrokeColor};
    stroke-width : ${e.pieStrokeWidth};
    opacity : ${e.pieOpacity};
  }
  .pieOuterCircle{
    stroke: ${e.pieOuterStrokeColor};
    stroke-width: ${e.pieOuterStrokeWidth};
    fill: none;
  }
  .pieTitleText {
    text-anchor: middle;
    font-size: ${e.pieTitleTextSize};
    fill: ${e.pieTitleTextColor};
    font-family: ${e.fontFamily};
  }
  .slice {
    font-family: ${e.fontFamily};
    fill: ${e.pieSectionTextColor};
    font-size:${e.pieSectionTextSize};
    // fill: white;
  }
  .legend text {
    fill: ${e.pieLegendTextColor};
    font-family: ${e.fontFamily};
    font-size: ${e.pieLegendTextSize};
  }
`,Dt=Nt,Rt=e=>{const h=Object.entries(e).map(y=>({label:y[0],value:y[1]})).sort((y,$)=>$.value-y.value);return vt().value(y=>y.value)(h)},Ft=(e,h,y,$)=>{tt.debug(`rendering pie chart
`+e);const x=$.db,S=et(),u=ht(x.getConfig(),S.pie),r=40,l=18,g=4,b=450,I=b,T=ut(h),d=T.append("g"),k=x.getSections();d.attr("transform","translate("+I/2+","+b/2+")");const{themeVariables:o}=S;let[A]=pt(o.pieOuterStrokeWidth);A??(A=2);const N=u.textPosition,E=Math.min(I,b)/2-r,m=Z().innerRadius(0).outerRadius(E),t=Z().innerRadius(E*N).outerRadius(E*N);d.append("circle").attr("cx",0).attr("cy",0).attr("r",E+A/2).attr("class","pieOuterCircle");const i=Rt(k),s=[o.pie1,o.pie2,o.pie3,o.pie4,o.pie5,o.pie6,o.pie7,o.pie8,o.pie9,o.pie10,o.pie11,o.pie12],a=dt(s);d.selectAll("mySlices").data(i).enter().append("path").attr("d",m).attr("fill",f=>a(f.data.label)).attr("class","pieCircle");let n=0;Object.keys(k).forEach(f=>{n+=k[f]}),d.selectAll("mySlices").data(i).enter().append("text").text(f=>(f.data.value/n*100).toFixed(0)+"%").attr("transform",f=>"translate("+t.centroid(f)+")").style("text-anchor","middle").attr("class","slice"),d.append("text").text(x.getDiagramTitle()).attr("x",0).attr("y",-400/2).attr("class","pieTitleText");const p=d.selectAll(".legend").data(a.domain()).enter().append("g").attr("class","legend").attr("transform",(f,V)=>{const R=l+g,z=R*a.domain().length/2,c=12*l,C=V*R-z;return"translate("+c+","+C+")"});p.append("rect").attr("width",l).attr("height",l).style("fill",a).style("stroke",a),p.data(i).append("text").attr("x",l+g).attr("y",l-g).text(f=>{const{label:V,value:R}=f.data;return x.getShowData()?`${V} [${R}]`:V});const v=Math.max(...p.selectAll("text").nodes().map(f=>(f==null?void 0:f.getBoundingClientRect().width)??0)),D=I+r+l+g+v;T.attr("viewBox",`0 0 ${D} ${b}`),yt(T,b,D,u.useMaxWidth)},Mt={draw:Ft},le={parser:xt,db:Pt,renderer:Mt,styles:Dt};export{le as diagram};
