@selimssevgi/cube-design-angular 0.8.0 → 0.9.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.
@@ -2800,16 +2800,20 @@ var CubeSquare = class CubeSquare {
2800
2800
  });
2801
2801
  let before = 0;
2802
2802
  let beforeView = null;
2803
+ let beforeCount = -1;
2803
2804
  effect(() => {
2804
2805
  const { cols, list } = this.layout();
2805
2806
  const view = this.view();
2807
+ const count = this.tiles().length;
2808
+ const measured = this.room().width > 0;
2806
2809
  const el = this.grid()?.nativeElement;
2807
- if (el && before && cols !== before && view === beforeView && !list && !reducedMotion$1() && typeof el.animate === "function") el.animate([{ transform: `scale(${cols / before})` }, { transform: "none" }], {
2810
+ if (el && before && measured && cols !== before && count !== beforeCount && beforeCount >= 0 && view === beforeView && !list && !reducedMotion$1() && typeof el.animate === "function") el.animate([{ transform: `scale(${cols / before})` }, { transform: "none" }], {
2808
2811
  duration: 420,
2809
2812
  easing: "cubic-bezier(.2,.7,.2,1)"
2810
2813
  });
2811
2814
  before = cols;
2812
2815
  beforeView = view;
2816
+ if (measured) beforeCount = count;
2813
2817
  });
2814
2818
  }
2815
2819
  static ɵfac = i0.ɵɵngDeclareFactory({
@@ -5676,6 +5680,702 @@ i0.ɵɵngDeclareClassMetadata({
5676
5680
  args: [{ providedIn: "root" }]
5677
5681
  }]
5678
5682
  });
5679
- export { ART_CHOICES_KEY, CONTEXT_CUBE_SOURCE, CONTEXT_CUBE_WORDS, CONTEXT_LAST_PARTS, CONTEXT_PART_ORDER, CUBE_ARTS, CUBE_CARRY_CLASSES, CUBE_CARRY_MOVE, CUBE_DROP_OUT, CUBE_HEAD_SWIPE, CUBE_HOLD_MS, CUBE_HOLD_SLOP, CUBE_ICON_NAMES, CUBE_LOADING_COLOURS, CUBE_LOADING_LEVELS, CUBE_LOADING_STEP_MS, CUBE_LOADING_STICKERS, CUBE_LOADING_WAYS, CUBE_LOADING_WIDTH, CUBE_PINCH_APART, CUBE_PINCH_TOGETHER, CUBE_ROOM_NARROW, CUBE_WHEEL_QUIET_MS, CUBE_WHEEL_STEP, CUBE_ZOOM_OPTIONS, CubeArtChoices, CubeCarry, CubeContext, CubeHead, CubeHold, CubeIcon, CubeLoading, CubePicture, CubePinch, CubeQuiet, CubeQuietLine, CubeRoom, CubeRoomMeasure, CubeSquare, CubeSquareTile, CubeTile, CubeZoomPinch, CubeZoomService, JUST_SAVED_MINUTES, MINE_SORT, PART_ICONS, REPORT_APP, REPORT_INCIDENTS_KEPT, REPORT_INCIDENTS_MS, REPORT_KINDS, ReportClient, ReportDiagnostics, ReportDraft, ReportErrorHandler, SQUARE_LEAST_CELL, SQUARE_LEAST_TALL, SQUARE_LIST_ROW, SQUARE_MAX_SIDE, SQUARE_ROOM_BELOW, TEXT_ORDERS, TURNING_BELOW, TURNING_NUDGE_UNTIL, TURNING_SIDES, VIEW_KEYS, addLevel, artFor, artLevel, bringLevel, bringOf, chooseArt, contextArtWidth, contextIcon, contextLevelFor, contextOf, contextSquare, cubeIconCells, cubeMovesThePage, cubeTilePicture, cubeTrailHolds, directionWords, drawArt, drawCube, environmentOf, errorLine, findJustSaved, gridFor, hideLevel, insideOf, isArt, isView, loadingStickers, loadingWayFor, moveBefore, namesLevel, orderLevel, orderOf, orderParts, partsLevel, placesOf, provideCubeZoom, provideReportDiagnostics, readArtChoices, refusalOf, reportContext, reportInterceptor, reportRefusal, reportRequest, routePattern, scrubbedPath, sizeFor, sortDirectionsLevel, sortItems, sortLevel, squareCell, squareGap, squareLayout, squareLeast, squareLevelFor, squareSideAt, squareTall, startsWheelGesture, stillStep, technicalLines, tellLevel, turningFront, turningRows, viewLevel, wheelWay, whereLevel, wouldLoop };
5683
+ const NAMES = "names";
5684
+ const HIDDEN = "hidden";
5685
+ const UNKNOWN = "unknown";
5686
+ const CHOICE = "choice:";
5687
+ const LIST = "names:";
5688
+ const isToken = (s) => s === "names" || s === "hidden" || s === "unknown" || s.startsWith("choice:");
5689
+ function cubePhysics(words) {
5690
+ const NOT_NAMED = words.notNamed;
5691
+ const clone = (w) => structuredClone(w);
5692
+ const live = (w) => w.ins.filter((i) => i.ended === void 0);
5693
+ const shown = (w, id) => !!w.pieces[id] && !w.pieces[id].hidden;
5694
+ const listWords = (w, t) => w.pieces[t]?.list?.length ? w.pieces[t].list : [words.names];
5695
+ const nameOf = (w, id) => id.startsWith("names:") ? listWords(w, id.slice(6))[0] : w.pieces[id]?.names[0] ?? NOT_NAMED;
5696
+ const placeOf = (w, id) => w.pieces[id]?.place ?? null;
5697
+ function partsIn(w, holder, hidden = false) {
5698
+ return live(w).filter((i) => i.holder === holder && (hidden || shown(w, i.piece))).sort((a, b) => a.order - b.order).map((i) => i.piece);
5699
+ }
5700
+ const holdersOf = (w, id) => live(w).filter((i) => i.piece === id).map((i) => i.holder);
5701
+ const stands = (w, piece, holder) => live(w).some((i) => i.piece === piece && i.holder === holder);
5702
+ const homeOf = (w, id) => live(w).find((i) => i.piece === id && i.home)?.holder ?? null;
5703
+ const homeIn = (w, id, holder) => live(w).some((i) => i.piece === id && i.holder === holder && i.home);
5704
+ function stand(w, piece, holder, home = false) {
5705
+ if (stands(w, piece, holder)) return;
5706
+ const order = Math.max(0, ...w.ins.filter((i) => i.holder === holder).map((i) => i.order)) + 1;
5707
+ w.ins.push({
5708
+ piece,
5709
+ holder,
5710
+ order,
5711
+ since: ++w.clock,
5712
+ home
5713
+ });
5714
+ }
5715
+ function leave(w, piece, holder) {
5716
+ for (const i of w.ins) if (i.piece === piece && i.holder === holder && i.ended === void 0) i.ended = ++w.clock;
5717
+ }
5718
+ function make(w, at, name, p, given = false) {
5719
+ const id = "p" + (Object.keys(w.pieces).length + 1);
5720
+ w.pieces[id] = {
5721
+ id,
5722
+ names: name ? [name] : [],
5723
+ hidden: false,
5724
+ given,
5725
+ place: p,
5726
+ made: ++w.clock
5727
+ };
5728
+ stand(w, id, at, true);
5729
+ return id;
5730
+ }
5731
+ const lobbyZone = (w, id) => placeOf(w, id) === "lobby" || placeOf(w, id) === "domain";
5732
+ const itemsOf = (w, t) => partsIn(w, t).filter((id) => placeOf(w, id) === "item" && homeIn(w, id, t));
5733
+ const isItemOf = (w, id, t) => placeOf(w, id) === "item" && homeIn(w, id, t);
5734
+ function tableOf(w, id) {
5735
+ let at = id;
5736
+ for (let k = 0; k < 30 && at; k++) {
5737
+ if (placeOf(w, at) === "table") return at;
5738
+ if (placeOf(w, at) === "domain" || placeOf(w, at) === "lobby") return null;
5739
+ at = homeOf(w, at);
5740
+ }
5741
+ return null;
5742
+ }
5743
+ function domainOf(w, id) {
5744
+ let at = id;
5745
+ for (let k = 0; k < 30 && at; k++) {
5746
+ if (placeOf(w, at) === "domain") return at;
5747
+ if (placeOf(w, at) === "lobby") return null;
5748
+ at = homeOf(w, at);
5749
+ }
5750
+ return null;
5751
+ }
5752
+ const tablesIn = (w, d, hidden = false) => partsIn(w, d, hidden).filter((id) => placeOf(w, id) === "table");
5753
+ const waysOf = (w, t, hidden = false) => partsIn(w, t, hidden).filter((id) => !isItemOf(w, id, t));
5754
+ function answersOf(w, way, t = tableOf(w, way), hidden = false) {
5755
+ return partsIn(w, way, hidden).filter((id) => !(t && isItemOf(w, id, t)) && !(placeOf(w, id) === "way" && homeIn(w, id, way)));
5756
+ }
5757
+ function answersDeep(w, way, t) {
5758
+ const out = [];
5759
+ const walk = (x) => {
5760
+ for (const a of answersOf(w, x, t)) if (!out.includes(a)) out.push(a), walk(a);
5761
+ };
5762
+ walk(way);
5763
+ return out;
5764
+ }
5765
+ function shared(w, way) {
5766
+ const t = tableOf(w, way);
5767
+ if (!t || placeOf(w, way) !== "way" || !homeIn(w, way, t)) return false;
5768
+ const answers = answersDeep(w, way, t);
5769
+ return itemsOf(w, t).some((i) => answers.filter((a) => stands(w, i, a)).length >= 2);
5770
+ }
5771
+ function siblings(w, a, b) {
5772
+ if (a === b || placeOf(w, a) !== "item" || placeOf(w, b) !== "item") return false;
5773
+ const h = homeOf(w, a);
5774
+ return !!h && h === homeOf(w, b);
5775
+ }
5776
+ const outOf = (path) => path.length > 1 ? path.slice(0, -1) : path.slice();
5777
+ function pieceBefore(path, k) {
5778
+ for (let i = k; i >= 0; i--) if (!isToken(path[i])) return path[i];
5779
+ return null;
5780
+ }
5781
+ function roleAt(w, path) {
5782
+ const last = path.at(-1) ?? w.top;
5783
+ if (last === "names") return "names";
5784
+ if (last === "hidden") return "hidden";
5785
+ if (last === "unknown") return "unknown";
5786
+ if (last.startsWith("choice:")) return "choice";
5787
+ const p = placeOf(w, last);
5788
+ const prev = path.length > 1 ? path.at(-2) : null;
5789
+ if (p === "lobby" || p === "domain" || p === "table") return p;
5790
+ if (prev === "names") return "item";
5791
+ if (prev && placeOf(w, prev) === "domain") return "table";
5792
+ const prevRole = prev && !isToken(prev) ? roleAt(w, path.slice(0, -1)) : null;
5793
+ if (prevRole === "table") return contextTable(w, path.slice(0, -1)) && isItemOf(w, last, contextTable(w, path.slice(0, -1))) ? "item" : "way";
5794
+ if (prevRole === "way" || prevRole === "answer") {
5795
+ const t = contextTable(w, path.slice(0, -1));
5796
+ return t && isItemOf(w, last, t) ? "item" : "answer";
5797
+ }
5798
+ if (p === "item") return "item";
5799
+ if (p === "way") return "way";
5800
+ return "answer";
5801
+ }
5802
+ function contextTable(w, path) {
5803
+ for (let k = path.length - 1; k >= 0; k--) {
5804
+ const s = path[k];
5805
+ if (isToken(s)) continue;
5806
+ if (placeOf(w, s) === "table") return s;
5807
+ if (k > 0 && placeOf(w, path[k - 1]) === "domain") return s;
5808
+ }
5809
+ return null;
5810
+ }
5811
+ function walksThrough(_w, _path) {
5812
+ return false;
5813
+ }
5814
+ function tableWays(w, t, hidden = false) {
5815
+ if (placeOf(w, t) === "table") return waysOf(w, t, hidden);
5816
+ return partsIn(w, t, hidden).filter((id) => placeOf(w, id) === "way" && homeIn(w, id, t));
5817
+ }
5818
+ function tableNames(w, t, hidden = false) {
5819
+ if (placeOf(w, t) === "table") return partsIn(w, t, hidden).filter((id) => isItemOf(w, id, t));
5820
+ return answersOf(w, t, tableOf(w, t), hidden);
5821
+ }
5822
+ function firstNames(w, ids, n = 3) {
5823
+ const names = ids.map((id) => nameOf(w, id));
5824
+ return names.length ? names.slice(0, n).join(words.and) + (names.length > n ? words.more : "") : "";
5825
+ }
5826
+ function tile(w, id, kind, line = "") {
5827
+ const p = w.pieces[id];
5828
+ return {
5829
+ id,
5830
+ kind,
5831
+ name: nameOf(w, id),
5832
+ line,
5833
+ given: p?.given || void 0,
5834
+ holds: partsIn(w, id).length
5835
+ };
5836
+ }
5837
+ const add = (at) => ({
5838
+ id: at,
5839
+ kind: "add",
5840
+ name: words.add,
5841
+ line: ""
5842
+ });
5843
+ function choicesOf(w, item, t) {
5844
+ const out = [];
5845
+ for (const x of tableWays(w, t)) {
5846
+ const answers = answersDeep(w, x, placeOf(w, t) === "table" ? t : null);
5847
+ if (!answers.length) {
5848
+ const yes = stands(w, item, x);
5849
+ out.push({
5850
+ id: x,
5851
+ kind: "choice",
5852
+ name: nameOf(w, x),
5853
+ line: yes ? words.yes : words.notKnownYet,
5854
+ ticked: yes
5855
+ });
5856
+ } else {
5857
+ const a = answers.filter((o) => stands(w, item, o));
5858
+ out.push({
5859
+ id: x,
5860
+ kind: "choice",
5861
+ name: nameOf(w, x),
5862
+ line: a.length ? firstNames(w, a, 9) : words.notKnownYet
5863
+ });
5864
+ }
5865
+ }
5866
+ for (const y of linkedTables(w, item, t)) {
5867
+ const theirs = itemsOf(w, y).filter((i) => stands(w, i, item));
5868
+ out.push({
5869
+ id: "link:" + y,
5870
+ kind: "choice",
5871
+ name: nameOf(w, y),
5872
+ line: theirs.length ? firstNames(w, theirs, 9) : words.notKnownYet
5873
+ });
5874
+ }
5875
+ return out;
5876
+ }
5877
+ function linkedTables(w, _item, t) {
5878
+ if (placeOf(w, t) !== "table") {
5879
+ const home = tableOf(w, t);
5880
+ return home ? [home] : [];
5881
+ }
5882
+ const out = [];
5883
+ for (const i of itemsOf(w, t)) for (const h of holdersOf(w, i)) {
5884
+ if (h === t || placeOf(w, h) === "item") continue;
5885
+ const y = tableOf(w, h);
5886
+ if (y && y !== t && !out.includes(y)) out.push(y);
5887
+ }
5888
+ return out;
5889
+ }
5890
+ function hiddenOf(w, path) {
5891
+ const at = path.at(-1) ?? w.top;
5892
+ if (isToken(at) && at !== "names") return [];
5893
+ return listOf(w, path, true).filter((x) => w.pieces[x]?.hidden);
5894
+ }
5895
+ function listOf(w, path, hidden) {
5896
+ const role = roleAt(w, path);
5897
+ const last = path.at(-1) ?? w.top;
5898
+ const t = contextTable(w, path);
5899
+ switch (role) {
5900
+ case "lobby": return partsIn(w, last, hidden);
5901
+ case "domain": {
5902
+ const tables = tablesIn(w, last, hidden);
5903
+ return [...tables, ...tables.flatMap((x) => waysOf(w, x, hidden).filter((y) => homeIn(w, y, x) && shared(w, y)))];
5904
+ }
5905
+ case "table": return tableWays(w, last, hidden);
5906
+ case "names": return t ? tableNames(w, t, hidden) : [];
5907
+ case "item": return [];
5908
+ case "way": return [...answersOf(w, last, t, hidden), ...t ? partsIn(w, last, hidden).filter((x) => isItemOf(w, x, t)) : []];
5909
+ case "answer": return [...answersOf(w, last, t, hidden), ...t ? partsIn(w, last, hidden).filter((x) => isItemOf(w, x, t)) : []];
5910
+ default: return [];
5911
+ }
5912
+ }
5913
+ function withHidden(w, tiles, path) {
5914
+ const n = hiddenOf(w, path).length;
5915
+ return n ? [...tiles, {
5916
+ id: HIDDEN,
5917
+ kind: "hidden",
5918
+ name: words.hidden,
5919
+ line: "",
5920
+ holds: n
5921
+ }] : tiles;
5922
+ }
5923
+ function stepOf(t) {
5924
+ switch (t.kind) {
5925
+ case "add":
5926
+ case "name": return null;
5927
+ case "list": return NAMES;
5928
+ case "unknown": return UNKNOWN;
5929
+ case "hidden": return HIDDEN;
5930
+ case "choice": return t.ticked === void 0 && !t.id.startsWith("link:") ? CHOICE + t.id : null;
5931
+ default: return t.id;
5932
+ }
5933
+ }
5934
+ function stepsInto(w, path, t) {
5935
+ const s = stepOf(t);
5936
+ if (!s) return null;
5937
+ return walksThrough(w, [...path, s]) ? [s, NAMES] : [s];
5938
+ }
5939
+ function levelAt(w, path) {
5940
+ const last = path.at(-1) ?? w.top;
5941
+ const role = roleAt(w, path);
5942
+ const level = (title, line, tiles) => ({
5943
+ path,
5944
+ title,
5945
+ line,
5946
+ lifted: false,
5947
+ tiles
5948
+ });
5949
+ const t = contextTable(w, path);
5950
+ if (role === "hidden") {
5951
+ const on = path.slice(0, -1);
5952
+ const at = pieceBefore(on, on.length - 1);
5953
+ const kindIn = (x) => kindOf(w, x, on);
5954
+ return level(words.hidden, at ? nameOf(w, at) : "", hiddenOf(w, on).map((x) => tile(w, x, kindIn(x))));
5955
+ }
5956
+ if (role === "unknown") {
5957
+ const way = pieceBefore(path, path.length - 2);
5958
+ const answers = answersDeep(w, way, t);
5959
+ const none = t ? itemsOf(w, t).filter((i) => !stands(w, i, way) && !answers.some((a) => stands(w, i, a))) : [];
5960
+ return level(words.notKnownYet, nameOf(w, way), none.map((i) => tile(w, i, "row")));
5961
+ }
5962
+ if (role === "choice") {
5963
+ const way = last.slice(7);
5964
+ const item = pieceBefore(path, path.length - 2);
5965
+ const opts = answersOf(w, way, t);
5966
+ return level(nameOf(w, way), nameOf(w, item), [...opts.map((o) => ({
5967
+ ...tile(w, o, "option"),
5968
+ ticked: stands(w, item, o)
5969
+ })), add("pick:" + way + ":" + item)]);
5970
+ }
5971
+ if (role === "names") {
5972
+ if (!t) return level(words.notHereAnyMore, "", []);
5973
+ const kind = placeOf(w, t) === "table" ? "item:" : "answer:";
5974
+ return level(nameOf(w, t), placeOf(w, t) === "table" ? nameOf(w, LIST + t) : words.names, [...withHidden(w, tableNames(w, t).map((x) => tile(w, x, "row")), path), add(kind + t)]);
5975
+ }
5976
+ const p = w.pieces[last];
5977
+ if (!p) return level(words.notHereAnyMore, "", []);
5978
+ switch (role) {
5979
+ case "lobby": {
5980
+ const parts = partsIn(w, last);
5981
+ const tiles = parts.map((x) => lobbyZone(w, x) ? tile(w, x, placeOf(w, x) === "domain" ? "door" : "lobby") : linkTile(w, x));
5982
+ const feature = p.given && last !== w.top && !parts.length;
5983
+ const hid = withHidden(w, tiles, path);
5984
+ return level(nameOf(w, last), feature ? words.appKeepsHere : "", feature ? hid : [...hid, add(last)]);
5985
+ }
5986
+ case "domain": return level(nameOf(w, last), "", [...withHidden(w, listOf(w, path, false).map((x) => tile(w, x, "table")), path), add("table:" + last)]);
5987
+ case "table": {
5988
+ const names = {
5989
+ id: LIST + last,
5990
+ kind: "list",
5991
+ name: nameOf(w, LIST + last),
5992
+ line: "",
5993
+ holds: tableNames(w, last).length
5994
+ };
5995
+ return level(nameOf(w, last), "", [
5996
+ names,
5997
+ ...withHidden(w, tableWays(w, last).map((x) => tile(w, x, "column")), path),
5998
+ add("way:" + last)
5999
+ ]);
6000
+ }
6001
+ case "item": {
6002
+ const own = {
6003
+ id: last,
6004
+ kind: "name",
6005
+ name: nameOf(w, last),
6006
+ line: words.itsName
6007
+ };
6008
+ return level(nameOf(w, last), t ? nameOf(w, t) : "", [
6009
+ own,
6010
+ ...t ? choicesOf(w, last, t) : [],
6011
+ add("cell:" + (t ?? "") + ":" + last)
6012
+ ]);
6013
+ }
6014
+ case "way":
6015
+ case "answer": {
6016
+ const answers = answersOf(w, last, t);
6017
+ const items = t ? partsIn(w, last).filter((x) => isItemOf(w, x, t)) : [];
6018
+ const deep = answersDeep(w, last, t);
6019
+ const none = role === "way" && t ? itemsOf(w, t).filter((i) => !stands(w, i, last) && !deep.some((a) => stands(w, i, a))) : [];
6020
+ const tiles = [...answers.map((x) => tile(w, x, "option")), ...items.map((x) => tile(w, x, "row"))];
6021
+ if (role === "way" && t) tiles.push({
6022
+ id: last,
6023
+ kind: "unknown",
6024
+ name: words.notKnownYet,
6025
+ line: "",
6026
+ holds: none.length
6027
+ });
6028
+ return level(nameOf(w, last), t ? nameOf(w, t) : "", [...withHidden(w, tiles, path), add((role === "way" ? "answer:" : "in:") + last + ":" + (t ?? ""))]);
6029
+ }
6030
+ }
6031
+ return level(nameOf(w, last), "", []);
6032
+ }
6033
+ const LINK_KIND = {
6034
+ table: "table",
6035
+ way: "column",
6036
+ answer: "option",
6037
+ item: "row"
6038
+ };
6039
+ function livesIn(w, id) {
6040
+ const h = homeOf(w, id);
6041
+ if (!h) return "";
6042
+ return nameOf(w, placeOf(w, id) === "way" ? tableOf(w, id) ?? h : h);
6043
+ }
6044
+ function linkTile(w, id) {
6045
+ return tile(w, id, LINK_KIND[placeOf(w, id)] ?? "row", livesIn(w, id));
6046
+ }
6047
+ function lobbyLinkable(w, holder) {
6048
+ if (placeOf(w, holder) !== "lobby" || holder === w.top || w.pieces[holder].given) return [];
6049
+ const out = [];
6050
+ const deep = (x, t) => {
6051
+ for (const a of answersOf(w, x, t)) if (!out.includes(a)) out.push(a), deep(a, t);
6052
+ };
6053
+ for (const d of Object.keys(w.pieces).filter((id) => placeOf(w, id) === "domain" && holdersOf(w, id).length)) {
6054
+ for (const t of tablesIn(w, d)) {
6055
+ out.push(t);
6056
+ for (const x of waysOf(w, t).filter((y) => homeIn(w, y, t))) {
6057
+ out.push(x);
6058
+ deep(x, t);
6059
+ }
6060
+ }
6061
+ for (const t of tablesIn(w, d)) out.push(...itemsOf(w, t));
6062
+ }
6063
+ return out;
6064
+ }
6065
+ function pathTo(w, id) {
6066
+ const steps = [];
6067
+ let at = id;
6068
+ for (let k = 0; k < 40 && at; k++) {
6069
+ steps.unshift(at);
6070
+ if (at === w.top) return steps;
6071
+ const h = homeOf(w, at);
6072
+ if (h && placeOf(w, at) === "item" && placeOf(w, h) === "table") steps.unshift(NAMES);
6073
+ at = h;
6074
+ }
6075
+ return null;
6076
+ }
6077
+ function pathInto(w, path, t) {
6078
+ if (roleAt(w, path) === "lobby" && w.pieces[t.id] && !lobbyZone(w, t.id)) return pathTo(w, t.id);
6079
+ const s = stepsInto(w, path, t);
6080
+ return s ? [...path, ...s] : null;
6081
+ }
6082
+ function kindOf(w, x, path) {
6083
+ const role = roleAt(w, path);
6084
+ if (role === "lobby") return lobbyZone(w, x) ? placeOf(w, x) === "domain" ? "door" : "lobby" : LINK_KIND[placeOf(w, x)] ?? "row";
6085
+ if (role === "domain") return "table";
6086
+ if (role === "table") return "column";
6087
+ if (role === "way" || role === "answer") return placeOf(w, x) === "item" ? "row" : "option";
6088
+ return "row";
6089
+ }
6090
+ const said = (world, says, before) => ({
6091
+ world,
6092
+ note: {
6093
+ says,
6094
+ undo: before
6095
+ }
6096
+ });
6097
+ const refuse = (world, says) => ({
6098
+ world,
6099
+ note: {
6100
+ says,
6101
+ refused: true
6102
+ }
6103
+ });
6104
+ function insideOf(w, id, seen = /* @__PURE__ */ new Set()) {
6105
+ for (const p of partsIn(w, id, true)) if (!seen.has(p)) seen.add(p), insideOf(w, p, seen);
6106
+ return seen;
6107
+ }
6108
+ function addAt(w, at, name, given = false) {
6109
+ const n = clone(w);
6110
+ const [kind, a, b] = at.includes(":") ? at.split(":") : [
6111
+ "lobby",
6112
+ at,
6113
+ ""
6114
+ ];
6115
+ switch (kind) {
6116
+ case "lobby":
6117
+ make(n, a, name, "lobby", given);
6118
+ break;
6119
+ case "table":
6120
+ make(n, a, name, "table", given);
6121
+ break;
6122
+ case "way":
6123
+ make(n, a, name, "way", given);
6124
+ break;
6125
+ case "item":
6126
+ make(n, a, name, "item", given);
6127
+ break;
6128
+ case "answer":
6129
+ make(n, a, name, "answer", given);
6130
+ break;
6131
+ case "cell":
6132
+ stand(n, b, make(n, a, name, "way", given));
6133
+ break;
6134
+ case "in":
6135
+ if (!b) return refuse(w, words.notHere);
6136
+ stand(n, make(n, b, name, placeOf(n, b) === "table" ? "item" : "answer", given), a);
6137
+ break;
6138
+ case "pick":
6139
+ stand(n, b, make(n, a, name, "answer", given));
6140
+ break;
6141
+ default: return refuse(w, words.notHere);
6142
+ }
6143
+ return { world: n };
6144
+ }
6145
+ function dropIn(w, piece, onto, path) {
6146
+ if (piece === onto || insideOf(w, piece).has(onto)) return refuse(w, words.notInsideItself);
6147
+ const role = roleAt(w, path);
6148
+ const at = path.at(-1) ?? w.top;
6149
+ const n = clone(w);
6150
+ if (role === "lobby") {
6151
+ if (!lobbyZone(n, onto) || placeOf(n, onto) === "domain") return refuse(w, words.standsOnItsOwn);
6152
+ const was = n.ins.find((i) => i.piece === piece && i.holder === at && i.ended === void 0);
6153
+ if (was) was.ended = ++n.clock;
6154
+ stand(n, piece, onto, was ? was.home : true);
6155
+ return { world: n };
6156
+ }
6157
+ if (siblings(n, piece, onto)) return refuse(w, words.eachOnItsOwn);
6158
+ if (role === "table") {
6159
+ if (!lobbyZone(n, piece) && placeOf(n, onto) !== "item" && stands(n, onto, at) && stands(n, piece, at)) {
6160
+ const was = n.ins.find((i) => i.piece === piece && i.holder === at && i.ended === void 0);
6161
+ was.ended = ++n.clock;
6162
+ stand(n, piece, onto, was.home);
6163
+ if (was.home && placeOf(n, piece) === "way") n.pieces[piece].place = "answer";
6164
+ return { world: n };
6165
+ }
6166
+ return refuse(w, words.standsOnItsOwn);
6167
+ }
6168
+ if (role === "way" || role === "answer") {
6169
+ const t = contextTable(n, path);
6170
+ const isItem = (x) => !!t && isItemOf(n, x, t);
6171
+ if (!isItem(piece) && !isItem(onto)) return makeOne(w, piece, onto, path);
6172
+ if (isItem(piece) && !isItem(onto)) {
6173
+ leave(n, piece, at);
6174
+ stand(n, piece, onto);
6175
+ return said(n, words.stoodIn(nameOf(n, piece), nameOf(n, onto)), clone(w));
6176
+ }
6177
+ return refuse(w, words.eachOnItsOwn);
6178
+ }
6179
+ return refuse(w, words.standsOnItsOwn);
6180
+ }
6181
+ function makeOne(w, a, b, path, name) {
6182
+ if (a === b) return refuse(w, words.notWithItself);
6183
+ const role = roleAt(w, path);
6184
+ const at = path.at(-1) ?? w.top;
6185
+ const n = clone(w);
6186
+ if (role === "lobby") {
6187
+ const g = make(n, at, name ?? null, "lobby");
6188
+ for (const x of [a, b]) {
6189
+ const home = homeIn(n, x, at);
6190
+ leave(n, x, at);
6191
+ stand(n, x, g, home);
6192
+ }
6193
+ return { world: n };
6194
+ }
6195
+ if (role === "way" || role === "answer") {
6196
+ const one = make(n, at, name ?? null, "answer");
6197
+ for (const x of [a, b]) {
6198
+ const home = homeIn(n, x, at);
6199
+ leave(n, x, at);
6200
+ stand(n, x, one, home);
6201
+ }
6202
+ return said(n, words.madeOne(name || words.notNamed, nameOf(n, a), nameOf(n, b), nameOf(n, at)), clone(w));
6203
+ }
6204
+ return refuse(w, words.eachOnItsOwn);
6205
+ }
6206
+ function placeRefusal(w, piece, holder) {
6207
+ if (stands(w, piece, holder)) return null;
6208
+ if (piece === holder || insideOf(w, piece).has(holder)) return words.notInsideItself;
6209
+ const pz = lobbyZone(w, piece);
6210
+ const hz = lobbyZone(w, holder);
6211
+ if (pz && hz) return placeOf(w, holder) === "domain" ? words.domainHoldsTables : null;
6212
+ if (pz !== hz) return pz ? words.domainHoldsThings : lobbyLinkable(w, holder).includes(piece) ? null : words.lobbyIsTheApp;
6213
+ const pp = placeOf(w, piece);
6214
+ if (pp === "table") return words.tablesSideBySide;
6215
+ if (pp === "item") {
6216
+ if (siblings(w, piece, holder)) return words.eachOnItsOwn;
6217
+ const t = homeOf(w, piece);
6218
+ const hp = placeOf(w, holder);
6219
+ if (hp === "way" && answersOf(w, holder, t).length) return words.inOneOfItsAnswers;
6220
+ if (hp === "way" || hp === "answer") return t && tableOf(w, holder) === t ? null : words.notInThisTable;
6221
+ return words.notInThisTable;
6222
+ }
6223
+ return words.staysWhereMade;
6224
+ }
6225
+ function placeAlso(w, piece, holder) {
6226
+ const no = placeRefusal(w, piece, holder);
6227
+ if (no) return refuse(w, no);
6228
+ const n = clone(w);
6229
+ stand(n, piece, holder);
6230
+ return { world: n };
6231
+ }
6232
+ function givenAt(w, id) {
6233
+ if (!w.pieces[id]?.given) return null;
6234
+ return w.ins.filter((i) => i.piece === id && i.home).sort((a, b) => a.since - b.since)[0]?.holder ?? null;
6235
+ }
6236
+ function takeOutRefusal(w, piece, holder) {
6237
+ if (!homeIn(w, piece, holder)) return null;
6238
+ if (!holdersOf(w, piece).filter((h) => h !== holder).length) return words.needsOnePlace;
6239
+ if (lobbyZone(w, piece)) return givenAt(w, piece) === holder && holder !== w.top ? words.staysWhereGiven : null;
6240
+ return w.pieces[piece]?.given ? words.staysWhereGiven : words.neverOutOfHome;
6241
+ }
6242
+ function takeOut(w, piece, holder) {
6243
+ const no = takeOutRefusal(w, piece, holder);
6244
+ if (no) return refuse(w, no);
6245
+ const n = clone(w);
6246
+ if (homeIn(n, piece, holder)) {
6247
+ leave(n, piece, holder);
6248
+ const back = givenAt(n, piece);
6249
+ const to = back && stands(n, piece, back) ? back : holdersOf(n, piece).at(-1);
6250
+ n.ins.find((i) => i.piece === piece && i.holder === to && i.ended === void 0).home = true;
6251
+ return said(n, words.movedInto(nameOf(n, piece), nameOf(n, to)), clone(w));
6252
+ }
6253
+ leave(n, piece, holder);
6254
+ return { world: n };
6255
+ }
6256
+ function pick(w, item, _way, answer) {
6257
+ const n = clone(w);
6258
+ if (stands(n, item, answer)) leave(n, item, answer);
6259
+ else stand(n, item, answer);
6260
+ return { world: n };
6261
+ }
6262
+ function linkable(w, item, t) {
6263
+ if (placeOf(w, t) !== "table") return [];
6264
+ const d = domainOf(w, t);
6265
+ return d ? tablesIn(w, d).filter((x) => x !== t).flatMap((x) => itemsOf(w, x)) : [];
6266
+ }
6267
+ const linked = (w, a, b) => stands(w, a, b) || stands(w, b, a);
6268
+ function link(w, a, b) {
6269
+ const ta = homeOf(w, a), tb = homeOf(w, b);
6270
+ if (!ta || !tb || ta === tb) return refuse(w, words.eachOnItsOwn);
6271
+ const n = clone(w);
6272
+ const [older, newer] = n.pieces[ta].made <= n.pieces[tb].made ? [a, b] : [b, a];
6273
+ const tOlder = older === a ? ta : tb;
6274
+ if (linked(n, a, b)) {
6275
+ leave(n, older, newer);
6276
+ if (!itemsOf(n, tOlder).some((i) => stands(n, i, newer))) leave(n, newer, tOlder);
6277
+ return { world: n };
6278
+ }
6279
+ stand(n, newer, tOlder);
6280
+ stand(n, older, newer);
6281
+ return { world: n };
6282
+ }
6283
+ function rename(w, piece, name) {
6284
+ const n = clone(w);
6285
+ if (piece.startsWith("names:")) {
6286
+ const t = n.pieces[piece.slice(6)];
6287
+ if (!t) return refuse(w, words.notHere);
6288
+ t.list = [name, ...listWords(n, t.id).filter((x) => x !== name)];
6289
+ return { world: n };
6290
+ }
6291
+ const p = n.pieces[piece];
6292
+ p.names = [name, ...p.names.filter((x) => x !== name)];
6293
+ return { world: n };
6294
+ }
6295
+ function hide(w, piece) {
6296
+ const n = clone(w);
6297
+ n.pieces[piece].hidden = true;
6298
+ return said(n, words.hiddenKept(nameOf(n, piece)), clone(w));
6299
+ }
6300
+ function show(w, piece) {
6301
+ const n = clone(w);
6302
+ n.pieces[piece].hidden = false;
6303
+ return said(n, words.shownAgain(nameOf(n, piece)), clone(w));
6304
+ }
6305
+ const undo = (note) => ({ world: note.undo });
6306
+ function settle(_w, _left, _before) {
6307
+ return null;
6308
+ }
6309
+ return {
6310
+ listWords,
6311
+ nameOf,
6312
+ placeOf,
6313
+ partsIn,
6314
+ holdersOf,
6315
+ stands,
6316
+ homeOf,
6317
+ lobbyZone,
6318
+ itemsOf,
6319
+ tableOf,
6320
+ domainOf,
6321
+ tablesIn,
6322
+ waysOf,
6323
+ answersOf,
6324
+ shared,
6325
+ siblings,
6326
+ outOf,
6327
+ roleAt,
6328
+ contextTable,
6329
+ walksThrough,
6330
+ choicesOf,
6331
+ linkedTables,
6332
+ hiddenOf,
6333
+ stepOf,
6334
+ stepsInto,
6335
+ levelAt,
6336
+ livesIn,
6337
+ lobbyLinkable,
6338
+ pathTo,
6339
+ pathInto,
6340
+ addAt,
6341
+ dropIn,
6342
+ makeOne,
6343
+ placeRefusal,
6344
+ placeAlso,
6345
+ givenAt,
6346
+ takeOutRefusal,
6347
+ takeOut,
6348
+ pick,
6349
+ linkable,
6350
+ linked,
6351
+ link,
6352
+ rename,
6353
+ hide,
6354
+ show,
6355
+ undo,
6356
+ settle,
6357
+ build: {
6358
+ make,
6359
+ stand
6360
+ },
6361
+ model: {
6362
+ levelAt,
6363
+ outOf,
6364
+ add: addAt,
6365
+ dropIn,
6366
+ makeOne,
6367
+ placeAlso,
6368
+ takeOut,
6369
+ pick,
6370
+ link,
6371
+ rename,
6372
+ hide,
6373
+ show,
6374
+ undo,
6375
+ settle
6376
+ }
6377
+ };
6378
+ }
6379
+ export { ART_CHOICES_KEY, CONTEXT_CUBE_SOURCE, CONTEXT_CUBE_WORDS, CONTEXT_LAST_PARTS, CONTEXT_PART_ORDER, CUBE_ARTS, CUBE_CARRY_CLASSES, CUBE_CARRY_MOVE, CUBE_DROP_OUT, CUBE_HEAD_SWIPE, CUBE_HOLD_MS, CUBE_HOLD_SLOP, CUBE_ICON_NAMES, CUBE_LOADING_COLOURS, CUBE_LOADING_LEVELS, CUBE_LOADING_STEP_MS, CUBE_LOADING_STICKERS, CUBE_LOADING_WAYS, CUBE_LOADING_WIDTH, CUBE_PINCH_APART, CUBE_PINCH_TOGETHER, CUBE_ROOM_NARROW, CUBE_WHEEL_QUIET_MS, CUBE_WHEEL_STEP, CUBE_ZOOM_OPTIONS, CubeArtChoices, CubeCarry, CubeContext, CubeHead, CubeHold, CubeIcon, CubeLoading, CubePicture, CubePinch, CubeQuiet, CubeQuietLine, CubeRoom, CubeRoomMeasure, CubeSquare, CubeSquareTile, CubeTile, CubeZoomPinch, CubeZoomService, JUST_SAVED_MINUTES, MINE_SORT, PART_ICONS, CHOICE as PHYSICS_CHOICE, HIDDEN as PHYSICS_HIDDEN, LIST as PHYSICS_LIST, NAMES as PHYSICS_NAMES, UNKNOWN as PHYSICS_UNKNOWN, REPORT_APP, REPORT_INCIDENTS_KEPT, REPORT_INCIDENTS_MS, REPORT_KINDS, ReportClient, ReportDiagnostics, ReportDraft, ReportErrorHandler, SQUARE_LEAST_CELL, SQUARE_LEAST_TALL, SQUARE_LIST_ROW, SQUARE_MAX_SIDE, SQUARE_ROOM_BELOW, TEXT_ORDERS, TURNING_BELOW, TURNING_NUDGE_UNTIL, TURNING_SIDES, VIEW_KEYS, addLevel, artFor, artLevel, bringLevel, bringOf, chooseArt, contextArtWidth, contextIcon, contextLevelFor, contextOf, contextSquare, cubeIconCells, cubeMovesThePage, cubePhysics, cubeTilePicture, cubeTrailHolds, directionWords, drawArt, drawCube, environmentOf, errorLine, findJustSaved, gridFor, hideLevel, insideOf, isArt, isToken as isPhysicsToken, isView, loadingStickers, loadingWayFor, moveBefore, namesLevel, orderLevel, orderOf, orderParts, partsLevel, placesOf, provideCubeZoom, provideReportDiagnostics, readArtChoices, refusalOf, reportContext, reportInterceptor, reportRefusal, reportRequest, routePattern, scrubbedPath, sizeFor, sortDirectionsLevel, sortItems, sortLevel, squareCell, squareGap, squareLayout, squareLeast, squareLevelFor, squareSideAt, squareTall, startsWheelGesture, stillStep, technicalLines, tellLevel, turningFront, turningRows, viewLevel, wheelWay, whereLevel, wouldLoop };
5680
6380
 
5681
6381
  //# sourceMappingURL=selimssevgi-cube-design-angular.mjs.map