@konoui/mjimage 0.0.39 → 0.0.41
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/dist/index.cjs +1 -1
- package/dist/index.d.cts +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +133 -133
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
`),t+=e[i].textContent}return t}if(this.clear().build(!0),typeof t=="function")t.call(this,this);else{t=(t+"").split(`
|
|
5
5
|
`);for(let e=0,n=t.length;e<n;e++)this.newLine(t[e])}return this.build(!1).rebuild()}}E(F,Ai);T({Container:{text:R(function(s=""){return this.put(new F).text(s)}),plain:R(function(s=""){return this.put(new F).plain(s)})}});N(F,"Text");class rn extends et{constructor(t,e=t){super(H("tspan",t),e),this._build=!1}dx(t){return this.attr("dx",t)}dy(t){return this.attr("dy",t)}newLine(){this.dom.newLined=!0;const t=this.parent();if(!(t instanceof F))return this;const e=t.index(this),n=I.window.getComputedStyle(this.node).getPropertyValue("font-size"),i=t.dom.leading*new k(n);return this.dy(e?i:0).attr("x",t.x())}text(t){return t==null?this.node.textContent+(this.dom.newLined?`
|
|
6
6
|
`:""):(typeof t=="function"?(this.clear().build(!0),t.call(this,this),this.build(!1)):this.plain(t),this)}}E(rn,Ai);T({Tspan:{tspan:R(function(s=""){const t=new rn;return this._build||this.clear(),this.put(t).text(s)})},Text:{newLine:function(s=""){return this.tspan(s).newLine()}}});N(rn,"Tspan");class ls extends et{constructor(t,e=t){super(H("circle",t),e)}radius(t){return this.attr("r",t)}rx(t){return this.attr("r",t)}ry(t){return this.rx(t)}size(t){return this.radius(new k(t).divide(2))}}E(ls,{x:hi,y:li,cx:ui,cy:fi,width:di,height:pi});T({Container:{circle:R(function(s=0){return this.put(new ls).size(s).move(0,0)})}});N(ls,"Circle");class Nn extends J{constructor(t,e=t){super(H("clipPath",t),e)}remove(){return this.targets().forEach(function(t){t.unclip()}),super.remove()}targets(){return ce("svg [clip-path*="+this.id()+"]")}}T({Container:{clip:R(function(){return this.defs().put(new Nn)})},Element:{clipper(){return this.reference("clip-path")},clipWith(s){const t=s instanceof Nn?s:this.parent().clip().add(s);return this.attr("clip-path","url(#"+t.id()+")")},unclip(){return this.attr("clip-path",null)}}});N(Nn,"ClipPath");class xi extends dt{constructor(t,e=t){super(H("foreignObject",t),e)}}T({Container:{foreignObject:R(function(s,t){return this.put(new xi).size(s,t)})}});N(xi,"ForeignObject");function Sa(s,t){return this.children().forEach(e=>{let n;try{n=e.node instanceof xr().SVGSVGElement?new L(e.attr(["x","y","width","height"])):e.bbox()}catch{return}const i=new A(e),r=i.translate(s,t).transform(i.inverse()),o=new B(n.x,n.y).transform(r);e.move(o.x,o.y)}),this}function va(s){return this.dmove(s,0)}function Aa(s){return this.dmove(0,s)}function xa(s,t=this.bbox()){return s==null?t.height:this.size(t.width,s,t)}function ka(s=0,t=0,e=this.bbox()){const n=s-e.x,i=t-e.y;return this.dmove(n,i)}function Ta(s,t,e=this.bbox()){const n=ae(this,s,t,e),i=n.width/e.width,r=n.height/e.height;return this.children().forEach(o=>{const a=new B(e).transform(new A(o).inverse());o.scale(i,r,a.x,a.y)}),this}function Oa(s,t=this.bbox()){return s==null?t.width:this.size(s,t.height,t)}function Ea(s,t=this.bbox()){return s==null?t.x:this.move(s,t.y,t)}function Ia(s,t=this.bbox()){return s==null?t.y:this.move(t.x,s,t)}const ki=Object.freeze(Object.defineProperty({__proto__:null,dmove:Sa,dx:va,dy:Aa,height:xa,move:ka,size:Ta,width:Oa,x:Ea,y:Ia},Symbol.toStringTag,{value:"Module"}));class z extends J{constructor(t,e=t){super(H("g",t),e)}}E(z,ki);T({Container:{group:R(function(){return this.put(new z)})}});N(z,"G");class Ze extends J{constructor(t,e=t){super(H("a",t),e)}target(t){return this.attr("target",t)}to(t){return this.attr("href",t,Oe)}}E(Ze,ki);T({Container:{link:R(function(s){return this.put(new Ze).to(s)})},Element:{unlink(){const s=this.linker();if(!s)return this;const t=s.parent();if(!t)return this.remove();const e=t.index(s);return t.add(this,e),s.remove(),this},linkTo(s){let t=this.linker();return t||(t=new Ze,this.wrap(t)),typeof s=="function"?s.call(t,t):t.to(s),this},linker(){const s=this.parent();return s&&s.node.nodeName.toLowerCase()==="a"?s:null}}});N(Ze,"A");class Mn extends J{constructor(t,e=t){super(H("mask",t),e)}remove(){return this.targets().forEach(function(t){t.unmask()}),super.remove()}targets(){return ce("svg [mask*="+this.id()+"]")}}T({Container:{mask:R(function(){return this.defs().put(new Mn)})},Element:{masker(){return this.reference("mask")},maskWith(s){const t=s instanceof Mn?s:this.parent().mask().add(s);return this.attr("mask","url(#"+t.id()+")")},unmask(){return this.attr("mask",null)}}});N(Mn,"Mask");class Ti extends dt{constructor(t,e=t){super(H("stop",t),e)}update(t){return(typeof t=="number"||t instanceof k)&&(t={offset:arguments[0],color:arguments[1],opacity:arguments[2]}),t.opacity!=null&&this.attr("stop-opacity",t.opacity),t.color!=null&&this.attr("stop-color",t.color),t.offset!=null&&this.attr("offset",new k(t.offset)),this}}T({Gradient:{stop:function(s,t,e){return this.put(new Ti).update(s,t,e)}}});N(Ti,"Stop");function Na(s,t){if(!s)return"";if(!t)return s;let e=s+"{";for(const n in t)e+=Sr(n)+":"+t[n]+";";return e+="}",e}class Dn extends dt{constructor(t,e=t){super(H("style",t),e)}addText(t=""){return this.node.textContent+=t,this}font(t,e,n={}){return this.rule("@font-face",{fontFamily:t,src:e,...n})}rule(t,e){return this.addText(Na(t,e))}}T("Dom",{style(s,t){return this.put(new Dn).rule(s,t)},fontface(s,t,e){return this.put(new Dn).font(s,t,e)}});N(Dn,"Style");class us extends F{constructor(t,e=t){super(H("textPath",t),e)}array(){const t=this.track();return t?t.array():null}plot(t){const e=this.track();let n=null;return e&&(n=e.plot(t)),t==null?n:this}track(){return this.reference("href")}}T({Container:{textPath:R(function(s,t){return s instanceof F||(s=this.text(s)),s.path(t)})},Text:{path:R(function(s,t=!0){const e=new us;s instanceof he||(s=this.defs().path(s)),e.attr("href","#"+s,Oe);let n;if(t)for(;n=this.node.firstChild;)e.node.appendChild(n);return this.put(e)}),textPath(){return this.findOne("textPath")}},Path:{text:R(function(s){return s instanceof F||(s=new F().addTo(this.parent()).text(s)),s.path(this)}),targets(){return ce("svg textPath").filter(s=>(s.attr("href")||"").includes(this.id()))}}});us.prototype.MorphArray=Wt;N(us,"TextPath");class on extends et{constructor(t,e=t){super(H("use",t),e)}use(t,e){return this.attr("href",(e||"")+"#"+t,Oe)}}T({Container:{use:R(function(s,t){return this.put(new on).use(s,t)})}});N(on,"Use");E([hs,sn,Ne,be,Fe],X("viewbox"));E([Se,Ce,De,he],X("marker"));E(F,X("Text"));E(he,X("Path"));E(ss,X("Defs"));E([F,rn],X("Tspan"));E([Re,nn,Ie,tt],X("radius"));E(Ee,X("EventTarget"));E(xt,X("Dom"));E(dt,X("Element"));E(et,X("Shape"));E([J,mi],X("Container"));E(Ie,X("Gradient"));E(tt,X("Runner"));$t.extend(_r());Jo([k,D,L,A,Qt,kt,Wt,B]);Vo();class te{constructor(t={}){S(this,"tileWidth");S(this,"tileHeight");S(this,"imageHostPath");S(this,"imageHostUrl");S(this,"imageExt");S(this,"scale");S(this,"svgSprite");this.scale=t.scale??1,this.imageHostPath=t.imageHostPath??"",this.imageHostUrl=t.imageHostUrl??"",this.imageExt=t.imageExt??"svg",this.tileWidth=vt.WIDTH*this.scale,this.tileHeight=vt.HEIGHT*this.scale,this.svgSprite=t.svgSprite??!1}getDiffTileHeightWidth(t){const e=t.imageSize(this.scale);return(e.baseHeight-e.baseWidth)/2}image(t){let e=new Ne().load(this.buildURL(t));return this.svgSprite&&(e=new on().use(te.buildID(t))),t instanceof g&&t.has(b.COLOR_GRAYSCALE)&&e.css({filter:"contrast(65%)"}),e}createImage(t,e,n){const i=t.imageSize(this.scale);return this.image(t).dx(e).dy(n).size(i.baseWidth,i.baseHeight)}createTextImage(t,e,n,i){const r=this.createImage(t,e,n),o=t.imageSize(this.scale),a=o.baseHeight*.2,c=o.baseWidth,h=o.baseHeight,l=new F().text(i);l.size(o.baseWidth,o.baseHeight).font({family:qn,size:a}).dx(c).dy(h);const u=new z;return u.add(r).add(l).translate(e,n),u}createRotate90Image(t,e,n,i=!1){const r=this.createImage(t,0,0),o=t.imageSize(this.scale),a=o.baseWidth/2,c=o.baseHeight/2,h=e+this.getDiffTileHeightWidth(t),l=i?n-this.getDiffTileHeightWidth(t):n,u=new z;return u.add(r).translate(h,l).rotate(90,a,c),u}createStick(t){return this.image(t)}static buildID(t){if(t==100||t==1e3)return t==100?"stick100":"stick1000";const e=t.t==d.BACK?0:t.n;return`${t.t}${e}`}buildURL(t){const e=`${te.buildID(t)}.${this.imageExt}`;return this.imageHostUrl!=""?`${this.imageHostUrl}${e}`:`${this.imageHostPath}${e}`}}class fs extends te{constructor(){super(...arguments);S(this,"blockMargin",vt.WIDTH*vt.BLOCK_MARGIN_SCALE*this.scale)}createBlockHandDiscard(e){const n=new z;let i=0;for(let r of e.tiles){const o=r.imageSize(this.scale),a=r.has(b.HORIZONTAL)?this.createRotate90Image.bind(this):this.createImage.bind(this),c=r.has(b.HORIZONTAL)?this.getDiffTileHeightWidth(r):0,h=a(r,i,c);n.add(h),i+=o.width}return n}createBlockPonChiKan(e){const n=e.tiles.findIndex(o=>o.has(b.HORIZONTAL));let i=0;const r=new z;if(e.type==_.SHO_KAN){let o=n;for(let a=0;a<e.tiles.length;a++)e.tiles[a].has(b.HORIZONTAL)&&(o=a);for(let a=0;a<e.tiles.length;a++){const c=e.tiles[a].imageSize(this.scale);if(a==o)continue;if(a==n){const u=e.tiles[n],f=e.tiles[o],m=u.imageSize(this.scale),p=this.createRotate90Image(u,0,0,!0),y=this.createRotate90Image(f,0,m.height,!0);r.add(new z().translate(i,0).add(p).add(y)),i+=m.width;continue}const h=c.width*2-c.height,l=this.createImage(e.tiles[a],i,h);i+=c.width,r.add(l)}return r}if(e.type==_.CHI){const o=this.createRotate90Image(e.tiles[n],i,this.getDiffTileHeightWidth(e.tiles[n]));i+=e.tiles[n].imageSize(this.scale).width,r.add(o);for(let a=0;a<e.tiles.length;a++){if(a==n)continue;const c=e.tiles[a].imageSize(this.scale),h=this.createImage(e.tiles[a],i,0);i+=c.width,r.add(h)}return r}for(let o=0;o<e.tiles.length;o++){const a=o==n?this.createRotate90Image.bind(this):this.createImage.bind(this),c=o==n?this.getDiffTileHeightWidth(e.tiles[o]):0,h=e.tiles[o].imageSize(this.scale),l=a(e.tiles[o],i,c);i+=h.width,r.add(l)}return r}}const Ma=s=>{const t=s.scale;return{[_.CHI]:function(n){const i=n.imageSize(t),r=s.createBlockPonChiKan(n);return{...i,e:r}},[_.PON]:function(n){const i=n.imageSize(t),r=s.createBlockPonChiKan(n);return{...i,e:r}},[_.DAI_KAN]:function(n){const i=n.imageSize(t),r=s.createBlockPonChiKan(n);return{...i,e:r}},[_.SHO_KAN]:function(n){const i=n.imageSize(t),r=s.createBlockPonChiKan(n);return{...i,e:r}},[_.AN_KAN]:function(n){assert(n instanceof U,`block type is not ankan: ${n.type}`);const i=n.imageSize(t),r=n.tilesWithBack.filter(a=>a.t!==d.BACK);assert(r!=null&&r.length==2,`back tile must be two but ${n}`);const o=s.createBlockHandDiscard(new U([r[0],r[1],r[0],r[1]]));return{...i,e:o}},[_.IMAGE_DORA]:function(n){const i=n.imageSize(t),r=new z,o=s.createTextImage(n.tiles[0],0,0,"(ドラ)");return r.add(o),{...i,e:r}},[_.TSUMO]:function(n){const i=n.imageSize(t),r=new z,o=s.createTextImage(n.tiles[0],0,0,"(ツモ)");return r.add(o),{...i,e:r}},[_.HAND]:function(n){const i=n.imageSize(t),r=s.createBlockHandDiscard(n);return{...i,e:r}},[_.IMAGE_DISCARD]:function(n){const i=n.imageSize(t),r=s.createBlockHandDiscard(n);return{...i,e:r}},[_.THREE]:function(n){throw new Error("three is unsupported")},[_.RUN]:function(n){throw new Error("run is unsupported")},[_.UNKNOWN]:function(n){if(n.tiles.some(o=>o.has(b.TSUMO)||o.has(b.DORA)))throw new Error("found an unknown block with operator tiles");const i=n.imageSize(t),r=s.createBlockHandDiscard(n);return{...i,e:r}},[_.PAIR]:function(n){throw new Error("pair is unsupported")},[_.ISOLATED]:function(n){throw new Error("isolated is unsupported")}}},Xt=(s,t)=>{const{maxHeight:e,sumWidth:n}=t.reduce((l,u)=>{const f=u.imageSize(s.scale);return{maxHeight:f.height>l.maxHeight?f.height:l.maxHeight,sumWidth:l.sumWidth+f.width}},{maxHeight:0,sumWidth:0}),i=e,r=n+(t.length-1)*s.blockMargin,o=Ma(s),a=[];for(let l of t){const u=o[l.type],f=u(l);a.push(f)}const c=new z;let h=0;for(let l of a){const u=i-l.height,f=new z().translate(h,u);f.add(l.e),c.add(f),h+=l.width+s.blockMargin}return{e:c,width:r,height:i}},Da=(s,t,e={},n={responsive:!1})=>{const i=new fs(e),r=Xt(i,t);n.responsive||s.size(r.width,r.height),s.viewbox(0,0,r.width,r.height),s.add(r.e)},Oi=()=>{const s=[0,1,2,3,4,5,6,7,8,9],t=[];for(let e of Object.values(d)){if(e==d.BACK){t.push(te.buildID(new g(e,0)));continue}t.push(...s.map(n=>te.buildID(new g(e,n))).flat())}return t},Ca=s=>{const t=Oi(),e=[];return s.each((n,i)=>{const r=i[n];if(r instanceof on){const a=r.attr("href").substring(1);t.includes(a)&&e.push(a)}}),e},Ra=s=>{const t=Oi(),e=Ca(s);s.each((n,i)=>{const r=i[n];r instanceof sn&&(t.includes(r.id())&&e.includes(r.id())||r.remove())},!0)},Ha=s=>{const e=[];for(let n=0;n<s.length;n+=6){const i=s.slice(n,n+6);e.push(i)}return e},ht=(s,t,e,n,i=0,r=0)=>{const o=new z().add(s);if(n==90){const a=i,c=r-e;return o.rotate(n,0,e).translate(a,c),o}if(n==180){const a=i+t,c=r-e;return o.rotate(n,0,e).translate(a,c),o}if(n==270){const a=i+e,c=r+(t-e);return o.rotate(n,0,e).translate(a,c),o}return o},ze=(s,t)=>{const e=new z,n=Ha(s);for(let i=0;i<n.length;i++){let r=n[i],o=i*t.tileHeight;const a=t.createBlockHandDiscard(new Xn(r,_.IMAGE_DISCARD)).translate(0,o);e.add(a)}return{e,width:t.tileWidth*5+t.tileHeight*1,height:t.tileHeight*n.length}},$a=(s,t,e)=>{const n=t.font,i=t.textWidth,r=t.textHeight,o=new z,a=e.sticks.dead,c=e.sticks.reach,h=125*s.scale,l=27.5*s.scale;let u=i*3,f=r;const m=(h+s.tileWidth+i-u)/2,p=new F().plain(e.round).font(n).move(m,0);o.add(p),f+=25*s.scale;const y=s.tileHeight,w=new z().size(h,y).translate(0,f),x={family:n.family,size:n.size*.7},O=s.createStick(1e3).size(h,l).move(0,0),$=new F().plain(c.toString()).font(x).attr({x:h,y:l});w.add(O),w.add($);const nt=s.createStick(100).size(h,l).move(0,l+l),K=new F().plain(a.toString()).font(x).attr({x:h,y:l*3});w.add(nt),w.add(K);const rt=s.createImage(e.doras[0],0,0).move(h+i,0);return w.add(rt),o.add(p),o.add(w),{e:o,width:h+s.tileWidth+i,height:f+s.tileHeight}},Wa=(s,t,e=0)=>{const n=Xt(s,t.front),i=Xt(s,t.right),r=Xt(s,t.opposite),o=Xt(s,t.left),a=[n.width,i.width,r.width,o.width].reduce((y,w)=>Math.max(y,w)),c=Math.max(e+s.tileHeight*2+s.blockMargin*2,a+s.tileWidth*2+s.blockMargin),h=c,l=new z().size(c,h),u=ht(n.e,n.width,n.height,0).translate((c-n.width)/2,h-n.height),f=ht(i.e,i.width,i.height,270).translate(c-i.height,(c-i.width)/2),m=ht(r.e,r.width,r.height,180).translate((c-r.width)/2,0),p=ht(o.e,o.width,o.height,90).translate(0,(c-o.width)/2);return l.add(u),l.add(f),l.add(m),l.add(p),{e:l,width:c,height:h}},Ba=s=>{const t=Object.values(tn),e=t.indexOf(s);return[...t.slice(e),...t.slice(0,e)]},za=(s,t,e)=>{const n=s.tileWidth*5+s.tileHeight*1,i=new z,r=new Re().size(n,n).move(0,0).fill("none").stroke("#000000");i.add(r);const o=t.font,a=t.textWidth,c=t.textHeight,h=t.numWidth,l=$a(s,t,e);l.e.translate(n/2-l.width/2,n/2-l.height/2);const u=(cn,Ts,ar)=>{const cr=`${cn} ${Ts}`,hr=new F().plain(cr).font(o).attr(ar);return{e:new z().add(hr),width:a+h*Ts.toString().length,height:c}},[f,m,p,y]=Ba(e.frontPlace),w=e.scores,O=u(f,w.front,{x:n/2,y:n,"dominant-baseline":"text-after-edge","text-anchor":"middle"}).e;let $=u(m,w.right,{"dominant-baseline":"text-after-edge","text-anchor":"middle"});const nt=ht($.e,$.width,$.height,270).translate(n,n/2-$.width);let K=u(p,w.opposite,{"text-anchor":"middle","dominant-baseline":"text-after-edge"});const rt=ht(K.e,K.width,K.height,180).translate(n/2-K.width,-K.height);let pt=u(y,w.left,{"dominant-baseline":"ideographic","text-anchor":"middle"});const Kt=ht(pt.e,pt.width,pt.height,90).translate(-pt.height,n/2);return i.add(l.e),i.add(O),i.add(nt),i.add(rt),i.add(Kt),{e:i,width:n,height:n}},Pa=(s,t)=>{const e=ze(t.front,s),n=ze(t.right,s),i=ze(t.opposite,s),r=ze(t.left,s),o=[e.height,n.height,i.height,r.height].reduce((O,$)=>Math.max(O,$)),a=s.tileWidth*5+s.tileHeight*1,c=o,h=a+o*2+s.blockMargin,l=h,u=new z().size(h,l),f=h/2-a/2,m=l/2-a/2,p=ht(e.e,a,c,0).translate(f,l-c),y=ht(n.e,a,c,270).translate(h-c,m),w=ht(i.e,a,c,180).translate(f,0),x=ht(r.e,a,c,90).translate(0,m);return u.add(p),u.add(y),u.add(w),u.add(x),{e:u,width:h,height:l}},Ei=(s,t,e,n,i)=>{const r=new z,o=Pa(s,n),a=Wa(s,e,o.height),c=za(s,t,i);return o.e.translate((a.width-o.width)/2,(a.height-o.height)/2),c.e.translate((a.width-c.width)/2,(a.height-c.height)/2),r.add(a.e),r.add(o.e),r.add(c.e),{e:r,width:a.width,height:a.height}},ja=(s,t,e={},n,i={responsive:!1})=>{const r=new fs(e),o=n,{discards:a,hands:c,scoreBoard:h}=Ii(t),l=Ei(r,o,c,a,h);i.responsive||s.size(l.width,l.height),s.viewbox(0,0,l.width,l.height),s.add(l.e)};var mt;function La(s){return{lang:(s==null?void 0:s.lang)??(mt==null?void 0:mt.lang),message:s==null?void 0:s.message,abortEarly:(s==null?void 0:s.abortEarly)??(mt==null?void 0:mt.abortEarly),abortPipeEarly:(s==null?void 0:s.abortPipeEarly)??(mt==null?void 0:mt.abortPipeEarly)}}var mn;function Ka(s){return mn==null?void 0:mn.get(s)}var gn;function Ua(s){return gn==null?void 0:gn.get(s)}var yn;function Fa(s,t){var e;return(e=yn==null?void 0:yn.get(s))==null?void 0:e.get(t)}function ee(s){var e,n;const t=typeof s;return t==="string"?`"${s}"`:t==="number"||t==="bigint"||t==="boolean"?`${s}`:t==="object"||t==="function"?(s&&((n=(e=Object.getPrototypeOf(s))==null?void 0:e.constructor)==null?void 0:n.name))??"null":t}function Bt(s,t,e,n,i){const r=i&&"input"in i?i.input:e.value,o=(i==null?void 0:i.expected)??s.expects??null,a=(i==null?void 0:i.received)??ee(r),c={kind:s.kind,type:s.type,input:r,expected:o,received:a,message:`Invalid ${t}: ${o?`Expected ${o} but r`:"R"}eceived ${a}`,requirement:s.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},h=s.kind==="schema",l=(i==null?void 0:i.message)??s.message??Fa(s.reference,c.lang)??(h?Ua(c.lang):null)??n.message??Ka(c.lang);l&&(c.message=typeof l=="function"?l(c):l),h&&(e.typed=!1),e.issues?e.issues.push(c):e.issues=[c]}function qa(s,t){const e=[...new Set(s)];return e.length>1?`(${e.join(` ${t} `)})`:e[0]??"never"}function Cn(s,t){return{kind:"validation",type:"max_value",reference:Cn,async:!1,expects:`<=${s instanceof Date?s.toJSON():ee(s)}`,requirement:s,message:t,_run(e,n){return e.typed&&e.value>this.requirement&&Bt(this,"value",e,n,{received:e.value instanceof Date?e.value.toJSON():ee(e.value)}),e}}}function Rn(s,t){return{kind:"validation",type:"min_value",reference:Rn,async:!1,expects:`>=${s instanceof Date?s.toJSON():ee(s)}`,requirement:s,message:t,_run(e,n){return e.typed&&e.value<this.requirement&&Bt(this,"value",e,n,{received:e.value instanceof Date?e.value.toJSON():ee(e.value)}),e}}}function Ga(s,t,e){return typeof s.default=="function"?s.default(t,e):s.default}function Ye(s){return{kind:"schema",type:"number",reference:Ye,expects:"number",async:!1,message:s,_run(t,e){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:Bt(this,"type",t,e),t}}}function it(s,...t){const e={kind:"schema",type:"optional",reference:it,expects:`(${s.expects} | undefined)`,async:!1,wrapped:s,_run(n,i){return n.value===void 0&&("default"in this&&(n.value=Ga(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(e.default=t[0]),e}function Hn(s,t){return{kind:"schema",type:"picklist",reference:Hn,expects:qa(s.map(ee),"|"),async:!1,options:s,message:t,_run(e,n){return this.options.includes(e.value)?e.typed=!0:Bt(this,"type",e,n),e}}}function ne(s,t){return{kind:"schema",type:"strict_object",reference:ne,expects:"Object",async:!1,entries:s,message:t,_run(e,n){var r;const i=e.value;if(i&&typeof i=="object"){e.typed=!0,e.value={};for(const o in this.entries){const a=i[o],c=this.entries[o]._run({typed:!1,value:a},n);if(c.issues){const h={type:"object",origin:"value",input:i,key:o,value:a};for(const l of c.issues)l.path?l.path.unshift(h):l.path=[h],(r=e.issues)==null||r.push(l);if(e.issues||(e.issues=c.issues),n.abortEarly){e.typed=!1;break}}c.typed||(e.typed=!1),(c.value!==void 0||o in i)&&(e.value[o]=c.value)}if(!e.issues||!n.abortEarly){for(const o in i)if(!(o in this.entries)){const a=i[o];Bt(this,"type",e,n,{input:a,expected:"never",path:[{type:"object",origin:"value",input:i,key:o,value:a}]});break}}}else Bt(this,"type",e,n);return e}}}function Xe(s){return{kind:"schema",type:"string",reference:Xe,expects:"string",async:!1,message:s,_run(t,e){return typeof t.value=="string"?t.typed=!0:Bt(this,"type",t,e),t}}}function Hs(...s){return{...s[0],pipe:s,_run(t,e){for(const n of s)if(n.kind!=="metadata"){if(t.issues&&(n.kind==="schema"||n.kind==="transformation")){t.typed=!1;break}(!t.issues||!e.abortEarly&&!e.abortPipeEarly)&&(t=n._run(t,e))}return t}}}function Za(s,t,e){const n=s._run({typed:!1,value:t},La(e));return{typed:n.typed,success:!n.issues,output:n.value,issues:n.issues}}const Pe=it(ne({discard:it(Xe(),""),hand:it(Xe(),""),score:it(Ye(),25e3)}),{discard:"",hand:"",score:25e3}),Ya=ne({[v.E]:Pe,[v.S]:Pe,[v.W]:Pe,[v.N]:Pe}),Ot={round:P.E1,sticks:{reach:0,dead:0},doras:v.S,front:v.E},Xa=it(ne({round:it(Hn(Object.keys(Gn)),Ot.round),sticks:it(ne({reach:it(Hs(Ye(),Rn(0,""),Cn(9,"")),Ot.sticks.reach),dead:it(Hs(Ye(),Rn(0,""),Cn(9,"")),Ot.sticks.dead)}),Ot.sticks),doras:it(Xe(),Ot.doras),front:it(Hn(Object.keys(tn)),Ot.front)}),Ot),Ja=ne({...Ya.entries,board:Xa}),Ii=s=>{const t=Ni(s);return Mi(t)},Ni=s=>{const t=Va(s),e=Za(Ja,t);if(!e.success)throw e.issues;return e.output},Va=s=>{const t="table",e="board",n=s.split(`
|
|
7
|
-
`).map(a=>a.trim()).filter(a=>a!="");if(n.length==0)throw new Error("empty input");const i=n.shift();if(!i.startsWith(t))throw new Error(`input does not start with table: ${i}`);const r={};let o=[v.E,v.S,v.W,v.N,e];for(;;){const a=n.shift();if(a==null)break;const c=o.find(h=>a.startsWith(h));if(c==null)throw new Error(`encountered unexpected line ${a}`);if(o=o.filter(h=>!a.startsWith(h)),c==e){const[h,l]=tc([...n]);r.board=h;for(let u=0;u<l;u++)n.shift()}else{const[h,l]=Qa([...n]);r[c]=h;for(let u=0;u<l;u++)n.shift()}}return r},lt=(s,t)=>s.replace(t,"").replace(":","").trim(),Qa=s=>{const t="hand",e="discard",n="score";let i={},r=0;for(;r<s.length;r++){const o=s[r];if(o.startsWith(t))i.hand=lt(o,t);else if(o.startsWith(e))i.discard=lt(o,e);else if(o.startsWith(n))i.score=Number(lt(o,n));else break}return[i,r]},tc=s=>{const t="doras",e="round",n="front",i="sticks",r="reach",o="dead";let a={},c=0;for(;c<s.length;c++){const h=s[c];if(h.startsWith(t))a.doras=lt(h,t);else if(h.startsWith(e))a.round=lt(h,e);else if(h.startsWith(n))a.front=lt(h,n);else if(h.startsWith(i)){a.sticks={};const l=s[c+1]??"",u=s[c+2]??"";l.startsWith(r)&&(a.sticks.reach=Number(lt(l,r))),l.startsWith(o)&&(a.sticks.dead=Number(lt(l,o))),u.startsWith(r)&&(a.sticks.reach=Number(lt(u,r))),u.startsWith(o)&&(a.sticks.dead=Number(lt(u,o))),a.sticks.dead!=null&&c++,a.sticks.reach!=null&&c++}else break}return[a,c]},Mi=s=>{const t=s.board.front,e=ec(t),n=a=>s[a].discard.replace(/\r?\n/g,""),i={front:new Q(n(e.front)).tiles(),right:new Q(n(e.right)).tiles(),opposite:new Q(n(e.opposite)).tiles(),left:new Q(n(e.left)).tiles()},r={front:new Q(s[e.front].hand).parse(),right:new Q(s[e.right].hand).parse(),opposite:new Q(s[e.opposite].hand).parse(),left:new Q(s[e.left].hand).parse()},o={round:Gn[s.board.round],frontPlace:tn[t],sticks:s.board.sticks,doras:new Q(s.board.doras).tiles(),scores:{front:s[e.front].score,right:s[e.right].score,opposite:s[e.opposite].score,left:s[e.left].score}};return{discards:i,hands:r,scoreBoard:o}},ec=s=>({front:s,right:At(s),opposite:At(At(s)),left:Xs(s)});class He{constructor(t,e=!1){S(this,"data");this.data={[d.M]:[0,0,0,0,0,0,0,0,0,0],[d.P]:[0,0,0,0,0,0,0,0,0,0],[d.S]:[0,0,0,0,0,0,0,0,0,0],[d.Z]:[0,0,0,0,0,0,0,0],[d.BACK]:["untouchable",0],called:[],reached:!1,tsumo:null},this.init(t,e)}init(t,e){const n=new Q(t).parse();for(let i of n){if(i.isCalled()){this.data.called=[...this.called,i];continue}else if(i.is(_.TSUMO)){const r=i.tiles[0];this.inc([r]),this.data.tsumo=r;continue}else if(i.is(_.HAND)){this.inc(i.tiles);continue}else if(t.split("").every(r=>r===d.BACK)){this.inc(i.tiles);continue}else if(e){this.inc(i.tiles);continue}throw new Error(`unexpected block ${i.type} ${i.toString()}`)}}get hands(){const t=[];for(let e of Object.values(d))for(let n=1;n<this.getArrayLen(e);n++){let i=this.get(e,n);e!=d.Z&&n==5&&this.get(e,0)>0&&(i-=this.get(e,0),t.push(new g(e,0)));for(let r=0;r<i;r++)t.push(new g(e,n))}if(this.drawn!=null){const e=this.drawn,n=t.findIndex(i=>i.equals(e));C(n>=0,`hand has drawn: ${this.drawn} but no tile in hands: ${t.join("")}`),t[n]=t[n].clone({add:b.TSUMO})}return C(t.length>0,`no tiles in hand ${t.length}, called: ${this.called}, data: ${JSON.stringify(this.data,null,2)}`),t}toString(){let t="";for(let r of this.called)t=`${t},${r.toString()}`;let e="";this.drawn&&(e=`,${this.drawn.toString()}`);const n=this.hands.filter(r=>!r.has(b.TSUMO));return`${new en(n).toString()}${e}${t}`}get called(){return this.data.called}get reached(){return this.data.reached}get drawn(){return this.data.tsumo}get menzen(){return!this.called.some(t=>!(t instanceof U))}getArrayLen(t){return this.data[t].length}sum(t){let e=0;for(let n=1;n<this.getArrayLen(t);n++)e+=this.get(t,n);return e}get(t,e){return t==d.BACK?this.data[t][1]:this.data[t][e]}inc(t){const e=[];for(let n of t){if(n.t!=d.BACK&&this.get(n.t,n.n)>=4)throw this.dec(e),new Error(`unable to increase ${n} in ${this.toString()}`);if(e.push(n),j(n)&&(this.data[n.t][5]+=1),n.t==d.BACK?this.data[n.t][1]+=1:this.data[n.t][n.n]+=1,V(n)&&this.get(n.t,5)==4&&this.get(n.t,0)==0){this.data[n.t][0]=1;const i=e.pop().clone({n:0});e.push(i)}}return e}dec(t){const e=[];for(let n of t){if(this.get(n.t,n.n)<1)throw this.inc(e),new Error(`unable to decrease ${n.toString()} in ${this.toString()}`);if(e.push(n),j(n)&&(this.data[n.t][5]-=1),n.t==d.BACK?this.data[n.t][1]-=1:this.data[n.t][n.n]-=1,V(n)&&this.get(n.t,5)==0&&this.get(n.t,0)>0){this.data[n.t][0]=0;const i=e.pop().clone({n:0});e.push(i)}}return e}draw(t){const e=t.clone({add:b.TSUMO});this.inc([e]),this.data.tsumo=e}discard(t){this.dec([t]),this.data.tsumo=null}reach(){if(!this.menzen)throw new Error("cannot reach");if(this.data.reached)throw new Error("already reached");this.data.reached=!0}call(t){if(!(t instanceof ft||t instanceof ct||t instanceof ut))throw new Error(`unexpected input ${t} ${t.type}`);const e=t.tiles.filter(n=>!n.has(b.HORIZONTAL));if(e.length!=t.tiles.length-1)throw new Error(`removal: ${e} block: ${t}`);this.dec(e),this.data.called=[...this.called,t],this.data.tsumo=null}kan(t){if(t instanceof U){let e=t.tiles[0];j(e)&&(e=new g(e.t,5)),this.dec([e,e,e,e]),this.data.called=[...this.called,t],this.data.tsumo=null;return}if(t instanceof at){const e=this.data.called.findIndex(i=>i.is(_.PON)&&i.tiles[0].equals(t.tiles[0],!0));if(e==-1)throw new Error(`unable to find ${t.tiles[0]}`);let n=t.tiles[0];j(n)&&(n=new g(n.t,5)),this.dec([n]),this.data.called=[...this.called.slice(0,e),...this.called.slice(e+1),t],this.data.tsumo=null;return}throw new Error(`unexpected input ${t}`)}clone(){const t=new He(this.toString());return t.data.reached=this.data.reached,t}}class $e{constructor(t){S(this,"hand");this.hand=t}calc(){return Math.min(this.sevenPairs(),this.thirteenOrphans(),this.fourSetsOnePair())}sevenPairs(){if(this.hand.called.length>0)return 1/0;let t=0,e=0;for(let n of Object.values(d))if(n!=d.BACK)for(let i=1;i<this.hand.getArrayLen(n);i++)this.hand.get(n,i)==2&&t++,this.hand.get(n,i)==1&&e++;return t>7&&(t=7),t+e>=7&&(e=7-t),13-2*t-e}thirteenOrphans(){if(this.hand.called.length>0)return 1/0;let t=0,e=0;for(let n of Object.values(d)){if(n==d.BACK)continue;const i=n==d.Z?Ae:yt;for(let r of i)this.hand.get(n,r)>=1&&t++,this.hand.get(n,r)>=2&&e++}return e>=1?12-t:13-t}fourSetsOnePair(){const t=n=>{const i=[0,0,0],r=d.Z;for(let m=1;m<this.hand.getArrayLen(r);m++)this.hand.get(r,m)>=3?i[0]++:this.hand.get(r,m)==2?i[1]++:this.hand.get(r,m)==1&&i[2]++;const o=[0,0,0],a=this.hand.get(d.BACK,0),c=a%3;o[0]=Math.floor(a/3),c==2&&(o[1]=1),c==1&&(o[2]=1);let h=13;const l=this.commonByType(d.M),u=this.commonByType(d.P),f=this.commonByType(d.S);for(let m of[l.patternA,l.patternB])for(let p of[u.patternA,u.patternB])for(let y of[f.patternA,f.patternB]){const w=[this.hand.called.length,0,0];for(let O=0;O<3;O++)w[O]+=m[O]+p[O]+y[O]+i[O]+o[O];let x=this.calcCommon(w[0],w[1],w[2],n);x<h&&(h=x)}return h};let e=t(!1);for(let n of Object.values(d))for(let i=1;i<this.hand.getArrayLen(n);i++)if(this.hand.get(n,i)>=2){const r=this.hand.dec([new g(n,i),new g(n,i)]),o=t(!0);this.hand.inc(r),o<e&&(e=o)}return e}commonByType(t,e=1){if(t==d.BACK||t==d.Z)throw new Error(`expect number type but ${t}`);if(e>9)return this.groupRemainingTiles(t);let n=this.commonByType(t,e+1);if(e<=7&&this.hand.get(t,e)>0&&this.hand.get(t,e+1)>0&&this.hand.get(t,e+2)>0){const i=this.hand.dec([new g(t,e),new g(t,e+1),new g(t,e+2)]),r=this.commonByType(t,e);this.hand.inc(i),r.patternA[0]++,r.patternB[0]++,(r.patternA[2]<n.patternA[2]||r.patternA[2]==n.patternA[2]&&r.patternA[1]<n.patternA[1])&&(n.patternA=r.patternA),(r.patternB[0]>n.patternB[0]||r.patternB[0]==n.patternB[0]&&r.patternB[1]>n.patternB[1])&&(n.patternB=r.patternB)}if(this.hand.get(t,e)>=3){const i=this.hand.dec([new g(t,e),new g(t,e),new g(t,e)]),r=this.commonByType(t,e);this.hand.inc(i),r.patternA[0]++,r.patternB[0]++,(r.patternA[2]<n.patternA[2]||r.patternA[2]==n.patternA[2]&&r.patternA[1]<n.patternA[1])&&(n.patternA=r.patternA),(r.patternB[0]>n.patternB[0]||r.patternB[0]==n.patternB[0]&&r.patternB[1]>n.patternB[1])&&(n.patternB=r.patternB)}return n}groupRemainingTiles(t){let e=0,n=0,i=0;for(let r=1;r<this.hand.getArrayLen(t);r++)i+=this.hand.get(t,r),r<=7&&this.hand.get(t,r+1)==0&&this.hand.get(t,r+2)==0&&(e+=i>>1,n+=i%2,i=0);return e+=i>>1,n+=i%2,{patternA:[0,e,n],patternB:[0,e,n]}}calcCommon(t,e,n,i){let r=i?4:5;return t>4&&(e+=t-4,t=4),t+e>4&&(n+=t+e-4,e=4-t),t+e+n>r&&(n=r-t-e),i&&e++,13-t*3-e*2-n}}class Di{constructor(t){S(this,"hand");this.hand=t}calc(t){return this.hand.drawn!=null&&(t=this.hand.drawn),this.markDrawn([...this.sevenPairs(),...this.thirteenOrphans(),...this.nineGates(),...this.fourSetsOnePair()],t)}markDrawn(t,e){if(t.length==0)return[];const n=this.hand.drawn!=null||e.has(b.TSUMO)?b.TSUMO:b.RON,i=[];for(let o=0;o<t.length;o++){const a=t[o],c={};for(let h=0;h<a.length;h++){const l=a[h];if(l.isCalled())continue;const u=l.tiles.findIndex(m=>m.equals(e,!0));if(u<0)continue;const f=Ci(l);c[f]||(c[f]=!0,i.push([o,h,u]))}}if(i.length==0)throw new Error(`found no tile ${e.toString()} in hands ${t[0].toString()}`);const r=[];for(let[o,a,c]of i){const l=t[o].map(m=>m.clone()),u=l[a],f=u.tiles[c].clone({add:n});l[a]=u.clone({replace:{idx:c,tile:f}}),r.push(l)}return r}sevenPairs(){if(this.hand.called.length>0)return[];const t=[];for(let e of Object.values(d))if(e!=d.BACK)for(let n=1;n<this.hand.getArrayLen(e);n++){const i=this.hand.get(e,n);if(i==2)t.push(new Z(new g(e,n),new g(e,n)));else{if(i==0)continue;return[]}}return[t]}thirteenOrphans(){const t=[];let e="";for(let n of Object.values(d)){if(n==d.BACK)continue;const i=n==d.Z?Ae:yt;for(let r of i)if(this.hand.get(n,r)==1)t.push(new Yn(new g(n,r)));else if(this.hand.get(n,r)==2&&e=="")t.unshift(new Z(new g(n,r),new g(n,r)));else return[]}return[t]}nineGates(){const t=(e,n,i)=>i.includes(this.hand.get(e,n));for(let e of Object.values(d)){if(e==d.BACK||e==d.Z)continue;const n=t(e,1,[3,4])&&t(e,9,[3,4])&&t(e,2,[1,2])&&t(e,3,[1,2])&&t(e,4,[1,2])&&t(e,5,[1,2])&&t(e,6,[1,2])&&t(e,7,[1,2])&&t(e,8,[1,2]),i=this.hand.sum(e)==14;if(n&&i)return[[new en(this.hand.hands)]]}return[]}fourSetsOnePair(){let t=[];for(let e of Object.values(d))for(let n=1;n<this.hand.getArrayLen(e);n++)if(this.hand.get(e,n)>=2){const i=this.hand.dec([new g(e,n),new g(e,n)]),r=this.commonAll().filter(o=>o.length==4).map(o=>(o.unshift(new Z(i[0],i[1])),o));t=[...t,...r],this.hand.inc(i)}return t}commonAll(){const t=()=>{const r=[],o=d.Z;for(let a=1;a<this.hand.getArrayLen(o);a++)if(this.hand.get(o,a)!=0){if(this.hand.get(o,a)!=3)return[];r.push(new ot([new g(o,a),new g(o,a),new g(o,a)]))}return r.length==0?[]:[r]},e=()=>{const r=[],o=d.BACK,a=this.hand.get(o,0);return a<3?[]:(Array(Math.floor(a/3)).fill(void 0).map(c=>{r.push(new ot([new g(o,0),new g(o,0),new g(o,0)]))}),r.length==0?[]:[r])},n=[this.commonByType(d.M),this.commonByType(d.P),this.commonByType(d.S),t(),e(),[this.hand.called.concat()]].sort((r,o)=>o.length-r.length),i=n[0].concat();for(let r=0;r<i.length;r++)for(let o=1;o<n.length;o++)for(let a of n[o])i[r]=[...i[r],...a];return i}commonByType(t,e=1){if(e>9)return[];if(this.hand.get(t,e)==0)return this.commonByType(t,e+1);const n=[];if(e<=7&&this.hand.get(t,e)>0&&this.hand.get(t,e+1)>0&&this.hand.get(t,e+2)>0){const i=this.hand.dec([new g(t,e),new g(t,e+1),new g(t,e+2)]),r=this.commonByType(t,e);this.hand.inc(i),r.length==0&&r.push([]);for(let o of r)o.unshift(new bt([i[0],i[1],i[2]])),n.push(o)}if(this.hand.get(t,e)==3){const i=this.hand.dec([new g(t,e),new g(t,e),new g(t,e)]),r=this.commonByType(t,e);this.hand.inc(i),r.length==0&&r.push([]);for(let o of r)o.unshift(new ot([i[0],i[1],i[2]])),n.push(o)}return n}}const Ae=[1,2,3,4,5,6,7],yt=[1,9],Le=s=>{var e;const t=s.boardContext;return{...s,hand:s.hand.map(W.deserialize),boardContext:{...t,doraMarkers:t.doraMarkers.map(g.from),blindDoraMarkers:(e=t.blindDoraMarkers)==null?void 0:e.map(g.from)}}};class $n{constructor(t,e){S(this,"hand");S(this,"cfg");this.hand=t,this.cfg={doras:e.doraMarkers.map(n=>Ws(n)),blindDoras:e.blindDoraMarkers==null?[]:e.blindDoraMarkers.map(n=>Ws(n)),roundWind:g.from(e.round.substring(0,2)),myWind:g.from(e.myWind),reached:e.reached??0,sticks:e.sticks??{dead:0,reach:0},replacementWin:e.replacementWin??!1,quadWin:e.quadWin??!1,finalWallWin:e.finalWallWin??!1,finalDiscardWin:e.finalDiscardWin??!1,oneShotWin:e.oneShotWin??!1,orig:e}}calc(t){const e=this.calcPatterns(t);if(e.length==0)return!1;let n=[0,0],i=0;for(let p=0;p<e.length;p++){const y=e[p],w=y.points.reduce((x,O)=>x+O.double,0);(w>n[0]||w==n[0]&&y.fu>n[1])&&(i=p,n[0]=w,n[1]=y.fu)}const r=(p,y=100)=>Math.ceil(p/y)*y,o=n[1]!=25?r(n[1],10):25,a=n[0];let c=o*2**(a+2);switch(a){case 26:c=16e3;break;case 13:c=8e3;break;case 12:case 11:c=6e3;break;case 10:case 9:case 8:c=6e3;break;case 7:case 6:c=4e3;break;case 5:c=2e3;break}a>13&&a<26&&(c=8e3);const h=e[i].hand.some(p=>p.tiles.some(y=>y.has(b.TSUMO))),l=this.cfg.orig.myWind,u=l==v.E,f=G(0);if(h){const p=this.cfg.sticks.dead*100;if(u){const y=r(c*2);f[v.E]+=y*3+p*3,f[v.S]-=y+p,f[v.W]-=y+p,f[v.N]-=y+p}else for(let y of Object.values(v)){if(y==l)continue;const w=y==v.E?2:1,x=r(c*w)+p;f[y]-=x,f[l]+=x}}else{const p=this.cfg.sticks.dead*300;if(this.cfg.orig.ronWind==null)throw new Error("ron wind is not specified in the parameters");const w=r(c*(u?6:4))+p;f[l]+=w,f[this.cfg.orig.ronWind]-=w}return f[l]+=1e3*this.cfg.sticks.reach,{deltas:f,sum:a,fu:o,points:e[i].points,point:f[l],hand:e[i].hand,boardContext:this.cfg.orig}}calcPatterns(t){const e=[];if(t.length==0)return e;for(let n of t){const i=[...this.dA13(n),...this.dB13(n),...this.dC13(n),...this.dD13(n),...this.dE13(n),...this.dF13(n),...this.dG13(n),...this.dH13(n),...this.dI13(n),...this.dJ13(n),...this.dK13(n)];i.length!=0&&e.push({points:i,fu:30,hand:n})}if(e.length>0)return e;for(let n of t){const i=this.calcFu(n),r=[...this.dA1(n),...this.dB1(n),...this.dC1(n),...this.dD1(n),...this.dE1(n),...this.dF1(n),...this.dG1(n),...this.dH1(n),...this.dI1(n),...this.dJ1(n),...this.dK1(n),...this.dA2(n),...this.dB2(n),...this.dC2(n),...this.dD2(n),...this.dE2(n),...this.dF2(n),...this.dG2(n),...this.dH2(n),...this.dI2(n),...this.dJ2(n),...this.dA3(n),...this.dB3(n),...this.dC3(n),...this.dA6(n)];r.length>0&&r.push(...this.dX1(n)),e.push({points:r,fu:i,hand:n})}return e}minus(){return this.hand.menzen?0:1}dA1(t){return this.cfg.reached==1?[{name:"立直",double:1}]:this.cfg.reached==2?[{name:"ダブルリーチ",double:2}]:[]}dB1(t){return this.minus()!=0?[]:(this.hand.drawn==null,t.some(n=>n.tiles.some(i=>i.has(b.TSUMO)))?[{name:"門前清自摸和",double:1}]:[])}dC1(t){if(this.minus()!=0)return[];const e="平和",n=this.calcFu(t);return n==20?[{name:e,double:1}]:!t.some(i=>i.tiles.some(r=>r.has(b.TSUMO)))&&n==30?[{name:e,double:1}]:[]}dD1(t){return t.some(n=>n.tiles.some(i=>i.t==d.Z||yt.includes(i.n)))?[]:[{name:"断么九",double:1}]}dE1(t){return this.minus()!=0?[]:$s(t)==1?[{name:"一盃口",double:1}]:[]}dF1(t){const e=[];return t.forEach(n=>{if(n instanceof Z)return;const i=n.tiles[0];i.t==d.Z&&(i.equals(this.cfg.myWind)?e.push({name:"自風",double:1}):i.equals(this.cfg.roundWind)?e.push({name:"場風",double:1}):i.n==5?e.push({name:"白",double:1}):i.n==6?e.push({name:"發",double:1}):i.n==7&&e.push({name:"中",double:1}))}),e}dG1(t){return this.cfg.oneShotWin?[{name:"一発",double:1}]:[]}dH1(t){return this.cfg.replacementWin?[{name:"嶺上開花",double:1}]:[]}dI1(t){return this.cfg.quadWin?[{name:"搶槓",double:1}]:[]}dJ1(t){return this.cfg.finalWallWin?[{name:"海底摸月",double:1}]:[]}dK1(t){return this.cfg.finalDiscardWin?[{name:"河底撈魚",double:1}]:[]}dX1(t){let e=0,n=0,i=0;for(let o of t)for(let a of o.tiles){for(let c of this.cfg.doras)a.equals(c,!0)&&e++;for(let c of this.cfg.blindDoras)a.equals(c,!0)&&i++;j(a)&&n++}const r=[];return e>0&&r.push({name:"ドラ",double:e}),n>0&&r.push({name:"赤ドラ",double:n}),this.hand.reached&&i>0&&r.push({name:"裏ドラ",double:i}),r}dA2(t){return t.length==7?[{name:"七対子",double:2}]:[]}dB2(t){const e=n=>n instanceof bt||n instanceof ct;for(let n of t){if(!e(n))continue;const i=Et(n);if(i.t==d.Z)continue;const r=[d.M,d.P,d.S].filter(c=>c!=i.t),o=t.some(c=>{const h=new g(r[0],i.n);return e(c)&&h.equals(Et(c),!0)}),a=t.some(c=>{const h=new g(r[1],i.n);return e(c)&&h.equals(Et(c),!0)});if(o&&a)return[{name:"三色同順",double:2-this.minus()}]}return[]}dC2(t){return t.length==7?[]:t.every(n=>n instanceof U||n instanceof at||n instanceof ut||n instanceof ot||n instanceof ft||n instanceof Z)?[{name:"対々和",double:2}]:[]}dD2(t){return this.minus()!=0?[]:t.filter(n=>(n instanceof U||n instanceof ot)&&!n.tiles.some(i=>i.has(b.RON))).length>=3?[{name:"三暗刻",double:2}]:[]}dE2(t){return t.filter(n=>n instanceof U||n instanceof at||n instanceof ut).length>=3?[{name:"三槓子",double:2}]:[]}dF2(t){const e=n=>n instanceof U||n instanceof at||n instanceof ut||n instanceof ot||n instanceof ft;for(let n of t){if(!e(n))continue;const i=Et(n);if(i.t==d.Z)continue;const r=[d.M,d.P,d.S].filter(c=>c!=i.t),o=t.some(c=>{const h=new g(r[0],i.n);return e(c)&&h.equals(Et(c),!0)}),a=t.some(c=>{const h=new g(r[1],i.n);return e(c)&&h.equals(Et(c),!0)});if(o&&a)return[{name:"三色同刻",double:2}]}return[]}dG2(t){return t.filter(n=>{const i=n.tiles[0];return i.t==d.Z&&[5,6,7].includes(i.n)}).length==3?[{name:"小三元",double:2}]:[]}dH2(t){return t.every(n=>{const i=n.tiles[0].t==d.Z?Ae:yt;return n.tiles.every(r=>i.includes(r.n))})?[{name:"混老頭",double:2}]:[]}dI2(t){return t.length==7?[]:t.some(n=>n instanceof bt||n instanceof ct)?t.some(n=>n.tiles[0].t==d.Z)?t.every(n=>{const i=n.tiles[0].t==d.Z?Ae:yt;return n.tiles.some(r=>i.includes(r.n))})?[{name:"混全帯么九",double:2-this.minus()}]:[]:[]:[]}dJ2(t){if(this.minus()!=0)return[];let e={[d.M]:[0,0,0],[d.S]:[0,0,0],[d.P]:[0,0,0]};for(let n of t){const i=Et(n);i.t!=d.BACK&&i.t!=d.Z&&(n instanceof bt||n instanceof ct)&&(i.n==1&&e[i.t][0]++,i.n==4&&e[i.t][1]++,i.n==7&&e[i.t][2]++)}for(let n of Object.values(e))if(n.filter(i=>i>0).length==n.length)return[{name:"一気通貫",double:2-this.minus()}];return[]}dA3(t){if(!t.some(n=>n.tiles[0].t==d.Z))return[];for(let n of Object.values(d))if(t.every(r=>r.tiles[0].t==d.Z||r.tiles[0].t==n))return[{name:"混一色",double:3-this.minus()}];return[]}dB3(t){return t.length==7?[]:t.some(n=>n instanceof bt||n instanceof ct)?t.some(n=>n.tiles[0].t==d.Z)?[]:t.every(n=>n.tiles.some(i=>yt.includes(i.n)))?[{name:"純全帯么九色",double:3-this.minus()}]:[]:[]}dC3(t){return this.minus()!=0?[]:$s(t)==2?[{name:"ニ盃口",double:3}]:[]}dA6(t){if(t.some(e=>e.tiles[0].t==d.Z))return[];for(let e of Object.values(d)){if(e==d.Z)continue;if(t.every(i=>i.tiles[0].t==e))return[{name:"清一色",double:6-this.minus()}]}return[]}dA13(t){return t.length!=13?[]:t.some(n=>n instanceof Z&&n.tiles.some(i=>i.has(b.TSUMO)||i.has(b.RON)))?[{name:"国士無双13面待ち",double:26}]:[{name:"国士無双",double:13}]}dB13(t){return t.length==1?[{name:"九蓮宝燈",double:13}]:[]}dC13(t){return t.length==7?[]:t.every(i=>i instanceof U||i instanceof ot&&!i.tiles.some(r=>r.has(b.RON))||i instanceof Z)?t.some(i=>i instanceof Z&&i.tiles.every(r=>r.has(b.TSUMO)||r.has(b.RON)))?[{name:"四暗刻単騎待ち",double:26}]:[{name:"四暗刻",double:13}]:[]}dD13(t){if(t.length==13)return[];const e=[5,6,7];return t.filter(i=>!(i instanceof Z)&&i.tiles.some(r=>r.t==d.Z&&e.includes(r.n))).length==3?[{name:"大三元",double:13}]:[]}dE13(t){return t.every(n=>n.tiles[0].t==d.Z)?[{name:"字一色",double:13}]:[]}dF13(t){return t.every(n=>n.tiles.every(i=>i.t!=d.Z&&yt.includes(i.n)))?[{name:"清老頭",double:13}]:[]}dG13(t){return t.filter(n=>n instanceof U||n instanceof at||n instanceof ut).length==4?[{name:"四槓子",double:13}]:[]}dH13(t){if(t.length==13)return[];if(t.length==7)return[];const e=[1,2,3,4];return t.filter(r=>r.tiles.some(o=>o.t==d.Z&&e.includes(o.n))).length==4?t.find(r=>r instanceof Z).tiles.some(r=>r.t==d.Z&&e.includes(r.n))?[{name:"小四喜",double:13}]:[{name:"大四喜",double:13}]:[]}dI13(t){const e=n=>!!(n.equals(new g(d.Z,6))||n.t==d.S&&[2,3,4,6,8].includes(n.n));return t.every(n=>n.tiles.every(i=>e(i)))?[{name:"緑一色",double:13}]:[]}dJ13(t){return[]}dK13(t){return[]}calcFu(t){let n=20;const i=this.cfg.myWind.n,r=this.cfg.roundWind.n;if(t.length==7)return 25;const o=t.find(p=>p.tiles.some(y=>y.has(b.TSUMO)||y.has(b.RON))),a=this.minus()==1,c=o.tiles.some(p=>p.has(b.TSUMO)),h=(p,y)=>{const w=p.tiles[0];return w.t==d.Z&&[5,6,7].includes(w.n)||w.t==d.Z&&[i,r].includes(w.n)||yt.includes(w.n)?y*2:y};for(let p of t)switch(!0){case p instanceof ot:let y=p.tiles.some(w=>w.has(b.RON))?2:4;n+=h(p,y);break;case p instanceof ft:n+=h(p,2);break;case(p instanceof ut||p instanceof at):n+=h(p,8);break;case p instanceof U:n+=h(p,16);break}n+=(p=>{if(p instanceof ot)return 0;if(p instanceof Z)return 2;const y=p.tiles,w=y.findIndex(x=>x.has(b.TSUMO)||x.has(b.RON));return w==1||w==0&&y[2].n==9||w==2&&y[0].n==1?2:0})(o);let f=t.find(p=>p instanceof Z).tiles[0];f.t==d.Z&&([5,6,7].includes(f.n)&&(n+=2),f.n==r&&(n+=2),f.n==i&&(n+=2));let m=!1;return!a&&n==20&&(m=!0),c&&!m&&(n+=2),!c&&!a&&(n+=10),!c&&!a&&n==30&&(m=!0),a&&n==20&&(n=30),n}}const Ci=s=>s.tiles.reduce((t,e)=>`${t}${e.n}${e.t}`,""),$s=s=>{let t={};for(let n of s){if(!(n instanceof bt))continue;const i=Ci(n);t[i]==null?t[i]=1:t[i]++}let e=0;for(let n in t)t[n]>=2&&e++;return e},Et=s=>[...s.tiles].sort(ye)[0],Ws=s=>{let t=j(s)?5:s.n,e=s.t;return new g(e,t%9+1)};class zt{static calcCandidates(t,e,n=!1){C(e.length>0,"choices to discard is zero");const i=new Map;let r=Number.POSITIVE_INFINITY;for(let o of e){const a=t.dec([o]),c=zt.candidateTiles(t);t.inc(a);const h=n&&j(o)?o.clone({n:5,removeAll:!0}):o.clone({removeAll:!0});c.shanten<r?(i.clear(),i.set(h.toString(),{shanten:c.shanten,candidates:c.candidates,tile:h}),r=c.shanten):c.shanten==r&&i.set(h.toString(),{shanten:c.shanten,candidates:c.candidates,tile:h})}return Array.from(i.values())}static candidateTiles(t){let e=Number.POSITIVE_INFINITY,n=[];const i=new $e(t);for(let r of Object.values(d))if(r!=d.BACK)for(let o=1;o<t.getArrayLen(r);o++){if(t.get(r,o)>=4)continue;const a=new g(r,o),c=t.inc([a]),h=i.calc();t.dec(c),h<e?(e=h,n=[a]):h==e&&n.push(a)}return{shanten:e,candidates:n}}static partialCandidateTiles(t){const e=new He(t,!0);return Array(13-e.hands.length).fill(void 0).map(()=>e.inc([new g(d.BACK,0)])),zt.candidateTiles(e)}}const Wn=()=>{const s=new Set;return{on(t){s.add(t)},off(t){s.delete(t)},offAll(){s.clear()},emit(t){s.forEach(e=>e(t))}}};function Ri(s){var r;const t=["RON","DAI_KAN","PON","CHI"],e=s.map(o=>o.choices),i=$i(e,t).map(o=>s[o]);return{events:i,type:Wi(t,(r=i[0])==null?void 0:r.choices)}}function Hi(s){var r;const t=["TSUMO","REACH","AN_KAN","SHO_KAN","DRAWN_GAME_BY_NINE_TILES","DISCARD"],e=s.map(o=>o.choices),i=$i(e,t).map(o=>s[o]);return{events:i,type:Wi(t,(r=i[0])==null?void 0:r.choices)}}function $i(s,t){let e=[],n=Number.POSITIVE_INFINITY;for(let i=0;i<s.length;i++){const r=s[i];if(nc(r,t)){const o=sc(t,r);o<n?(n=o,e=[i]):o===n&&e.push(i)}}return e}function nc(s,t){return t.some(e=>!!s[e])}function sc(s,t){for(let e=0;e<s.length;e++){const n=s[e];if(t[n])return e}return Number.POSITIVE_INFINITY}function Wi(s,t){if(t==null)return!1;for(const e of s)if(t[e])return e;return!1}const pe=()=>{const s=Wn(),t=Wn(),e={emit:s.emit,on:i=>t.on(i)},n={emit:t.emit,on:i=>s.on(i)};return[e,n]},Bi=()=>{const s=Wn();return{emit:n=>{s.emit(n)},on:n=>{s.on(n)}}};class xe{constructor(t){S(this,"reachValue",1e3);S(this,"m");this.m=t}get summary(){return structuredClone(this.m)}reach(t){this.m[t]-=this.reachValue}restoreReachStick(t){this.m[t]+=this.reachValue}update(t,e){for(let n in e){const i=e[n],r=t[i];this.m[n]+=r}}}class ke{constructor(t,e){S(this,"pToW",{});S(this,"wToP",G(""));S(this,"round");S(this,"sticks");this.round=(e==null?void 0:e.round)??"1w1",this.sticks=(e==null?void 0:e.sticks)??{reach:0,dead:0},this.pToW=t;for(let n in this.pToW)this.wToP[this.pToW[n]]=n}update(){for(let t in this.pToW){const e=At(this.pToW[t]);this.pToW[t]=e,this.wToP[e]=t}}incrementDeadStick(){this.sticks.dead++}incrementReachStick(){this.sticks.reach++}nextRound(){const t=ge(this.round);this.round=t,this.update()}decrementReachStick(){this.sticks.reach--,C(this.sticks.reach>=0)}resetDeadStick(){this.sticks.dead=0}resetReachStick(){this.sticks.reach=0}is(t){return this.round==t}wind(t){return this.pToW[t]}playerID(t){return this.wToP[t]}get playerMap(){return structuredClone(this.pToW)}}function ds(s){for(let t=s.length-1;t>0;t--){const e=Math.floor(Math.random()*(t+1));[s[t],s[e]]=[s[e],s[t]]}return s}class zi{constructor(t=!1){S(this,"c",{[d.M]:[1,4,4,4,4,4,4,4,4,4],[d.S]:[1,4,4,4,4,4,4,4,4,4],[d.P]:[1,4,4,4,4,4,4,4,4,4],[d.Z]:[0,4,4,4,4,4,4,4]});S(this,"safeMap",G({},!0));this.disable=t}get(t){return t.t==d.BACK?0:j(t)?this.c[t.t][5]:this.c[t.t][t.n]}dec(...t){if(!this.disable){for(let e of t)if(e.t!=d.BACK){if(this.get(e)<=0)throw new Error(`cannot decrease ${e.toString()} due to zero`);this.c[e.t][e.n]-=1,j(e)&&(this.c[e.t][5]-=1)}}}addTileToSafeMap(t,e){this.disable||(this.safeMap[e][this.key(t.t,t.n)]=!0)}isSafeTile(t,e,n){return this.safeMap[n][this.key(t,e)]}key(t,e){return e==0&&(e=5),`${t}${e}`}reset(){this.c={[d.M]:[1,4,4,4,4,4,4,4,4,4],[d.S]:[1,4,4,4,4,4,4,4,4,4],[d.P]:[1,4,4,4,4,4,4,4,4,4],[d.Z]:[0,4,4,4,4,4,4,4]}}}class ps{constructor(){S(this,"m",[])}discard(t,e){this.m.push({w:e,t})}get lastTile(){const t=this.m.at(-1);return C(t!=null,`lastTile is null(${t}). river: ${JSON.stringify(this.m,null,2)}`),t}discards(t){return t==null?[...this.m]:this.m.filter(e=>e.w==t)}markCalled(){this.lastTile.callMarker=!0}cannotContinue(){const t=this.discards();if(t.length!=4)return!1;let e=t[0].t;if(e.isNum())return!1;for(let n=0;n<4;n++)if(!e.equals(t[n].t))return!1;return!0}}function ic(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global}function rc(){const s=ic();if(s.__xstate__)return s.__xstate__}const oc=s=>{if(typeof window>"u")return;const t=rc();t&&t.register(s)};class Bs{constructor(t){this._process=t,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(t){const e={value:t,next:null};if(this._current){this._last.next=e,this._last=e;return}this._current=e,this._last=e,this._active&&this.flush()}flush(){for(;this._current;){const t=this._current;this._process(t.value),this._current=t.next}this._last=null}}const Pi=".",ac="",ji="",cc="#",hc="*",Li="xstate.init",Bn="xstate.stop";function lc(s,t){return{type:`xstate.after.${s}.${t}`}}function zn(s,t){return{type:`xstate.done.state.${s}`,output:t}}function uc(s,t){return{type:`xstate.done.actor.${s}`,output:t,actorId:s}}function fc(s,t){return{type:`xstate.error.actor.${s}`,error:t,actorId:s}}function Ki(s){return{type:Li,input:s}}function gt(s){setTimeout(()=>{throw s})}const dc=typeof Symbol=="function"&&Symbol.observable||"@@observable";function Ui(s,t){const e=zs(s),n=zs(t);return typeof n=="string"?typeof e=="string"?n===e:!1:typeof e=="string"?e in n:Object.keys(e).every(i=>i in n?Ui(e[i],n[i]):!1)}function ms(s){if(qi(s))return s;let t=[],e="";for(let n=0;n<s.length;n++){switch(s.charCodeAt(n)){case 92:e+=s[n+1],n++;continue;case 46:t.push(e),e="";continue}e+=s[n]}return t.push(e),t}function zs(s){if(qc(s))return s.value;if(typeof s!="string")return s;const t=ms(s);return pc(t)}function pc(s){if(s.length===1)return s[0];const t={};let e=t;for(let n=0;n<s.length-1;n++)if(n===s.length-2)e[s[n]]=s[n+1];else{const i=e;e={},i[s[n]]=e}return t}function Ps(s,t){const e={},n=Object.keys(s);for(let i=0;i<n.length;i++){const r=n[i];e[r]=t(s[r],r,s,i)}return e}function Fi(s){return qi(s)?s:[s]}function St(s){return s===void 0?[]:Fi(s)}function Pn(s,t,e,n){return typeof s=="function"?s({context:t,event:e,self:n}):s}function qi(s){return Array.isArray(s)}function mc(s){return s.type.startsWith("xstate.error.actor")}function Gt(s){return Fi(s).map(t=>typeof t>"u"||typeof t=="string"?{target:t}:t)}function Gi(s){if(!(s===void 0||s===ac))return St(s)}function jn(s,t,e){var r,o,a;const n=typeof s=="object",i=n?s:void 0;return{next:(r=n?s.next:s)==null?void 0:r.bind(i),error:(o=n?s.error:t)==null?void 0:o.bind(i),complete:(a=n?s.complete:e)==null?void 0:a.bind(i)}}function js(s,t){return`${t}.${s}`}function gs(s,t){const e=t.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!e)return s.implementations.actors[t];const[,n,i]=e,o=s.getStateNodeById(i).config.invoke;return(Array.isArray(o)?o[n]:o).src}function Ls(s,t){return`${s.sessionId}.${t}`}let gc=0;function yc(s,t){const e=new Map,n=new Map,i=new WeakMap,r=new Set,o={},{clock:a,logger:c}=t,h={schedule:(f,m,p,y,w=Math.random().toString(36).slice(2))=>{const x={source:f,target:m,event:p,delay:y,id:w,startedAt:Date.now()},O=Ls(f,w);u._snapshot._scheduledEvents[O]=x;const $=a.setTimeout(()=>{delete o[O],delete u._snapshot._scheduledEvents[O],u._relay(f,m,p)},y);o[O]=$},cancel:(f,m)=>{const p=Ls(f,m),y=o[p];delete o[p],delete u._snapshot._scheduledEvents[p],y!==void 0&&a.clearTimeout(y)},cancelAll:f=>{for(const m in u._snapshot._scheduledEvents){const p=u._snapshot._scheduledEvents[m];p.source===f&&h.cancel(f,p.id)}}},l=f=>{if(!r.size)return;const m={...f,rootId:s.sessionId};r.forEach(p=>{var y;return(y=p.next)==null?void 0:y.call(p,m)})},u={_snapshot:{_scheduledEvents:((t==null?void 0:t.snapshot)&&t.snapshot.scheduler)??{}},_bookId:()=>`x:${gc++}`,_register:(f,m)=>(e.set(f,m),f),_unregister:f=>{e.delete(f.sessionId);const m=i.get(f);m!==void 0&&(n.delete(m),i.delete(f))},get:f=>n.get(f),_set:(f,m)=>{const p=n.get(f);if(p&&p!==m)throw new Error(`Actor with system ID '${f}' already exists.`);n.set(f,m),i.set(m,f)},inspect:f=>{const m=jn(f);return r.add(m),{unsubscribe(){r.delete(m)}}},_sendInspectionEvent:l,_relay:(f,m,p)=>{u._sendInspectionEvent({type:"@xstate.event",sourceRef:f,actorRef:m,event:p}),m._send(p)},scheduler:h,getSnapshot:()=>({_scheduledEvents:{...u._snapshot._scheduledEvents}}),start:()=>{const f=u._snapshot._scheduledEvents;u._snapshot._scheduledEvents={};for(const m in f){const{source:p,target:y,event:w,delay:x,id:O}=f[m];h.schedule(p,y,w,x,O)}},_clock:a,_logger:c};return u}const ys=1;let q=function(s){return s[s.NotStarted=0]="NotStarted",s[s.Running=1]="Running",s[s.Stopped=2]="Stopped",s}({});const wc={clock:{setTimeout:(s,t)=>setTimeout(s,t),clearTimeout:s=>clearTimeout(s)},logger:console.log.bind(console),devTools:!1};class _c{constructor(t,e){this.logic=t,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new Bs(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=q.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this._systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];const n={...wc,...e},{clock:i,logger:r,parent:o,syncSnapshot:a,id:c,systemId:h,inspect:l}=n;this.system=o?o.system:yc(this,{clock:i,logger:r}),l&&!o&&this.system.inspect(jn(l)),this.sessionId=this.system._bookId(),this.id=c??this.sessionId,this.logger=(e==null?void 0:e.logger)??this.system._logger,this.clock=(e==null?void 0:e.clock)??this.system._clock,this._parent=o,this._syncSnapshot=a,this.options=n,this.src=n.src??t,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:u=>{this._deferred.push(u)},system:this.system,stopChild:u=>{if(u._parent!==this)throw new Error(`Cannot stop child actor ${u.id} of ${this.id} because it is not a child`);u._stop()},emit:u=>{const f=this.eventListeners.get(u.type),m=this.eventListeners.get("*");if(!f&&!m)return;const p=new Set([...f?f.values():[],...m?m.values():[]]);for(const y of Array.from(p))y(u)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),h&&(this._systemId=h,this.system._set(h,this)),this._initState((e==null?void 0:e.snapshot)??(e==null?void 0:e.state)),h&&this._snapshot.status!=="active"&&this.system._unregister(this)}_initState(t){var e;try{this._snapshot=t?this.logic.restoreSnapshot?this.logic.restoreSnapshot(t,this._actorScope):t:this.logic.getInitialSnapshot(this._actorScope,(e=this.options)==null?void 0:e.input)}catch(n){this._snapshot={status:"error",output:void 0,error:n}}}update(t,e){var i,r;this._snapshot=t;let n;for(;n=this._deferred.shift();)try{n()}catch(o){this._deferred.length=0,this._snapshot={...t,status:"error",error:o}}switch(this._snapshot.status){case"active":for(const o of this.observers)try{(i=o.next)==null||i.call(o,t)}catch(a){gt(a)}break;case"done":for(const o of this.observers)try{(r=o.next)==null||r.call(o,t)}catch(a){gt(a)}this._stopProcedure(),this._complete(),this._doneEvent=uc(this.id,this._snapshot.output),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case"error":this._error(this._snapshot.error);break}this.system._sendInspectionEvent({type:"@xstate.snapshot",actorRef:this,event:e,snapshot:t})}subscribe(t,e,n){var r;const i=jn(t,e,n);if(this._processingStatus!==q.Stopped)this.observers.add(i);else switch(this._snapshot.status){case"done":try{(r=i.complete)==null||r.call(i)}catch(o){gt(o)}break;case"error":{const o=this._snapshot.error;if(!i.error)gt(o);else try{i.error(o)}catch(a){gt(a)}break}}return{unsubscribe:()=>{this.observers.delete(i)}}}on(t,e){let n=this.eventListeners.get(t);n||(n=new Set,this.eventListeners.set(t,n));const i=e.bind(void 0);return n.add(i),{unsubscribe:()=>{n.delete(i)}}}start(){if(this._processingStatus===q.Running)return this;this._syncSnapshot&&this.subscribe({next:n=>{n.status==="active"&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:n})},error:()=>{}}),this.system._register(this.sessionId,this),this._systemId&&this.system._set(this._systemId,this),this._processingStatus=q.Running;const t=Ki(this.options.input);switch(this.system._sendInspectionEvent({type:"@xstate.event",sourceRef:this._parent,actorRef:this,event:t}),this._snapshot.status){case"done":return this.update(this._snapshot,t),this;case"error":return this._error(this._snapshot.error),this}if(this._parent||this.system.start(),this.logic.start)try{this.logic.start(this._snapshot,this._actorScope)}catch(n){return this._snapshot={...this._snapshot,status:"error",error:n},this._error(n),this}return this.update(this._snapshot,t),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(t){let e,n;try{e=this.logic.transition(this._snapshot,t,this._actorScope)}catch(i){n={err:i}}if(n){const{err:i}=n;this._snapshot={...this._snapshot,status:"error",error:i},this._error(i);return}this.update(e,t),t.type===Bn&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===q.Stopped?this:(this.mailbox.clear(),this._processingStatus===q.NotStarted?(this._processingStatus=q.Stopped,this):(this.mailbox.enqueue({type:Bn}),this))}stop(){if(this._parent)throw new Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){var t;for(const e of this.observers)try{(t=e.complete)==null||t.call(e)}catch(n){gt(n)}this.observers.clear()}_reportError(t){if(!this.observers.size){this._parent||gt(t);return}let e=!1;for(const n of this.observers){const i=n.error;e||(e=!i);try{i==null||i(t)}catch(r){gt(r)}}this.observers.clear(),e&>(t)}_error(t){this._stopProcedure(),this._reportError(t),this._parent&&this.system._relay(this,this._parent,fc(this.id,t))}_stopProcedure(){return this._processingStatus!==q.Running?this:(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new Bs(this._process.bind(this)),this._processingStatus=q.Stopped,this.system._unregister(this),this)}_send(t){this._processingStatus!==q.Stopped&&this.mailbox.enqueue(t)}send(t){this.system._relay(void 0,this,t)}attachDevTools(){const{devTools:t}=this.options;t&&(typeof t=="function"?t:oc)(this)}toJSON(){return{xstate$$type:ys,id:this.id}}getPersistedSnapshot(t){return this.logic.getPersistedSnapshot(this._snapshot,t)}[dc](){return this}getSnapshot(){return this._snapshot}}function se(s,...[t]){return new _c(s,t)}function bc(s,t,e,n,{sendId:i}){const r=typeof i=="function"?i(e,n):i;return[t,r]}function Sc(s,t){s.defer(()=>{s.system.scheduler.cancel(s.self,t)})}function vc(s){function t(e,n){}return t.type="xstate.cancel",t.sendId=s,t.resolve=bc,t.execute=Sc,t}function Ac(s,t,e,n,{id:i,systemId:r,src:o,input:a,syncSnapshot:c}){const h=typeof o=="string"?gs(t.machine,o):o,l=typeof i=="function"?i(e):i;let u;return h&&(u=se(h,{id:l,src:o,parent:s.self,syncSnapshot:c,systemId:r,input:typeof a=="function"?a({context:t.context,event:e.event,self:s.self}):a})),[Pt(t,{children:{...t.children,[l]:u}}),{id:i,actorRef:u}]}function xc(s,{id:t,actorRef:e}){e&&s.defer(()=>{e._processingStatus!==q.Stopped&&e.start()})}function kc(...[s,{id:t,systemId:e,input:n,syncSnapshot:i=!1}={}]){function r(o,a){}return r.type="snapshot.spawnChild",r.id=t,r.systemId=e,r.src=s,r.input=n,r.syncSnapshot=i,r.resolve=Ac,r.execute=xc,r}function Tc(s,t,e,n,{actorRef:i}){const r=typeof i=="function"?i(e,n):i,o=typeof r=="string"?t.children[r]:r;let a=t.children;return o&&(a={...a},delete a[o.id]),[Pt(t,{children:a}),o]}function Oc(s,t){if(t){if(s.system._unregister(t),t._processingStatus!==q.Running){s.stopChild(t);return}s.defer(()=>{s.stopChild(t)})}}function Zi(s){function t(e,n){}return t.type="xstate.stopChild",t.actorRef=s,t.resolve=Tc,t.execute=Oc,t}function ws(s,t,e,n){const{machine:i}=n,r=typeof s=="function",o=r?s:i.implementations.guards[typeof s=="string"?s:s.type];if(!r&&!o)throw new Error(`Guard '${typeof s=="string"?s:s.type}' is not implemented.'.`);if(typeof o!="function")return ws(o,t,e,n);const a={context:t,event:e},c=r||typeof s=="string"?void 0:"params"in s?typeof s.params=="function"?s.params({context:t,event:e}):s.params:void 0;return"check"in o?o.check(n,a,o):o(a,c)}const _s=s=>s.type==="atomic"||s.type==="final";function ie(s){return Object.values(s.states).filter(t=>t.type!=="history")}function We(s,t){const e=[];if(t===s)return e;let n=s.parent;for(;n&&n!==t;)e.push(n),n=n.parent;return e}function Je(s){const t=new Set(s),e=Xi(t);for(const n of t)if(n.type==="compound"&&(!e.get(n)||!e.get(n).length))Ks(n).forEach(i=>t.add(i));else if(n.type==="parallel"){for(const i of ie(n))if(i.type!=="history"&&!t.has(i)){const r=Ks(i);for(const o of r)t.add(o)}}for(const n of t){let i=n.parent;for(;i;)t.add(i),i=i.parent}return t}function Yi(s,t){const e=t.get(s);if(!e)return{};if(s.type==="compound"){const i=e[0];if(i){if(_s(i))return i.key}else return{}}const n={};for(const i of e)n[i.key]=Yi(i,t);return n}function Xi(s){const t=new Map;for(const e of s)t.has(e)||t.set(e,[]),e.parent&&(t.has(e.parent)||t.set(e.parent,[]),t.get(e.parent).push(e));return t}function Ji(s,t){const e=Je(t);return Yi(s,Xi(e))}function bs(s,t){return t.type==="compound"?ie(t).some(e=>e.type==="final"&&s.has(e)):t.type==="parallel"?ie(t).every(e=>bs(s,e)):t.type==="final"}const an=s=>s[0]===cc;function Ec(s,t){return s.transitions.get(t)||[...s.transitions.keys()].filter(n=>{if(n===hc)return!0;if(!n.endsWith(".*"))return!1;const i=n.split("."),r=t.split(".");for(let o=0;o<i.length;o++){const a=i[o],c=r[o];if(a==="*")return o===i.length-1;if(a!==c)return!1}return!0}).sort((n,i)=>i.length-n.length).flatMap(n=>s.transitions.get(n))}function Ic(s){const t=s.config.after;if(!t)return[];const e=(i,r)=>{const o=lc(i,s.id),a=o.type;return s.entry.push(eh(o,{id:a,delay:i})),s.exit.push(vc(a)),a};return Object.keys(t).flatMap((i,r)=>{const o=t[i],a=typeof o=="string"?{target:o}:o,c=Number.isNaN(+i)?i:+i,h=e(c);return St(a).map(l=>({...l,event:h,delay:c}))}).map(i=>{const{delay:r}=i;return{...Dt(s,i.event,i),delay:r}})}function Dt(s,t,e){const n=Gi(e.target),i=e.reenter??!1,r=Dc(s,n),o={...e,actions:St(e.actions),guard:e.guard,target:r,source:s,reenter:i,eventType:t,toJSON:()=>({...o,source:`#${s.id}`,target:r?r.map(a=>`#${a.id}`):void 0})};return o}function Nc(s){const t=new Map;if(s.config.on)for(const e of Object.keys(s.config.on)){if(e===ji)throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');const n=s.config.on[e];t.set(e,Gt(n).map(i=>Dt(s,e,i)))}if(s.config.onDone){const e=`xstate.done.state.${s.id}`;t.set(e,Gt(s.config.onDone).map(n=>Dt(s,e,n)))}for(const e of s.invoke){if(e.onDone){const n=`xstate.done.actor.${e.id}`;t.set(n,Gt(e.onDone).map(i=>Dt(s,n,i)))}if(e.onError){const n=`xstate.error.actor.${e.id}`;t.set(n,Gt(e.onError).map(i=>Dt(s,n,i)))}if(e.onSnapshot){const n=`xstate.snapshot.${e.id}`;t.set(n,Gt(e.onSnapshot).map(i=>Dt(s,n,i)))}}for(const e of s.after){let n=t.get(e.eventType);n||(n=[],t.set(e.eventType,n)),n.push(e)}return t}function Mc(s,t){const e=typeof t=="string"?s.states[t]:t?s.states[t.target]:void 0;if(!e&&t)throw new Error(`Initial state node "${t}" not found on parent state node #${s.id}`);const n={source:s,actions:!t||typeof t=="string"?[]:St(t.actions),eventType:null,reenter:!1,target:e?[e]:[],toJSON:()=>({...n,source:`#${s.id}`,target:e?[`#${e.id}`]:[]})};return n}function Dc(s,t){if(t!==void 0)return t.map(e=>{if(typeof e!="string")return e;if(an(e))return s.machine.getStateNodeById(e);const n=e[0]===Pi;if(n&&!s.parent)return Ve(s,e.slice(1));const i=n?s.key+e:e;if(s.parent)try{return Ve(s.parent,i)}catch(r){throw new Error(`Invalid transition definition for state node '${s.id}':
|
|
7
|
+
`).map(a=>a.trim()).filter(a=>a!="");if(n.length==0)throw new Error("empty input");const i=n.shift();if(!i.startsWith(t))throw new Error(`input does not start with table: ${i}`);const r={};let o=[v.E,v.S,v.W,v.N,e];for(;;){const a=n.shift();if(a==null)break;const c=o.find(h=>a.startsWith(h));if(c==null)throw new Error(`encountered unexpected line ${a}`);if(o=o.filter(h=>!a.startsWith(h)),c==e){const[h,l]=tc([...n]);r.board=h;for(let u=0;u<l;u++)n.shift()}else{const[h,l]=Qa([...n]);r[c]=h;for(let u=0;u<l;u++)n.shift()}}return r},lt=(s,t)=>s.replace(t,"").replace(":","").trim(),Qa=s=>{const t="hand",e="discard",n="score";let i={},r=0;for(;r<s.length;r++){const o=s[r];if(o.startsWith(t))i.hand=lt(o,t);else if(o.startsWith(e))i.discard=lt(o,e);else if(o.startsWith(n))i.score=Number(lt(o,n));else break}return[i,r]},tc=s=>{const t="doras",e="round",n="front",i="sticks",r="reach",o="dead";let a={},c=0;for(;c<s.length;c++){const h=s[c];if(h.startsWith(t))a.doras=lt(h,t);else if(h.startsWith(e))a.round=lt(h,e);else if(h.startsWith(n))a.front=lt(h,n);else if(h.startsWith(i)){a.sticks={};const l=s[c+1]??"",u=s[c+2]??"";l.startsWith(r)&&(a.sticks.reach=Number(lt(l,r))),l.startsWith(o)&&(a.sticks.dead=Number(lt(l,o))),u.startsWith(r)&&(a.sticks.reach=Number(lt(u,r))),u.startsWith(o)&&(a.sticks.dead=Number(lt(u,o))),a.sticks.dead!=null&&c++,a.sticks.reach!=null&&c++}else break}return[a,c]},Mi=s=>{const t=s.board.front,e=ec(t),n=a=>s[a].discard.replace(/\r?\n/g,""),i={front:new Q(n(e.front)).tiles(),right:new Q(n(e.right)).tiles(),opposite:new Q(n(e.opposite)).tiles(),left:new Q(n(e.left)).tiles()},r={front:new Q(s[e.front].hand).parse(),right:new Q(s[e.right].hand).parse(),opposite:new Q(s[e.opposite].hand).parse(),left:new Q(s[e.left].hand).parse()},o={round:Gn[s.board.round],frontPlace:tn[t],sticks:s.board.sticks,doras:new Q(s.board.doras).tiles(),scores:{front:s[e.front].score,right:s[e.right].score,opposite:s[e.opposite].score,left:s[e.left].score}};return{discards:i,hands:r,scoreBoard:o}},ec=s=>({front:s,right:At(s),opposite:At(At(s)),left:Xs(s)});class He{constructor(t,e=!1){S(this,"data");this.data={[d.M]:[0,0,0,0,0,0,0,0,0,0],[d.P]:[0,0,0,0,0,0,0,0,0,0],[d.S]:[0,0,0,0,0,0,0,0,0,0],[d.Z]:[0,0,0,0,0,0,0,0],[d.BACK]:["untouchable",0],called:[],reached:!1,tsumo:null},this.init(t,e)}init(t,e){const n=new Q(t).parse();for(let i of n){if(i.isCalled()){this.data.called=[...this.called,i];continue}else if(i.is(_.TSUMO)){const r=i.tiles[0];this.inc([r]),this.data.tsumo=r;continue}else if(i.is(_.HAND)){this.inc(i.tiles);continue}else if(t.split("").every(r=>r===d.BACK)){this.inc(i.tiles);continue}else if(e){this.inc(i.tiles);continue}throw new Error(`unexpected block ${i.type} ${i.toString()}`)}}get hands(){const t=[];for(let e of Object.values(d))for(let n=1;n<this.getArrayLen(e);n++){let i=this.get(e,n);e!=d.Z&&n==5&&this.get(e,0)>0&&(i-=this.get(e,0),t.push(new g(e,0)));for(let r=0;r<i;r++)t.push(new g(e,n))}if(this.drawn!=null){const e=this.drawn,n=t.findIndex(i=>i.equals(e));C(n>=0,`hand has drawn: ${this.drawn} but no tile in hands: ${t.join("")}`),t[n]=t[n].clone({add:b.TSUMO})}return C(t.length>0,`no tiles in hand ${t.length}, called: ${this.called}, data: ${JSON.stringify(this.data,null,2)}`),t}toString(){let t="";for(let r of this.called)t=`${t},${r.toString()}`;let e="";this.drawn&&(e=`,${this.drawn.toString()}`);const n=this.hands.filter(r=>!r.has(b.TSUMO));return`${new en(n).toString()}${e}${t}`}get called(){return this.data.called}get reached(){return this.data.reached}get drawn(){return this.data.tsumo}get menzen(){return!this.called.some(t=>!(t instanceof U))}getArrayLen(t){return this.data[t].length}sum(t){let e=0;for(let n=1;n<this.getArrayLen(t);n++)e+=this.get(t,n);return e}get(t,e){return t==d.BACK?this.data[t][1]:this.data[t][e]}inc(t){const e=[];for(let n of t){if(n.t!=d.BACK&&this.get(n.t,n.n)>=4)throw this.dec(e),new Error(`unable to increase ${n} in ${this.toString()}`);if(e.push(n),j(n)&&(this.data[n.t][5]+=1),n.t==d.BACK?this.data[n.t][1]+=1:this.data[n.t][n.n]+=1,V(n)&&this.get(n.t,5)==4&&this.get(n.t,0)==0){this.data[n.t][0]=1;const i=e.pop().clone({n:0});e.push(i)}}return e}dec(t){const e=[];for(let n of t){if(this.get(n.t,n.n)<1)throw this.inc(e),new Error(`unable to decrease ${n.toString()} in ${this.toString()}`);if(e.push(n),j(n)&&(this.data[n.t][5]-=1),n.t==d.BACK?this.data[n.t][1]-=1:this.data[n.t][n.n]-=1,V(n)&&this.get(n.t,5)==0&&this.get(n.t,0)>0){this.data[n.t][0]=0;const i=e.pop().clone({n:0});e.push(i)}}return e}draw(t){const e=t.clone({add:b.TSUMO});this.inc([e]),this.data.tsumo=e}discard(t){this.dec([t]),this.data.tsumo=null}reach(){if(!this.menzen)throw new Error("cannot reach");if(this.data.reached)throw new Error("already reached");this.data.reached=!0}call(t){if(!(t instanceof ft||t instanceof ct||t instanceof ut))throw new Error(`unexpected input ${t} ${t.type}`);const e=t.tiles.filter(n=>!n.has(b.HORIZONTAL));if(e.length!=t.tiles.length-1)throw new Error(`removal: ${e} block: ${t}`);this.dec(e),this.data.called=[...this.called,t],this.data.tsumo=null}kan(t){if(t instanceof U){let e=t.tiles[0];j(e)&&(e=new g(e.t,5)),this.dec([e,e,e,e]),this.data.called=[...this.called,t],this.data.tsumo=null;return}if(t instanceof at){const e=this.data.called.findIndex(i=>i.is(_.PON)&&i.tiles[0].equals(t.tiles[0],!0));if(e==-1)throw new Error(`unable to find ${t.tiles[0]}`);let n=t.tiles[0];j(n)&&(n=new g(n.t,5)),this.dec([n]),this.data.called=[...this.called.slice(0,e),...this.called.slice(e+1),t],this.data.tsumo=null;return}throw new Error(`unexpected input ${t}`)}clone(){const t=new He(this.toString());return t.data.reached=this.data.reached,t}}class $e{constructor(t){S(this,"hand");this.hand=t}calc(){return Math.min(this.sevenPairs(),this.thirteenOrphans(),this.fourSetsOnePair())}sevenPairs(){if(this.hand.called.length>0)return 1/0;let t=0,e=0;for(let n of Object.values(d))if(n!=d.BACK)for(let i=1;i<this.hand.getArrayLen(n);i++)this.hand.get(n,i)==2&&t++,this.hand.get(n,i)==1&&e++;return t>7&&(t=7),t+e>=7&&(e=7-t),13-2*t-e}thirteenOrphans(){if(this.hand.called.length>0)return 1/0;let t=0,e=0;for(let n of Object.values(d)){if(n==d.BACK)continue;const i=n==d.Z?Ae:yt;for(let r of i)this.hand.get(n,r)>=1&&t++,this.hand.get(n,r)>=2&&e++}return e>=1?12-t:13-t}fourSetsOnePair(){const t=n=>{const i=[0,0,0],r=d.Z;for(let m=1;m<this.hand.getArrayLen(r);m++)this.hand.get(r,m)>=3?i[0]++:this.hand.get(r,m)==2?i[1]++:this.hand.get(r,m)==1&&i[2]++;const o=[0,0,0],a=this.hand.get(d.BACK,0),c=a%3;o[0]=Math.floor(a/3),c==2&&(o[1]=1),c==1&&(o[2]=1);let h=13;const l=this.commonByType(d.M),u=this.commonByType(d.P),f=this.commonByType(d.S);for(let m of[l.patternA,l.patternB])for(let p of[u.patternA,u.patternB])for(let y of[f.patternA,f.patternB]){const w=[this.hand.called.length,0,0];for(let O=0;O<3;O++)w[O]+=m[O]+p[O]+y[O]+i[O]+o[O];let x=this.calcCommon(w[0],w[1],w[2],n);x<h&&(h=x)}return h};let e=t(!1);for(let n of Object.values(d))for(let i=1;i<this.hand.getArrayLen(n);i++)if(this.hand.get(n,i)>=2){const r=this.hand.dec([new g(n,i),new g(n,i)]),o=t(!0);this.hand.inc(r),o<e&&(e=o)}return e}commonByType(t,e=1){if(t==d.BACK||t==d.Z)throw new Error(`expect number type but ${t}`);if(e>9)return this.groupRemainingTiles(t);let n=this.commonByType(t,e+1);if(e<=7&&this.hand.get(t,e)>0&&this.hand.get(t,e+1)>0&&this.hand.get(t,e+2)>0){const i=this.hand.dec([new g(t,e),new g(t,e+1),new g(t,e+2)]),r=this.commonByType(t,e);this.hand.inc(i),r.patternA[0]++,r.patternB[0]++,(r.patternA[2]<n.patternA[2]||r.patternA[2]==n.patternA[2]&&r.patternA[1]<n.patternA[1])&&(n.patternA=r.patternA),(r.patternB[0]>n.patternB[0]||r.patternB[0]==n.patternB[0]&&r.patternB[1]>n.patternB[1])&&(n.patternB=r.patternB)}if(this.hand.get(t,e)>=3){const i=this.hand.dec([new g(t,e),new g(t,e),new g(t,e)]),r=this.commonByType(t,e);this.hand.inc(i),r.patternA[0]++,r.patternB[0]++,(r.patternA[2]<n.patternA[2]||r.patternA[2]==n.patternA[2]&&r.patternA[1]<n.patternA[1])&&(n.patternA=r.patternA),(r.patternB[0]>n.patternB[0]||r.patternB[0]==n.patternB[0]&&r.patternB[1]>n.patternB[1])&&(n.patternB=r.patternB)}return n}groupRemainingTiles(t){let e=0,n=0,i=0;for(let r=1;r<this.hand.getArrayLen(t);r++)i+=this.hand.get(t,r),r<=7&&this.hand.get(t,r+1)==0&&this.hand.get(t,r+2)==0&&(e+=i>>1,n+=i%2,i=0);return e+=i>>1,n+=i%2,{patternA:[0,e,n],patternB:[0,e,n]}}calcCommon(t,e,n,i){let r=i?4:5;return t>4&&(e+=t-4,t=4),t+e>4&&(n+=t+e-4,e=4-t),t+e+n>r&&(n=r-t-e),i&&e++,13-t*3-e*2-n}}class Di{constructor(t){S(this,"hand");this.hand=t}calc(t){return this.hand.drawn!=null&&(t=this.hand.drawn),this.markDrawn([...this.sevenPairs(),...this.thirteenOrphans(),...this.nineGates(),...this.fourSetsOnePair()],t)}markDrawn(t,e){if(t.length==0)return[];const n=this.hand.drawn!=null||e.has(b.TSUMO)?b.TSUMO:b.RON,i=[];for(let o=0;o<t.length;o++){const a=t[o],c={};for(let h=0;h<a.length;h++){const l=a[h];if(l.isCalled())continue;const u=l.tiles.findIndex(m=>m.equals(e,!0));if(u<0)continue;const f=Ci(l);c[f]||(c[f]=!0,i.push([o,h,u]))}}if(i.length==0)throw new Error(`found no tile ${e.toString()} in hands ${t[0].toString()}`);const r=[];for(let[o,a,c]of i){const l=t[o].map(m=>m.clone()),u=l[a],f=u.tiles[c].clone({add:n});l[a]=u.clone({replace:{idx:c,tile:f}}),r.push(l)}return r}sevenPairs(){if(this.hand.called.length>0)return[];const t=[];for(let e of Object.values(d))if(e!=d.BACK)for(let n=1;n<this.hand.getArrayLen(e);n++){const i=this.hand.get(e,n);if(i==2)t.push(new Z(new g(e,n),new g(e,n)));else{if(i==0)continue;return[]}}return[t]}thirteenOrphans(){const t=[];let e="";for(let n of Object.values(d)){if(n==d.BACK)continue;const i=n==d.Z?Ae:yt;for(let r of i)if(this.hand.get(n,r)==1)t.push(new Yn(new g(n,r)));else if(this.hand.get(n,r)==2&&e=="")t.unshift(new Z(new g(n,r),new g(n,r)));else return[]}return[t]}nineGates(){const t=(e,n,i)=>i.includes(this.hand.get(e,n));for(let e of Object.values(d)){if(e==d.BACK||e==d.Z)continue;const n=t(e,1,[3,4])&&t(e,9,[3,4])&&t(e,2,[1,2])&&t(e,3,[1,2])&&t(e,4,[1,2])&&t(e,5,[1,2])&&t(e,6,[1,2])&&t(e,7,[1,2])&&t(e,8,[1,2]),i=this.hand.sum(e)==14;if(n&&i)return[[new en(this.hand.hands)]]}return[]}fourSetsOnePair(){let t=[];for(let e of Object.values(d))for(let n=1;n<this.hand.getArrayLen(e);n++)if(this.hand.get(e,n)>=2){const i=this.hand.dec([new g(e,n),new g(e,n)]),r=this.commonAll().filter(o=>o.length==4).map(o=>(o.unshift(new Z(i[0],i[1])),o));t=[...t,...r],this.hand.inc(i)}return t}commonAll(){const t=()=>{const r=[],o=d.Z;for(let a=1;a<this.hand.getArrayLen(o);a++)if(this.hand.get(o,a)!=0){if(this.hand.get(o,a)!=3)return[];r.push(new ot([new g(o,a),new g(o,a),new g(o,a)]))}return r.length==0?[]:[r]},e=()=>{const r=[],o=d.BACK,a=this.hand.get(o,0);return a<3?[]:(Array(Math.floor(a/3)).fill(void 0).map(c=>{r.push(new ot([new g(o,0),new g(o,0),new g(o,0)]))}),r.length==0?[]:[r])},n=[this.commonByType(d.M),this.commonByType(d.P),this.commonByType(d.S),t(),e(),[this.hand.called.concat()]].sort((r,o)=>o.length-r.length),i=n[0].concat();for(let r=0;r<i.length;r++)for(let o=1;o<n.length;o++)for(let a of n[o])i[r]=[...i[r],...a];return i}commonByType(t,e=1){if(e>9)return[];if(this.hand.get(t,e)==0)return this.commonByType(t,e+1);const n=[];if(e<=7&&this.hand.get(t,e)>0&&this.hand.get(t,e+1)>0&&this.hand.get(t,e+2)>0){const i=this.hand.dec([new g(t,e),new g(t,e+1),new g(t,e+2)]),r=this.commonByType(t,e);this.hand.inc(i),r.length==0&&r.push([]);for(let o of r)o.unshift(new bt([i[0],i[1],i[2]])),n.push(o)}if(this.hand.get(t,e)==3){const i=this.hand.dec([new g(t,e),new g(t,e),new g(t,e)]),r=this.commonByType(t,e);this.hand.inc(i),r.length==0&&r.push([]);for(let o of r)o.unshift(new ot([i[0],i[1],i[2]])),n.push(o)}return n}}const Ae=[1,2,3,4,5,6,7],yt=[1,9],Le=s=>{var e;const t=s.boardContext;return{...s,hand:s.hand.map(W.deserialize),boardContext:{...t,doraMarkers:t.doraMarkers.map(g.from),blindDoraMarkers:(e=t.blindDoraMarkers)==null?void 0:e.map(g.from)}}};class $n{constructor(t,e){S(this,"hand");S(this,"cfg");this.hand=t,this.cfg={doras:e.doraMarkers.map(n=>Ws(n)),blindDoras:e.blindDoraMarkers==null?[]:e.blindDoraMarkers.map(n=>Ws(n)),roundWind:g.from(e.round.substring(0,2)),myWind:g.from(e.myWind),reached:e.reached??0,sticks:e.sticks??{dead:0,reach:0},replacementWin:e.replacementWin??!1,quadWin:e.quadWin??!1,finalWallWin:e.finalWallWin??!1,finalDiscardWin:e.finalDiscardWin??!1,oneShotWin:e.oneShotWin??!1,orig:e}}calc(t){const e=this.calcPatterns(t);if(e.length==0)return!1;let n=[0,0],i=0;for(let p=0;p<e.length;p++){const y=e[p],w=y.points.reduce((x,O)=>x+O.double,0);(w>n[0]||w==n[0]&&y.fu>n[1])&&(i=p,n[0]=w,n[1]=y.fu)}const r=(p,y=100)=>Math.ceil(p/y)*y,o=n[1]!=25?r(n[1],10):25,a=n[0];let c=o*2**(a+2);switch(a){case 26:c=16e3;break;case 13:c=8e3;break;case 12:case 11:c=6e3;break;case 10:case 9:case 8:c=6e3;break;case 7:case 6:c=4e3;break;case 5:c=2e3;break}a>13&&a<26&&(c=8e3);const h=e[i].hand.some(p=>p.tiles.some(y=>y.has(b.TSUMO))),l=this.cfg.orig.myWind,u=l==v.E,f=G(0);if(h){const p=this.cfg.sticks.dead*100;if(u){const y=r(c*2);f[v.E]+=y*3+p*3,f[v.S]-=y+p,f[v.W]-=y+p,f[v.N]-=y+p}else for(let y of Object.values(v)){if(y==l)continue;const w=y==v.E?2:1,x=r(c*w)+p;f[y]-=x,f[l]+=x}}else{const p=this.cfg.sticks.dead*300;if(this.cfg.orig.ronWind==null)throw new Error("ron wind is not specified in the parameters");const w=r(c*(u?6:4))+p;f[l]+=w,f[this.cfg.orig.ronWind]-=w}return f[l]+=1e3*this.cfg.sticks.reach,{deltas:f,sum:a,fu:o,points:e[i].points,point:f[l],hand:e[i].hand,boardContext:this.cfg.orig}}calcPatterns(t){const e=[];if(t.length==0)return e;for(let n of t){const i=[...this.dA13(n),...this.dB13(n),...this.dC13(n),...this.dD13(n),...this.dE13(n),...this.dF13(n),...this.dG13(n),...this.dH13(n),...this.dI13(n),...this.dJ13(n),...this.dK13(n)];i.length!=0&&e.push({points:i,fu:30,hand:n})}if(e.length>0)return e;for(let n of t){const i=this.calcFu(n),r=[...this.dA1(n),...this.dB1(n),...this.dC1(n),...this.dD1(n),...this.dE1(n),...this.dF1(n),...this.dG1(n),...this.dH1(n),...this.dI1(n),...this.dJ1(n),...this.dK1(n),...this.dA2(n),...this.dB2(n),...this.dC2(n),...this.dD2(n),...this.dE2(n),...this.dF2(n),...this.dG2(n),...this.dH2(n),...this.dI2(n),...this.dJ2(n),...this.dA3(n),...this.dB3(n),...this.dC3(n),...this.dA6(n)];r.length>0&&r.push(...this.dX1(n)),e.push({points:r,fu:i,hand:n})}return e}minus(){return this.hand.menzen?0:1}dA1(t){return this.cfg.reached==1?[{name:"立直",double:1}]:this.cfg.reached==2?[{name:"ダブルリーチ",double:2}]:[]}dB1(t){return this.minus()!=0?[]:(this.hand.drawn==null,t.some(n=>n.tiles.some(i=>i.has(b.TSUMO)))?[{name:"門前清自摸和",double:1}]:[])}dC1(t){if(this.minus()!=0)return[];const e="平和",n=this.calcFu(t);return n==20?[{name:e,double:1}]:!t.some(i=>i.tiles.some(r=>r.has(b.TSUMO)))&&n==30?[{name:e,double:1}]:[]}dD1(t){return t.some(n=>n.tiles.some(i=>i.t==d.Z||yt.includes(i.n)))?[]:[{name:"断么九",double:1}]}dE1(t){return this.minus()!=0?[]:$s(t)==1?[{name:"一盃口",double:1}]:[]}dF1(t){const e=[];return t.forEach(n=>{if(n instanceof Z)return;const i=n.tiles[0];i.t==d.Z&&(i.equals(this.cfg.myWind)?e.push({name:"自風",double:1}):i.equals(this.cfg.roundWind)?e.push({name:"場風",double:1}):i.n==5?e.push({name:"白",double:1}):i.n==6?e.push({name:"發",double:1}):i.n==7&&e.push({name:"中",double:1}))}),e}dG1(t){return this.cfg.oneShotWin?[{name:"一発",double:1}]:[]}dH1(t){return this.cfg.replacementWin?[{name:"嶺上開花",double:1}]:[]}dI1(t){return this.cfg.quadWin?[{name:"搶槓",double:1}]:[]}dJ1(t){return this.cfg.finalWallWin?[{name:"海底摸月",double:1}]:[]}dK1(t){return this.cfg.finalDiscardWin?[{name:"河底撈魚",double:1}]:[]}dX1(t){let e=0,n=0,i=0;for(let o of t)for(let a of o.tiles){for(let c of this.cfg.doras)a.equals(c,!0)&&e++;for(let c of this.cfg.blindDoras)a.equals(c,!0)&&i++;j(a)&&n++}const r=[];return e>0&&r.push({name:"ドラ",double:e}),n>0&&r.push({name:"赤ドラ",double:n}),this.hand.reached&&i>0&&r.push({name:"裏ドラ",double:i}),r}dA2(t){return t.length==7?[{name:"七対子",double:2}]:[]}dB2(t){const e=n=>n instanceof bt||n instanceof ct;for(let n of t){if(!e(n))continue;const i=Et(n);if(i.t==d.Z)continue;const r=[d.M,d.P,d.S].filter(c=>c!=i.t),o=t.some(c=>{const h=new g(r[0],i.n);return e(c)&&h.equals(Et(c),!0)}),a=t.some(c=>{const h=new g(r[1],i.n);return e(c)&&h.equals(Et(c),!0)});if(o&&a)return[{name:"三色同順",double:2-this.minus()}]}return[]}dC2(t){return t.length==7?[]:t.every(n=>n instanceof U||n instanceof at||n instanceof ut||n instanceof ot||n instanceof ft||n instanceof Z)?[{name:"対々和",double:2}]:[]}dD2(t){return this.minus()!=0?[]:t.filter(n=>(n instanceof U||n instanceof ot)&&!n.tiles.some(i=>i.has(b.RON))).length>=3?[{name:"三暗刻",double:2}]:[]}dE2(t){return t.filter(n=>n instanceof U||n instanceof at||n instanceof ut).length>=3?[{name:"三槓子",double:2}]:[]}dF2(t){const e=n=>n instanceof U||n instanceof at||n instanceof ut||n instanceof ot||n instanceof ft;for(let n of t){if(!e(n))continue;const i=Et(n);if(i.t==d.Z)continue;const r=[d.M,d.P,d.S].filter(c=>c!=i.t),o=t.some(c=>{const h=new g(r[0],i.n);return e(c)&&h.equals(Et(c),!0)}),a=t.some(c=>{const h=new g(r[1],i.n);return e(c)&&h.equals(Et(c),!0)});if(o&&a)return[{name:"三色同刻",double:2}]}return[]}dG2(t){return t.filter(n=>{const i=n.tiles[0];return i.t==d.Z&&[5,6,7].includes(i.n)}).length==3?[{name:"小三元",double:2}]:[]}dH2(t){return t.every(n=>{const i=n.tiles[0].t==d.Z?Ae:yt;return n.tiles.every(r=>i.includes(r.n))})?[{name:"混老頭",double:2}]:[]}dI2(t){return t.length==7?[]:t.some(n=>n instanceof bt||n instanceof ct)?t.some(n=>n.tiles[0].t==d.Z)?t.every(n=>{const i=n.tiles[0].t==d.Z?Ae:yt;return n.tiles.some(r=>i.includes(r.n))})?[{name:"混全帯么九",double:2-this.minus()}]:[]:[]:[]}dJ2(t){if(this.minus()!=0)return[];let e={[d.M]:[0,0,0],[d.S]:[0,0,0],[d.P]:[0,0,0]};for(let n of t){const i=Et(n);i.t!=d.BACK&&i.t!=d.Z&&(n instanceof bt||n instanceof ct)&&(i.n==1&&e[i.t][0]++,i.n==4&&e[i.t][1]++,i.n==7&&e[i.t][2]++)}for(let n of Object.values(e))if(n.filter(i=>i>0).length==n.length)return[{name:"一気通貫",double:2-this.minus()}];return[]}dA3(t){if(!t.some(n=>n.tiles[0].t==d.Z))return[];for(let n of Object.values(d))if(t.every(r=>r.tiles[0].t==d.Z||r.tiles[0].t==n))return[{name:"混一色",double:3-this.minus()}];return[]}dB3(t){return t.length==7?[]:t.some(n=>n instanceof bt||n instanceof ct)?t.some(n=>n.tiles[0].t==d.Z)?[]:t.every(n=>n.tiles.some(i=>yt.includes(i.n)))?[{name:"純全帯么九色",double:3-this.minus()}]:[]:[]}dC3(t){return this.minus()!=0?[]:$s(t)==2?[{name:"ニ盃口",double:3}]:[]}dA6(t){if(t.some(e=>e.tiles[0].t==d.Z))return[];for(let e of Object.values(d)){if(e==d.Z)continue;if(t.every(i=>i.tiles[0].t==e))return[{name:"清一色",double:6-this.minus()}]}return[]}dA13(t){return t.length!=13?[]:t.some(n=>n instanceof Z&&n.tiles.some(i=>i.has(b.TSUMO)||i.has(b.RON)))?[{name:"国士無双13面待ち",double:26}]:[{name:"国士無双",double:13}]}dB13(t){return t.length==1?[{name:"九蓮宝燈",double:13}]:[]}dC13(t){return t.length==7?[]:t.every(i=>i instanceof U||i instanceof ot&&!i.tiles.some(r=>r.has(b.RON))||i instanceof Z)?t.some(i=>i instanceof Z&&i.tiles.every(r=>r.has(b.TSUMO)||r.has(b.RON)))?[{name:"四暗刻単騎待ち",double:26}]:[{name:"四暗刻",double:13}]:[]}dD13(t){if(t.length==13)return[];const e=[5,6,7];return t.filter(i=>!(i instanceof Z)&&i.tiles.some(r=>r.t==d.Z&&e.includes(r.n))).length==3?[{name:"大三元",double:13}]:[]}dE13(t){return t.every(n=>n.tiles[0].t==d.Z)?[{name:"字一色",double:13}]:[]}dF13(t){return t.every(n=>n.tiles.every(i=>i.t!=d.Z&&yt.includes(i.n)))?[{name:"清老頭",double:13}]:[]}dG13(t){return t.filter(n=>n instanceof U||n instanceof at||n instanceof ut).length==4?[{name:"四槓子",double:13}]:[]}dH13(t){if(t.length==13)return[];if(t.length==7)return[];const e=[1,2,3,4];return t.filter(r=>r.tiles.some(o=>o.t==d.Z&&e.includes(o.n))).length==4?t.find(r=>r instanceof Z).tiles.some(r=>r.t==d.Z&&e.includes(r.n))?[{name:"小四喜",double:13}]:[{name:"大四喜",double:13}]:[]}dI13(t){const e=n=>!!(n.equals(new g(d.Z,6))||n.t==d.S&&[2,3,4,6,8].includes(n.n));return t.every(n=>n.tiles.every(i=>e(i)))?[{name:"緑一色",double:13}]:[]}dJ13(t){return[]}dK13(t){return[]}calcFu(t){let n=20;const i=this.cfg.myWind.n,r=this.cfg.roundWind.n;if(t.length==7)return 25;const o=t.find(p=>p.tiles.some(y=>y.has(b.TSUMO)||y.has(b.RON))),a=this.minus()==1,c=o.tiles.some(p=>p.has(b.TSUMO)),h=(p,y)=>{const w=p.tiles[0];return w.t==d.Z&&[5,6,7].includes(w.n)||w.t==d.Z&&[i,r].includes(w.n)||yt.includes(w.n)?y*2:y};for(let p of t)switch(!0){case p instanceof ot:let y=p.tiles.some(w=>w.has(b.RON))?2:4;n+=h(p,y);break;case p instanceof ft:n+=h(p,2);break;case(p instanceof ut||p instanceof at):n+=h(p,8);break;case p instanceof U:n+=h(p,16);break}n+=(p=>{if(p instanceof ot)return 0;if(p instanceof Z)return 2;const y=p.tiles,w=y.findIndex(x=>x.has(b.TSUMO)||x.has(b.RON));return w==1||w==0&&y[2].n==9||w==2&&y[0].n==1?2:0})(o);let f=t.find(p=>p instanceof Z).tiles[0];f.t==d.Z&&([5,6,7].includes(f.n)&&(n+=2),f.n==r&&(n+=2),f.n==i&&(n+=2));let m=!1;return!a&&n==20&&(m=!0),c&&!m&&(n+=2),!c&&!a&&(n+=10),!c&&!a&&n==30&&(m=!0),a&&n==20&&(n=30),n}}const Ci=s=>s.tiles.reduce((t,e)=>`${t}${e.n}${e.t}`,""),$s=s=>{let t={};for(let n of s){if(!(n instanceof bt))continue;const i=Ci(n);t[i]==null?t[i]=1:t[i]++}let e=0;for(let n in t)t[n]>=2&&e++;return e},Et=s=>[...s.tiles].sort(ye)[0],Ws=s=>{let t=j(s)?5:s.n,e=s.t;return new g(e,t%9+1)};class zt{static calcCandidates(t,e,n){C(e.length>0,"choices to discard is zero");const i=new Map;let r=Number.POSITIVE_INFINITY;for(let o of e){const a=t.dec([o]),c=zt.candidateTiles(t,n);t.inc(a);const h=n!=null&&n.arrangeRed&&j(o)?o.clone({n:5,removeAll:!0}):o.clone({removeAll:!0});c.shanten<r?(i.clear(),i.set(h.toString(),{shanten:c.shanten,candidates:c.candidates,tile:h}),r=c.shanten):c.shanten==r&&i.set(h.toString(),{shanten:c.shanten,candidates:c.candidates,tile:h})}return Array.from(i.values())}static candidateTiles(t,e){let n=Number.POSITIVE_INFINITY,i=[];const r=new $e(t);for(let o of Object.values(d))if(o!=d.BACK)for(let a=1;a<t.getArrayLen(o);a++){if(t.get(o,a)>=4)continue;const c=new g(o,a),h=t.inc([c]),l=e!=null&&e.fourSetsOnePair?r.fourSetsOnePair():r.calc();t.dec(h),l<n?(n=l,i=[c]):l==n&&i.push(c)}return{shanten:n,candidates:i}}static partialCandidateTiles(t,e){const n=new He(t,!0);return Array(13-n.hands.length).fill(void 0).map(()=>n.inc([new g(d.BACK,0)])),zt.candidateTiles(n,e)}}const Wn=()=>{const s=new Set;return{on(t){s.add(t)},off(t){s.delete(t)},offAll(){s.clear()},emit(t){s.forEach(e=>e(t))}}};function Ri(s){var r;const t=["RON","DAI_KAN","PON","CHI"],e=s.map(o=>o.choices),i=$i(e,t).map(o=>s[o]);return{events:i,type:Wi(t,(r=i[0])==null?void 0:r.choices)}}function Hi(s){var r;const t=["TSUMO","REACH","AN_KAN","SHO_KAN","DRAWN_GAME_BY_NINE_TILES","DISCARD"],e=s.map(o=>o.choices),i=$i(e,t).map(o=>s[o]);return{events:i,type:Wi(t,(r=i[0])==null?void 0:r.choices)}}function $i(s,t){let e=[],n=Number.POSITIVE_INFINITY;for(let i=0;i<s.length;i++){const r=s[i];if(nc(r,t)){const o=sc(t,r);o<n?(n=o,e=[i]):o===n&&e.push(i)}}return e}function nc(s,t){return t.some(e=>!!s[e])}function sc(s,t){for(let e=0;e<s.length;e++){const n=s[e];if(t[n])return e}return Number.POSITIVE_INFINITY}function Wi(s,t){if(t==null)return!1;for(const e of s)if(t[e])return e;return!1}const pe=()=>{const s=Wn(),t=Wn(),e={emit:s.emit,on:i=>t.on(i)},n={emit:t.emit,on:i=>s.on(i)};return[e,n]},Bi=()=>{const s=Wn();return{emit:n=>{s.emit(n)},on:n=>{s.on(n)}}};class xe{constructor(t){S(this,"reachValue",1e3);S(this,"m");this.m=t}get summary(){return structuredClone(this.m)}reach(t){this.m[t]-=this.reachValue}restoreReachStick(t){this.m[t]+=this.reachValue}update(t,e){for(let n in e){const i=e[n],r=t[i];this.m[n]+=r}}}class ke{constructor(t,e){S(this,"pToW",{});S(this,"wToP",G(""));S(this,"round");S(this,"sticks");this.round=(e==null?void 0:e.round)??"1w1",this.sticks=(e==null?void 0:e.sticks)??{reach:0,dead:0},this.pToW=t;for(let n in this.pToW)this.wToP[this.pToW[n]]=n}update(){for(let t in this.pToW){const e=At(this.pToW[t]);this.pToW[t]=e,this.wToP[e]=t}}incrementDeadStick(){this.sticks.dead++}incrementReachStick(){this.sticks.reach++}nextRound(){const t=ge(this.round);this.round=t,this.update()}decrementReachStick(){this.sticks.reach--,C(this.sticks.reach>=0)}resetDeadStick(){this.sticks.dead=0}resetReachStick(){this.sticks.reach=0}is(t){return this.round==t}wind(t){return this.pToW[t]}playerID(t){return this.wToP[t]}get playerMap(){return structuredClone(this.pToW)}}function ds(s){for(let t=s.length-1;t>0;t--){const e=Math.floor(Math.random()*(t+1));[s[t],s[e]]=[s[e],s[t]]}return s}class zi{constructor(t=!1){S(this,"c",{[d.M]:[1,4,4,4,4,4,4,4,4,4],[d.S]:[1,4,4,4,4,4,4,4,4,4],[d.P]:[1,4,4,4,4,4,4,4,4,4],[d.Z]:[0,4,4,4,4,4,4,4]});S(this,"safeMap",G({},!0));this.disable=t}get(t){return t.t==d.BACK?0:j(t)?this.c[t.t][5]:this.c[t.t][t.n]}dec(...t){if(!this.disable){for(let e of t)if(e.t!=d.BACK){if(this.get(e)<=0)throw new Error(`cannot decrease ${e.toString()} due to zero`);this.c[e.t][e.n]-=1,j(e)&&(this.c[e.t][5]-=1)}}}addTileToSafeMap(t,e){this.disable||(this.safeMap[e][this.key(t.t,t.n)]=!0)}isSafeTile(t,e,n){return this.safeMap[n][this.key(t,e)]}key(t,e){return e==0&&(e=5),`${t}${e}`}reset(){this.c={[d.M]:[1,4,4,4,4,4,4,4,4,4],[d.S]:[1,4,4,4,4,4,4,4,4,4],[d.P]:[1,4,4,4,4,4,4,4,4,4],[d.Z]:[0,4,4,4,4,4,4,4]}}}class ps{constructor(){S(this,"m",[])}discard(t,e){this.m.push({w:e,t})}get lastTile(){const t=this.m.at(-1);return C(t!=null,`lastTile is null(${t}). river: ${JSON.stringify(this.m,null,2)}`),t}discards(t){return t==null?[...this.m]:this.m.filter(e=>e.w==t)}markCalled(){this.lastTile.callMarker=!0}cannotContinue(){const t=this.discards();if(t.length!=4)return!1;let e=t[0].t;if(e.isNum())return!1;for(let n=0;n<4;n++)if(!e.equals(t[n].t))return!1;return!0}}function ic(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global}function rc(){const s=ic();if(s.__xstate__)return s.__xstate__}const oc=s=>{if(typeof window>"u")return;const t=rc();t&&t.register(s)};class Bs{constructor(t){this._process=t,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(t){const e={value:t,next:null};if(this._current){this._last.next=e,this._last=e;return}this._current=e,this._last=e,this._active&&this.flush()}flush(){for(;this._current;){const t=this._current;this._process(t.value),this._current=t.next}this._last=null}}const Pi=".",ac="",ji="",cc="#",hc="*",Li="xstate.init",Bn="xstate.stop";function lc(s,t){return{type:`xstate.after.${s}.${t}`}}function zn(s,t){return{type:`xstate.done.state.${s}`,output:t}}function uc(s,t){return{type:`xstate.done.actor.${s}`,output:t,actorId:s}}function fc(s,t){return{type:`xstate.error.actor.${s}`,error:t,actorId:s}}function Ki(s){return{type:Li,input:s}}function gt(s){setTimeout(()=>{throw s})}const dc=typeof Symbol=="function"&&Symbol.observable||"@@observable";function Ui(s,t){const e=zs(s),n=zs(t);return typeof n=="string"?typeof e=="string"?n===e:!1:typeof e=="string"?e in n:Object.keys(e).every(i=>i in n?Ui(e[i],n[i]):!1)}function ms(s){if(qi(s))return s;let t=[],e="";for(let n=0;n<s.length;n++){switch(s.charCodeAt(n)){case 92:e+=s[n+1],n++;continue;case 46:t.push(e),e="";continue}e+=s[n]}return t.push(e),t}function zs(s){if(qc(s))return s.value;if(typeof s!="string")return s;const t=ms(s);return pc(t)}function pc(s){if(s.length===1)return s[0];const t={};let e=t;for(let n=0;n<s.length-1;n++)if(n===s.length-2)e[s[n]]=s[n+1];else{const i=e;e={},i[s[n]]=e}return t}function Ps(s,t){const e={},n=Object.keys(s);for(let i=0;i<n.length;i++){const r=n[i];e[r]=t(s[r],r,s,i)}return e}function Fi(s){return qi(s)?s:[s]}function St(s){return s===void 0?[]:Fi(s)}function Pn(s,t,e,n){return typeof s=="function"?s({context:t,event:e,self:n}):s}function qi(s){return Array.isArray(s)}function mc(s){return s.type.startsWith("xstate.error.actor")}function Gt(s){return Fi(s).map(t=>typeof t>"u"||typeof t=="string"?{target:t}:t)}function Gi(s){if(!(s===void 0||s===ac))return St(s)}function jn(s,t,e){var r,o,a;const n=typeof s=="object",i=n?s:void 0;return{next:(r=n?s.next:s)==null?void 0:r.bind(i),error:(o=n?s.error:t)==null?void 0:o.bind(i),complete:(a=n?s.complete:e)==null?void 0:a.bind(i)}}function js(s,t){return`${t}.${s}`}function gs(s,t){const e=t.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!e)return s.implementations.actors[t];const[,n,i]=e,o=s.getStateNodeById(i).config.invoke;return(Array.isArray(o)?o[n]:o).src}function Ls(s,t){return`${s.sessionId}.${t}`}let gc=0;function yc(s,t){const e=new Map,n=new Map,i=new WeakMap,r=new Set,o={},{clock:a,logger:c}=t,h={schedule:(f,m,p,y,w=Math.random().toString(36).slice(2))=>{const x={source:f,target:m,event:p,delay:y,id:w,startedAt:Date.now()},O=Ls(f,w);u._snapshot._scheduledEvents[O]=x;const $=a.setTimeout(()=>{delete o[O],delete u._snapshot._scheduledEvents[O],u._relay(f,m,p)},y);o[O]=$},cancel:(f,m)=>{const p=Ls(f,m),y=o[p];delete o[p],delete u._snapshot._scheduledEvents[p],y!==void 0&&a.clearTimeout(y)},cancelAll:f=>{for(const m in u._snapshot._scheduledEvents){const p=u._snapshot._scheduledEvents[m];p.source===f&&h.cancel(f,p.id)}}},l=f=>{if(!r.size)return;const m={...f,rootId:s.sessionId};r.forEach(p=>{var y;return(y=p.next)==null?void 0:y.call(p,m)})},u={_snapshot:{_scheduledEvents:((t==null?void 0:t.snapshot)&&t.snapshot.scheduler)??{}},_bookId:()=>`x:${gc++}`,_register:(f,m)=>(e.set(f,m),f),_unregister:f=>{e.delete(f.sessionId);const m=i.get(f);m!==void 0&&(n.delete(m),i.delete(f))},get:f=>n.get(f),_set:(f,m)=>{const p=n.get(f);if(p&&p!==m)throw new Error(`Actor with system ID '${f}' already exists.`);n.set(f,m),i.set(m,f)},inspect:f=>{const m=jn(f);return r.add(m),{unsubscribe(){r.delete(m)}}},_sendInspectionEvent:l,_relay:(f,m,p)=>{u._sendInspectionEvent({type:"@xstate.event",sourceRef:f,actorRef:m,event:p}),m._send(p)},scheduler:h,getSnapshot:()=>({_scheduledEvents:{...u._snapshot._scheduledEvents}}),start:()=>{const f=u._snapshot._scheduledEvents;u._snapshot._scheduledEvents={};for(const m in f){const{source:p,target:y,event:w,delay:x,id:O}=f[m];h.schedule(p,y,w,x,O)}},_clock:a,_logger:c};return u}const ys=1;let q=function(s){return s[s.NotStarted=0]="NotStarted",s[s.Running=1]="Running",s[s.Stopped=2]="Stopped",s}({});const wc={clock:{setTimeout:(s,t)=>setTimeout(s,t),clearTimeout:s=>clearTimeout(s)},logger:console.log.bind(console),devTools:!1};class _c{constructor(t,e){this.logic=t,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new Bs(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=q.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this._systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];const n={...wc,...e},{clock:i,logger:r,parent:o,syncSnapshot:a,id:c,systemId:h,inspect:l}=n;this.system=o?o.system:yc(this,{clock:i,logger:r}),l&&!o&&this.system.inspect(jn(l)),this.sessionId=this.system._bookId(),this.id=c??this.sessionId,this.logger=(e==null?void 0:e.logger)??this.system._logger,this.clock=(e==null?void 0:e.clock)??this.system._clock,this._parent=o,this._syncSnapshot=a,this.options=n,this.src=n.src??t,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:u=>{this._deferred.push(u)},system:this.system,stopChild:u=>{if(u._parent!==this)throw new Error(`Cannot stop child actor ${u.id} of ${this.id} because it is not a child`);u._stop()},emit:u=>{const f=this.eventListeners.get(u.type),m=this.eventListeners.get("*");if(!f&&!m)return;const p=new Set([...f?f.values():[],...m?m.values():[]]);for(const y of Array.from(p))y(u)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),h&&(this._systemId=h,this.system._set(h,this)),this._initState((e==null?void 0:e.snapshot)??(e==null?void 0:e.state)),h&&this._snapshot.status!=="active"&&this.system._unregister(this)}_initState(t){var e;try{this._snapshot=t?this.logic.restoreSnapshot?this.logic.restoreSnapshot(t,this._actorScope):t:this.logic.getInitialSnapshot(this._actorScope,(e=this.options)==null?void 0:e.input)}catch(n){this._snapshot={status:"error",output:void 0,error:n}}}update(t,e){var i,r;this._snapshot=t;let n;for(;n=this._deferred.shift();)try{n()}catch(o){this._deferred.length=0,this._snapshot={...t,status:"error",error:o}}switch(this._snapshot.status){case"active":for(const o of this.observers)try{(i=o.next)==null||i.call(o,t)}catch(a){gt(a)}break;case"done":for(const o of this.observers)try{(r=o.next)==null||r.call(o,t)}catch(a){gt(a)}this._stopProcedure(),this._complete(),this._doneEvent=uc(this.id,this._snapshot.output),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case"error":this._error(this._snapshot.error);break}this.system._sendInspectionEvent({type:"@xstate.snapshot",actorRef:this,event:e,snapshot:t})}subscribe(t,e,n){var r;const i=jn(t,e,n);if(this._processingStatus!==q.Stopped)this.observers.add(i);else switch(this._snapshot.status){case"done":try{(r=i.complete)==null||r.call(i)}catch(o){gt(o)}break;case"error":{const o=this._snapshot.error;if(!i.error)gt(o);else try{i.error(o)}catch(a){gt(a)}break}}return{unsubscribe:()=>{this.observers.delete(i)}}}on(t,e){let n=this.eventListeners.get(t);n||(n=new Set,this.eventListeners.set(t,n));const i=e.bind(void 0);return n.add(i),{unsubscribe:()=>{n.delete(i)}}}start(){if(this._processingStatus===q.Running)return this;this._syncSnapshot&&this.subscribe({next:n=>{n.status==="active"&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:n})},error:()=>{}}),this.system._register(this.sessionId,this),this._systemId&&this.system._set(this._systemId,this),this._processingStatus=q.Running;const t=Ki(this.options.input);switch(this.system._sendInspectionEvent({type:"@xstate.event",sourceRef:this._parent,actorRef:this,event:t}),this._snapshot.status){case"done":return this.update(this._snapshot,t),this;case"error":return this._error(this._snapshot.error),this}if(this._parent||this.system.start(),this.logic.start)try{this.logic.start(this._snapshot,this._actorScope)}catch(n){return this._snapshot={...this._snapshot,status:"error",error:n},this._error(n),this}return this.update(this._snapshot,t),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(t){let e,n;try{e=this.logic.transition(this._snapshot,t,this._actorScope)}catch(i){n={err:i}}if(n){const{err:i}=n;this._snapshot={...this._snapshot,status:"error",error:i},this._error(i);return}this.update(e,t),t.type===Bn&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===q.Stopped?this:(this.mailbox.clear(),this._processingStatus===q.NotStarted?(this._processingStatus=q.Stopped,this):(this.mailbox.enqueue({type:Bn}),this))}stop(){if(this._parent)throw new Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){var t;for(const e of this.observers)try{(t=e.complete)==null||t.call(e)}catch(n){gt(n)}this.observers.clear()}_reportError(t){if(!this.observers.size){this._parent||gt(t);return}let e=!1;for(const n of this.observers){const i=n.error;e||(e=!i);try{i==null||i(t)}catch(r){gt(r)}}this.observers.clear(),e&>(t)}_error(t){this._stopProcedure(),this._reportError(t),this._parent&&this.system._relay(this,this._parent,fc(this.id,t))}_stopProcedure(){return this._processingStatus!==q.Running?this:(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new Bs(this._process.bind(this)),this._processingStatus=q.Stopped,this.system._unregister(this),this)}_send(t){this._processingStatus!==q.Stopped&&this.mailbox.enqueue(t)}send(t){this.system._relay(void 0,this,t)}attachDevTools(){const{devTools:t}=this.options;t&&(typeof t=="function"?t:oc)(this)}toJSON(){return{xstate$$type:ys,id:this.id}}getPersistedSnapshot(t){return this.logic.getPersistedSnapshot(this._snapshot,t)}[dc](){return this}getSnapshot(){return this._snapshot}}function se(s,...[t]){return new _c(s,t)}function bc(s,t,e,n,{sendId:i}){const r=typeof i=="function"?i(e,n):i;return[t,r]}function Sc(s,t){s.defer(()=>{s.system.scheduler.cancel(s.self,t)})}function vc(s){function t(e,n){}return t.type="xstate.cancel",t.sendId=s,t.resolve=bc,t.execute=Sc,t}function Ac(s,t,e,n,{id:i,systemId:r,src:o,input:a,syncSnapshot:c}){const h=typeof o=="string"?gs(t.machine,o):o,l=typeof i=="function"?i(e):i;let u;return h&&(u=se(h,{id:l,src:o,parent:s.self,syncSnapshot:c,systemId:r,input:typeof a=="function"?a({context:t.context,event:e.event,self:s.self}):a})),[Pt(t,{children:{...t.children,[l]:u}}),{id:i,actorRef:u}]}function xc(s,{id:t,actorRef:e}){e&&s.defer(()=>{e._processingStatus!==q.Stopped&&e.start()})}function kc(...[s,{id:t,systemId:e,input:n,syncSnapshot:i=!1}={}]){function r(o,a){}return r.type="snapshot.spawnChild",r.id=t,r.systemId=e,r.src=s,r.input=n,r.syncSnapshot=i,r.resolve=Ac,r.execute=xc,r}function Tc(s,t,e,n,{actorRef:i}){const r=typeof i=="function"?i(e,n):i,o=typeof r=="string"?t.children[r]:r;let a=t.children;return o&&(a={...a},delete a[o.id]),[Pt(t,{children:a}),o]}function Oc(s,t){if(t){if(s.system._unregister(t),t._processingStatus!==q.Running){s.stopChild(t);return}s.defer(()=>{s.stopChild(t)})}}function Zi(s){function t(e,n){}return t.type="xstate.stopChild",t.actorRef=s,t.resolve=Tc,t.execute=Oc,t}function ws(s,t,e,n){const{machine:i}=n,r=typeof s=="function",o=r?s:i.implementations.guards[typeof s=="string"?s:s.type];if(!r&&!o)throw new Error(`Guard '${typeof s=="string"?s:s.type}' is not implemented.'.`);if(typeof o!="function")return ws(o,t,e,n);const a={context:t,event:e},c=r||typeof s=="string"?void 0:"params"in s?typeof s.params=="function"?s.params({context:t,event:e}):s.params:void 0;return"check"in o?o.check(n,a,o):o(a,c)}const _s=s=>s.type==="atomic"||s.type==="final";function ie(s){return Object.values(s.states).filter(t=>t.type!=="history")}function We(s,t){const e=[];if(t===s)return e;let n=s.parent;for(;n&&n!==t;)e.push(n),n=n.parent;return e}function Je(s){const t=new Set(s),e=Xi(t);for(const n of t)if(n.type==="compound"&&(!e.get(n)||!e.get(n).length))Ks(n).forEach(i=>t.add(i));else if(n.type==="parallel"){for(const i of ie(n))if(i.type!=="history"&&!t.has(i)){const r=Ks(i);for(const o of r)t.add(o)}}for(const n of t){let i=n.parent;for(;i;)t.add(i),i=i.parent}return t}function Yi(s,t){const e=t.get(s);if(!e)return{};if(s.type==="compound"){const i=e[0];if(i){if(_s(i))return i.key}else return{}}const n={};for(const i of e)n[i.key]=Yi(i,t);return n}function Xi(s){const t=new Map;for(const e of s)t.has(e)||t.set(e,[]),e.parent&&(t.has(e.parent)||t.set(e.parent,[]),t.get(e.parent).push(e));return t}function Ji(s,t){const e=Je(t);return Yi(s,Xi(e))}function bs(s,t){return t.type==="compound"?ie(t).some(e=>e.type==="final"&&s.has(e)):t.type==="parallel"?ie(t).every(e=>bs(s,e)):t.type==="final"}const an=s=>s[0]===cc;function Ec(s,t){return s.transitions.get(t)||[...s.transitions.keys()].filter(n=>{if(n===hc)return!0;if(!n.endsWith(".*"))return!1;const i=n.split("."),r=t.split(".");for(let o=0;o<i.length;o++){const a=i[o],c=r[o];if(a==="*")return o===i.length-1;if(a!==c)return!1}return!0}).sort((n,i)=>i.length-n.length).flatMap(n=>s.transitions.get(n))}function Ic(s){const t=s.config.after;if(!t)return[];const e=(i,r)=>{const o=lc(i,s.id),a=o.type;return s.entry.push(eh(o,{id:a,delay:i})),s.exit.push(vc(a)),a};return Object.keys(t).flatMap((i,r)=>{const o=t[i],a=typeof o=="string"?{target:o}:o,c=Number.isNaN(+i)?i:+i,h=e(c);return St(a).map(l=>({...l,event:h,delay:c}))}).map(i=>{const{delay:r}=i;return{...Dt(s,i.event,i),delay:r}})}function Dt(s,t,e){const n=Gi(e.target),i=e.reenter??!1,r=Dc(s,n),o={...e,actions:St(e.actions),guard:e.guard,target:r,source:s,reenter:i,eventType:t,toJSON:()=>({...o,source:`#${s.id}`,target:r?r.map(a=>`#${a.id}`):void 0})};return o}function Nc(s){const t=new Map;if(s.config.on)for(const e of Object.keys(s.config.on)){if(e===ji)throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');const n=s.config.on[e];t.set(e,Gt(n).map(i=>Dt(s,e,i)))}if(s.config.onDone){const e=`xstate.done.state.${s.id}`;t.set(e,Gt(s.config.onDone).map(n=>Dt(s,e,n)))}for(const e of s.invoke){if(e.onDone){const n=`xstate.done.actor.${e.id}`;t.set(n,Gt(e.onDone).map(i=>Dt(s,n,i)))}if(e.onError){const n=`xstate.error.actor.${e.id}`;t.set(n,Gt(e.onError).map(i=>Dt(s,n,i)))}if(e.onSnapshot){const n=`xstate.snapshot.${e.id}`;t.set(n,Gt(e.onSnapshot).map(i=>Dt(s,n,i)))}}for(const e of s.after){let n=t.get(e.eventType);n||(n=[],t.set(e.eventType,n)),n.push(e)}return t}function Mc(s,t){const e=typeof t=="string"?s.states[t]:t?s.states[t.target]:void 0;if(!e&&t)throw new Error(`Initial state node "${t}" not found on parent state node #${s.id}`);const n={source:s,actions:!t||typeof t=="string"?[]:St(t.actions),eventType:null,reenter:!1,target:e?[e]:[],toJSON:()=>({...n,source:`#${s.id}`,target:e?[`#${e.id}`]:[]})};return n}function Dc(s,t){if(t!==void 0)return t.map(e=>{if(typeof e!="string")return e;if(an(e))return s.machine.getStateNodeById(e);const n=e[0]===Pi;if(n&&!s.parent)return Ve(s,e.slice(1));const i=n?s.key+e:e;if(s.parent)try{return Ve(s.parent,i)}catch(r){throw new Error(`Invalid transition definition for state node '${s.id}':
|
|
8
8
|
${r.message}`)}else throw new Error(`Invalid target: "${e}" is not a valid target from the root node. Did you mean ".${e}"?`)})}function Vi(s){const t=Gi(s.config.target);return t?{target:t.map(e=>typeof e=="string"?Ve(s.parent,e):e)}:s.parent.initial}function Ct(s){return s.type==="history"}function Ks(s){const t=Qi(s);for(const e of t)for(const n of We(e,s))t.add(n);return t}function Qi(s){const t=new Set;function e(n){if(!t.has(n)){if(t.add(n),n.type==="compound")e(n.initial.target[0]);else if(n.type==="parallel")for(const i of ie(n))e(i)}}return e(s),t}function re(s,t){if(an(t))return s.machine.getStateNodeById(t);if(!s.states)throw new Error(`Unable to retrieve child state '${t}' from '${s.id}'; no child states exist.`);const e=s.states[t];if(!e)throw new Error(`Child state '${t}' does not exist on '${s.id}'`);return e}function Ve(s,t){if(typeof t=="string"&&an(t))try{return s.machine.getStateNodeById(t)}catch{}const e=ms(t).slice();let n=s;for(;e.length;){const i=e.shift();if(!i.length)break;n=re(n,i)}return n}function Qe(s,t){if(typeof t=="string"){const i=s.states[t];if(!i)throw new Error(`State '${t}' does not exist on '${s.id}'`);return[s,i]}const e=Object.keys(t),n=e.map(i=>re(s,i)).filter(Boolean);return[s.machine.root,s].concat(n,e.reduce((i,r)=>{const o=re(s,r);if(!o)return i;const a=Qe(o,t[r]);return i.concat(a)},[]))}function Cc(s,t,e,n){const r=re(s,t).next(e,n);return!r||!r.length?s.next(e,n):r}function Rc(s,t,e,n){const i=Object.keys(t),r=re(s,i[0]),o=Ss(r,t[i[0]],e,n);return!o||!o.length?s.next(e,n):o}function Hc(s,t,e,n){const i=[];for(const r of Object.keys(t)){const o=t[r];if(!o)continue;const a=re(s,r),c=Ss(a,o,e,n);c&&i.push(...c)}return i.length?i:s.next(e,n)}function Ss(s,t,e,n){return typeof t=="string"?Cc(s,t,e,n):Object.keys(t).length===1?Rc(s,t,e,n):Hc(s,t,e,n)}function $c(s){return Object.keys(s.states).map(t=>s.states[t]).filter(t=>t.type==="history")}function Tt(s,t){let e=s;for(;e.parent&&e.parent!==t;)e=e.parent;return e.parent===t}function Wc(s,t){const e=new Set(s),n=new Set(t);for(const i of e)if(n.has(i))return!0;for(const i of n)if(e.has(i))return!0;return!1}function tr(s,t,e){const n=new Set;for(const i of s){let r=!1;const o=new Set;for(const a of n)if(Wc(Ln([i],t,e),Ln([a],t,e)))if(Tt(i.source,a.source))o.add(a);else{r=!0;break}if(!r){for(const a of o)n.delete(a);n.add(i)}}return Array.from(n)}function Bc(s){const[t,...e]=s;for(const n of We(t,void 0))if(e.every(i=>Tt(i,n)))return n}function vs(s,t){if(!s.target)return[];const e=new Set;for(const n of s.target)if(Ct(n))if(t[n.id])for(const i of t[n.id])e.add(i);else for(const i of vs(Vi(n),t))e.add(i);else e.add(n);return[...e]}function er(s,t){const e=vs(s,t);if(!e)return;if(!s.reenter&&e.every(i=>i===s.source||Tt(i,s.source)))return s.source;const n=Bc(e.concat(s.source));if(n)return n;if(!s.reenter)return s.source.machine.root}function Ln(s,t,e){var i;const n=new Set;for(const r of s)if((i=r.target)!=null&&i.length){const o=er(r,e);r.reenter&&r.source===o&&n.add(o);for(const a of t)Tt(a,o)&&n.add(a)}return[...n]}function zc(s,t){if(s.length!==t.size)return!1;for(const e of s)if(!t.has(e))return!1;return!0}function Kn(s,t,e,n,i,r){if(!s.length)return t;const o=new Set(t._nodes);let a=t.historyValue;const c=tr(s,o,a);let h=t;i||([h,a]=Kc(h,n,e,c,o,a,r)),h=oe(h,n,e,c.flatMap(u=>u.actions),r),h=jc(h,n,e,c,o,r,a,i);const l=[...o];h.status==="done"&&(h=oe(h,n,e,l.sort((u,f)=>f.order-u.order).flatMap(u=>u.exit),r));try{return a===t.historyValue&&zc(t._nodes,o)?h:Pt(h,{_nodes:l,historyValue:a})}catch(u){throw u}}function Pc(s,t,e,n,i){if(n.output===void 0)return;const r=zn(i.id,i.output!==void 0&&i.parent?Pn(i.output,s.context,t,e.self):void 0);return Pn(n.output,s.context,r,e.self)}function jc(s,t,e,n,i,r,o,a){let c=s;const h=new Set,l=new Set;Lc(n,o,l,h),a&&l.add(s.machine.root);const u=new Set;for(const f of[...h].sort((m,p)=>m.order-p.order)){i.add(f);const m=[];m.push(...f.entry);for(const p of f.invoke)m.push(kc(p.src,{...p,syncSnapshot:!!p.onSnapshot}));if(l.has(f)){const p=f.initial.actions;m.push(...p)}if(c=oe(c,t,e,m,r,f.invoke.map(p=>p.id)),f.type==="final"){const p=f.parent;let y=(p==null?void 0:p.type)==="parallel"?p:p==null?void 0:p.parent,w=y||f;for((p==null?void 0:p.type)==="compound"&&r.push(zn(p.id,f.output!==void 0?Pn(f.output,c.context,t,e.self):void 0));(y==null?void 0:y.type)==="parallel"&&!u.has(y)&&bs(i,y);)u.add(y),r.push(zn(y.id)),w=y,y=y.parent;if(y)continue;c=Pt(c,{status:"done",output:Pc(c,t,e,c.machine.root,w)})}}return c}function Lc(s,t,e,n){for(const i of s){const r=er(i,t);for(const a of i.target||[])!Ct(a)&&(i.source!==a||i.source!==r||i.reenter)&&(n.add(a),e.add(a)),Jt(a,t,e,n);const o=vs(i,t);for(const a of o){const c=We(a,r);(r==null?void 0:r.type)==="parallel"&&c.push(r),nr(n,t,e,c,!i.source.parent&&i.reenter?void 0:r)}}}function Jt(s,t,e,n){var i;if(Ct(s))if(t[s.id]){const r=t[s.id];for(const o of r)n.add(o),Jt(o,t,e,n);for(const o of r)wn(o,s.parent,n,t,e)}else{const r=Vi(s);for(const o of r.target)n.add(o),r===((i=s.parent)==null?void 0:i.initial)&&e.add(s.parent),Jt(o,t,e,n);for(const o of r.target)wn(o,s.parent,n,t,e)}else if(s.type==="compound"){const[r]=s.initial.target;Ct(r)||(n.add(r),e.add(r)),Jt(r,t,e,n),wn(r,s,n,t,e)}else if(s.type==="parallel")for(const r of ie(s).filter(o=>!Ct(o)))[...n].some(o=>Tt(o,r))||(Ct(r)||(n.add(r),e.add(r)),Jt(r,t,e,n))}function nr(s,t,e,n,i){for(const r of n)if((!i||Tt(r,i))&&s.add(r),r.type==="parallel")for(const o of ie(r).filter(a=>!Ct(a)))[...s].some(a=>Tt(a,o))||(s.add(o),Jt(o,t,e,s))}function wn(s,t,e,n,i){nr(e,n,i,We(s,t))}function Kc(s,t,e,n,i,r,o){let a=s;const c=Ln(n,i,r);c.sort((l,u)=>u.order-l.order);let h;for(const l of c)for(const u of $c(l)){let f;u.history==="deep"?f=m=>_s(m)&&Tt(m,l):f=m=>m.parent===l,h??(h={...r}),h[u.id]=Array.from(i).filter(f)}for(const l of c)a=oe(a,t,e,[...l.exit,...l.invoke.map(u=>Zi(u.id))],o),i.delete(l);return[a,h||r]}let Us=!1;function sr(s,t,e,n,i,r){const{machine:o}=s;let a=s;for(const c of n){let m=function(){e.system._sendInspectionEvent({type:"@xstate.action",actorRef:e.self,action:{type:typeof c=="string"?c:typeof c=="object"?c.type:c.name||"(anonymous)",params:f}});try{Us=l,l(u,f)}finally{Us=!1}};const h=typeof c=="function",l=h?c:o.implementations.actions[typeof c=="string"?c:c.type];if(!l)continue;const u={context:a.context,event:t,self:e.self,system:e.system},f=h||typeof c=="string"?void 0:"params"in c?typeof c.params=="function"?c.params({context:a.context,event:t}):c.params:void 0;if(!("resolve"in l)){e.self._processingStatus===q.Running?m():e.defer(()=>{m()});continue}const p=l,[y,w,x]=p.resolve(e,a,u,f,l,i);a=y,"retryResolve"in p&&(r==null||r.push([p,w])),"execute"in p&&(e.self._processingStatus===q.Running?p.execute(e,w):e.defer(p.execute.bind(null,e,w))),x&&(a=sr(a,t,e,x,i,r))}return a}function oe(s,t,e,n,i,r){const o=r?[]:void 0,a=sr(s,t,e,n,{internalQueue:i,deferredActorIds:r},o);return o==null||o.forEach(([c,h])=>{c.retryResolve(e,a,h)}),a}function _n(s,t,e,n=[]){let i=s;const r=[];function o(h,l,u){e.system._sendInspectionEvent({type:"@xstate.microstep",actorRef:e.self,event:l,snapshot:h,_transitions:u}),r.push(h)}if(t.type===Bn)return i=Pt(Fs(i,t,e),{status:"stopped"}),o(i,t,[]),{snapshot:i,microstates:r};let a=t;if(a.type!==Li){const h=a,l=mc(h),u=qs(h,i);if(l&&!u.length)return i=Pt(s,{status:"error",error:h.error}),o(i,h,[]),{snapshot:i,microstates:r};i=Kn(u,s,e,a,!1,n),o(i,h,u)}let c=!0;for(;i.status==="active";){let h=c?Uc(i,a):[];const l=h.length?i:void 0;if(!h.length){if(!n.length)break;a=n.shift(),h=qs(a,i)}i=Kn(h,i,e,a,!1,n),c=i!==l,o(i,a,h)}return i.status!=="active"&&Fs(i,a,e),{snapshot:i,microstates:r}}function Fs(s,t,e){return oe(s,t,e,Object.values(s.children).map(n=>Zi(n)),[])}function qs(s,t){return t.machine.getTransitionData(t,s)}function Uc(s,t){const e=new Set,n=s._nodes.filter(_s);for(const i of n)t:for(const r of[i].concat(We(i,void 0)))if(r.always){for(const o of r.always)if(o.guard===void 0||ws(o.guard,s.context,t,s)){e.add(o);break t}}return tr(Array.from(e),new Set(s._nodes),s.historyValue)}function Fc(s,t){const e=Je(Qe(s,t));return Ji(s,[...e])}function qc(s){return!!s&&typeof s=="object"&&"machine"in s&&"value"in s}const Gc=function(t){return Ui(t,this.value)},Zc=function(t){return this.tags.has(t)},Yc=function(t){const e=this.machine.getTransitionData(this,t);return!!(e!=null&&e.length)&&e.some(n=>n.target!==void 0||n.actions.length)},Xc=function(){const{_nodes:t,tags:e,machine:n,getMeta:i,toJSON:r,can:o,hasTag:a,matches:c,...h}=this;return{...h,tags:Array.from(e)}},Jc=function(){return this._nodes.reduce((t,e)=>(e.meta!==void 0&&(t[e.id]=e.meta),t),{})};function Ke(s,t){return{status:s.status,output:s.output,error:s.error,machine:t,context:s.context,_nodes:s._nodes,value:Ji(t.root,s._nodes),tags:new Set(s._nodes.flatMap(e=>e.tags)),children:s.children,historyValue:s.historyValue||{},matches:Gc,hasTag:Zc,can:Yc,getMeta:Jc,toJSON:Xc}}function Pt(s,t={}){return Ke({...s,...t},s.machine)}function Vc(s,t){const{_nodes:e,tags:n,machine:i,children:r,context:o,can:a,hasTag:c,matches:h,getMeta:l,toJSON:u,...f}=s,m={};for(const y in r){const w=r[y];m[y]={snapshot:w.getPersistedSnapshot(t),src:w.src,systemId:w._systemId,syncSnapshot:w._syncSnapshot}}return{...f,context:ir(o),children:m}}function ir(s){let t;for(const e in s){const n=s[e];if(n&&typeof n=="object")if("sessionId"in n&&"send"in n&&"ref"in n)t??(t=Array.isArray(s)?s.slice():{...s}),t[e]={xstate$$type:ys,id:n.id};else{const i=ir(n);i!==n&&(t??(t=Array.isArray(s)?s.slice():{...s}),t[e]=i)}}return t??s}function Qc(s,t,e,n,{event:i,id:r,delay:o},{internalQueue:a}){const c=t.machine.implementations.delays;if(typeof i=="string")throw new Error(`Only event objects may be used with raise; use raise({ type: "${i}" }) instead`);const h=typeof i=="function"?i(e,n):i;let l;if(typeof o=="string"){const u=c&&c[o];l=typeof u=="function"?u(e,n):u}else l=typeof o=="function"?o(e,n):o;return typeof l!="number"&&a.push(h),[t,{event:h,id:r,delay:l}]}function th(s,t){const{event:e,delay:n,id:i}=t;if(typeof n=="number"){s.defer(()=>{const r=s.self;s.system.scheduler.schedule(r,r,e,n,i)});return}}function eh(s,t){function e(n,i){}return e.type="xstate.raise",e.event=s,e.id=t==null?void 0:t.id,e.delay=t==null?void 0:t.delay,e.resolve=Qc,e.execute=th,e}function nh(s,{machine:t,context:e},n,i){const r=(o,a={})=>{const{systemId:c,input:h}=a;if(typeof o=="string"){const l=gs(t,o);if(!l)throw new Error(`Actor logic '${o}' not implemented in machine '${t.id}'`);const u=se(l,{id:a.id,parent:s.self,syncSnapshot:a.syncSnapshot,input:typeof h=="function"?h({context:e,event:n,self:s.self}):h,src:o,systemId:c});return i[u.id]=u,u}else return se(o,{id:a.id,parent:s.self,syncSnapshot:a.syncSnapshot,input:a.input,src:o,systemId:c})};return(o,a)=>{const c=r(o,a);return i[c.id]=c,s.defer(()=>{c._processingStatus!==q.Stopped&&c.start()}),c}}function sh(s,t,e,n,{assignment:i}){if(!t.context)throw new Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");const r={},o={context:t.context,event:e.event,spawn:nh(s,t,e.event,r),self:s.self,system:s.system};let a={};if(typeof i=="function")a=i(o,n);else for(const h of Object.keys(i)){const l=i[h];a[h]=typeof l=="function"?l(o,n):l}const c=Object.assign({},t.context,a);return[Pt(t,{context:c,children:Object.keys(r).length?{...t.children,...r}:t.children})]}function ih(s){function t(e,n){}return t.type="xstate.assign",t.assignment=s,t.resolve=sh,t}const Gs=new WeakMap;function qt(s,t,e){let n=Gs.get(s);return n?t in n||(n[t]=e()):(n={[t]:e()},Gs.set(s,n)),n[t]}const rh={},ue=s=>typeof s=="string"?{type:s}:typeof s=="function"?"resolve"in s?{type:s.type}:{type:s.name}:s;class As{constructor(t,e){if(this.config=t,this.key=void 0,this.id=void 0,this.type=void 0,this.path=void 0,this.states=void 0,this.history=void 0,this.entry=void 0,this.exit=void 0,this.parent=void 0,this.machine=void 0,this.meta=void 0,this.output=void 0,this.order=-1,this.description=void 0,this.tags=[],this.transitions=void 0,this.always=void 0,this.parent=e._parent,this.key=e._key,this.machine=e._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(Pi),this.type=this.config.type||(this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.description=this.config.description,this.order=this.machine.idMap.size,this.machine.idMap.set(this.id,this),this.states=this.config.states?Ps(this.config.states,(n,i)=>new As(n,{_parent:this,_key:i,_machine:this.machine})):rh,this.type==="compound"&&!this.config.initial)throw new Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);this.history=this.config.history===!0?"shallow":this.config.history||!1,this.entry=St(this.config.entry).slice(),this.exit=St(this.config.exit).slice(),this.meta=this.config.meta,this.output=this.type==="final"||!this.parent?this.config.output:void 0,this.tags=St(t.tags).slice()}_initialize(){this.transitions=Nc(this),this.config.always&&(this.always=Gt(this.config.always).map(t=>Dt(this,ji,t))),Object.keys(this.states).forEach(t=>{this.states[t]._initialize()})}get definition(){return{id:this.id,key:this.key,version:this.machine.version,type:this.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(ue),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(t=>`#${t.id}`),source:`#${this.id}`,actions:this.initial.actions.map(ue),eventType:null})}:void 0,history:this.history,states:Ps(this.states,t=>t.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(t=>({...t,actions:t.actions.map(ue)})),entry:this.entry.map(ue),exit:this.exit.map(ue),meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}toJSON(){return this.definition}get invoke(){return qt(this,"invoke",()=>St(this.config.invoke).map((t,e)=>{const{src:n,systemId:i}=t,r=t.id??js(this.id,e),o=typeof n=="string"?n:`xstate.invoke.${js(this.id,e)}`;return{...t,src:o,id:r,systemId:i,toJSON(){const{onDone:a,onError:c,...h}=t;return{...h,type:"xstate.invoke",src:o,id:r}}}}))}get on(){return qt(this,"on",()=>[...this.transitions].flatMap(([e,n])=>n.map(i=>[e,i])).reduce((e,[n,i])=>(e[n]=e[n]||[],e[n].push(i),e),{}))}get after(){return qt(this,"delayedTransitions",()=>Ic(this))}get initial(){return qt(this,"initial",()=>Mc(this,this.config.initial))}next(t,e){const n=e.type,i=[];let r;const o=qt(this,`candidates-${n}`,()=>Ec(this,n));for(const a of o){const{guard:c}=a,h=t.context;let l=!1;try{l=!c||ws(c,h,e,t)}catch(u){const f=typeof c=="string"?c:typeof c=="object"?c.type:void 0;throw new Error(`Unable to evaluate guard ${f?`'${f}' `:""}in transition for event '${n}' in state node '${this.id}':
|
|
9
9
|
${u.message}`)}if(l){i.push(...a.actions),r=a;break}}return r?[r]:void 0}get events(){return qt(this,"events",()=>{const{states:t}=this,e=new Set(this.ownEvents);if(t)for(const n of Object.keys(t)){const i=t[n];if(i.states)for(const r of i.events)e.add(`${r}`)}return Array.from(e)})}get ownEvents(){const t=new Set([...this.transitions.keys()].filter(e=>this.transitions.get(e).some(n=>!(!n.target&&!n.actions.length&&!n.reenter))));return Array.from(t)}}const oh="#";class xs{constructor(t,e){this.config=t,this.version=void 0,this.schemas=void 0,this.implementations=void 0,this.__xstatenode=!0,this.idMap=new Map,this.root=void 0,this.id=void 0,this.states=void 0,this.events=void 0,this.id=t.id||"(machine)",this.implementations={actors:(e==null?void 0:e.actors)??{},actions:(e==null?void 0:e.actions)??{},delays:(e==null?void 0:e.delays)??{},guards:(e==null?void 0:e.guards)??{}},this.version=this.config.version,this.schemas=this.config.schemas,this.transition=this.transition.bind(this),this.getInitialSnapshot=this.getInitialSnapshot.bind(this),this.getPersistedSnapshot=this.getPersistedSnapshot.bind(this),this.restoreSnapshot=this.restoreSnapshot.bind(this),this.start=this.start.bind(this),this.root=new As(t,{_key:this.id,_machine:this}),this.root._initialize(),this.states=this.root.states,this.events=this.root.events}provide(t){const{actions:e,guards:n,actors:i,delays:r}=this.implementations;return new xs(this.config,{actions:{...e,...t.actions},guards:{...n,...t.guards},actors:{...i,...t.actors},delays:{...r,...t.delays}})}resolveState(t){const e=Fc(this.root,t.value),n=Je(Qe(this.root,e));return Ke({_nodes:[...n],context:t.context||{},children:{},status:bs(n,this.root)?"done":t.status||"active",output:t.output,error:t.error,historyValue:t.historyValue},this)}transition(t,e,n){return _n(t,e,n).snapshot}microstep(t,e,n){return _n(t,e,n).microstates}getTransitionData(t,e){return Ss(this.root,t.value,t,e)||[]}getPreInitialState(t,e,n){const{context:i}=this.config,r=Ke({context:typeof i!="function"&&i?i:{},_nodes:[this.root],children:{},status:"active"},this);return typeof i=="function"?oe(r,e,t,[ih(({spawn:a,event:c,self:h})=>i({spawn:a,input:c.input,self:h}))],n):r}getInitialSnapshot(t,e){const n=Ki(e),i=[],r=this.getPreInitialState(t,n,i),o=Kn([{target:[...Qi(this.root)],source:this.root,reenter:!0,actions:[],eventType:null,toJSON:null}],r,t,n,!0,i),{snapshot:a}=_n(o,n,t,i);return a}start(t){Object.values(t.children).forEach(e=>{e.getSnapshot().status==="active"&&e.start()})}getStateNodeById(t){const e=ms(t),n=e.slice(1),i=an(e[0])?e[0].slice(oh.length):e[0],r=this.idMap.get(i);if(!r)throw new Error(`Child state node '#${i}' does not exist on machine '${this.id}'`);return Ve(r,n)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(t,e){return Vc(t,e)}restoreSnapshot(t,e){const n={},i=t.children;Object.keys(i).forEach(c=>{const h=i[c],l=h.snapshot,u=h.src,f=typeof u=="string"?gs(this,u):u;if(!f)return;const m=se(f,{id:c,parent:e.self,syncSnapshot:h.syncSnapshot,snapshot:l,src:u,systemId:h.systemId});n[c]=m});const r=Ke({...t,children:n,_nodes:Array.from(Je(Qe(this.root,t.value)))},this);let o=new Set;function a(c,h){if(!o.has(c)){o.add(c);for(let l in c){const u=c[l];if(u&&typeof u=="object"){if("xstate$$type"in u&&u.xstate$$type===ys){c[l]=h[u.id];continue}a(u,h)}}}}return a(r.context,n),r}}function ah(s,t){return new xs(s,t)}const je=s=>s===!1?!1:s.map(t=>t.serialize()),ch=s=>s===!1?!1:s.serialize(),hh=s=>s===!1?!1:s.map(t=>({tile:t.tile.toString(),candidates:t.candidates.map(e=>e.toString()),shanten:t.shanten})),Un=s=>JSON.parse(JSON.stringify(s)),bn=s=>s===!1?!1:Un(s),Fn=s=>ah({id:"Untitled",initial:"distribute",context:{currentWind:v.E,oneShotMap:G(!1),missingMap:G(!1),controller:s,genEventID:rr()},states:{distribute:{on:{NEXT:{target:"drawn"}},entry:{type:"notify_distribution"}},drawn:{entry:{type:"notify_draw"},on:{NEXT:{target:"waiting_user_event_after_drawn",actions:{type:"notify_choice_after_drawn"},description:`可能なアクションとその詳細を通知\\
|
|
10
10
|
DISCARD の場合は捨てられる牌の一覧`}}},waiting_user_event_after_drawn:{description:"ツモった1ユーザからのレスポンス待ち",on:{TSUMO:{target:"tsumo",guard:"canWin"},REACH:{target:"discarded",guard:"canReach",actions:{type:"notify_reach"},description:`入力に牌が必要\\
|
package/dist/index.d.cts
CHANGED
|
@@ -752,12 +752,19 @@ export declare const drawTable: (svg: Svg, tableInput: string, config: ImageHelp
|
|
|
752
752
|
}) => void;
|
|
753
753
|
|
|
754
754
|
export declare class Efficiency {
|
|
755
|
-
static calcCandidates(hand: Hand, choices: Tile[],
|
|
756
|
-
|
|
755
|
+
static calcCandidates(hand: Hand, choices: Tile[], options?: {
|
|
756
|
+
arrangeRed?: boolean;
|
|
757
|
+
fourSetsOnePair?: boolean;
|
|
758
|
+
}): Candidate[];
|
|
759
|
+
static candidateTiles(hand: Hand, options?: {
|
|
760
|
+
fourSetsOnePair?: boolean;
|
|
761
|
+
}): {
|
|
757
762
|
shanten: number;
|
|
758
763
|
candidates: Tile[];
|
|
759
764
|
};
|
|
760
|
-
static partialCandidateTiles(input: string
|
|
765
|
+
static partialCandidateTiles(input: string, options?: {
|
|
766
|
+
fourSetsOnePair?: boolean;
|
|
767
|
+
}): {
|
|
761
768
|
shanten: number;
|
|
762
769
|
candidates: Tile[];
|
|
763
770
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -752,12 +752,19 @@ export declare const drawTable: (svg: Svg, tableInput: string, config: ImageHelp
|
|
|
752
752
|
}) => void;
|
|
753
753
|
|
|
754
754
|
export declare class Efficiency {
|
|
755
|
-
static calcCandidates(hand: Hand, choices: Tile[],
|
|
756
|
-
|
|
755
|
+
static calcCandidates(hand: Hand, choices: Tile[], options?: {
|
|
756
|
+
arrangeRed?: boolean;
|
|
757
|
+
fourSetsOnePair?: boolean;
|
|
758
|
+
}): Candidate[];
|
|
759
|
+
static candidateTiles(hand: Hand, options?: {
|
|
760
|
+
fourSetsOnePair?: boolean;
|
|
761
|
+
}): {
|
|
757
762
|
shanten: number;
|
|
758
763
|
candidates: Tile[];
|
|
759
764
|
};
|
|
760
|
-
static partialCandidateTiles(input: string
|
|
765
|
+
static partialCandidateTiles(input: string, options?: {
|
|
766
|
+
fourSetsOnePair?: boolean;
|
|
767
|
+
}): {
|
|
761
768
|
shanten: number;
|
|
762
769
|
candidates: Tile[];
|
|
763
770
|
};
|
package/dist/index.js
CHANGED
|
@@ -740,7 +740,7 @@ function Xs(s) {
|
|
|
740
740
|
Xs(s.children[t]);
|
|
741
741
|
return s.id && (s.id = Ys(s.nodeName)), s;
|
|
742
742
|
}
|
|
743
|
-
function
|
|
743
|
+
function I(s, t) {
|
|
744
744
|
let e, n;
|
|
745
745
|
for (s = Array.isArray(s) ? s : [s], n = s.length - 1; n >= 0; n--)
|
|
746
746
|
for (e in t)
|
|
@@ -808,7 +808,7 @@ T("Dom", {
|
|
|
808
808
|
insertBefore: xr,
|
|
809
809
|
insertAfter: kr
|
|
810
810
|
});
|
|
811
|
-
const Js = /^([+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?)([a-z%]*)$/i, Tr = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,
|
|
811
|
+
const Js = /^([+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?)([a-z%]*)$/i, Tr = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i, Or = /rgb\((\d+),(\d+),(\d+)\)/, Ir = /(#[a-z_][a-z0-9\-_]*)/i, Er = /\)\s*,?\s*/, Nr = /\s/g, _s = /^#[a-f0-9]{3}$|^#[a-f0-9]{6}$/i, bs = /^rgb\(/, Ss = /^(\s+)?$/, vs = /^[+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i, Mr = /\.(jpg|jpeg|png|gif|svg)(\?[^=]+.*)?/i, yt = /[\s,]+/, Yn = /[MLHVCSQTAZ]/i;
|
|
812
812
|
function Dr() {
|
|
813
813
|
const s = this.attr("class");
|
|
814
814
|
return s == null ? [] : s.trim().split(yt);
|
|
@@ -1044,7 +1044,7 @@ class D {
|
|
|
1044
1044
|
Object.assign(this, u);
|
|
1045
1045
|
} else if (typeof t == "string")
|
|
1046
1046
|
if (bs.test(t)) {
|
|
1047
|
-
const u = t.replace(Nr, ""), [f, m, p] =
|
|
1047
|
+
const u = t.replace(Nr, ""), [f, m, p] = Or.exec(u).slice(1, 4).map((y) => parseInt(y));
|
|
1048
1048
|
Object.assign(this, { _a: f, _b: m, _c: p, _d: 0, space: "rgb" });
|
|
1049
1049
|
} else if (_s.test(t)) {
|
|
1050
1050
|
const u = (y) => parseInt(y, 16), [, f, m, p] = Tr.exec(Fr(t)).map(u);
|
|
@@ -1076,8 +1076,8 @@ class D {
|
|
|
1076
1076
|
const { c: rt, h: ft } = this, Pt = Math.PI / 180;
|
|
1077
1077
|
p = rt * Math.cos(Pt * ft), y = rt * Math.sin(Pt * ft);
|
|
1078
1078
|
}
|
|
1079
|
-
const w = (m + 16) / 116, x = p / 500 + w,
|
|
1080
|
-
t = 0.95047 * (x ** 3 > tt ? x ** 3 : (x - H) / L), e = 1 * (w ** 3 > tt ? w ** 3 : (w - H) / L), n = 1.08883 * (
|
|
1079
|
+
const w = (m + 16) / 116, x = p / 500 + w, O = w - y / 200, H = 16 / 116, tt = 8856e-6, L = 7.787;
|
|
1080
|
+
t = 0.95047 * (x ** 3 > tt ? x ** 3 : (x - H) / L), e = 1 * (w ** 3 > tt ? w ** 3 : (w - H) / L), n = 1.08883 * (O ** 3 > tt ? O ** 3 : (O - H) / L);
|
|
1081
1081
|
}
|
|
1082
1082
|
const i = t * 3.2406 + e * -1.5372 + n * -0.4986, r = t * -0.9689 + e * 1.8758 + n * 0.0415, o = t * 0.0557 + e * -0.204 + n * 1.057, a = Math.pow, c = 31308e-7, h = i > c ? 1.055 * a(i, 1 / 2.4) - 0.055 : 12.92 * i, l = r > c ? 1.055 * a(r, 1 / 2.4) - 0.055 : 12.92 * r, u = o > c ? 1.055 * a(o, 1 / 2.4) - 0.055 : 12.92 * o;
|
|
1083
1083
|
return new D(255 * h, 255 * l, 255 * u);
|
|
@@ -1169,7 +1169,7 @@ class A {
|
|
|
1169
1169
|
), y = p.x, w = p.y, x = new W(
|
|
1170
1170
|
t.translate || t.tx || t.translateX,
|
|
1171
1171
|
t.ty || t.translateY
|
|
1172
|
-
),
|
|
1172
|
+
), O = x.x, H = x.y, tt = new W(
|
|
1173
1173
|
t.relative || t.rx || t.relativeX,
|
|
1174
1174
|
t.ry || t.relativeY
|
|
1175
1175
|
), L = tt.x, rt = tt.y;
|
|
@@ -1182,7 +1182,7 @@ class A {
|
|
|
1182
1182
|
theta: l,
|
|
1183
1183
|
rx: L,
|
|
1184
1184
|
ry: rt,
|
|
1185
|
-
tx:
|
|
1185
|
+
tx: O,
|
|
1186
1186
|
ty: H,
|
|
1187
1187
|
ox: f,
|
|
1188
1188
|
oy: m,
|
|
@@ -1215,14 +1215,14 @@ class A {
|
|
|
1215
1215
|
}
|
|
1216
1216
|
// Decomposes this matrix into its affine parameters
|
|
1217
1217
|
decompose(t = 0, e = 0) {
|
|
1218
|
-
const n = this.a, i = this.b, r = this.c, o = this.d, a = this.e, c = this.f, h = n * o - i * r, l = h > 0 ? 1 : -1, u = l * Math.sqrt(n * n + i * i), f = Math.atan2(l * i, l * n), m = 180 / Math.PI * f, p = Math.cos(f), y = Math.sin(f), w = (n * r + i * o) / h, x = r * u / (w * n - i) || o * u / (w * i + n),
|
|
1218
|
+
const n = this.a, i = this.b, r = this.c, o = this.d, a = this.e, c = this.f, h = n * o - i * r, l = h > 0 ? 1 : -1, u = l * Math.sqrt(n * n + i * i), f = Math.atan2(l * i, l * n), m = 180 / Math.PI * f, p = Math.cos(f), y = Math.sin(f), w = (n * r + i * o) / h, x = r * u / (w * n - i) || o * u / (w * i + n), O = a - t + t * p * u + e * (w * p * u - y * x), H = c - e + t * y * u + e * (w * y * u + p * x);
|
|
1219
1219
|
return {
|
|
1220
1220
|
// Return the affine parameters
|
|
1221
1221
|
scaleX: u,
|
|
1222
1222
|
scaleY: x,
|
|
1223
1223
|
shear: w,
|
|
1224
1224
|
rotate: m,
|
|
1225
|
-
translateX:
|
|
1225
|
+
translateX: O,
|
|
1226
1226
|
translateY: H,
|
|
1227
1227
|
originX: t,
|
|
1228
1228
|
originY: e,
|
|
@@ -1512,7 +1512,7 @@ class $t extends Array {
|
|
|
1512
1512
|
this.length = 0, this.push(...t);
|
|
1513
1513
|
}
|
|
1514
1514
|
}
|
|
1515
|
-
|
|
1515
|
+
I([$t], {
|
|
1516
1516
|
each(s, ...t) {
|
|
1517
1517
|
return typeof s == "function" ? this.map((e, n, i) => s.call(e, e, n, i)) : this.map((e) => e[s](...t));
|
|
1518
1518
|
},
|
|
@@ -1524,7 +1524,7 @@ const no = ["toArray", "constructor", "each"];
|
|
|
1524
1524
|
$t.extend = function(s) {
|
|
1525
1525
|
s = s.reduce((t, e) => (no.includes(e) || e[0] === "_" || (e in Array.prototype && (t["$" + e] = Array.prototype[e]), t[e] = function(...n) {
|
|
1526
1526
|
return this.each(e, ...n);
|
|
1527
|
-
}), t), {}),
|
|
1527
|
+
}), t), {}), I([$t], s);
|
|
1528
1528
|
};
|
|
1529
1529
|
function oe(s, t) {
|
|
1530
1530
|
return new $t(
|
|
@@ -1943,7 +1943,7 @@ class St extends we {
|
|
|
1943
1943
|
return e ? this.replace(r) && o : this.add(r);
|
|
1944
1944
|
}
|
|
1945
1945
|
}
|
|
1946
|
-
|
|
1946
|
+
I(St, { attr: uo, find: so, findOne: io });
|
|
1947
1947
|
N(St, "Dom");
|
|
1948
1948
|
class ut extends St {
|
|
1949
1949
|
constructor(t, e) {
|
|
@@ -2005,7 +2005,7 @@ class ut extends St {
|
|
|
2005
2005
|
// Get referenced element form attribute value
|
|
2006
2006
|
reference(t) {
|
|
2007
2007
|
if (t = this.attr(t), !t) return null;
|
|
2008
|
-
const e = (t + "").match(
|
|
2008
|
+
const e = (t + "").match(Ir);
|
|
2009
2009
|
return e ? G(e[1]) : null;
|
|
2010
2010
|
}
|
|
2011
2011
|
// Get parent document
|
|
@@ -2039,7 +2039,7 @@ class ut extends St {
|
|
|
2039
2039
|
return this.attr("y", t);
|
|
2040
2040
|
}
|
|
2041
2041
|
}
|
|
2042
|
-
|
|
2042
|
+
I(ut, {
|
|
2043
2043
|
bbox: Qr,
|
|
2044
2044
|
rbox: to,
|
|
2045
2045
|
inside: eo,
|
|
@@ -2286,7 +2286,7 @@ class Xe extends Q {
|
|
|
2286
2286
|
);
|
|
2287
2287
|
}
|
|
2288
2288
|
}
|
|
2289
|
-
|
|
2289
|
+
I(Xe, _o);
|
|
2290
2290
|
T("Container", {
|
|
2291
2291
|
// Create an ellipse
|
|
2292
2292
|
ellipse: R(function(s = 0, t = s) {
|
|
@@ -2349,7 +2349,7 @@ class _e extends X {
|
|
|
2349
2349
|
return "url(#" + this.id() + ")";
|
|
2350
2350
|
}
|
|
2351
2351
|
}
|
|
2352
|
-
|
|
2352
|
+
I(_e, bo);
|
|
2353
2353
|
T({
|
|
2354
2354
|
Container: {
|
|
2355
2355
|
// Create gradient element in defs
|
|
@@ -2558,7 +2558,7 @@ class me extends Q {
|
|
|
2558
2558
|
return this.attr(this.array().size(n.width, n.height).toLine());
|
|
2559
2559
|
}
|
|
2560
2560
|
}
|
|
2561
|
-
|
|
2561
|
+
I(me, ts);
|
|
2562
2562
|
T({
|
|
2563
2563
|
Container: {
|
|
2564
2564
|
// Create a line element
|
|
@@ -2683,7 +2683,7 @@ function xs() {
|
|
|
2683
2683
|
const s = (this._duration || 500) / 1e3, t = this._overshoot || 0, e = 1e-10, n = Math.PI, i = Math.log(t / 100 + e), r = -i / Math.sqrt(n * n + i * i), o = 3.9 / (r * s);
|
|
2684
2684
|
this.d = 2 * r * o, this.k = o * o;
|
|
2685
2685
|
}
|
|
2686
|
-
class
|
|
2686
|
+
class Oo extends Be {
|
|
2687
2687
|
constructor(t = 500, e = 0) {
|
|
2688
2688
|
super(), this.duration(t).overshoot(e);
|
|
2689
2689
|
}
|
|
@@ -2696,11 +2696,11 @@ class Io extends Be {
|
|
|
2696
2696
|
return i.velocity = r + o * n, i.done = Math.abs(e - a) + Math.abs(r) < 2e-3, i.done ? e : a;
|
|
2697
2697
|
}
|
|
2698
2698
|
}
|
|
2699
|
-
|
|
2699
|
+
I(Oo, {
|
|
2700
2700
|
duration: qt("_duration", xs),
|
|
2701
2701
|
overshoot: qt("_overshoot", xs)
|
|
2702
2702
|
});
|
|
2703
|
-
class
|
|
2703
|
+
class Io extends Be {
|
|
2704
2704
|
constructor(t = 0.1, e = 0.01, n = 0, i = 1e3) {
|
|
2705
2705
|
super(), this.p(t).i(e).d(n).windup(i);
|
|
2706
2706
|
}
|
|
@@ -2714,7 +2714,7 @@ class Oo extends Be {
|
|
|
2714
2714
|
return c !== !1 && (o = Math.max(-c, Math.min(o, c))), i.error = r, i.integral = o, i.done = Math.abs(r) < 1e-3, i.done ? e : t + (this.P * r + this.I * o + this.D * a);
|
|
2715
2715
|
}
|
|
2716
2716
|
}
|
|
2717
|
-
|
|
2717
|
+
I(Io, {
|
|
2718
2718
|
windup: qt("_windup"),
|
|
2719
2719
|
p: qt("P"),
|
|
2720
2720
|
i: qt("I"),
|
|
@@ -2784,7 +2784,7 @@ function kn(s) {
|
|
|
2784
2784
|
return s.segment.length && s.segment.length - 1 === Eo[s.segment[0].toUpperCase()];
|
|
2785
2785
|
}
|
|
2786
2786
|
function Mo(s, t) {
|
|
2787
|
-
s.inNumber &&
|
|
2787
|
+
s.inNumber && Ot(s, !1);
|
|
2788
2788
|
const e = Yn.test(t);
|
|
2789
2789
|
if (e)
|
|
2790
2790
|
s.segment = [t];
|
|
@@ -2794,7 +2794,7 @@ function Mo(s, t) {
|
|
|
2794
2794
|
}
|
|
2795
2795
|
return s.inSegment = !0, s.lastCommand = s.segment[0], e;
|
|
2796
2796
|
}
|
|
2797
|
-
function
|
|
2797
|
+
function Ot(s, t) {
|
|
2798
2798
|
if (!s.inNumber) throw new Error("Parser Error");
|
|
2799
2799
|
s.number && s.segment.push(parseFloat(s.number)), s.inNumber = t, s.number = "", s.pointSeen = !1, s.hasExponent = !1, kn(s) && Tn(s);
|
|
2800
2800
|
}
|
|
@@ -2830,7 +2830,7 @@ function $o(s, t = !0) {
|
|
|
2830
2830
|
if (!(!i.inSegment && Mo(i, n))) {
|
|
2831
2831
|
if (n === ".") {
|
|
2832
2832
|
if (i.pointSeen || i.hasExponent) {
|
|
2833
|
-
|
|
2833
|
+
Ot(i, !1), --e;
|
|
2834
2834
|
continue;
|
|
2835
2835
|
}
|
|
2836
2836
|
i.inNumber = !0, i.pointSeen = !0, i.number += n;
|
|
@@ -2838,19 +2838,19 @@ function $o(s, t = !0) {
|
|
|
2838
2838
|
}
|
|
2839
2839
|
if (!isNaN(parseInt(n))) {
|
|
2840
2840
|
if (i.number === "0" || Do(i)) {
|
|
2841
|
-
i.inNumber = !0, i.number = n,
|
|
2841
|
+
i.inNumber = !0, i.number = n, Ot(i, !0);
|
|
2842
2842
|
continue;
|
|
2843
2843
|
}
|
|
2844
2844
|
i.inNumber = !0, i.number += n;
|
|
2845
2845
|
continue;
|
|
2846
2846
|
}
|
|
2847
2847
|
if (Ro.has(n)) {
|
|
2848
|
-
i.inNumber &&
|
|
2848
|
+
i.inNumber && Ot(i, !1);
|
|
2849
2849
|
continue;
|
|
2850
2850
|
}
|
|
2851
2851
|
if (n === "-" || n === "+") {
|
|
2852
2852
|
if (i.inNumber && !Co(i)) {
|
|
2853
|
-
|
|
2853
|
+
Ot(i, !1), --e;
|
|
2854
2854
|
continue;
|
|
2855
2855
|
}
|
|
2856
2856
|
i.number += n, i.inNumber = !0;
|
|
@@ -2862,7 +2862,7 @@ function $o(s, t = !0) {
|
|
|
2862
2862
|
}
|
|
2863
2863
|
if (Yn.test(n)) {
|
|
2864
2864
|
if (i.inNumber)
|
|
2865
|
-
|
|
2865
|
+
Ot(i, !1);
|
|
2866
2866
|
else if (kn(i))
|
|
2867
2867
|
Tn(i);
|
|
2868
2868
|
else
|
|
@@ -2870,7 +2870,7 @@ function $o(s, t = !0) {
|
|
|
2870
2870
|
--e;
|
|
2871
2871
|
}
|
|
2872
2872
|
}
|
|
2873
|
-
return i.inNumber &&
|
|
2873
|
+
return i.inNumber && Ot(i, !1), i.inSegment && kn(i) && Tn(i), i.segments;
|
|
2874
2874
|
}
|
|
2875
2875
|
function Ho(s) {
|
|
2876
2876
|
let t = "";
|
|
@@ -2910,9 +2910,9 @@ class Ht extends Yt {
|
|
|
2910
2910
|
}
|
|
2911
2911
|
const fi = (s) => {
|
|
2912
2912
|
const t = typeof s;
|
|
2913
|
-
return t === "number" ? k : t === "string" ? D.isColor(s) ? D : yt.test(s) ? Yn.test(s) ? Ht : Yt : Js.test(s) ? k :
|
|
2913
|
+
return t === "number" ? k : t === "string" ? D.isColor(s) ? D : yt.test(s) ? Yn.test(s) ? Ht : Yt : Js.test(s) ? k : On : ns.indexOf(s.constructor) > -1 ? s.constructor : Array.isArray(s) ? Yt : t === "object" ? ge : On;
|
|
2914
2914
|
};
|
|
2915
|
-
class
|
|
2915
|
+
class It {
|
|
2916
2916
|
constructor(t) {
|
|
2917
2917
|
this._stepper = t || new An("-"), this._from = null, this._to = null, this._type = null, this._context = null, this._morphObj = null;
|
|
2918
2918
|
}
|
|
@@ -2950,7 +2950,7 @@ class Ot {
|
|
|
2950
2950
|
}), e;
|
|
2951
2951
|
}
|
|
2952
2952
|
}
|
|
2953
|
-
class
|
|
2953
|
+
class On {
|
|
2954
2954
|
constructor(...t) {
|
|
2955
2955
|
this.init(...t);
|
|
2956
2956
|
}
|
|
@@ -3059,14 +3059,14 @@ class ge {
|
|
|
3059
3059
|
return t;
|
|
3060
3060
|
}
|
|
3061
3061
|
}
|
|
3062
|
-
const ns = [
|
|
3062
|
+
const ns = [On, Se, ge];
|
|
3063
3063
|
function Bo(s = []) {
|
|
3064
3064
|
ns.push(...[].concat(s));
|
|
3065
3065
|
}
|
|
3066
3066
|
function zo() {
|
|
3067
|
-
|
|
3067
|
+
I(ns, {
|
|
3068
3068
|
to(s) {
|
|
3069
|
-
return new
|
|
3069
|
+
return new It().type(this.constructor).from(this.toArray()).to(s);
|
|
3070
3070
|
},
|
|
3071
3071
|
fromArray(s) {
|
|
3072
3072
|
return this.init(s), this;
|
|
@@ -3179,8 +3179,8 @@ T({
|
|
|
3179
3179
|
})
|
|
3180
3180
|
}
|
|
3181
3181
|
});
|
|
3182
|
-
|
|
3183
|
-
|
|
3182
|
+
I(ve, ts);
|
|
3183
|
+
I(ve, di);
|
|
3184
3184
|
N(ve, "Polygon");
|
|
3185
3185
|
class Ae extends Q {
|
|
3186
3186
|
// Initialize node
|
|
@@ -3196,8 +3196,8 @@ T({
|
|
|
3196
3196
|
})
|
|
3197
3197
|
}
|
|
3198
3198
|
});
|
|
3199
|
-
|
|
3200
|
-
|
|
3199
|
+
I(Ae, ts);
|
|
3200
|
+
I(Ae, di);
|
|
3201
3201
|
N(Ae, "Polyline");
|
|
3202
3202
|
class xe extends Q {
|
|
3203
3203
|
// Initialize node
|
|
@@ -3205,7 +3205,7 @@ class xe extends Q {
|
|
|
3205
3205
|
super($("rect", t), e);
|
|
3206
3206
|
}
|
|
3207
3207
|
}
|
|
3208
|
-
|
|
3208
|
+
I(xe, { rx: Vn, ry: Qn });
|
|
3209
3209
|
T({
|
|
3210
3210
|
Container: {
|
|
3211
3211
|
// Create a rect element
|
|
@@ -3628,7 +3628,7 @@ class ze {
|
|
|
3628
3628
|
clearTransformsFromQueue() {
|
|
3629
3629
|
}
|
|
3630
3630
|
}
|
|
3631
|
-
|
|
3631
|
+
I([V, ze], {
|
|
3632
3632
|
mergeWith(s) {
|
|
3633
3633
|
return new ze(
|
|
3634
3634
|
s.transforms.lmultiply(this.transforms),
|
|
@@ -3713,7 +3713,7 @@ T({
|
|
|
3713
3713
|
}
|
|
3714
3714
|
});
|
|
3715
3715
|
const Yo = (s, t) => s.filter((e) => !t.includes(e));
|
|
3716
|
-
|
|
3716
|
+
I(V, {
|
|
3717
3717
|
attr(s, t) {
|
|
3718
3718
|
return this.styleAttr("attr", s, t);
|
|
3719
3719
|
},
|
|
@@ -3726,7 +3726,7 @@ O(V, {
|
|
|
3726
3726
|
return this.styleAttr(s, { [t]: e });
|
|
3727
3727
|
let n = t;
|
|
3728
3728
|
if (this._tryRetarget(s, n)) return this;
|
|
3729
|
-
let i = new
|
|
3729
|
+
let i = new It(this._stepper).to(n), r = Object.keys(n);
|
|
3730
3730
|
return this.queue(
|
|
3731
3731
|
function() {
|
|
3732
3732
|
i = i.from(this.element()[s](r));
|
|
@@ -3747,7 +3747,7 @@ O(V, {
|
|
|
3747
3747
|
},
|
|
3748
3748
|
zoom(s, t) {
|
|
3749
3749
|
if (this._tryRetarget("zoom", s, t)) return this;
|
|
3750
|
-
let e = new
|
|
3750
|
+
let e = new It(this._stepper).to(new k(s));
|
|
3751
3751
|
return this.queue(
|
|
3752
3752
|
function() {
|
|
3753
3753
|
e = e.from(this.element().zoom());
|
|
@@ -3780,7 +3780,7 @@ O(V, {
|
|
|
3780
3780
|
return this;
|
|
3781
3781
|
const n = A.isMatrixLike(s);
|
|
3782
3782
|
e = s.affine != null ? s.affine : e ?? !n;
|
|
3783
|
-
const i = new
|
|
3783
|
+
const i = new It(this._stepper).type(
|
|
3784
3784
|
e ? Se : A
|
|
3785
3785
|
);
|
|
3786
3786
|
let r, o, a, c, h;
|
|
@@ -3799,8 +3799,8 @@ O(V, {
|
|
|
3799
3799
|
w.rotate = L[Pt];
|
|
3800
3800
|
}
|
|
3801
3801
|
t && (n || (w.rotate = s.rotate || 0), this._isDeclarative && c && (x.rotate = c)), i.from(x), i.to(w);
|
|
3802
|
-
const
|
|
3803
|
-
return c =
|
|
3802
|
+
const O = i.at(m);
|
|
3803
|
+
return c = O.rotate, a = new A(O), this.addTransform(a), o._addRunner(this), i.done();
|
|
3804
3804
|
}
|
|
3805
3805
|
function f(m) {
|
|
3806
3806
|
(m.origin || "center").toString() !== (s.origin || "center").toString() && (r = bn(m, o)), s = { ...m, origin: r };
|
|
@@ -3832,7 +3832,7 @@ O(V, {
|
|
|
3832
3832
|
},
|
|
3833
3833
|
_queueNumberDelta(s, t) {
|
|
3834
3834
|
if (t = new k(t), this._tryRetarget(s, t)) return this;
|
|
3835
|
-
const e = new
|
|
3835
|
+
const e = new It(this._stepper).to(t);
|
|
3836
3836
|
let n = null;
|
|
3837
3837
|
return this.queue(
|
|
3838
3838
|
function() {
|
|
@@ -3848,7 +3848,7 @@ O(V, {
|
|
|
3848
3848
|
},
|
|
3849
3849
|
_queueObject(s, t) {
|
|
3850
3850
|
if (this._tryRetarget(s, t)) return this;
|
|
3851
|
-
const e = new
|
|
3851
|
+
const e = new It(this._stepper).to(t);
|
|
3852
3852
|
return this.queue(
|
|
3853
3853
|
function() {
|
|
3854
3854
|
e.from(this.element()[s]());
|
|
@@ -3898,7 +3898,7 @@ O(V, {
|
|
|
3898
3898
|
if (arguments.length === 4)
|
|
3899
3899
|
return this.plot([s, t, e, n]);
|
|
3900
3900
|
if (this._tryRetarget("plot", s)) return this;
|
|
3901
|
-
const i = new
|
|
3901
|
+
const i = new It(this._stepper).type(this._element.MorphArray).to(s);
|
|
3902
3902
|
return this.queue(
|
|
3903
3903
|
function() {
|
|
3904
3904
|
i.from(this._element.array());
|
|
@@ -3924,7 +3924,7 @@ O(V, {
|
|
|
3924
3924
|
}) : (s.opacity != null && this.attr("stop-opacity", s.opacity), s.color != null && this.attr("stop-color", s.color), s.offset != null && this.attr("offset", s.offset), this);
|
|
3925
3925
|
}
|
|
3926
3926
|
});
|
|
3927
|
-
|
|
3927
|
+
I(V, { rx: Vn, ry: Qn, from: li, to: ui });
|
|
3928
3928
|
N(V, "Runner");
|
|
3929
3929
|
class ss extends X {
|
|
3930
3930
|
constructor(t, e = t) {
|
|
@@ -4086,7 +4086,7 @@ class U extends Q {
|
|
|
4086
4086
|
return this.build(!1).rebuild();
|
|
4087
4087
|
}
|
|
4088
4088
|
}
|
|
4089
|
-
|
|
4089
|
+
I(U, yi);
|
|
4090
4090
|
T({
|
|
4091
4091
|
Container: {
|
|
4092
4092
|
// Create text element
|
|
@@ -4128,7 +4128,7 @@ class Ve extends Q {
|
|
|
4128
4128
|
` : "") : (typeof t == "function" ? (this.clear().build(!0), t.call(this, this), this.build(!1)) : this.plain(t), this);
|
|
4129
4129
|
}
|
|
4130
4130
|
}
|
|
4131
|
-
|
|
4131
|
+
I(Ve, yi);
|
|
4132
4132
|
T({
|
|
4133
4133
|
Tspan: {
|
|
4134
4134
|
tspan: R(function(s = "") {
|
|
@@ -4162,7 +4162,7 @@ class is extends Q {
|
|
|
4162
4162
|
return this.radius(new k(t).divide(2));
|
|
4163
4163
|
}
|
|
4164
4164
|
}
|
|
4165
|
-
|
|
4165
|
+
I(is, { x: si, y: ii, cx: ri, cy: oi, width: ai, height: ci });
|
|
4166
4166
|
T({
|
|
4167
4167
|
Container: {
|
|
4168
4168
|
// Create circle element
|
|
@@ -4172,7 +4172,7 @@ T({
|
|
|
4172
4172
|
}
|
|
4173
4173
|
});
|
|
4174
4174
|
N(is, "Circle");
|
|
4175
|
-
class
|
|
4175
|
+
class In extends X {
|
|
4176
4176
|
constructor(t, e = t) {
|
|
4177
4177
|
super($("clipPath", t), e);
|
|
4178
4178
|
}
|
|
@@ -4190,7 +4190,7 @@ T({
|
|
|
4190
4190
|
Container: {
|
|
4191
4191
|
// Create clipping element
|
|
4192
4192
|
clip: R(function() {
|
|
4193
|
-
return this.defs().put(new
|
|
4193
|
+
return this.defs().put(new In());
|
|
4194
4194
|
})
|
|
4195
4195
|
},
|
|
4196
4196
|
Element: {
|
|
@@ -4199,7 +4199,7 @@ T({
|
|
|
4199
4199
|
return this.reference("clip-path");
|
|
4200
4200
|
},
|
|
4201
4201
|
clipWith(s) {
|
|
4202
|
-
const t = s instanceof
|
|
4202
|
+
const t = s instanceof In ? s : this.parent().clip().add(s);
|
|
4203
4203
|
return this.attr("clip-path", "url(#" + t.id() + ")");
|
|
4204
4204
|
},
|
|
4205
4205
|
// Unclip element
|
|
@@ -4208,7 +4208,7 @@ T({
|
|
|
4208
4208
|
}
|
|
4209
4209
|
}
|
|
4210
4210
|
});
|
|
4211
|
-
N(
|
|
4211
|
+
N(In, "ClipPath");
|
|
4212
4212
|
class wi extends ut {
|
|
4213
4213
|
constructor(t, e = t) {
|
|
4214
4214
|
super($("foreignObject", t), e);
|
|
@@ -4280,7 +4280,7 @@ class B extends X {
|
|
|
4280
4280
|
super($("g", t), e);
|
|
4281
4281
|
}
|
|
4282
4282
|
}
|
|
4283
|
-
|
|
4283
|
+
I(B, _i);
|
|
4284
4284
|
T({
|
|
4285
4285
|
Container: {
|
|
4286
4286
|
// Create a group element
|
|
@@ -4303,7 +4303,7 @@ class Pe extends X {
|
|
|
4303
4303
|
return this.attr("href", t, ye);
|
|
4304
4304
|
}
|
|
4305
4305
|
}
|
|
4306
|
-
|
|
4306
|
+
I(Pe, _i);
|
|
4307
4307
|
T({
|
|
4308
4308
|
Container: {
|
|
4309
4309
|
// Create a hyperlink element
|
|
@@ -4499,20 +4499,20 @@ T({
|
|
|
4499
4499
|
}
|
|
4500
4500
|
});
|
|
4501
4501
|
N(Qe, "Use");
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4502
|
+
I([ss, Je, be, pe, We], Y("viewbox"));
|
|
4503
|
+
I([me, Ae, ve, ae], Y("marker"));
|
|
4504
|
+
I(U, Y("Text"));
|
|
4505
|
+
I(ae, Y("Path"));
|
|
4506
|
+
I(Jn, Y("Defs"));
|
|
4507
|
+
I([U, Ve], Y("Tspan"));
|
|
4508
|
+
I([xe, Xe, _e, V], Y("radius"));
|
|
4509
|
+
I(we, Y("EventTarget"));
|
|
4510
|
+
I(St, Y("Dom"));
|
|
4511
|
+
I(ut, Y("Element"));
|
|
4512
|
+
I(Q, Y("Shape"));
|
|
4513
|
+
I([X, hi], Y("Container"));
|
|
4514
|
+
I(_e, Y("Gradient"));
|
|
4515
|
+
I(V, Y("Runner"));
|
|
4516
4516
|
$t.extend(or());
|
|
4517
4517
|
Bo([
|
|
4518
4518
|
k,
|
|
@@ -4777,7 +4777,7 @@ const wa = (s) => {
|
|
|
4777
4777
|
return o.rotate(n, 0, e).translate(a, c), o;
|
|
4778
4778
|
}
|
|
4779
4779
|
return o;
|
|
4780
|
-
},
|
|
4780
|
+
}, Oe = (s, t) => {
|
|
4781
4781
|
const e = new B(), n = ba(s);
|
|
4782
4782
|
for (let i = 0; i < n.length; i++) {
|
|
4783
4783
|
let r = n[i], o = i * t.tileHeight;
|
|
@@ -4794,8 +4794,8 @@ const wa = (s) => {
|
|
|
4794
4794
|
let u = i * 3, f = r;
|
|
4795
4795
|
const m = (h + s.tileWidth + i - u) / 2, p = new U().plain(e.round).font(n).move(m, 0);
|
|
4796
4796
|
o.add(p), f += 25 * s.scale;
|
|
4797
|
-
const y = s.tileHeight, w = new B().size(h, y).translate(0, f), x = { family: n.family, size: n.size * 0.7 },
|
|
4798
|
-
w.add(
|
|
4797
|
+
const y = s.tileHeight, w = new B().size(h, y).translate(0, f), x = { family: n.family, size: n.size * 0.7 }, O = s.createStick(1e3).size(h, l).move(0, 0), H = new U().plain(c.toString()).font(x).attr({ x: h, y: l });
|
|
4798
|
+
w.add(O), w.add(H);
|
|
4799
4799
|
const tt = s.createStick(100).size(h, l).move(0, l + l), L = new U().plain(a.toString()).font(x).attr({ x: h, y: l * 3 });
|
|
4800
4800
|
w.add(tt), w.add(L);
|
|
4801
4801
|
const rt = s.createImage(e.doras[0], 0, 0).move(h + i, 0);
|
|
@@ -4844,7 +4844,7 @@ const wa = (s) => {
|
|
|
4844
4844
|
};
|
|
4845
4845
|
}, [f, m, p, y] = Aa(
|
|
4846
4846
|
e.frontPlace
|
|
4847
|
-
), w = e.scores,
|
|
4847
|
+
), w = e.scores, O = u(f, w.front, {
|
|
4848
4848
|
x: n / 2,
|
|
4849
4849
|
y: n,
|
|
4850
4850
|
"dominant-baseline": "text-after-edge",
|
|
@@ -4874,10 +4874,10 @@ const wa = (s) => {
|
|
|
4874
4874
|
-ft.height,
|
|
4875
4875
|
n / 2
|
|
4876
4876
|
);
|
|
4877
|
-
return i.add(l.e), i.add(
|
|
4877
|
+
return i.add(l.e), i.add(O), i.add(tt), i.add(rt), i.add(Pt), { e: i, width: n, height: n };
|
|
4878
4878
|
}, ka = (s, t) => {
|
|
4879
|
-
const e =
|
|
4880
|
-
(
|
|
4879
|
+
const e = Oe(t.front, s), n = Oe(t.right, s), i = Oe(t.opposite, s), r = Oe(t.left, s), o = [e.height, n.height, i.height, r.height].reduce(
|
|
4880
|
+
(O, H) => Math.max(O, H)
|
|
4881
4881
|
), a = s.tileWidth * 5 + s.tileHeight * 1, c = o, h = a + o * 2 + s.blockMargin, l = h, u = new B().size(h, l), f = h / 2 - a / 2, m = l / 2 - a / 2, p = ot(e.e, a, c, 0).translate(
|
|
4882
4882
|
f,
|
|
4883
4883
|
l - c
|
|
@@ -4908,7 +4908,7 @@ const wa = (s) => {
|
|
|
4908
4908
|
i.responsive || s.size(l.width, l.height), s.viewbox(0, 0, l.width, l.height), s.add(l.e);
|
|
4909
4909
|
};
|
|
4910
4910
|
var dt;
|
|
4911
|
-
function
|
|
4911
|
+
function Oa(s) {
|
|
4912
4912
|
return {
|
|
4913
4913
|
lang: (s == null ? void 0 : s.lang) ?? (dt == null ? void 0 : dt.lang),
|
|
4914
4914
|
message: s == null ? void 0 : s.message,
|
|
@@ -4917,7 +4917,7 @@ function Ia(s) {
|
|
|
4917
4917
|
};
|
|
4918
4918
|
}
|
|
4919
4919
|
var fn;
|
|
4920
|
-
function
|
|
4920
|
+
function Ia(s) {
|
|
4921
4921
|
return fn == null ? void 0 : fn.get(s);
|
|
4922
4922
|
}
|
|
4923
4923
|
var dn;
|
|
@@ -4948,7 +4948,7 @@ function Wt(s, t, e, n, i) {
|
|
|
4948
4948
|
lang: n.lang,
|
|
4949
4949
|
abortEarly: n.abortEarly,
|
|
4950
4950
|
abortPipeEarly: n.abortPipeEarly
|
|
4951
|
-
}, h = s.kind === "schema", l = (i == null ? void 0 : i.message) ?? s.message ?? Na(s.reference, c.lang) ?? (h ? Ea(c.lang) : null) ?? n.message ??
|
|
4951
|
+
}, h = s.kind === "schema", l = (i == null ? void 0 : i.message) ?? s.message ?? Na(s.reference, c.lang) ?? (h ? Ea(c.lang) : null) ?? n.message ?? Ia(c.lang);
|
|
4952
4952
|
l && (c.message = typeof l == "function" ? (
|
|
4953
4953
|
// @ts-expect-error
|
|
4954
4954
|
l(c)
|
|
@@ -5139,7 +5139,7 @@ function ks(...s) {
|
|
|
5139
5139
|
function Ca(s, t, e) {
|
|
5140
5140
|
const n = s._run(
|
|
5141
5141
|
{ typed: !1, value: t },
|
|
5142
|
-
|
|
5142
|
+
Oa(e)
|
|
5143
5143
|
);
|
|
5144
5144
|
return {
|
|
5145
5145
|
typed: n.typed,
|
|
@@ -5148,7 +5148,7 @@ function Ca(s, t, e) {
|
|
|
5148
5148
|
issues: n.issues
|
|
5149
5149
|
};
|
|
5150
5150
|
}
|
|
5151
|
-
const
|
|
5151
|
+
const Ie = it(
|
|
5152
5152
|
Vt({
|
|
5153
5153
|
discard: it(Le(), ""),
|
|
5154
5154
|
hand: it(Le(), ""),
|
|
@@ -5156,10 +5156,10 @@ const Oe = it(
|
|
|
5156
5156
|
}),
|
|
5157
5157
|
{ discard: "", hand: "", score: 25e3 }
|
|
5158
5158
|
), Ra = Vt({
|
|
5159
|
-
[v.E]:
|
|
5160
|
-
[v.S]:
|
|
5161
|
-
[v.W]:
|
|
5162
|
-
[v.N]:
|
|
5159
|
+
[v.E]: Ie,
|
|
5160
|
+
[v.S]: Ie,
|
|
5161
|
+
[v.W]: Ie,
|
|
5162
|
+
[v.N]: Ie
|
|
5163
5163
|
}), xt = {
|
|
5164
5164
|
round: P.E1,
|
|
5165
5165
|
sticks: { reach: 0, dead: 0 },
|
|
@@ -5495,8 +5495,8 @@ class en {
|
|
|
5495
5495
|
for (let p of [u.patternA, u.patternB])
|
|
5496
5496
|
for (let y of [f.patternA, f.patternB]) {
|
|
5497
5497
|
const w = [this.hand.called.length, 0, 0];
|
|
5498
|
-
for (let
|
|
5499
|
-
w[
|
|
5498
|
+
for (let O = 0; O < 3; O++)
|
|
5499
|
+
w[O] += m[O] + p[O] + y[O] + i[O] + o[O];
|
|
5500
5500
|
let x = this.calcCommon(w[0], w[1], w[2], n);
|
|
5501
5501
|
x < h && (h = x);
|
|
5502
5502
|
}
|
|
@@ -5718,9 +5718,9 @@ class Ts {
|
|
|
5718
5718
|
S(this, "hand");
|
|
5719
5719
|
S(this, "cfg");
|
|
5720
5720
|
this.hand = t, this.cfg = {
|
|
5721
|
-
doras: e.doraMarkers.map((n) =>
|
|
5721
|
+
doras: e.doraMarkers.map((n) => Is(n)),
|
|
5722
5722
|
// convert to dora
|
|
5723
|
-
blindDoras: e.blindDoraMarkers == null ? [] : e.blindDoraMarkers.map((n) =>
|
|
5723
|
+
blindDoras: e.blindDoraMarkers == null ? [] : e.blindDoraMarkers.map((n) => Is(n)),
|
|
5724
5724
|
roundWind: g.from(e.round.substring(0, 2)),
|
|
5725
5725
|
myWind: g.from(e.myWind),
|
|
5726
5726
|
reached: e.reached ?? 0,
|
|
@@ -5739,7 +5739,7 @@ class Ts {
|
|
|
5739
5739
|
let n = [0, 0], i = 0;
|
|
5740
5740
|
for (let p = 0; p < e.length; p++) {
|
|
5741
5741
|
const y = e[p], w = y.points.reduce(
|
|
5742
|
-
(x,
|
|
5742
|
+
(x, O) => x + O.double,
|
|
5743
5743
|
0
|
|
5744
5744
|
);
|
|
5745
5745
|
(w > n[0] || w == n[0] && y.fu > n[1]) && (i = p, n[0] = w, n[1] = y.fu);
|
|
@@ -5882,7 +5882,7 @@ class Ts {
|
|
|
5882
5882
|
) ? [] : [{ name: "断么九", double: 1 }];
|
|
5883
5883
|
}
|
|
5884
5884
|
dE1(t) {
|
|
5885
|
-
return this.minus() != 0 ? [] :
|
|
5885
|
+
return this.minus() != 0 ? [] : Os(t) == 1 ? [{ name: "一盃口", double: 1 }] : [];
|
|
5886
5886
|
}
|
|
5887
5887
|
dF1(t) {
|
|
5888
5888
|
const e = [];
|
|
@@ -6014,7 +6014,7 @@ class Ts {
|
|
|
6014
6014
|
return t.length == 7 ? [] : t.some((n) => n instanceof Nt || n instanceof lt) ? t.some((n) => n.tiles[0].t == d.Z) ? [] : t.every((n) => n.tiles.some((i) => wt.includes(i.n))) ? [{ name: "純全帯么九色", double: 3 - this.minus() }] : [] : [];
|
|
6015
6015
|
}
|
|
6016
6016
|
dC3(t) {
|
|
6017
|
-
return this.minus() != 0 ? [] :
|
|
6017
|
+
return this.minus() != 0 ? [] : Os(t) == 2 ? [{ name: "ニ盃口", double: 3 }] : [];
|
|
6018
6018
|
}
|
|
6019
6019
|
dA6(t) {
|
|
6020
6020
|
if (t.some((e) => e.tiles[0].t == d.Z)) return [];
|
|
@@ -6116,7 +6116,7 @@ class Ts {
|
|
|
6116
6116
|
return !a && n == 20 && (m = !0), c && !m && (n += 2), !c && !a && (n += 10), !c && !a && n == 30 && (m = !0), a && n == 20 && (n = 30), n;
|
|
6117
6117
|
}
|
|
6118
6118
|
}
|
|
6119
|
-
const Ai = (s) => s.tiles.reduce((t, e) => `${t}${e.n}${e.t}`, ""),
|
|
6119
|
+
const Ai = (s) => s.tiles.reduce((t, e) => `${t}${e.n}${e.t}`, ""), Os = (s) => {
|
|
6120
6120
|
let t = {};
|
|
6121
6121
|
for (let n of s) {
|
|
6122
6122
|
if (!(n instanceof Nt)) continue;
|
|
@@ -6127,21 +6127,21 @@ const Ai = (s) => s.tiles.reduce((t, e) => `${t}${e.n}${e.t}`, ""), Is = (s) =>
|
|
|
6127
6127
|
for (let n in t)
|
|
6128
6128
|
t[n] >= 2 && e++;
|
|
6129
6129
|
return e;
|
|
6130
|
-
}, kt = (s) => [...s.tiles].sort(Re)[0],
|
|
6130
|
+
}, kt = (s) => [...s.tiles].sort(Re)[0], Is = (s) => {
|
|
6131
6131
|
let t = K(s) ? 5 : s.n, e = s.t;
|
|
6132
6132
|
return new g(e, t % 9 + 1);
|
|
6133
6133
|
};
|
|
6134
6134
|
class Qt {
|
|
6135
6135
|
// ツモった後の14枚の手配から、牌効率に従って捨てるべき牌を返す。
|
|
6136
6136
|
// choices は、通常なら hand.hand を指定する。ただし、リーチしている場合は捨てる牌が限られているので choices で制限する。
|
|
6137
|
-
static calcCandidates(t, e, n
|
|
6137
|
+
static calcCandidates(t, e, n) {
|
|
6138
6138
|
C(e.length > 0, "choices to discard is zero");
|
|
6139
6139
|
const i = /* @__PURE__ */ new Map();
|
|
6140
6140
|
let r = Number.POSITIVE_INFINITY;
|
|
6141
6141
|
for (let o of e) {
|
|
6142
|
-
const a = t.dec([o]), c = Qt.candidateTiles(t);
|
|
6142
|
+
const a = t.dec([o]), c = Qt.candidateTiles(t, n);
|
|
6143
6143
|
t.inc(a);
|
|
6144
|
-
const h = n && K(o) ? o.clone({ n: 5, removeAll: !0 }) : o.clone({ removeAll: !0 });
|
|
6144
|
+
const h = n != null && n.arrangeRed && K(o) ? o.clone({ n: 5, removeAll: !0 }) : o.clone({ removeAll: !0 });
|
|
6145
6145
|
c.shanten < r ? (i.clear(), i.set(h.toString(), {
|
|
6146
6146
|
shanten: c.shanten,
|
|
6147
6147
|
candidates: c.candidates,
|
|
@@ -6155,25 +6155,25 @@ class Qt {
|
|
|
6155
6155
|
return Array.from(i.values());
|
|
6156
6156
|
}
|
|
6157
6157
|
// 積もる前の13枚の手配から、有効牌の一覧を返す
|
|
6158
|
-
static candidateTiles(t) {
|
|
6159
|
-
let
|
|
6160
|
-
const
|
|
6161
|
-
for (let
|
|
6162
|
-
if (
|
|
6163
|
-
for (let
|
|
6164
|
-
if (t.get(
|
|
6165
|
-
const
|
|
6166
|
-
t.dec(
|
|
6158
|
+
static candidateTiles(t, e) {
|
|
6159
|
+
let n = Number.POSITIVE_INFINITY, i = [];
|
|
6160
|
+
const r = new en(t);
|
|
6161
|
+
for (let o of Object.values(d))
|
|
6162
|
+
if (o != d.BACK)
|
|
6163
|
+
for (let a = 1; a < t.getArrayLen(o); a++) {
|
|
6164
|
+
if (t.get(o, a) >= 4) continue;
|
|
6165
|
+
const c = new g(o, a), h = t.inc([c]), l = e != null && e.fourSetsOnePair ? r.fourSetsOnePair() : r.calc();
|
|
6166
|
+
t.dec(h), l < n ? (n = l, i = [c]) : l == n && i.push(c);
|
|
6167
6167
|
}
|
|
6168
6168
|
return {
|
|
6169
|
-
shanten:
|
|
6170
|
-
candidates:
|
|
6169
|
+
shanten: n,
|
|
6170
|
+
candidates: i
|
|
6171
6171
|
};
|
|
6172
6172
|
}
|
|
6173
6173
|
// allow a partial input such as 23456s11z => 1,4,7s
|
|
6174
|
-
static partialCandidateTiles(t) {
|
|
6175
|
-
const
|
|
6176
|
-
return Array(13 -
|
|
6174
|
+
static partialCandidateTiles(t, e) {
|
|
6175
|
+
const n = new tn(t, !0);
|
|
6176
|
+
return Array(13 - n.hands.length).fill(void 0).map(() => n.inc([new g(d.BACK, 0)])), Qt.candidateTiles(n, e);
|
|
6177
6177
|
}
|
|
6178
6178
|
}
|
|
6179
6179
|
const Rn = () => {
|
|
@@ -6385,7 +6385,7 @@ class Xa {
|
|
|
6385
6385
|
};
|
|
6386
6386
|
}
|
|
6387
6387
|
}
|
|
6388
|
-
class
|
|
6388
|
+
class Oi {
|
|
6389
6389
|
constructor() {
|
|
6390
6390
|
S(this, "m", []);
|
|
6391
6391
|
}
|
|
@@ -6464,7 +6464,7 @@ class Es {
|
|
|
6464
6464
|
this._last = null;
|
|
6465
6465
|
}
|
|
6466
6466
|
}
|
|
6467
|
-
const
|
|
6467
|
+
const Ii = ".", tc = "", Ei = "", ec = "#", nc = "*", Ni = "xstate.init", $n = "xstate.stop";
|
|
6468
6468
|
function sc(s, t) {
|
|
6469
6469
|
return {
|
|
6470
6470
|
type: `xstate.after.${s}.${t}`
|
|
@@ -6617,12 +6617,12 @@ function lc(s, t) {
|
|
|
6617
6617
|
delay: y,
|
|
6618
6618
|
id: w,
|
|
6619
6619
|
startedAt: Date.now()
|
|
6620
|
-
},
|
|
6621
|
-
u._snapshot._scheduledEvents[
|
|
6620
|
+
}, O = Cs(f, w);
|
|
6621
|
+
u._snapshot._scheduledEvents[O] = x;
|
|
6622
6622
|
const H = a.setTimeout(() => {
|
|
6623
|
-
delete o[
|
|
6623
|
+
delete o[O], delete u._snapshot._scheduledEvents[O], u._relay(f, m, p);
|
|
6624
6624
|
}, y);
|
|
6625
|
-
o[
|
|
6625
|
+
o[O] = H;
|
|
6626
6626
|
},
|
|
6627
6627
|
cancel: (f, m) => {
|
|
6628
6628
|
const p = Cs(f, m), y = o[p];
|
|
@@ -6695,9 +6695,9 @@ function lc(s, t) {
|
|
|
6695
6695
|
target: y,
|
|
6696
6696
|
event: w,
|
|
6697
6697
|
delay: x,
|
|
6698
|
-
id:
|
|
6698
|
+
id: O
|
|
6699
6699
|
} = f[m];
|
|
6700
|
-
h.schedule(p, y, w, x,
|
|
6700
|
+
h.schedule(p, y, w, x, O);
|
|
6701
6701
|
}
|
|
6702
6702
|
},
|
|
6703
6703
|
_clock: a,
|
|
@@ -7398,7 +7398,7 @@ function kc(s, t) {
|
|
|
7398
7398
|
return e;
|
|
7399
7399
|
if (nn(e))
|
|
7400
7400
|
return s.machine.getStateNodeById(e);
|
|
7401
|
-
const n = e[0] ===
|
|
7401
|
+
const n = e[0] === Ii;
|
|
7402
7402
|
if (n && !s.parent)
|
|
7403
7403
|
return Ze(s, e.slice(1));
|
|
7404
7404
|
const i = n ? s.key + e : e;
|
|
@@ -7488,11 +7488,11 @@ function Tc(s, t, e, n) {
|
|
|
7488
7488
|
const r = ne(s, t).next(e, n);
|
|
7489
7489
|
return !r || !r.length ? s.next(e, n) : r;
|
|
7490
7490
|
}
|
|
7491
|
-
function
|
|
7491
|
+
function Oc(s, t, e, n) {
|
|
7492
7492
|
const i = Object.keys(t), r = ne(s, i[0]), o = fs(r, t[i[0]], e, n);
|
|
7493
7493
|
return !o || !o.length ? s.next(e, n) : o;
|
|
7494
7494
|
}
|
|
7495
|
-
function
|
|
7495
|
+
function Ic(s, t, e, n) {
|
|
7496
7496
|
const i = [];
|
|
7497
7497
|
for (const r of Object.keys(t)) {
|
|
7498
7498
|
const o = t[r];
|
|
@@ -7504,7 +7504,7 @@ function Oc(s, t, e, n) {
|
|
|
7504
7504
|
return i.length ? i : s.next(e, n);
|
|
7505
7505
|
}
|
|
7506
7506
|
function fs(s, t, e, n) {
|
|
7507
|
-
return typeof t == "string" ? Tc(s, t, e, n) : Object.keys(t).length === 1 ?
|
|
7507
|
+
return typeof t == "string" ? Tc(s, t, e, n) : Object.keys(t).length === 1 ? Oc(s, t, e, n) : Ic(s, t, e, n);
|
|
7508
7508
|
}
|
|
7509
7509
|
function Ec(s) {
|
|
7510
7510
|
return Object.keys(s.states).map((t) => s.states[t]).filter((t) => t.type === "history");
|
|
@@ -8108,7 +8108,7 @@ const Vc = {}, he = (s) => typeof s == "string" ? {
|
|
|
8108
8108
|
} : s;
|
|
8109
8109
|
class ps {
|
|
8110
8110
|
constructor(t, e) {
|
|
8111
|
-
if (this.config = t, this.key = void 0, this.id = void 0, this.type = void 0, this.path = void 0, this.states = void 0, this.history = void 0, this.entry = void 0, this.exit = void 0, this.parent = void 0, this.machine = void 0, this.meta = void 0, this.output = void 0, this.order = -1, this.description = void 0, this.tags = [], this.transitions = void 0, this.always = void 0, this.parent = e._parent, this.key = e._key, this.machine = e._machine, this.path = this.parent ? this.parent.path.concat(this.key) : [], this.id = this.config.id || [this.machine.id, ...this.path].join(
|
|
8111
|
+
if (this.config = t, this.key = void 0, this.id = void 0, this.type = void 0, this.path = void 0, this.states = void 0, this.history = void 0, this.entry = void 0, this.exit = void 0, this.parent = void 0, this.machine = void 0, this.meta = void 0, this.output = void 0, this.order = -1, this.description = void 0, this.tags = [], this.transitions = void 0, this.always = void 0, this.parent = e._parent, this.key = e._key, this.machine = e._machine, this.path = this.parent ? this.parent.path.concat(this.key) : [], this.id = this.config.id || [this.machine.id, ...this.path].join(Ii), this.type = this.config.type || (this.config.states && Object.keys(this.config.states).length ? "compound" : this.config.history ? "history" : "atomic"), this.description = this.config.description, this.order = this.machine.idMap.size, this.machine.idMap.set(this.id, this), this.states = this.config.states ? Ms(this.config.states, (n, i) => new ps(n, {
|
|
8112
8112
|
_parent: this,
|
|
8113
8113
|
_key: i,
|
|
8114
8114
|
_machine: this.machine
|
|
@@ -9474,7 +9474,7 @@ class sn {
|
|
|
9474
9474
|
])
|
|
9475
9475
|
), o.length == 0) return !1;
|
|
9476
9476
|
if (i.hands.length == 4) {
|
|
9477
|
-
const m = o[0], p = this.cannotDiscardTile(o[0]), y = i.dec([m.tiles[1], m.tiles[2]]), w = p.reduce((x,
|
|
9477
|
+
const m = o[0], p = this.cannotDiscardTile(o[0]), y = i.dec([m.tiles[1], m.tiles[2]]), w = p.reduce((x, O) => x + i.get(O.t, O.n), 0) == 2;
|
|
9478
9478
|
if (i.inc(y), w) return !1;
|
|
9479
9479
|
}
|
|
9480
9480
|
const u = i.get(n.t, 0) > 0, f = this.redPattern(o, u);
|
|
@@ -9616,7 +9616,7 @@ class ie extends tn {
|
|
|
9616
9616
|
class Zi {
|
|
9617
9617
|
constructor(t, e) {
|
|
9618
9618
|
S(this, "id");
|
|
9619
|
-
S(this, "river", new
|
|
9619
|
+
S(this, "river", new Oi());
|
|
9620
9620
|
S(this, "placeManager", new Fe({}));
|
|
9621
9621
|
// empty for init
|
|
9622
9622
|
S(this, "scoreManager", new Ue({}));
|
|
@@ -9820,7 +9820,7 @@ class ih extends Zi {
|
|
|
9820
9820
|
class Me extends Zi {
|
|
9821
9821
|
constructor(e, n) {
|
|
9822
9822
|
super(e, n);
|
|
9823
|
-
S(this, "river", new
|
|
9823
|
+
S(this, "river", new Oi());
|
|
9824
9824
|
S(this, "doras", []);
|
|
9825
9825
|
this.eventHandler.on((i) => this.handleEvent(i));
|
|
9826
9826
|
}
|
|
@@ -10020,7 +10020,7 @@ export {
|
|
|
10020
10020
|
js as ROUND_MAP,
|
|
10021
10021
|
ph as Replayer,
|
|
10022
10022
|
fe as RiskRank,
|
|
10023
|
-
|
|
10023
|
+
Oi as River,
|
|
10024
10024
|
Ue as ScoreManager,
|
|
10025
10025
|
en as ShantenCalculator,
|
|
10026
10026
|
Qi as TABLE_CONTEXT,
|