@mborecki/sliding-puzzle 0.1.0
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/cjs/app-globals-V2Kpy_OQ.js +5 -0
- package/dist/cjs/index-C425pVBv.js +3053 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +13 -0
- package/dist/cjs/mb-sliding-puzzle.cjs.entry.js +170 -0
- package/dist/cjs/sliding-puzzle.cjs.js +25 -0
- package/dist/collection/collection-manifest.json +12 -0
- package/dist/collection/components/sliding-puzzle/sliding-puzzle.css +25 -0
- package/dist/collection/components/sliding-puzzle/sliding-puzzle.js +119 -0
- package/dist/collection/components/sliding-puzzle/types.js +1 -0
- package/dist/collection/index.js +1 -0
- package/dist/components/index.d.ts +35 -0
- package/dist/components/index.js +1 -0
- package/dist/components/mb-sliding-puzzle.d.ts +11 -0
- package/dist/components/mb-sliding-puzzle.js +1 -0
- package/dist/esm/app-globals-DQuL1Twl.js +3 -0
- package/dist/esm/index-CoGw-MK9.js +3047 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +11 -0
- package/dist/esm/mb-sliding-puzzle.entry.js +168 -0
- package/dist/esm/sliding-puzzle.js +21 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/sliding-puzzle/index.esm.js +0 -0
- package/dist/sliding-puzzle/p-CoGw-MK9.js +2 -0
- package/dist/sliding-puzzle/p-DQuL1Twl.js +1 -0
- package/dist/sliding-puzzle/p-a6576773.entry.js +1 -0
- package/dist/sliding-puzzle/sliding-puzzle.esm.js +1 -0
- package/dist/types/components/sliding-puzzle/sliding-puzzle.d.ts +11 -0
- package/dist/types/components/sliding-puzzle/types.d.ts +10 -0
- package/dist/types/components.d.ts +48 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/roboczy/mb-puzzle/apps/sliding-puzzle/.stencil/apps/sliding-puzzle/vitest.config.d.ts +2 -0
- package/dist/types/roboczy/mb-puzzle/apps/sliding-puzzle/.stencil/shared/grid/src/grid.d.ts +14 -0
- package/dist/types/roboczy/mb-puzzle/apps/sliding-puzzle/.stencil/shared/grid/vitest.config.d.ts +2 -0
- package/dist/types/roboczy/mb-puzzle/apps/sliding-puzzle/.stencil/shared/vec2/src/vec2.d.ts +24 -0
- package/dist/types/roboczy/mb-puzzle/apps/sliding-puzzle/.stencil/shared/vec2/src/vec2.test.d.ts +1 -0
- package/dist/types/roboczy/mb-puzzle/apps/sliding-puzzle/.stencil/shared/vec2/vitest.config.d.ts +2 -0
- package/dist/types/stencil-public-runtime.d.ts +1839 -0
- package/dist/vitest.config.js +4 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/package.json +53 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { b as bootstrapLazy } from './index-CoGw-MK9.js';
|
|
2
|
+
export { s as setNonce } from './index-CoGw-MK9.js';
|
|
3
|
+
import { g as globalScripts } from './app-globals-DQuL1Twl.js';
|
|
4
|
+
|
|
5
|
+
const defineCustomElements = async (win, options) => {
|
|
6
|
+
if (typeof window === 'undefined') return undefined;
|
|
7
|
+
await globalScripts();
|
|
8
|
+
return bootstrapLazy([["mb-sliding-puzzle",[[513,"mb-sliding-puzzle",{"tiles":[1040],"size":[32],"checkAnswer":[64]}]]]], options);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { defineCustomElements };
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { r as registerInstance, h } from './index-CoGw-MK9.js';
|
|
2
|
+
|
|
3
|
+
class Vec2 {
|
|
4
|
+
x;
|
|
5
|
+
y;
|
|
6
|
+
get 0() {
|
|
7
|
+
return this.x;
|
|
8
|
+
}
|
|
9
|
+
set 0(x) {
|
|
10
|
+
this.x = x;
|
|
11
|
+
}
|
|
12
|
+
get 1() {
|
|
13
|
+
return this.y;
|
|
14
|
+
}
|
|
15
|
+
set 1(y) {
|
|
16
|
+
this.y = y;
|
|
17
|
+
}
|
|
18
|
+
get width() {
|
|
19
|
+
return this.x;
|
|
20
|
+
}
|
|
21
|
+
set width(x) {
|
|
22
|
+
this.x = x;
|
|
23
|
+
}
|
|
24
|
+
get height() {
|
|
25
|
+
return this.y;
|
|
26
|
+
}
|
|
27
|
+
set height(y) {
|
|
28
|
+
this.y = y;
|
|
29
|
+
}
|
|
30
|
+
get xy() {
|
|
31
|
+
return [this.x, this.y];
|
|
32
|
+
}
|
|
33
|
+
*[Symbol.iterator]() {
|
|
34
|
+
yield this.x;
|
|
35
|
+
yield this.y;
|
|
36
|
+
}
|
|
37
|
+
constructor(x, y) {
|
|
38
|
+
this.x = x;
|
|
39
|
+
this.y = y;
|
|
40
|
+
}
|
|
41
|
+
add(v) {
|
|
42
|
+
return new Vec2(this.x + v.x, this.y + v.y);
|
|
43
|
+
}
|
|
44
|
+
eq(v) {
|
|
45
|
+
return this.x === v.x && this.y === v.y;
|
|
46
|
+
}
|
|
47
|
+
clone() {
|
|
48
|
+
return new Vec2(this.x, this.y);
|
|
49
|
+
}
|
|
50
|
+
static from(source) {
|
|
51
|
+
if (typeof source === 'number') {
|
|
52
|
+
return new Vec2(source, source);
|
|
53
|
+
}
|
|
54
|
+
if (Array.isArray(source)) {
|
|
55
|
+
return new Vec2(source[0] ?? 0, source[1] ?? 0);
|
|
56
|
+
}
|
|
57
|
+
if (typeof source === 'object' && typeof source.x === 'number' && typeof source.y === 'number') {
|
|
58
|
+
return new Vec2(source.x, source.y);
|
|
59
|
+
}
|
|
60
|
+
throw new Error('Wrong Vec2 source');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
class Grid {
|
|
65
|
+
size;
|
|
66
|
+
constructor(size) {
|
|
67
|
+
if (size.x <= 0 || size.y <= 0) {
|
|
68
|
+
throw new Error(`Invalid grid size: width and height must be positive (got ${size.x}x${size.y})`);
|
|
69
|
+
}
|
|
70
|
+
this.size = size;
|
|
71
|
+
}
|
|
72
|
+
getIndexFromVec(v) {
|
|
73
|
+
return Grid.getIndexFromVec(v, this.size.width);
|
|
74
|
+
}
|
|
75
|
+
getVecFromIndex(index) {
|
|
76
|
+
return Grid.getVecFromIndex(index, this.size.width);
|
|
77
|
+
}
|
|
78
|
+
isBlack(v) {
|
|
79
|
+
return Boolean((v.x + v.y) % 2);
|
|
80
|
+
}
|
|
81
|
+
isWhite(v) {
|
|
82
|
+
return !Boolean((v.x + v.y) % 2);
|
|
83
|
+
}
|
|
84
|
+
isInGrid(v) {
|
|
85
|
+
return Grid.isInGrid(v, this.size);
|
|
86
|
+
}
|
|
87
|
+
static getVecFromIndex(index, width) {
|
|
88
|
+
const _w = width instanceof Vec2 ? width.width : width;
|
|
89
|
+
const x = index % _w;
|
|
90
|
+
const y = Math.floor(index / _w);
|
|
91
|
+
return new Vec2(x, y);
|
|
92
|
+
}
|
|
93
|
+
static getIndexFromVec(v, width) {
|
|
94
|
+
const _w = width instanceof Vec2 ? width.width : width;
|
|
95
|
+
return v.y * _w + v.x;
|
|
96
|
+
}
|
|
97
|
+
static isInGrid(v, size) {
|
|
98
|
+
return v.x >= 0 && size.x > v.x && v.y >= 0 && size.y > v.y;
|
|
99
|
+
}
|
|
100
|
+
static getOrtoSiblings(v, size) {
|
|
101
|
+
const dirs = [
|
|
102
|
+
new Vec2(-1, 0),
|
|
103
|
+
new Vec2(1, 0),
|
|
104
|
+
new Vec2(0, -1),
|
|
105
|
+
new Vec2(0, 1),
|
|
106
|
+
];
|
|
107
|
+
return dirs.map(d => d.add(v))
|
|
108
|
+
.filter(v => Grid.isInGrid(v, size));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const slidingPuzzleCss = () => `.board{width:100%;height:100%;display:inline-block;aspect-ratio:calc(var(--width, 1) / var(--height, 1));border:1px solid black;position:relative;container-type:size}.tile{position:absolute;width:calc(100cqw / var(--width, 1));height:calc(100cqh / var(--height, 1));padding:0;border:none;transform:translate(calc(100% * var(--x)), calc(100% * var(--y)));transition:transform 0.5s}.tile img{display:block;width:100%;height:100%;pointer-events:none}`;
|
|
113
|
+
|
|
114
|
+
const MbSlidingPuzzle = class {
|
|
115
|
+
constructor(hostRef) {
|
|
116
|
+
registerInstance(this, hostRef);
|
|
117
|
+
}
|
|
118
|
+
size = new Vec2(3, 3);
|
|
119
|
+
tiles = [];
|
|
120
|
+
async checkAnswer() {
|
|
121
|
+
return this.tiles.every(t => t.position === t.correctPosition);
|
|
122
|
+
}
|
|
123
|
+
getTileById(id) {
|
|
124
|
+
const tile = this.tiles.find(t => t.id === id);
|
|
125
|
+
if (!tile) {
|
|
126
|
+
throw new Error('Tile not found');
|
|
127
|
+
}
|
|
128
|
+
return tile;
|
|
129
|
+
}
|
|
130
|
+
onTileClicked(id) {
|
|
131
|
+
const tile = this.getTileById(id);
|
|
132
|
+
const v = Grid.getVecFromIndex(tile.position, this.size.width);
|
|
133
|
+
const siblings = Grid.getOrtoSiblings(v, this.size);
|
|
134
|
+
const emptySibling = siblings.find(v => {
|
|
135
|
+
const index = Grid.getIndexFromVec(v, this.size.width);
|
|
136
|
+
return this.tiles.every(t => t.position !== index);
|
|
137
|
+
});
|
|
138
|
+
if (emptySibling) {
|
|
139
|
+
this.setTilePosition(tile, Grid.getIndexFromVec(emptySibling, this.size));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
setTilePosition(tile, position) {
|
|
143
|
+
const id = typeof tile === 'string' ? tile : tile.id;
|
|
144
|
+
this.tiles = this.tiles.map(t => {
|
|
145
|
+
if (t.id !== id)
|
|
146
|
+
return t;
|
|
147
|
+
return {
|
|
148
|
+
...t,
|
|
149
|
+
position
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
render() {
|
|
154
|
+
return h("div", { key: 'b22497e26d2ce6f7aeadc788f9475bb9fcd92e76', class: "board", style: {
|
|
155
|
+
'--width': `${this.size.width}`,
|
|
156
|
+
'--height': `${this.size.height}`,
|
|
157
|
+
} }, this.tiles.map(tile => {
|
|
158
|
+
const v = Grid.getVecFromIndex(tile.position, this.size.width);
|
|
159
|
+
return h("button", { key: tile.id, class: "tile", style: {
|
|
160
|
+
'--x': `${v.x}`,
|
|
161
|
+
'--y': `${v.y}`
|
|
162
|
+
}, onClick: this.onTileClicked.bind(this, tile.id) }, h("img", { src: tile.imageSrc, alt: "" }));
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
MbSlidingPuzzle.style = slidingPuzzleCss();
|
|
167
|
+
|
|
168
|
+
export { MbSlidingPuzzle as mb_sliding_puzzle };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { p as promiseResolve, b as bootstrapLazy } from './index-CoGw-MK9.js';
|
|
2
|
+
export { s as setNonce } from './index-CoGw-MK9.js';
|
|
3
|
+
import { g as globalScripts } from './app-globals-DQuL1Twl.js';
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
Stencil Client Patch Browser v4.41.0 | MIT Licensed | https://stenciljs.com
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
var patchBrowser = () => {
|
|
10
|
+
const importMeta = import.meta.url;
|
|
11
|
+
const opts = {};
|
|
12
|
+
if (importMeta !== "") {
|
|
13
|
+
opts.resourcesUrl = new URL(".", importMeta).href;
|
|
14
|
+
}
|
|
15
|
+
return promiseResolve(opts);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
patchBrowser().then(async (options) => {
|
|
19
|
+
await globalScripts();
|
|
20
|
+
return bootstrapLazy([["mb-sliding-puzzle",[[513,"mb-sliding-puzzle",{"tiles":[1040],"size":[32],"checkAnswer":[64]}]]]], options);
|
|
21
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./cjs/index.cjs.js');
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './esm/index.js';
|
|
File without changes
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var t,e,n,i,s,r,o,l,h,c,f,u,a,p,d,v,m,w=Object.create,b=Object.defineProperty,g=Object.getOwnPropertyDescriptor,y=Object.getOwnPropertyNames,$=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty,O=t=>{throw TypeError(t)},j=(t,e)=>function(){return e||(0,t[y(t)[0]])((e={exports:{}}).exports,e),e.exports},E=(t,e,n)=>e.has(t)||O("Cannot "+n),M=(t,e,n)=>(E(t,e,"read from private field"),n?n.call(t):e.get(t)),k=(t,e,n)=>e.has(t)?O("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),x=(t,e,n)=>(E(t,e,"write to private field"),e.set(t,n),n),N=(t,e,n)=>(E(t,e,"access private method"),n),P=j({"node_modules/balanced-match/index.js"(t,e){function n(t,e,n){t instanceof RegExp&&(t=i(t,n)),e instanceof RegExp&&(e=i(e,n));var r=s(t,e,n);return r&&{start:r[0],end:r[1],pre:n.slice(0,r[0]),body:n.slice(r[0]+t.length,r[1]),post:n.slice(r[1]+e.length)}}function i(t,e){var n=e.match(t);return n?n[0]:null}function s(t,e,n){var i,s,r,o,l,h=n.indexOf(t),c=n.indexOf(e,h+1),f=h;if(h>=0&&c>0){if(t===e)return[h,c];for(i=[],r=n.length;f>=0&&!l;)f==h?(i.push(f),h=n.indexOf(t,f+1)):1==i.length?l=[i.pop(),c]:((s=i.pop())<r&&(r=s,o=c),c=n.indexOf(e,f+1)),f=h<c&&h>=0?h:c;i.length&&(l=[r,o])}return l}e.exports=n,n.range=s}}),R=j({"node_modules/brace-expansion/index.js"(t,e){var n=P();e.exports=function(t){return t?("{}"===t.substr(0,2)&&(t="\\{\\}"+t.substr(2)),v(function(t){return t.split("\\\\").join(i).split("\\{").join(s).split("\\}").join(r).split("\\,").join(o).split("\\.").join(l)}(t),!0).map(c)):[]};var i="\0SLASH"+Math.random()+"\0",s="\0OPEN"+Math.random()+"\0",r="\0CLOSE"+Math.random()+"\0",o="\0COMMA"+Math.random()+"\0",l="\0PERIOD"+Math.random()+"\0";function h(t){return parseInt(t,10)==t?parseInt(t,10):t.charCodeAt(0)}function c(t){return t.split(i).join("\\").split(s).join("{").split(r).join("}").split(o).join(",").split(l).join(".")}function f(t){if(!t)return[""];var e=[],i=n("{","}",t);if(!i)return t.split(",");var s=i.body,r=i.post,o=i.pre.split(",");o[o.length-1]+="{"+s+"}";var l=f(r);return r.length&&(o[o.length-1]+=l.shift(),o.push.apply(o,l)),e.push.apply(e,o),e}function u(t){return"{"+t+"}"}function a(t){return/^-?0\d/.test(t)}function p(t,e){return t<=e}function d(t,e){return t>=e}function v(t,e){var i=[],s=n("{","}",t);if(!s)return[t];var o=s.pre,l=s.post.length?v(s.post,!1):[""];if(/\$$/.test(s.pre))for(var c=0;c<l.length;c++)i.push(C=o+"{"+s.body+"}"+l[c]);else{var m,w,b=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(s.body),g=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(s.body),y=b||g,$=s.body.indexOf(",")>=0;if(!y&&!$)return s.post.match(/,(?!,).*\}/)?v(t=s.pre+"{"+s.body+r+s.post):[t];if(y)m=s.body.split(/\.\./);else if(1===(m=f(s.body)).length&&1===(m=v(m[0],!1).map(u)).length)return l.map((function(t){return s.pre+m[0]+t}));if(y){var S=h(m[0]),O=h(m[1]),j=Math.max(m[0].length,m[1].length),E=3==m.length?Math.abs(h(m[2])):1,M=p;O<S&&(E*=-1,M=d);var k=m.some(a);w=[];for(var x=S;M(x,O);x+=E){var N;if(g)"\\"===(N=String.fromCharCode(x))&&(N="");else if(N=x+"",k){var P=j-N.length;if(P>0){var R=Array(P+1).join("0");N=x<0?"-"+R+N.slice(1):R+N}}w.push(N)}}else{w=[];for(var W=0;W<m.length;W++)w.push.apply(w,v(m[W],!1))}for(W=0;W<w.length;W++)for(c=0;c<l.length;c++){var C=o+w[W]+l[c];(!e||y||C)&&i.push(C)}}return i}}}),W=(t,e)=>{var n;Object.entries(null!=(n=e.i.t)?n:{}).map((([n,[i]])=>{if(31&i||32&i){const i=t[n],s=function(t,e){for(;t;){const n=Object.getOwnPropertyDescriptor(t,e);if(null==n?void 0:n.get)return n;t=Object.getPrototypeOf(t)}}(Object.getPrototypeOf(t),n)||Object.getOwnPropertyDescriptor(t,n);s&&Object.defineProperty(t,n,{get(){return s.get.call(this)},set(t){s.set.call(this,t)},configurable:!0,enumerable:!0}),t[n]=e.o.has(n)?e.o.get(n):i}}))},C=t=>{if(t.__stencil__getHostRef)return t.__stencil__getHostRef()},z=(t,e)=>{e&&(t.__stencil__getHostRef=()=>e,e.l=t,512&e.i.h&&W(t,e))},L=(t,e)=>e in t,A=(t,e)=>(0,console.error)(t,e),T=new Map,_=new Map,D="slot-fb{display:contents}slot-fb[hidden]{display:none}",G="undefined"!=typeof window?window:{},U={h:0,u:"",jmp:t=>t(),raf:t=>requestAnimationFrame(t),ael:(t,e,n,i)=>t.addEventListener(e,n,i),rel:(t,e,n,i)=>t.removeEventListener(e,n,i),ce:(t,e)=>new CustomEvent(t,e)},I=t=>Promise.resolve(t),Z=(()=>{try{return!!G.document.adoptedStyleSheets&&(new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replaceSync)}catch(t){}return!1})(),F=!!Z&&(()=>!!G.document&&Object.getOwnPropertyDescriptor(G.document.adoptedStyleSheets,"length").writable)(),H=!1,V=[],q=[],B=(t,e)=>n=>{t.push(n),H||(H=!0,e&&4&U.h?K(Y):U.raf(Y))},J=t=>{for(let e=0;e<t.length;e++)try{t[e](performance.now())}catch(t){A(t)}t.length=0},Y=()=>{J(V),J(q),(H=V.length>0)&&U.raf(Y)},K=t=>I().then(t),Q=B(q,!0),X=t=>"object"==(t=typeof t)||"function"===t,tt=((t,e,n)=>(n=null!=t?w($(t)):{},((t,e,n,i)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let n of y(e))S.call(t,n)||undefined===n||b(t,n,{get:()=>e[n],enumerable:!(i=g(e,n))||i.enumerable});return t})(b(n,"default",{value:t,enumerable:!0}),t)))(R()),et=t=>{if("string"!=typeof t)throw new TypeError("invalid pattern");if(t.length>65536)throw new TypeError("pattern is too long")},nt={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},it=t=>t.replace(/[[\]\\-]/g,"\\$&"),st=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),rt=t=>t.join(""),ot=(t,e)=>{const n=e;if("["!==t.charAt(n))throw Error("not in a brace expression");const i=[],s=[];let r=n+1,o=!1,l=!1,h=!1,c=!1,f=n,u="";t:for(;r<t.length;){const e=t.charAt(r);if("!"!==e&&"^"!==e||r!==n+1){if("]"===e&&o&&!h){f=r+1;break}if(o=!0,"\\"!==e||h){if("["===e&&!h)for(const[e,[o,h,c]]of Object.entries(nt))if(t.startsWith(e,r)){if(u)return["$.",!1,t.length-n,!0];r+=e.length,c?s.push(o):i.push(o),l=l||h;continue t}h=!1,u?(e>u?i.push(it(u)+"-"+it(e)):e===u&&i.push(it(e)),u="",r++):t.startsWith("-]",r+1)?(i.push(it(e+"-")),r+=2):t.startsWith("-",r+1)?(u=e,r+=2):(i.push(it(e)),r++)}else h=!0,r++}else c=!0,r++}if(f<r)return["",!1,0,!1];if(!i.length&&!s.length)return["$.",!1,t.length-n,!0];if(0===s.length&&1===i.length&&/^\\?.$/.test(i[0])&&!c){const t=2===i[0].length?i[0].slice(-1):i[0];return[st(t),!1,f-n,!1]}const a="["+(c?"^":"")+rt(i)+"]",p="["+(c?"":"^")+rt(s)+"]";return[i.length&&s.length?"("+a+"|"+p+")":i.length?a:p,l,f-n,!0]},lt=(t,{windowsPathsNoEscape:e=!1}={})=>e?t.replace(/\[([^\/\\])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"),ht=new Set(["!","?","+","*","@"]),ct=t=>ht.has(t),ft="(?!\\.)",ut=new Set(["[","."]),at=new Set(["..","."]),pt=new Set("().*{}+?[]^$\\!"),dt=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),vt="[^/]",mt=vt+"*?",wt=vt+"+?",bt=class w{constructor(a,p,d={}){k(this,u),((t,e,n)=>{((t,e,n)=>{e in t?b(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n})(t,e+"",n)})(this,"type"),k(this,t),k(this,e),k(this,n,!1),k(this,i,[]),k(this,s),k(this,r),k(this,o),k(this,l,!1),k(this,h),k(this,c),k(this,f,!1),this.type=a,a&&x(this,e,!0),x(this,s,p),x(this,t,M(this,s)?M(M(this,s),t):this),x(this,h,M(this,t)===this?d:M(M(this,t),h)),x(this,o,M(this,t)===this?[]:M(M(this,t),o)),"!"!==a||M(M(this,t),l)||M(this,o).push(this),x(this,r,M(this,s)?M(M(this,s),i).length:0)}get hasMagic(){if(void 0!==M(this,e))return M(this,e);for(const t of M(this,i))if("string"!=typeof t&&(t.type||t.hasMagic))return x(this,e,!0);return M(this,e)}toString(){return void 0!==M(this,c)?M(this,c):x(this,c,this.type?this.type+"("+M(this,i).map((t=>t+"")).join("|")+")":M(this,i).map((t=>t+"")).join(""))}push(...t){for(const e of t)if(""!==e){if("string"!=typeof e&&!(e instanceof w&&M(e,s)===this))throw Error("invalid part: "+e);M(this,i).push(e)}}toJSON(){var e;const n=null===this.type?M(this,i).slice().map((t=>"string"==typeof t?t:t.toJSON())):[this.type,...M(this,i).map((t=>t.toJSON()))];return this.isStart()&&!this.type&&n.unshift([]),this.isEnd()&&(this===M(this,t)||M(M(this,t),l)&&"!"===(null==(e=M(this,s))?void 0:e.type))&&n.push({}),n}isStart(){var e;if(M(this,t)===this)return!0;if(!(null==(e=M(this,s))?void 0:e.isStart()))return!1;if(0===M(this,r))return!0;const n=M(this,s);for(let t=0;t<M(this,r);t++){const e=M(n,i)[t];if(!(e instanceof w&&"!"===e.type))return!1}return!0}isEnd(){var e,n,o;if(M(this,t)===this)return!0;if("!"===(null==(e=M(this,s))?void 0:e.type))return!0;if(!(null==(n=M(this,s))?void 0:n.isEnd()))return!1;if(!this.type)return null==(o=M(this,s))?void 0:o.isEnd();const l=M(this,s)?M(M(this,s),i).length:0;return M(this,r)===l-1}copyIn(t){this.push("string"==typeof t?t:t.clone(this))}clone(t){const e=new w(this.type,t);for(const t of M(this,i))e.copyIn(t);return e}static fromGlob(t,e={}){var n;const i=new w(null,void 0,e);return N(n=w,p,d).call(n,t,i,0,e),i}toMMPattern(){if(this!==M(this,t))return M(this,t).toMMPattern();const n=""+this,[i,s,r,o]=this.toRegExpSource();if(!(r||M(this,e)||M(this,h).nocase&&!M(this,h).nocaseMagicOnly&&n.toUpperCase()!==n.toLowerCase()))return s;const l=(M(this,h).nocase?"i":"")+(o?"u":"");return Object.assign(RegExp(`^${i}$`,l),{_src:i,_glob:n})}get options(){return M(this,h)}toRegExpSource(r){var o;const c=null!=r?r:!!M(this,h).dot;if(M(this,t)===this&&N(this,u,a).call(this),!this.type){const h=this.isStart()&&this.isEnd(),f=M(this,i).map((t=>{var i;const[s,o,l,c]="string"==typeof t?N(i=w,p,m).call(i,t,M(this,e),h):t.toRegExpSource(r);return x(this,e,M(this,e)||l),x(this,n,M(this,n)||c),s})).join("");let u="";if(this.isStart()&&"string"==typeof M(this,i)[0]&&(1!==M(this,i).length||!at.has(M(this,i)[0]))){const t=ut,e=c&&t.has(f.charAt(0))||f.startsWith("\\.")&&t.has(f.charAt(2))||f.startsWith("\\.\\.")&&t.has(f.charAt(4)),n=!c&&!r&&t.has(f.charAt(0));u=e?"(?!(?:^|/)\\.\\.?(?:$|/))":n?ft:""}let a="";return this.isEnd()&&M(M(this,t),l)&&"!"===(null==(o=M(this,s))?void 0:o.type)&&(a="(?:$|\\/)"),[u+f+a,lt(f),x(this,e,!!M(this,e)),M(this,n)]}const d="*"===this.type||"+"===this.type,b="!"===this.type?"(?:(?!(?:":"(?:";let g=N(this,u,v).call(this,c);if(this.isStart()&&this.isEnd()&&!g&&"!"!==this.type){const t=""+this;return x(this,i,[t]),this.type=null,x(this,e,void 0),[t,lt(""+this),!1,!1]}let y=!d||r||c?"":N(this,u,v).call(this,!0);y===g&&(y=""),y&&(g=`(?:${g})(?:${y})*?`);let $="";return $="!"===this.type&&M(this,f)?(this.isStart()&&!c?ft:"")+wt:b+g+("!"===this.type?"))"+(!this.isStart()||c||r?"":ft)+mt+")":"@"===this.type?")":"?"===this.type?")?":"+"===this.type&&y?")":"*"===this.type&&y?")?":")"+this.type),[$,lt(g),x(this,e,!!M(this,e)),M(this,n)]}};t=new WeakMap,e=new WeakMap,n=new WeakMap,i=new WeakMap,s=new WeakMap,r=new WeakMap,o=new WeakMap,l=new WeakMap,h=new WeakMap,c=new WeakMap,f=new WeakMap,u=new WeakSet,a=function(){if(this!==M(this,t))throw Error("should only call on root");if(M(this,l))return this;let e;for(x(this,l,!0);e=M(this,o).pop();){if("!"!==e.type)continue;let t=e,n=M(t,s);for(;n;){for(let s=M(t,r)+1;!n.type&&s<M(n,i).length;s++)for(const t of M(e,i)){if("string"==typeof t)throw Error("string part in extglob AST??");t.copyIn(M(n,i)[s])}t=n,n=M(t,s)}}return this},p=new WeakSet,d=function(t,n,s,r){var o,l;let h=!1,c=!1,u=-1,a=!1;if(null===n.type){let e=s,i="";for(;e<t.length;){const s=t.charAt(e++);if(h||"\\"===s)h=!h,i+=s;else if(c)e===u+1?"^"!==s&&"!"!==s||(a=!0):"]"!==s||e===u+2&&a||(c=!1),i+=s;else if("["!==s)if(r.noext||!ct(s)||"("!==t.charAt(e))i+=s;else{n.push(i),i="";const l=new bt(s,n);e=N(o=bt,p,d).call(o,t,l,e,r),n.push(l)}else c=!0,u=e,a=!1,i+=s}return n.push(i),e}let v=s+1,m=new bt(null,n);const w=[];let b="";for(;v<t.length;){const e=t.charAt(v++);if(h||"\\"===e)h=!h,b+=e;else if(c)v===u+1?"^"!==e&&"!"!==e||(a=!0):"]"!==e||v===u+2&&a||(c=!1),b+=e;else if("["!==e)if(ct(e)&&"("===t.charAt(v)){m.push(b),b="";const n=new bt(e,m);m.push(n),v=N(l=bt,p,d).call(l,t,n,v,r)}else if("|"!==e){if(")"===e)return""===b&&0===M(n,i).length&&x(n,f,!0),m.push(b),b="",n.push(...w,m),v;b+=e}else m.push(b),b="",w.push(m),m=new bt(null,n);else c=!0,u=v,a=!1,b+=e}return n.type=null,x(n,e,void 0),x(n,i,[t.substring(s-1)]),v},v=function(t){return M(this,i).map((e=>{if("string"==typeof e)throw Error("string type in extglob ast??");const[i,s,r,o]=e.toRegExpSource(t);return x(this,n,M(this,n)||o),i})).filter((t=>!(this.isStart()&&this.isEnd()&&!t))).join("|")},m=function(t,e,n=!1){let i=!1,s="",r=!1;for(let o=0;o<t.length;o++){const l=t.charAt(o);if(i)i=!1,s+=(pt.has(l)?"\\":"")+l;else if("\\"!==l){if("["===l){const[n,i,l,h]=ot(t,o);if(l){s+=n,r=r||i,o+=l-1,e=e||h;continue}}"*"!==l?"?"!==l?s+=dt(l):(s+=vt,e=!0):(s+=n&&"*"===t?wt:mt,e=!0)}else o===t.length-1?s+="\\\\":i=!0}return[s,lt(t),!!e,r]},k(bt,p);var gt=bt,yt=(t,e,n={})=>(et(e),!(!n.nocomment&&"#"===e.charAt(0))&&new Vt(e,n).match(t)),$t=/^\*+([^+@!?\*\[\(]*)$/,St=t=>e=>!e.startsWith(".")&&e.endsWith(t),Ot=t=>e=>e.endsWith(t),jt=t=>(t=t.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(t)),Et=t=>(t=t.toLowerCase(),e=>e.toLowerCase().endsWith(t)),Mt=/^\*+\.\*+$/,kt=t=>!t.startsWith(".")&&t.includes("."),xt=t=>"."!==t&&".."!==t&&t.includes("."),Nt=/^\.\*+$/,Pt=t=>"."!==t&&".."!==t&&t.startsWith("."),Rt=/^\*+$/,Wt=t=>0!==t.length&&!t.startsWith("."),Ct=t=>0!==t.length&&"."!==t&&".."!==t,zt=/^\?+([^+@!?\*\[\(]*)?$/,Lt=([t,e=""])=>{const n=Dt([t]);return e?(e=e.toLowerCase(),t=>n(t)&&t.toLowerCase().endsWith(e)):n},At=([t,e=""])=>{const n=Gt([t]);return e?(e=e.toLowerCase(),t=>n(t)&&t.toLowerCase().endsWith(e)):n},Tt=([t,e=""])=>{const n=Gt([t]);return e?t=>n(t)&&t.endsWith(e):n},_t=([t,e=""])=>{const n=Dt([t]);return e?t=>n(t)&&t.endsWith(e):n},Dt=([t])=>{const e=t.length;return t=>t.length===e&&!t.startsWith(".")},Gt=([t])=>{const e=t.length;return t=>t.length===e&&"."!==t&&".."!==t},Ut="object"==typeof process&&process?"object"==typeof process.env&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix";yt.sep="win32"===Ut?"\\":"/";var It=Symbol("globstar **");yt.GLOBSTAR=It,yt.filter=(t,e={})=>n=>yt(n,t,e);var Zt=(t,e={})=>Object.assign({},t,e);yt.defaults=t=>{if(!t||"object"!=typeof t||!Object.keys(t).length)return yt;const e=yt;return Object.assign(((n,i,s={})=>e(n,i,Zt(t,s))),{Minimatch:class extends e.Minimatch{constructor(e,n={}){super(e,Zt(t,n))}static defaults(n){return e.defaults(Zt(t,n)).Minimatch}},AST:class extends e.AST{constructor(e,n,i={}){super(e,n,Zt(t,i))}static fromGlob(n,i={}){return e.AST.fromGlob(n,Zt(t,i))}},unescape:(n,i={})=>e.unescape(n,Zt(t,i)),escape:(n,i={})=>e.escape(n,Zt(t,i)),filter:(n,i={})=>e.filter(n,Zt(t,i)),defaults:n=>e.defaults(Zt(t,n)),makeRe:(n,i={})=>e.makeRe(n,Zt(t,i)),braceExpand:(n,i={})=>e.braceExpand(n,Zt(t,i)),match:(n,i,s={})=>e.match(n,i,Zt(t,s)),sep:e.sep,GLOBSTAR:It})};var Ft=(t,e={})=>(et(t),e.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:(0,tt.default)(t));yt.braceExpand=Ft,yt.makeRe=(t,e={})=>new Vt(t,e).makeRe(),yt.match=(t,e,n={})=>{const i=new Vt(e,n);return t=t.filter((t=>i.match(t))),i.options.nonull&&!t.length&&t.push(e),t};var Ht=/[?*]|[+@!]\(.*?\)|\[|\]/,Vt=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,e={}){et(t),this.options=e=e||{},this.pattern=t,this.platform=e.platform||Ut,this.isWindows="win32"===this.platform,this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||!1===e.allowWindowsEscape,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!e.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!e.nonegate,this.comment=!1,this.empty=!1,this.partial=!!e.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=void 0!==e.windowsNoMagicRoot?e.windowsNoMagicRoot:!(!this.isWindows||!this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(const t of this.set)for(const e of t)if("string"!=typeof e)return!0;return!1}debug(...t){}make(){const t=this.pattern,e=this.options;if(!e.nocomment&&"#"===t.charAt(0))return void(this.comment=!0);if(!t)return void(this.empty=!0);this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],e.debug&&(this.debug=(...t)=>console.error(...t)),this.debug(this.pattern,this.globSet);const n=this.globSet.map((t=>this.slashSplit(t)));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((t=>{if(this.isWindows&&this.windowsNoMagicRoot){const e=!(""!==t[0]||""!==t[1]||"?"!==t[2]&&Ht.test(t[2])||Ht.test(t[3])),n=/^[a-z]:/i.test(t[0]);if(e)return[...t.slice(0,4),...t.slice(4).map((t=>this.parse(t)))];if(n)return[t[0],...t.slice(1).map((t=>this.parse(t)))]}return t.map((t=>this.parse(t)))}));if(this.debug(this.pattern,i),this.set=i.filter((t=>-1===t.indexOf(!1))),this.isWindows)for(let t=0;t<this.set.length;t++){const e=this.set[t];""===e[0]&&""===e[1]&&"?"===this.globParts[t][2]&&"string"==typeof e[3]&&/^[a-z]:$/i.test(e[3])&&(e[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let e=0;e<t.length;e++)for(let n=0;n<t[e].length;n++)"**"===t[e][n]&&(t[e][n]="*");const{optimizationLevel:e=1}=this.options;return e>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):t=e>=1?this.levelOneOptimize(t):this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map((t=>{let e=-1;for(;-1!==(e=t.indexOf("**",e+1));){let n=e;for(;"**"===t[n+1];)n++;n!==e&&t.splice(e,n-e)}return t}))}levelOneOptimize(t){return t.map((t=>0===(t=t.reduce(((t,e)=>{const n=t[t.length-1];return"**"===e&&"**"===n?t:".."===e&&n&&".."!==n&&"."!==n&&"**"!==n?(t.pop(),t):(t.push(e),t)}),[])).length?[""]:t))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let e=!1;do{if(e=!1,!this.preserveMultipleSlashes){for(let n=1;n<t.length-1;n++){const i=t[n];1===n&&""===i&&""===t[0]||"."!==i&&""!==i||(e=!0,t.splice(n,1),n--)}"."!==t[0]||2!==t.length||"."!==t[1]&&""!==t[1]||(e=!0,t.pop())}let n=0;for(;-1!==(n=t.indexOf("..",n+1));){const i=t[n-1];i&&"."!==i&&".."!==i&&"**"!==i&&(e=!0,t.splice(n-1,2),n-=2)}}while(e);return 0===t.length?[""]:t}firstPhasePreProcess(t){let e=!1;do{e=!1;for(let n of t){let i=-1;for(;-1!==(i=n.indexOf("**",i+1));){let s=i;for(;"**"===n[s+1];)s++;s>i&&n.splice(i+1,s-i);const r=n[i+2],o=n[i+3];if(".."!==n[i+1])continue;if(!r||"."===r||".."===r||!o||"."===o||".."===o)continue;e=!0,n.splice(i,1);const l=n.slice(0);l[i]="**",t.push(l),i--}if(!this.preserveMultipleSlashes){for(let t=1;t<n.length-1;t++){const i=n[t];1===t&&""===i&&""===n[0]||"."!==i&&""!==i||(e=!0,n.splice(t,1),t--)}"."!==n[0]||2!==n.length||"."!==n[1]&&""!==n[1]||(e=!0,n.pop())}let s=0;for(;-1!==(s=n.indexOf("..",s+1));){const t=n[s-1];t&&"."!==t&&".."!==t&&"**"!==t&&(e=!0,n.splice(s-1,2,...1===s&&"**"===n[s+1]?["."]:[]),0===n.length&&n.push(""),s-=2)}}}while(e);return t}secondPhasePreProcess(t){for(let e=0;e<t.length-1;e++)for(let n=e+1;n<t.length;n++){const i=this.partsMatch(t[e],t[n],!this.preserveMultipleSlashes);i&&(t[e]=i,t[n]=[])}return t.filter((t=>t.length))}partsMatch(t,e,n=!1){let i=0,s=0,r=[],o="";for(;i<t.length&&s<e.length;)if(t[i]===e[s])r.push("b"===o?e[s]:t[i]),i++,s++;else if(n&&"**"===t[i]&&e[s]===t[i+1])r.push(t[i]),i++;else if(n&&"**"===e[s]&&t[i]===e[s+1])r.push(e[s]),s++;else if("*"!==t[i]||!e[s]||!this.options.dot&&e[s].startsWith(".")||"**"===e[s]){if("*"!==e[s]||!t[i]||!this.options.dot&&t[i].startsWith(".")||"**"===t[i])return!1;if("a"===o)return!1;o="b",r.push(e[s]),i++,s++}else{if("b"===o)return!1;o="a",r.push(t[i]),i++,s++}return t.length===e.length&&r}parseNegate(){if(this.nonegate)return;const t=this.pattern;let e=!1,n=0;for(let i=0;i<t.length&&"!"===t.charAt(i);i++)e=!e,n++;n&&(this.pattern=t.slice(n)),this.negate=e}matchOne(t,e,n=!1){const i=this.options;if(this.isWindows){const n="string"==typeof t[0]&&/^[a-z]:$/i.test(t[0]),i=!n&&""===t[0]&&""===t[1]&&"?"===t[2]&&/^[a-z]:$/i.test(t[3]),s="string"==typeof e[0]&&/^[a-z]:$/i.test(e[0]),r=i?3:n?0:void 0,o=!s&&""===e[0]&&""===e[1]&&"?"===e[2]&&"string"==typeof e[3]&&/^[a-z]:$/i.test(e[3])?3:s?0:void 0;if("number"==typeof r&&"number"==typeof o){const[n,i]=[t[r],e[o]];n.toLowerCase()===i.toLowerCase()&&(e[o]=n,o>r?e=e.slice(o):r>o&&(t=t.slice(r)))}}const{optimizationLevel:s=1}=this.options;s>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:e}),this.debug("matchOne",t.length,e.length);for(var r=0,o=0,l=t.length,h=e.length;r<l&&o<h;r++,o++){this.debug("matchOne loop");var c=e[o],f=t[r];if(this.debug(e,c,f),!1===c)return!1;if(c===It){this.debug("GLOBSTAR",[e,c,f]);var u=r,a=o+1;if(a===h){for(this.debug("** at the end");r<l;r++)if("."===t[r]||".."===t[r]||!i.dot&&"."===t[r].charAt(0))return!1;return!0}for(;u<l;){var p=t[u];if(this.debug("\nglobstar while",t,u,e,a,p),this.matchOne(t.slice(u),e.slice(a),n))return this.debug("globstar found match!",u,l,p),!0;if("."===p||".."===p||!i.dot&&"."===p.charAt(0)){this.debug("dot detected!",t,u,e,a);break}this.debug("globstar swallow a segment, and continue"),u++}return!(!n||(this.debug("\n>>> no match, partial?",t,u,e,a),u!==l))}let s;if("string"==typeof c?(s=f===c,this.debug("string match",c,f,s)):(s=c.test(f),this.debug("pattern match",c,f,s)),!s)return!1}if(r===l&&o===h)return!0;if(r===l)return n;if(o===h)return r===l-1&&""===t[r];throw Error("wtf?")}braceExpand(){return Ft(this.pattern,this.options)}parse(t){et(t);const e=this.options;if("**"===t)return It;if(""===t)return"";let n,i=null;(n=t.match(Rt))?i=e.dot?Ct:Wt:(n=t.match($t))?i=(e.nocase?e.dot?Et:jt:e.dot?Ot:St)(n[1]):(n=t.match(zt))?i=(e.nocase?e.dot?At:Lt:e.dot?Tt:_t)(n):(n=t.match(Mt))?i=e.dot?xt:kt:(n=t.match(Nt))&&(i=Pt);const s=gt.fromGlob(t,this.options).toMMPattern();return i&&"object"==typeof s&&Reflect.defineProperty(s,"test",{value:i}),s}makeRe(){if(this.regexp||!1===this.regexp)return this.regexp;const t=this.set;if(!t.length)return this.regexp=!1,this.regexp;const e=this.options,n=e.noglobstar?"[^/]*?":e.dot?"(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?":"(?:(?!(?:\\/|^)\\.).)*?",i=new Set(e.nocase?["i"]:[]);let s=t.map((t=>{const e=t.map((t=>{if(t instanceof RegExp)for(const e of t.flags.split(""))i.add(e);return"string"==typeof t?(t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"))(t):t===It?It:t._src}));return e.forEach(((t,i)=>{const s=e[i+1],r=e[i-1];t===It&&r!==It&&(void 0===r?void 0!==s&&s!==It?e[i+1]="(?:\\/|"+n+"\\/)?"+s:e[i]=n:void 0===s?e[i-1]=r+"(?:\\/|"+n+")?":s!==It&&(e[i-1]=r+"(?:\\/|\\/"+n+"\\/)"+s,e[i+1]=It))})),e.filter((t=>t!==It)).join("/")})).join("|");const[r,o]=t.length>1?["(?:",")"]:["",""];s="^"+r+s+o+"$",this.negate&&(s="^(?!"+s+").+$");try{this.regexp=RegExp(s,[...i].join(""))}catch(t){this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,e=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return""===t;if("/"===t&&e)return!0;const n=this.options;this.isWindows&&(t=t.split("\\").join("/"));const i=this.slashSplit(t);this.debug(this.pattern,"split",i);const s=this.set;this.debug(this.pattern,"set",s);let r=i[i.length-1];if(!r)for(let t=i.length-2;!r&&t>=0;t--)r=i[t];for(let t=0;t<s.length;t++){const o=s[t];let l=i;if(n.matchBase&&1===o.length&&(l=[r]),this.matchOne(l,o,e))return!!n.flipNegate||!this.negate}return!n.flipNegate&&this.negate}static defaults(t){return yt.defaults(t).Minimatch}};function qt(t){var e,n,i;return null!=(i=null==(n=null==(e=t.head)?void 0:e.querySelector('meta[name="csp-nonce"]'))?void 0:n.getAttribute("content"))?i:void 0}yt.AST=gt,yt.Minimatch=Vt,yt.escape=(t,{windowsPathsNoEscape:e=!1}={})=>e?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&"),yt.unescape=lt,((t,e)=>{for(var n in e)b(t,n,{get:e[n],enumerable:!0})})({},{err:()=>Jt,map:()=>Yt,ok:()=>Bt,unwrap:()=>Qt,unwrapErr:()=>Xt});var Bt=t=>({isOk:!0,isErr:!1,value:t}),Jt=t=>({isOk:!1,isErr:!0,value:t});function Yt(t,e){if(t.isOk){const n=e(t.value);return n instanceof Promise?n.then((t=>Bt(t))):Bt(n)}if(t.isErr)return Jt(t.value);throw"should never get here"}var Kt,Qt=t=>{if(t.isOk)return t.value;throw t.value},Xt=t=>{if(t.isErr)return t.value;throw t.value};function te(){const t=this.attachShadow({mode:"open"});void 0===Kt&&(Kt=null),Kt&&(F?t.adoptedStyleSheets.push(Kt):t.adoptedStyleSheets=[...t.adoptedStyleSheets,Kt])}function ee(t,e,n){let i,s=0,r=[];for(;s<t.length;s++){if(i=t[s],i["s-sr"]&&(!e||i["s-hn"]===e)&&(void 0===n||ne(i)===n)&&(r.push(i),void 0!==n))return r;r=[...r,...ee(i.childNodes,e,n)]}return r}var ne=t=>"string"==typeof t["s-sn"]?t["s-sn"]:1===t.nodeType&&t.getAttribute("slot")||void 0;var ie=new WeakMap,se=t=>"sc-"+t.p,re=(t,e,...n)=>{let i=null,s=null,r=!1,o=!1;const l=[],h=e=>{for(let n=0;n<e.length;n++)i=e[n],Array.isArray(i)?h(i):null!=i&&"boolean"!=typeof i&&((r="function"!=typeof t&&!X(i))&&(i+=""),r&&o?l[l.length-1].v+=i:l.push(r?oe(null,i):i),o=r)};if(h(n),e){e.key&&(s=e.key);{const t=e.className||e.class;t&&(e.class="object"!=typeof t?t:Object.keys(t).filter((e=>t[e])).join(" "))}}const c=oe(t,null);return c.m=e,l.length>0&&(c.$=l),c.S=s,c},oe=(t,e)=>({h:0,O:t,v:e,j:null,$:null,m:null,S:null}),le={},he=t=>{const e=(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))(t);return RegExp(`(^|[^@]|@(?!supports\\s+selector\\s*\\([^{]*?${e}))(${e}\\b)`,"g")};he("::slotted"),he(":host"),he(":host-context");var ce,fe=t=>(null==t||X(t),t),ue=(t,e,n,i,s,r)=>{if(n===i)return;let o=L(t,e),l=e.toLowerCase();if("class"===e){const e=t.classList,s=pe(n);let r=pe(i);e.remove(...s.filter((t=>t&&!r.includes(t)))),e.add(...r.filter((t=>t&&!s.includes(t))))}else if("style"===e){for(const e in n)i&&null!=i[e]||(e.includes("-")?t.style.removeProperty(e):t.style[e]="");for(const e in i)n&&i[e]===n[e]||(e.includes("-")?t.style.setProperty(e,i[e]):t.style[e]=i[e])}else if("key"===e);else if(o||"o"!==e[0]||"n"!==e[1]){const l=X(i);if(o||l&&null!==i)try{if(t.tagName.includes("-"))t[e]!==i&&(t[e]=i);else{const s=null==i?"":i;"list"===e?o=!1:null!=n&&t[e]==s||("function"==typeof t.__lookupSetter__(e)?t[e]=s:t.setAttribute(e,s))}}catch(t){}null==i||!1===i?!1===i&&""!==t.getAttribute(e)||t.removeAttribute(e):(!o||4&r||s)&&!l&&1===t.nodeType&&t.setAttribute(e,i=!0===i?"":i)}else if(e="-"===e[2]?e.slice(3):L(G,l)?l.slice(2):l[2]+e.slice(3),n||i){const s=e.endsWith(de);e=e.replace(ve,""),n&&U.rel(t,e,n,s),i&&U.ael(t,e,i,s)}},ae=/\s/,pe=t=>("object"==typeof t&&t&&"baseVal"in t&&(t=t.baseVal),t&&"string"==typeof t?t.split(ae):[]),de="Capture",ve=RegExp(de+"$"),me=(t,e,n)=>{const i=11===e.j.nodeType&&e.j.host?e.j.host:e.j,s=t&&t.m||{},r=e.m||{};for(const t of we(Object.keys(s)))t in r||ue(i,t,s[t],void 0,n,e.h);for(const t of we(Object.keys(r)))ue(i,t,s[t],r[t],n,e.h)};function we(t){return t.includes("ref")?[...t.filter((t=>"ref"!==t)),"ref"]:t}var be=!1,ge=(t,e,n)=>{const i=e.$[n];let s,r,o=0;if(null!==i.v)s=i.j=G.document.createTextNode(i.v);else{if(!G.document)throw Error("You are trying to render a Stencil component in an environment that doesn't support the DOM. Make sure to populate the [`window`](https://developer.mozilla.org/en-US/docs/Web/API/Window/window) object before rendering a component.");if(s=i.j=G.document.createElement(i.O),me(null,i,be),i.$){const e="template"===i.O?s.content:s;for(o=0;o<i.$.length;++o)r=ge(t,i,o),r&&e.appendChild(r)}}return s["s-hn"]=ce,s},ye=(t,e,n,i,s,r)=>{let o,l=t;for(l.shadowRoot&&l.tagName===ce&&(l=l.shadowRoot),"template"===n.O&&(l=l.content);s<=r;++s)i[s]&&(o=ge(null,n,s),o&&(i[s].j=o,je(l,o,e)))},$e=(t,e,n)=>{for(let i=e;i<=n;++i){const e=t[i];if(e){const t=e.j;t&&t.remove()}}},Se=(t,e,n=!1)=>t.O===e.O&&(n?(n&&!t.S&&e.S&&(t.S=e.S),!0):t.S===e.S),Oe=(t,e,n=!1)=>{const i=e.j=t.j,s=t.$,r=e.$,o=e.v;null===o?(me(t,e,be),null!==s&&null!==r?((t,e,n,i,s=!1)=>{let r,o,l=0,h=0,c=0,f=0,u=e.length-1,a=e[0],p=e[u],d=i.length-1,v=i[0],m=i[d];const w="template"===n.O?t.content:t;for(;l<=u&&h<=d;)if(null==a)a=e[++l];else if(null==p)p=e[--u];else if(null==v)v=i[++h];else if(null==m)m=i[--d];else if(Se(a,v,s))Oe(a,v,s),a=e[++l],v=i[++h];else if(Se(p,m,s))Oe(p,m,s),p=e[--u],m=i[--d];else if(Se(a,m,s))Oe(a,m,s),je(w,a.j,p.j.nextSibling),a=e[++l],m=i[--d];else if(Se(p,v,s))Oe(p,v,s),je(w,p.j,a.j),p=e[--u],v=i[++h];else{for(c=-1,f=l;f<=u;++f)if(e[f]&&null!==e[f].S&&e[f].S===v.S){c=f;break}c>=0?(o=e[c],o.O!==v.O?r=ge(e&&e[h],n,c):(Oe(o,v,s),e[c]=void 0,r=o.j),v=i[++h]):(r=ge(e&&e[h],n,h),v=i[++h]),r&&je(a.j.parentNode,r,a.j)}l>u?ye(t,null==i[d+1]?null:i[d+1].j,n,i,h,d):h>d&&$e(e,l,u)})(i,s,e,r,n):null!==r?(null!==t.v&&(i.textContent=""),ye(i,null,e,r,0,r.length-1)):!n&&null!==s&&$e(s,0,s.length-1)):t.v!==o&&(i.data=o)},je=(t,e,n)=>{if("string"==typeof e["s-sn"]){t.insertBefore(e,n);const{slotNode:i}=function(t,e){var n;if(!(e=e||(null==(n=t["s-ol"])?void 0:n.parentElement)))return{slotNode:null,slotName:""};const i=t["s-sn"]=ne(t)||"";return{slotNode:ee(function(t,e){if("__"+e in t){const n=t["__"+e];return"function"!=typeof n?n:n.bind(t)}return"function"!=typeof t[e]?t[e]:t[e].bind(t)}(e,"childNodes"),e.tagName,i)[0],slotName:i}}(e);return i&&function(t){t.dispatchEvent(new CustomEvent("slotchange",{bubbles:!1,cancelable:!1,composed:!1}))}(i),e}return t.__insertBefore?t.__insertBefore(e,n):null==t?void 0:t.insertBefore(e,n)},Ee=(t,e)=>{if(e&&!t.M&&e["s-p"]){const n=e["s-p"].push(new Promise((i=>t.M=()=>{e["s-p"].splice(n-1,1),i()})))}},Me=(t,e)=>{if(t.h|=16,4&t.h)return void(t.h|=512);Ee(t,t.k);const n=()=>ke(t,e);if(!e)return Q(n);queueMicrotask((()=>{n()}))},ke=(t,e)=>{const n=t.$hostElement$,i=t.l;if(!i)throw Error(`Can't render component <${n.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`);let s;return e?(t.N.length&&t.N.forEach((t=>t(n))),s=ze(i,"componentWillLoad",void 0,n)):s=ze(i,"componentWillUpdate",void 0,n),s=xe(s,(()=>ze(i,"componentWillRender",void 0,n))),xe(s,(()=>Pe(t,i,e)))},xe=(t,e)=>Ne(t)?t.then(e).catch((t=>{console.error(t),e()})):e(),Ne=t=>t instanceof Promise||t&&t.then&&"function"==typeof t.then,Pe=async(t,e,n)=>{var i;const s=t.$hostElement$,r=s["s-rc"];n&&(t=>{const e=t.i,n=t.$hostElement$,i=e.h,s=((t,e)=>{var n,i,s;const r=se(e),o=_.get(r);if(!G.document)return r;if(t=11===t.nodeType?t:G.document,o)if("string"==typeof o){let s,l=ie.get(t=t.head||t);if(l||ie.set(t,l=new Set),!l.has(r)){s=G.document.createElement("style"),s.innerHTML=o;const h=null!=(n=U.P)?n:qt(G.document);if(null!=h&&s.setAttribute("nonce",h),!(1&e.h))if("HEAD"===t.nodeName){const e=t.querySelectorAll("link[rel=preconnect]"),n=e.length>0?e[e.length-1].nextSibling:t.querySelector("style");t.insertBefore(s,(null==n?void 0:n.parentNode)===t?n:null)}else if("host"in t)if(Z){const e=new(null!=(i=t.defaultView)?i:t.ownerDocument.defaultView).CSSStyleSheet;e.replaceSync(o),F?t.adoptedStyleSheets.unshift(e):t.adoptedStyleSheets=[e,...t.adoptedStyleSheets]}else{const e=t.querySelector("style");e?e.innerHTML=o+e.innerHTML:t.prepend(s)}else t.append(s);1&e.h&&t.insertBefore(s,null),4&e.h&&(s.innerHTML+=D),l&&l.add(r)}}else{let e=ie.get(t);if(e||ie.set(t,e=new Set),!e.has(r)){const n=null!=(s=t.defaultView)?s:t.ownerDocument.defaultView;let i;if(o.constructor===n.CSSStyleSheet)i=o;else{i=new n.CSSStyleSheet;for(let t=0;t<o.cssRules.length;t++)i.insertRule(o.cssRules[t].cssText,t)}F?t.adoptedStyleSheets.push(i):t.adoptedStyleSheets=[...t.adoptedStyleSheets,i],e.add(r)}}return r})(n.shadowRoot?n.shadowRoot:n.getRootNode(),e);10&i&&(n["s-sc"]=s,n.classList.add(s+"-h"))})(t);Re(t,e,s,n),r&&(r.map((t=>t())),s["s-rc"]=void 0);{const e=null!=(i=s["s-p"])?i:[],n=()=>We(t);0===e.length?n():(Promise.all(e).then(n),t.h|=4,e.length=0)}},Re=(t,e,n,i)=>{try{e=e.render(),t.h&=-17,t.h|=2,((t,e,n=!1)=>{const i=t.$hostElement$,s=t.R||oe(null,null),r=(t=>t&&t.O===le)(e)?e:re(null,null,e);if(ce=i.tagName,n&&r.m)for(const t of Object.keys(r.m))i.hasAttribute(t)&&!["key","ref","style","class"].includes(t)&&(r.m[t]=i[t]);r.O=null,r.h|=4,t.R=r,r.j=s.j=i.shadowRoot||i,Oe(s,r,n)})(t,e,i)}catch(e){A(e,t.$hostElement$)}return null},We=t=>{const e=t.$hostElement$,n=t.l,i=t.k;ze(n,"componentDidRender",void 0,e),64&t.h?ze(n,"componentDidUpdate",void 0,e):(t.h|=64,Le(e),ze(n,"componentDidLoad",void 0,e),t.W(e),i||Ce()),t.C(e),t.M&&(t.M(),t.M=void 0),512&t.h&&K((()=>Me(t,!1))),t.h&=-517},Ce=()=>{K((()=>(t=>{const e=U.ce("appload",{detail:{namespace:"sliding-puzzle"}});return t.dispatchEvent(e),e})(G)))},ze=(t,e,n,i)=>{if(t&&t[e])try{return t[e](n)}catch(t){A(t,i)}},Le=t=>t.classList.add("hydrated"),Ae=(t,e,n,i)=>{const s=C(t);if(!s)return;if(!s)throw Error(`Couldn't find host element for "${i.p}" as it is unknown to this Stencil runtime. This usually happens when integrating a 3rd party Stencil component with another Stencil component or application. Please reach out to the maintainers of the 3rd party Stencil component or report this on the Stencil Discord server (https://chat.stenciljs.com) or comment on this similar [GitHub issue](https://github.com/stenciljs/core/issues/5457).`);const r=s.o.get(e),o=s.h,l=s.l;if(n=fe(n),!(8&o&&void 0!==r||n===r||Number.isNaN(r)&&Number.isNaN(n)||(s.o.set(e,n),2!=(18&o)))){if(l.componentShouldUpdate&&!1===l.componentShouldUpdate(n,r,e))return;Me(s,!1)}},Te=(t,e,n)=>{var i;const s=t.prototype;return e.t&&Object.entries(null!=(i=e.t)?i:{}).map((([t,[i]])=>{if(31&i||2&n&&32&i){const{get:r,set:o}=Object.getOwnPropertyDescriptor(s,t)||{};r&&(e.t[t][0]|=2048),o&&(e.t[t][0]|=4096),(1&n||!r)&&Object.defineProperty(s,t,{get(){{if(!(2048&e.t[t][0]))return((t,e)=>C(this).o.get(e))(0,t);const n=C(this),i=n?n.l:s;if(!i)return;return i[t]}},configurable:!0,enumerable:!0}),Object.defineProperty(s,t,{set(s){const r=C(this);if(r){if(o)return void 0===(32&i?this[t]:r.$hostElement$[t])&&r.o.get(t)&&(s=r.o.get(t)),o.call(this,fe(s)),void Ae(this,t,s=32&i?this[t]:r.$hostElement$[t],e);{if(!(1&n&&4096&e.t[t][0]))return Ae(this,t,s,e),void(1&n&&!r.l&&r.N.push((()=>{4096&e.t[t][0]&&r.l[t]!==r.o.get(t)&&(r.l[t]=s)})));const i=()=>{const n=r.l[t];!r.o.get(t)&&n&&r.o.set(t,n),r.l[t]=fe(s),Ae(this,t,r.l[t],e)};r.l?i():r.N.push((()=>{i()}))}}}})}else 1&n&&64&i&&Object.defineProperty(s,t,{value(...e){var n;const i=C(this);return null==(n=null==i?void 0:i.L)?void 0:n.then((()=>{var n;return null==(n=i.l)?void 0:n[t](...e)}))}})})),t},_e=(t,e)=>{ze(t,"connectedCallback",void 0,e)},De=(t,e)=>{ze(t,"disconnectedCallback",void 0,e||t)},Ge=(t,e={})=>{var n;if(!G.document)return void console.warn("Stencil: No document found. Skipping bootstrapping lazy components.");const i=[],s=e.exclude||[],r=G.customElements,o=G.document.head,l=o.querySelector("meta[charset]"),h=G.document.createElement("style"),c=[];let f,u=!0;Object.assign(U,e),U.u=new URL(e.resourcesUrl||"./",G.document.baseURI).href;let a=!1;if(t.map((t=>{t[1].map((e=>{const n={h:e[0],p:e[1],t:e[2],A:e[3]};4&n.h&&(a=!0),n.t=e[2];const o=n.p,l=class extends HTMLElement{"s-p";"s-rc";hasRegisteredEventListeners=!1;constructor(t){if(super(t),((t,e)=>{const n={h:0,$hostElement$:t,i:e,o:new Map,T:new Map};n.L=new Promise((t=>n.C=t)),n._=new Promise((t=>n.W=t)),t["s-p"]=[],t["s-rc"]=[],n.N=[];const i=n;t.__stencil__getHostRef=()=>i})(t=this,n),1&n.h)if(t.shadowRoot){if("open"!==t.shadowRoot.mode)throw Error(`Unable to re-use existing shadow root for ${n.p}! Mode is set to ${t.shadowRoot.mode} but Stencil only supports open shadow roots.`)}else te.call(t,n)}connectedCallback(){C(this)&&(this.hasRegisteredEventListeners||(this.hasRegisteredEventListeners=!0),f&&(clearTimeout(f),f=null),u?c.push(this):U.jmp((()=>(t=>{if(!(1&U.h)){const e=C(t);if(!e)return;const n=e.i,i=()=>{};if(1&e.h)(null==e?void 0:e.l)?_e(e.l,t):(null==e?void 0:e._)&&e._.then((()=>_e(e.l,t)));else{e.h|=1;{let n=t;for(;n=n.parentNode||n.host;)if(n["s-p"]){Ee(e,e.k=n);break}}n.t&&Object.entries(n.t).map((([e,[n]])=>{if(31&n&&e in t&&t[e]!==Object.prototype[e]){const n=t[e];delete t[e],t[e]=n}})),(async(t,e,n)=>{let i;if(!(32&e.h)){if(e.h|=32,n.D){const s=((t,e)=>{const n=t.p.replace(/-/g,"_"),i=t.D;if(!i)return;const s=T.get(i);return s?s[n]:import(`./${i}.entry.js`).then((t=>(T.set(i,t),t[n])),(t=>{A(t,e.$hostElement$)}))
|
|
2
|
+
/*!__STENCIL_STATIC_IMPORT_SWITCH__*/})(n,e);if(s&&"then"in s){const t=()=>{};i=await s,t()}else i=s;if(!i)throw Error(`Constructor for "${n.p}#${e.G}" was not found`);i.isProxied||(Te(i,n,2),i.isProxied=!0);const r=()=>{};e.h|=8;try{new i(e)}catch(e){A(e,t)}e.h&=-9,r(),_e(e.l,t)}else i=t.constructor,customElements.whenDefined(t.localName).then((()=>e.h|=128));if(i&&i.style){let t;"string"==typeof i.style&&(t=i.style);const e=se(n);if(!_.has(e)){const i=()=>{};((t,e,n)=>{let i=_.get(t);Z&&n?(i=i||new CSSStyleSheet,"string"==typeof i?i=e:i.replaceSync(e)):i=e,_.set(t,i)})(e,t,!!(1&n.h)),i()}}}const s=e.k,r=()=>Me(e,!0);s&&s["s-rc"]?s["s-rc"].push(r):r()})(t,e,n)}i()}})(this))))}disconnectedCallback(){U.jmp((()=>(async t=>{if(!(1&U.h)){const e=C(t);(null==e?void 0:e.l)?De(e.l,t):(null==e?void 0:e._)&&e._.then((()=>De(e.l,t)))}ie.has(t)&&ie.delete(t),t.shadowRoot&&ie.has(t.shadowRoot)&&ie.delete(t.shadowRoot)})(this))),U.raf((()=>{var t;const e=C(this);if(!e)return;const n=c.findIndex((t=>t===this));n>-1&&c.splice(n,1),(null==(t=null==e?void 0:e.R)?void 0:t.j)instanceof Node&&!e.R.j.isConnected&&delete e.R.j}))}componentOnReady(){var t;return null==(t=C(this))?void 0:t._}};n.D=t[0],s.includes(o)||r.get(o)||(i.push(o),r.define(o,Te(l,n,1)))}))})),i.length>0&&(a&&(h.textContent+=D),h.textContent+=i.sort()+"{visibility:hidden}.hydrated{visibility:inherit}",h.innerHTML.length)){h.setAttribute("data-styles","");const t=null!=(n=U.P)?n:qt(G.document);null!=t&&h.setAttribute("nonce",t),o.insertBefore(h,l?l.nextSibling:o.firstChild)}u=!1,c.length?c.map((t=>t.connectedCallback())):U.jmp((()=>f=setTimeout(Ce,30)))},Ue=t=>U.P=t;export{Ge as b,re as h,I as p,z as r,Ue as s}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o=()=>{};export{o as g}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,h as e}from"./p-CoGw-MK9.js";class i{x;y;get 0(){return this.x}set 0(t){this.x=t}get 1(){return this.y}set 1(t){this.y=t}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}get xy(){return[this.x,this.y]}*[Symbol.iterator](){yield this.x,yield this.y}constructor(t,e){this.x=t,this.y=e}add(t){return new i(this.x+t.x,this.y+t.y)}eq(t){return this.x===t.x&&this.y===t.y}clone(){return new i(this.x,this.y)}static from(t){if("number"==typeof t)return new i(t,t);if(Array.isArray(t))return new i(t[0]??0,t[1]??0);if("object"==typeof t&&"number"==typeof t.x&&"number"==typeof t.y)return new i(t.x,t.y);throw new Error("Wrong Vec2 source")}}class r{size;constructor(t){if(t.x<=0||t.y<=0)throw new Error(`Invalid grid size: width and height must be positive (got ${t.x}x${t.y})`);this.size=t}getIndexFromVec(t){return r.getIndexFromVec(t,this.size.width)}getVecFromIndex(t){return r.getVecFromIndex(t,this.size.width)}isBlack(t){return Boolean((t.x+t.y)%2)}isWhite(t){return!Boolean((t.x+t.y)%2)}isInGrid(t){return r.isInGrid(t,this.size)}static getVecFromIndex(t,e){const r=e instanceof i?e.width:e,s=t%r,n=Math.floor(t/r);return new i(s,n)}static getIndexFromVec(t,e){return t.y*(e instanceof i?e.width:e)+t.x}static isInGrid(t,e){return t.x>=0&&e.x>t.x&&t.y>=0&&e.y>t.y}static getOrtoSiblings(t,e){return[new i(-1,0),new i(1,0),new i(0,-1),new i(0,1)].map((e=>e.add(t))).filter((t=>r.isInGrid(t,e)))}}const s=class{constructor(e){t(this,e)}size=new i(3,3);tiles=[];async checkAnswer(){return this.tiles.every((t=>t.position===t.correctPosition))}getTileById(t){const e=this.tiles.find((e=>e.id===t));if(!e)throw new Error("Tile not found");return e}onTileClicked(t){const e=this.getTileById(t),i=r.getVecFromIndex(e.position,this.size.width),s=r.getOrtoSiblings(i,this.size).find((t=>{const e=r.getIndexFromVec(t,this.size.width);return this.tiles.every((t=>t.position!==e))}));s&&this.setTilePosition(e,r.getIndexFromVec(s,this.size))}setTilePosition(t,e){const i="string"==typeof t?t:t.id;this.tiles=this.tiles.map((t=>t.id!==i?t:{...t,position:e}))}render(){return e("div",{key:"b22497e26d2ce6f7aeadc788f9475bb9fcd92e76",class:"board",style:{"--width":`${this.size.width}`,"--height":`${this.size.height}`}},this.tiles.map((t=>{const i=r.getVecFromIndex(t.position,this.size.width);return e("button",{key:t.id,class:"tile",style:{"--x":`${i.x}`,"--y":`${i.y}`},onClick:this.onTileClicked.bind(this,t.id)},e("img",{src:t.imageSrc,alt:""}))})))}};s.style=".board{width:100%;height:100%;display:inline-block;aspect-ratio:calc(var(--width, 1) / var(--height, 1));border:1px solid black;position:relative;container-type:size}.tile{position:absolute;width:calc(100cqw / var(--width, 1));height:calc(100cqh / var(--height, 1));padding:0;border:none;transform:translate(calc(100% * var(--x)), calc(100% * var(--y)));transition:transform 0.5s}.tile img{display:block;width:100%;height:100%;pointer-events:none}";export{s as mb_sliding_puzzle}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{p as e,b as o}from"./p-CoGw-MK9.js";export{s as setNonce}from"./p-CoGw-MK9.js";import{g as p}from"./p-DQuL1Twl.js";(()=>{const s=import.meta.url,o={};return""!==s&&(o.resourcesUrl=new URL(".",s).href),e(o)})().then((async s=>(await p(),o([["p-a6576773",[[513,"mb-sliding-puzzle",{tiles:[1040],size:[32],checkAnswer:[64]}]]]],s))));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Vec2 } from '@mb-puzzle/vec2';
|
|
2
|
+
import { TileData } from "./types";
|
|
3
|
+
export declare class MbSlidingPuzzle {
|
|
4
|
+
size: Vec2;
|
|
5
|
+
tiles: TileData[];
|
|
6
|
+
checkAnswer(): Promise<boolean>;
|
|
7
|
+
getTileById(id: string): TileData;
|
|
8
|
+
onTileClicked(id: string): void;
|
|
9
|
+
setTilePosition(tile: string | TileData, position: number): void;
|
|
10
|
+
render(): any;
|
|
11
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/**
|
|
4
|
+
* This is an autogenerated file created by the Stencil compiler.
|
|
5
|
+
* It contains typing information for all components that exist in this project.
|
|
6
|
+
*/
|
|
7
|
+
import { HTMLStencilElement, JSXBase } from "./stencil-public-runtime";
|
|
8
|
+
import { TileData } from "./components/sliding-puzzle/types";
|
|
9
|
+
export { TileData } from "./components/sliding-puzzle/types";
|
|
10
|
+
export namespace Components {
|
|
11
|
+
interface MbSlidingPuzzle {
|
|
12
|
+
"checkAnswer": () => Promise<boolean>;
|
|
13
|
+
/**
|
|
14
|
+
* @default []
|
|
15
|
+
*/
|
|
16
|
+
"tiles": TileData[];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
declare global {
|
|
20
|
+
interface HTMLMbSlidingPuzzleElement extends Components.MbSlidingPuzzle, HTMLStencilElement {
|
|
21
|
+
}
|
|
22
|
+
var HTMLMbSlidingPuzzleElement: {
|
|
23
|
+
prototype: HTMLMbSlidingPuzzleElement;
|
|
24
|
+
new (): HTMLMbSlidingPuzzleElement;
|
|
25
|
+
};
|
|
26
|
+
interface HTMLElementTagNameMap {
|
|
27
|
+
"mb-sliding-puzzle": HTMLMbSlidingPuzzleElement;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
declare namespace LocalJSX {
|
|
31
|
+
interface MbSlidingPuzzle {
|
|
32
|
+
/**
|
|
33
|
+
* @default []
|
|
34
|
+
*/
|
|
35
|
+
"tiles"?: TileData[];
|
|
36
|
+
}
|
|
37
|
+
interface IntrinsicElements {
|
|
38
|
+
"mb-sliding-puzzle": MbSlidingPuzzle;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export { LocalJSX as JSX };
|
|
42
|
+
declare module "@stencil/core" {
|
|
43
|
+
export namespace JSX {
|
|
44
|
+
interface IntrinsicElements {
|
|
45
|
+
"mb-sliding-puzzle": LocalJSX.MbSlidingPuzzle & JSXBase.HTMLAttributes<HTMLMbSlidingPuzzleElement>;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview entry point for your component library
|
|
3
|
+
*
|
|
4
|
+
* This is the entry point for your component library. Use this file to export utilities,
|
|
5
|
+
* constants or data structure that accompany your components.
|
|
6
|
+
*
|
|
7
|
+
* DO NOT use this file to export your components. Instead, use the recommended approaches
|
|
8
|
+
* to consume components of this package as outlined in the `README.md`.
|
|
9
|
+
*/
|
|
10
|
+
export type * from './components';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Vec2 } from '@mb-puzzle/vec2';
|
|
2
|
+
export declare class Grid {
|
|
3
|
+
private size;
|
|
4
|
+
constructor(size: Vec2);
|
|
5
|
+
getIndexFromVec(v: Vec2): number;
|
|
6
|
+
getVecFromIndex(index: number): Vec2;
|
|
7
|
+
isBlack(v: Vec2): boolean;
|
|
8
|
+
isWhite(v: Vec2): boolean;
|
|
9
|
+
isInGrid(v: Vec2): boolean;
|
|
10
|
+
static getVecFromIndex(index: number, width: number | Vec2): Vec2;
|
|
11
|
+
static getIndexFromVec(v: Vec2, width: number | Vec2): number;
|
|
12
|
+
static isInGrid(v: Vec2, size: Vec2): boolean;
|
|
13
|
+
static getOrtoSiblings(v: Vec2, size: Vec2): Vec2[];
|
|
14
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface Vec2ParsableObject {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}
|
|
5
|
+
export type Vec2Source = number | number[] | Required<Vec2ParsableObject>;
|
|
6
|
+
export declare class Vec2 {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
get 0(): number;
|
|
10
|
+
set 0(x: number);
|
|
11
|
+
get 1(): number;
|
|
12
|
+
set 1(y: number);
|
|
13
|
+
get width(): number;
|
|
14
|
+
set width(x: number);
|
|
15
|
+
get height(): number;
|
|
16
|
+
set height(y: number);
|
|
17
|
+
get xy(): number[];
|
|
18
|
+
[Symbol.iterator](): Generator<number, void, unknown>;
|
|
19
|
+
constructor(x: number, y: number);
|
|
20
|
+
add(v: Vec2): Vec2;
|
|
21
|
+
eq(v: Vec2): boolean;
|
|
22
|
+
clone(): Vec2;
|
|
23
|
+
static from(source: Vec2Source): Vec2;
|
|
24
|
+
}
|
package/dist/types/roboczy/mb-puzzle/apps/sliding-puzzle/.stencil/shared/vec2/src/vec2.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|