UNPKG

ranui

Version:

A framework-agnostic Web Components UI library built on native custom elements, with TypeScript types, light/dark theming, SSR and PWA support.

71 lines (59 loc) 18 kB
const l=require("./chunk-Y2CYZVJY-DPaYLFFP.cjs");require("./src-C9EhKhbk.cjs");const D=require("./chunk-WYO6CB5R-u4mJNOcO.cjs"),ct=require("./chunk-ICXQ74PX-BbT9JaEW.cjs"),ut=require("./chunk-VAUOI2AC-DfQf5L2_.cjs"),dt=require("./rough.esm-BfSi6CZE.cjs");var J=(function(){var t=l.__name(function(e,n,c,i){for(c=c||{},i=e.length;i--;c[e[i]]=n);return c},"o"),u=[1,4],s=[1,14],a=[1,12],r=[1,13],o=[6,7,8],g=[1,20],h=[1,18],p=[1,19],y=[6,7,11],w=[1,6,13,14],m=[1,23],$=[1,24],v=[1,6,7,11,13,14],P={trace:l.__name(function(){},"trace"),yy:{},symbols_:{error:2,start:3,ishikawa:4,spaceLines:5,SPACELINE:6,NL:7,ISHIKAWA:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,TEXT:14,$accept:0,$end:1},terminals_:{2:"error",6:"SPACELINE",7:"NL",8:"ISHIKAWA",11:"EOF",13:"SPACELIST",14:"TEXT"},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,2],[12,1],[12,1],[12,1]],performAction:l.__name(function(n,c,i,d,k,f,E){var b=f.length-1;switch(k){case 6:case 7:return d;case 15:d.addNode(f[b-1].length,f[b].trim());break;case 16:d.addNode(0,f[b].trim());break}},"anonymous"),table:[{3:1,4:2,5:3,6:[1,5],8:u},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:u},{6:s,7:[1,10],9:9,12:11,13:a,14:r},t(o,[2,3]),{1:[2,2]},t(o,[2,4]),t(o,[2,5]),{1:[2,6],6:s,12:15,13:a,14:r},{6:s,9:16,12:11,13:a,14:r},{6:g,7:h,10:17,11:p},t(y,[2,18],{14:[1,21]}),t(y,[2,16]),t(y,[2,17]),{6:g,7:h,10:22,11:p},{1:[2,7],6:s,12:15,13:a,14:r},t(w,[2,14],{7:m,11:$}),t(v,[2,8]),t(v,[2,9]),t(v,[2,10]),t(y,[2,15]),t(w,[2,13],{7:m,11:$}),t(v,[2,11]),t(v,[2,12])],defaultActions:{2:[2,1],6:[2,2]},parseError:l.__name(function(n,c){if(c.recoverable)this.trace(n);else{var i=new Error(n);throw i.hash=c,i}},"parseError"),parse:l.__name(function(n){var c=this,i=[0],d=[],k=[null],f=[],E=this.table,b="",x=0,B=0,S=0,T=2,M=1,V=f.slice.call(arguments,1),_=Object.create(this.lexer),I={yy:{}};for(var R in this.yy)Object.prototype.hasOwnProperty.call(this.yy,R)&&(I.yy[R]=this.yy[R]);_.setInput(n,I.yy),I.yy.lexer=_,I.yy.parser=this,typeof _.yylloc>"u"&&(_.yylloc={});var q=_.yylloc;f.push(q);var G=_.options&&_.options.ranges;typeof I.yy.parseError=="function"?this.parseError=I.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function ht(C){i.length=i.length-2*C,k.length=k.length-C,f.length=f.length-C}l.__name(ht,"popStack");function tt(){var C=d.pop()||_.lex()||M;return typeof C!="number"&&(C instanceof Array&&(d=C,C=d.pop()),C=c.symbols_[C]||C),C}l.__name(tt,"lex");for(var L,X,W,N,Z,F={},H,O,et,Y;;){if(W=i[i.length-1],this.defaultActions[W]?N=this.defaultActions[W]:((L===null||typeof L>"u")&&(L=tt()),N=E[W]&&E[W][L]),typeof N>"u"||!N.length||!N[0]){var K="";Y=[];for(H in E[W])this.terminals_[H]&&H>T&&Y.push("'"+this.terminals_[H]+"'");_.showPosition?K="Parse error on line "+(x+1)+`: `+_.showPosition()+` Expecting `+Y.join(", ")+", got '"+(this.terminals_[L]||L)+"'":K="Parse error on line "+(x+1)+": Unexpected "+(L==M?"end of input":"'"+(this.terminals_[L]||L)+"'"),this.parseError(K,{text:_.match,token:this.terminals_[L]||L,line:_.yylineno,loc:q,expected:Y})}if(N[0]instanceof Array&&N.length>1)throw new Error("Parse Error: multiple actions possible at state: "+W+", token: "+L);switch(N[0]){case 1:i.push(L),k.push(_.yytext),f.push(_.yylloc),i.push(N[1]),L=null,X?(L=X,X=null):(B=_.yyleng,b=_.yytext,x=_.yylineno,q=_.yylloc,S>0&&S--);break;case 2:if(O=this.productions_[N[1]][1],F.$=k[k.length-O],F._$={first_line:f[f.length-(O||1)].first_line,last_line:f[f.length-1].last_line,first_column:f[f.length-(O||1)].first_column,last_column:f[f.length-1].last_column},G&&(F._$.range=[f[f.length-(O||1)].range[0],f[f.length-1].range[1]]),Z=this.performAction.apply(F,[b,B,x,I.yy,N[1],k,f].concat(V)),typeof Z<"u")return Z;O&&(i=i.slice(0,-1*O*2),k=k.slice(0,-1*O),f=f.slice(0,-1*O)),i.push(this.productions_[N[1]][0]),k.push(F.$),f.push(F._$),et=E[i[i.length-2]][i[i.length-1]],i.push(et);break;case 3:return!0}}return!0},"parse")};P.lexer=(function(){return{EOF:1,parseError:l.__name(function(n,c){if(this.yy.parser)this.yy.parser.parseError(n,c);else throw new Error(n)},"parseError"),setInput:l.__name(function(e,n){return this.yy=n||this.yy||{},this._input=e,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},"setInput"),input:l.__name(function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},"input"),unput:l.__name(function(e){var n=e.length,c=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-n),this.offset-=n;var i=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),c.length-1&&(this.yylineno-=c.length-1);var d=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:c?(c.length===i.length?this.yylloc.first_column:0)+i[i.length-c.length].length-c[0].length:this.yylloc.first_column-n},this.options.ranges&&(this.yylloc.range=[d[0],d[0]+this.yyleng-n]),this.yyleng=this.yytext.length,this},"unput"),more:l.__name(function(){return this._more=!0,this},"more"),reject:l.__name(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},"reject"),less:l.__name(function(e){this.unput(this.match.slice(e))},"less"),pastInput:l.__name(function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:l.__name(function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:l.__name(function(){var e=this.pastInput(),n=new Array(e.length+1).join("-");return e+this.upcomingInput()+` `+n+"^"},"showPosition"),test_match:l.__name(function(e,n){var c,i,d;if(this.options.backtrack_lexer&&(d={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&&(d.yylloc.range=this.yylloc.range.slice(0))),i=e[0].match(/(?:\r\n?|\n).*/g),i&&(this.yylineno+=i.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:i?i[i.length-1].length-i[i.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,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(e[0].length),this.matched+=e[0],c=this.performAction.call(this,this.yy,this,n,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),c)return c;if(this._backtrack){for(var k in d)this[k]=d[k];return!1}return!1},"test_match"),next:l.__name(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var e,n,c,i;this._more||(this.yytext="",this.match="");for(var d=this._currentRules(),k=0;k<d.length;k++)if(c=this._input.match(this.rules[d[k]]),c&&(!n||c[0].length>n[0].length)){if(n=c,i=k,this.options.backtrack_lexer){if(e=this.test_match(c,d[k]),e!==!1)return e;if(this._backtrack){n=!1;continue}else return!1}else if(!this.options.flex)break}return n?(e=this.test_match(n,d[i]),e!==!1?e:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text. `+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:l.__name(function(){var n=this.next();return n||this.lex()},"lex"),begin:l.__name(function(n){this.conditionStack.push(n)},"begin"),popState:l.__name(function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:l.__name(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:l.__name(function(n){return n=this.conditionStack.length-1-Math.abs(n||0),n>=0?this.conditionStack[n]:"INITIAL"},"topState"),pushState:l.__name(function(n){this.begin(n)},"pushState"),stateStackSize:l.__name(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:l.__name(function(n,c,i,d){switch(i){case 0:return 6;case 1:return 8;case 2:return 8;case 3:return 6;case 4:return 7;case 5:return 13;case 6:return 14;case 7:return 11}},"anonymous"),rules:[/^(?:\s*%%.*)/i,/^(?:ishikawa-beta\b)/i,/^(?:ishikawa\b)/i,/^(?:[\s]+[\n])/i,/^(?:[\n]+)/i,/^(?:[\s]+)/i,/^(?:[^\n]+)/i,/^(?:$)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7],inclusive:!0}}}})();function A(){this.yy={}}return l.__name(A,"Parser"),A.prototype=P,P.Parser=A,new A})();J.parser=J;var yt=J,ft=class{constructor(){this.stack=[],this.clear=this.clear.bind(this),this.addNode=this.addNode.bind(this),this.getRoot=this.getRoot.bind(this)}static{l.__name(this,"IshikawaDB")}clear(){this.root=void 0,this.stack=[],this.baseLevel=void 0,D.clear()}getRoot(){return this.root}addNode(t,u){const s=D.common_default.sanitizeText(u,D.getConfig2());if(!this.root){this.root={text:s,children:[]},this.stack=[{level:0,node:this.root}],D.setDiagramTitle(s);return}this.baseLevel??=t;let a=t-this.baseLevel+1;for(a<=0&&(a=1);this.stack.length>1&&this.stack[this.stack.length-1].level>=a;)this.stack.pop();const r=this.stack[this.stack.length-1].node,o={text:s,children:[]};r.children.push(o),this.stack.push({level:a,node:o})}getAccTitle(){return D.getAccTitle()}setAccTitle(t){D.setAccTitle(t)}getAccDescription(){return D.getAccDescription()}setAccDescription(t){D.setAccDescription(t)}getDiagramTitle(){return D.getDiagramTitle()}setDiagramTitle(t){D.setDiagramTitle(t)}},pt=14,j=250,_t=30,gt=60,mt=5,lt=82*Math.PI/180,it=Math.cos(lt),nt=Math.sin(lt),st=l.__name((t,u,s)=>{const a=t.node().getBBox(),r=a.width+u*2,o=a.height+u*2;D.configureSvgSize(t,o,r,s),t.attr("viewBox",`${a.x-u} ${a.y-u} ${r} ${o}`)},"applyPaddedViewBox"),kt=l.__name((t,u,s,a)=>{const r=a.db.getRoot();if(!r)return;const o=D.getConfig2(),{look:g,handDrawnSeed:h,themeVariables:p}=o,y=ct.parseFontSize(o.fontSize)[0]??pt,w=g==="handDrawn",m=r.children??[],$=o.ishikawa?.diagramPadding??20,v=o.ishikawa?.useMaxWidth??!1,P=ut.selectSvgElement(u),A=P.append("g").attr("class","ishikawa"),e=w?dt.at.svg(P.node()):void 0,n=e?{roughSvg:e,seed:h??0,lineColor:p?.lineColor??"#333",fillColor:p?.mainBkg??"#fff"}:void 0,c=`ishikawa-arrow-${u}`;w||A.append("defs").append("marker").attr("id",c).attr("viewBox","0 0 10 10").attr("refX",0).attr("refY",5).attr("markerWidth",6).attr("markerHeight",6).attr("orient","auto").append("path").attr("d","M 10 0 L 0 5 L 10 10 Z").attr("class","ishikawa-arrow");let i=0,d=j;const k=w?void 0:z(A,i,d,i,d,"ishikawa-spine");if(wt(A,i,d,r.text,y,n),!m.length){w&&z(A,i,d,i,d,"ishikawa-spine",n),st(P,$,v);return}i-=20;const f=m.filter((_,I)=>I%2===0),E=m.filter((_,I)=>I%2===1),b=at(f),x=at(E),B=b.total+x.total;let S=j,T=j;if(B>0){const _=j*2,I=j*.3;S=Math.max(I,_*(b.total/B)),T=Math.max(I,_*(x.total/B))}const M=y*2;S=Math.max(S,b.max*M),T=Math.max(T,x.max*M),d=Math.max(S,j),k&&k.attr("y1",d).attr("y2",d),A.select(".ishikawa-head-group").attr("transform",`translate(0,${d})`);const V=Math.ceil(m.length/2);for(let _=0;_<V;_++){const I=A.append("g").attr("class","ishikawa-pair");for(const[R,q,G]of[[m[_*2],-1,S],[m[_*2+1],1,T]])R&&vt(I,R,i,d,q,G,y,n);i=I.selectAll("text").nodes().reduce((R,q)=>Math.min(R,q.getBBox().x),1/0)}if(w)z(A,i,d,0,d,"ishikawa-spine",n);else{k.attr("x1",i);const _=`url(#${c})`;A.selectAll("line.ishikawa-branch, line.ishikawa-sub-branch").attr("marker-start",_)}st(P,$,v)},"draw"),at=l.__name(t=>{const u=l.__name(s=>s.children.reduce((a,r)=>a+1+u(r),0),"countDescendants");return t.reduce((s,a)=>{const r=u(a);return s.total+=r,s.max=Math.max(s.max,r),s},{total:0,max:0})},"sideStats"),wt=l.__name((t,u,s,a,r,o)=>{const g=Math.max(6,Math.floor(110/(r*.6))),h=t.append("g").attr("class","ishikawa-head-group").attr("transform",`translate(${u},${s})`),p=U(h,ot(a,g),0,0,"ishikawa-head-label","start",r),y=p.node().getBBox(),w=Math.max(60,y.width+6),m=Math.max(40,y.height*2+40),$=`M 0 ${-m/2} L 0 ${m/2} Q ${w*2.4} 0 0 ${-m/2} Z`;if(o){const v=o.roughSvg.path($,{roughness:1.5,seed:o.seed,fill:o.fillColor,fillStyle:"hachure",fillWeight:2.5,hachureGap:5,stroke:o.lineColor,strokeWidth:2});h.insert(()=>v,":first-child").attr("class","ishikawa-head")}else h.insert("path",":first-child").attr("class","ishikawa-head").attr("d",$);p.attr("transform",`translate(${(w-y.width)/2-y.x+3},${-y.y-y.height/2})`)},"drawHead"),bt=l.__name((t,u)=>{const s=[],a=[],r=l.__name((o,g,h)=>{const p=u===-1?[...o].reverse():o;for(const y of p){const w=s.length,m=y.children??[];s.push({depth:h,text:ot(y.text,15),parentIndex:g,childCount:m.length}),h%2===0?(a.push(w),m.length&&r(m,w,h+1)):(m.length&&r(m,w,h+1),a.push(w))}},"walk");return r(t,-1,2),{entries:s,yOrder:a}},"flattenTree"),xt=l.__name((t,u,s,a,r,o,g)=>{const h=t.append("g").attr("class","ishikawa-label-group"),p=U(h,u,s,a+11*r,"ishikawa-label cause","middle",o).node().getBBox();if(g){const y=g.roughSvg.rectangle(p.x-20,p.y-2,p.width+40,p.height+4,{roughness:1.5,seed:g.seed,fill:g.fillColor,fillStyle:"hachure",fillWeight:2.5,hachureGap:5,stroke:g.lineColor,strokeWidth:2});h.insert(()=>y,":first-child").attr("class","ishikawa-label-box")}else h.insert("rect",":first-child").attr("class","ishikawa-label-box").attr("x",p.x-20).attr("y",p.y-2).attr("width",p.width+40).attr("height",p.height+4)},"drawCauseLabel"),Q=l.__name((t,u,s,a,r,o)=>{const g=Math.sqrt(a*a+r*r);if(g===0)return;const h=a/g,p=r/g,y=6,w=-p*y,m=h*y,$=u,v=s,P=`M ${$} ${v} L ${$-h*y*2+w} ${v-p*y*2+m} L ${$-h*y*2-w} ${v-p*y*2-m} Z`,A=o.roughSvg.path(P,{roughness:1,seed:o.seed,fill:o.lineColor,fillStyle:"solid",stroke:o.lineColor,strokeWidth:1});t.append(()=>A)},"drawArrowMarker"),vt=l.__name((t,u,s,a,r,o,g,h)=>{const p=u.children??[],y=o*(p.length?1:.2),w=-it*y,m=nt*y*r,$=s+w,v=a+m;if(z(t,s,a,$,v,"ishikawa-branch",h),h&&Q(t,s,a,s-$,a-v,h),xt(t,u.text,$,v,r,g,h),!p.length)return;const{entries:P,yOrder:A}=bt(p,r),e=P.length,n=new Array(e);for(const[f,E]of A.entries())n[E]=a+m*((f+1)/(e+1));const c=new Map;c.set(-1,{x0:s,y0:a,x1:$,y1:v,childCount:p.length,childrenDrawn:0});const i=-it,d=nt*r,k=r<0?"ishikawa-label up":"ishikawa-label down";for(const[f,E]of P.entries()){const b=n[f],x=c.get(E.parentIndex),B=t.append("g").attr("class","ishikawa-sub-group");let S=0,T=0,M=0;if(E.depth%2===0){const V=x.y1-x.y0;S=rt(x.x0,x.x1,V?(b-x.y0)/V:.5),T=b,M=S-(E.childCount>0?gt+E.childCount*mt:_t),z(B,S,b,M,b,"ishikawa-sub-branch",h),h&&Q(B,S,b,1,0,h),U(B,E.text,M,b,"ishikawa-label align","end",g)}else{const V=x.childrenDrawn++;S=rt(x.x0,x.x1,(x.childCount-V)/(x.childCount+1)),T=x.y0,M=S+i*((b-T)/d),z(B,S,T,M,b,"ishikawa-sub-branch",h),h&&Q(B,S,T,S-M,T-b,h),U(B,E.text,M,b,k,"end",g)}E.childCount>0&&c.set(f,{x0:S,y0:T,x1:M,y1:b,childCount:E.childCount,childrenDrawn:0})}},"drawBranch"),St=l.__name(t=>t.split(/<br\s*\/?>|\n/),"splitLines"),ot=l.__name((t,u)=>{if(t.length<=u)return t;const s=[];for(const a of t.split(/\s+/)){const r=s.length-1;r>=0&&s[r].length+1+a.length<=u?s[r]+=" "+a:s.push(a)}return s.join(` `)},"wrapText"),U=l.__name((t,u,s,a,r,o,g)=>{const h=St(u),p=g*1.05,y=t.append("text").attr("class",r).attr("text-anchor",o).attr("x",s).attr("y",a-(h.length-1)*p/2);for(const[w,m]of h.entries())y.append("tspan").attr("x",s).attr("dy",w===0?0:p).text(m);return y},"drawMultilineText"),rt=l.__name((t,u,s)=>t+(u-t)*s,"lerp"),z=l.__name((t,u,s,a,r,o,g)=>{if(g){const h=g.roughSvg.line(u,s,a,r,{roughness:1.5,seed:g.seed,stroke:g.lineColor,strokeWidth:2});t.append(()=>h).attr("class",o);return}return t.append("line").attr("class",o).attr("x1",u).attr("y1",s).attr("x2",a).attr("y2",r)},"drawLine"),Et={parser:yt,get db(){return new ft},renderer:{draw:kt},styles:l.__name(t=>` .ishikawa .ishikawa-spine, .ishikawa .ishikawa-branch, .ishikawa .ishikawa-sub-branch { stroke: ${t.lineColor}; stroke-width: 2; fill: none; } .ishikawa .ishikawa-sub-branch { stroke-width: 1; } .ishikawa .ishikawa-arrow { fill: ${t.lineColor}; } .ishikawa .ishikawa-head { fill: ${t.mainBkg}; stroke: ${t.lineColor}; stroke-width: 2; } .ishikawa .ishikawa-label-box { fill: ${t.mainBkg}; stroke: ${t.lineColor}; stroke-width: 2; } .ishikawa text { font-family: ${t.fontFamily}; font-size: ${t.fontSize}; fill: ${t.textColor}; } .ishikawa .ishikawa-head-label { font-weight: 600; text-anchor: middle; dominant-baseline: middle; font-size: 14px; } .ishikawa .ishikawa-label { text-anchor: end; } .ishikawa .ishikawa-label.cause { text-anchor: middle; dominant-baseline: middle; } .ishikawa .ishikawa-label.align { text-anchor: end; dominant-baseline: middle; } .ishikawa .ishikawa-label.up { dominant-baseline: baseline; } .ishikawa .ishikawa-label.down { dominant-baseline: hanging; } `,"getStyles")};exports.diagram=Et;