PageSourceSearch

https://support.charge.net.nz/__theme/b_8ca5a7d7-80f3-41c8-bea7-75…oll-sites-help-center-theme/49/page-tree.js

js charge.net.nz collected 2026-09-24 10:51:53 UTC 10,073 bytes, 314 lines download raw bytes

1var B = (a) => {
2  throw TypeError(a);
3};
4var k = (a, c, t) => c.has(a) || B("Cannot " + t);
5var s = (a, c, t) => (k(a, c, "read from private field"), t ? t.call(a) : c.get(a)), h = (a, c, t) => c.has(a) ? B("Cannot add the same private member more than once") : c instanceof WeakSet ? c.add(a) : c.set(a, t), d = (a, c, t, e) => (k(a, c, "write to private field"), e ? e.call(a, t) : c.set(a, t), t), g = (a, c, t) => (k(a, c, "access private method"), t);
6import { c as J } from "./theme-DUl74mCB.js";
7var w, A, N, m, f, b, E, I, H;
8const n = class n extends EventTarget {
9  /** @param {{ sourceUrl?: string, pathPrefix?: string }} config */
10  constructor({
11    sourceUrl: t,
12    pathPrefix: e = ""
13  }) {
14    super();
15    h(this, I);
16    if (s(n, w))
17      return s(n, w);
18    d(n, A, t), d(n, N, e.replace(/\/+$/, "")), d(n, w, this);
19  }
20  async load() {
21    if (!(s(n, m) === "pending" || s(n, m) === "resolved")) {
22      d(n, m, "pending");
23      try {
24        if (!s(n, A)) {
25          d(n, f, /* @__PURE__ */ new Map()), d(n, b, /* @__PURE__ */ new Map()), d(n, E, []), d(n, m, "resolved"), this.dispatchEvent(new CustomEvent("change"));
26          return;
27        }
28        const t = await fetch(s(n, A), {
29          signal: AbortSignal.timeout(1e4)
30        });
31        if (!t.ok)
32          throw new Error(`Page tree fetch failed: ${t.status}`);
33        if (t.status === 204)
34          throw new Error("Page tree response is empty");
35        const e = t.headers.get("content-type") ?? "";
36        if (!e.toLowerCase().includes("application/json"))
37          throw new Error(`Page tree response is not JSON: ${e}`);
38        const r = await t.json();
39        if (!Array.isArray(r))
40          throw new Error("Page tree response is not an array");
41        const {
42          nodes: i,
43          pathIndex: l,
44          rootIds: u
45        } = g(this, I, H).call(this, r);
46        d(n, f, i), d(n, b, l), d(n, E, u), d(n, m, "resolved"), this.dispatchEvent(new CustomEvent("change"));
47      } catch (t) {
48        if (d(n, m, "rejected"), this.dispatchEvent(new CustomEvent("change")), t instanceof DOMException && t.name === "TimeoutError") {
49          console.error("Page tree request timed out", {
50            cause: t
51          });
52          return;
53        }
54        console.error(t);
55      }
56    }
57  }
58  /** @returns {PageTreeStatus} */
59  get status() {
60    return s(n, m);
61  }
62  /** @returns {number} */
63  get size() {
64    var t;
65    return ((t = s(n, f)) == null ? void 0 : t.size) ?? 0;
66  }
67  /**
68   * @param {string} id
69   * @returns {PageTreeNode | undefined}
70   */
71  getNode(t) {
72    var e;
73    return (e = s(n, f)) == null ? void 0 : e.get(t);
74  }
75  /** @returns {PageTreeNode[]} */
76  get rootNodes() {
77    var t;
78    return ((t = s(n, E)) == null ? void 0 : t.map((e) => this.getNode(e))) ?? [];
79  }
80  /**
81   * @param {string} id
82   * @returns {PageTreeNode[]}
83   */
84  getChildren(t) {
85    const e = this.getNode(t);
86    return e ? e.children.map((r) => this.getNode(r)) : [];
87  }
88  /**
89   * @param {string | undefined} id
90   * @returns {string[]}
91   */
92  getAncestorIds(t) {
93    var i, l;
94    if (!t) return [];
95    const e = [];
96    let r = (i = this.getNode(t)) == null ? void 0 : i.parent;
97    for (; r; )
98      e.push(r), r = (l = this.getNode(r)) == null ? void 0 : l.parent;
99    return e;
100  }
101  /**
102   * @param {string | undefined} id
103   * @returns {PageTreeNode[]}
104   */
105  getAncestors(t) {
106    return this.getAncestorIds(t).map((e) => this.getNode(e));
107  }
108  /** @returns {string | undefined} */
109  get activeNodeId() {
110    var t;
111    return (t = s(n, b)) == null ? void 0 : t.get(location.pathname);
112  }
113  /** @returns {PageTreeNode | undefined} */
114  get activeNode() {
115    return this.getNode(this.activeNodeId);
116  }
117  /**
118   * @param {string} path
119   * @returns {PageTreeNode | null}
120   */
121  getNodeByPath(t) {
122    var r;
123    const e = (r = s(n, b)) == null ? void 0 : r.get(t);
124    return e ? this.getNode(e) : null;
125  }
126};
127w = new WeakMap(), A = new WeakMap(), N = new WeakMap(), m = new WeakMap(), f = new WeakMap(), b = new WeakMap(), E = new WeakMap(), I = new WeakSet(), /**
128 * @param {RawPageTreeNode[]} nodes
129 * @returns {{ nodes: Map<string, PageTreeNode>, pathIndex: Map<string, string>, rootIds: string[] }}
130 */
131H = function(t) {
132  const e = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = [], l = [];
133  for (const u of t)
134    i.push(u.id), l.push([u, void 0]);
135  for (; l.length > 0; ) {
136    const [{
137      id: u,
138      title: T,
139      path: Y,
140      children: x = []
141    }, F] = l.pop(), S = s(n, N) + Y, U = new Array(x.length);
142    for (let v = 0; v < x.length; v++)
143      U[v] = x[v].id, l.push([x[v], u]);
144    e.set(u, {
145      id: u,
146      title: T,
147      path: S,
148      parent: F,
149      children: U
150    }), r.set(S, u);
151  }
152  return {
153    nodes: e,
154    pathIndex: r,
155    rootIds: i
156  };
157}, /** @type {PageTreeService | null} */
158h(n, w, null), /** @type {string | undefined} */
159h(n, A), /** @type {string} */
160h(n, N, ""), /** @type {PageTreeStatus} */
161h(n, m, "idle"), /** @type {Map<string, PageTreeNode> | null} */
162h(n, f, null), /** @type {Map<string, string> | null} */
163h(n, b, null), /** @type {string[] | null} */
164h(n, E, null);
165let L = n;
166const j = document.getElementById("pageTreeSource"), R = new L({
167  sourceUrl: j instanceof HTMLLinkElement ? j.href : void 0,
168  pathPrefix: J().pathname
169}), V = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" aria-hidden="true" data-component="icon" class="icon icon-pending">
170	<style>
171		circle {
172			animation-iteration-count: infinite;
173			animation-duration: 860ms;
174			animation-name: bouncy;
175
176			&:nth-of-type(1) {
177				animation-delay: -200ms;
178			}
179
180			&:nth-of-type(2) {
181				animation-delay: -100ms;
182			}
183		}
184
185		@keyframes bouncy {
186			0% {
187				animation-timing-function: ease-in;
188				transform: translateY(0);
189			}
190
191			50% {
192				animation-timing-function: ease-out;
193				transform: translateY(35%);
194			}
195		}
196	</style>
197	<circle cx="3.5" cy="5" r="1.5" />
198	<circle cx="8" cy="5" r="1.5" />
199	<circle cx="12.5" cy="5" r="1.5" />
200</svg>
201`;
202var p, y, o, $, C, M, q, D, P, z, O;
203class G extends HTMLElement {
204  constructor() {
205    super();
206    h(this, o);
207    h(this, p);
208    h(this, y, new AbortController());
209    /** @param {PointerEvent} event */
210    h(this, C, (t) => {
211      var l;
212      const e = (
213        /** @type {Element} */
214        t.target.closest("button.tree-action")
215      );
216      if (!e || e.hasAttribute("data-queued"))
217        return;
218      if (e.matches('[aria-busy="true"]')) {
219        e.setAttribute("data-queued", ""), e.innerHTML = /** @type {string} */
220        V;
221        return;
222      }
223      if (e.hasAttribute("aria-controls")) {
224        g(this, o, D).call(this, e);
225        return;
226      }
227      const r = (l = e.nextElementSibling) == null ? void 0 : l.getAttribute("href"), i = r ? s(this, p).getNodeByPath(r) : null;
228      i && g(this, o, P).call(this, e, i);
229    });
230    d(this, p, R), s(this, p).load();
231  }
232  connectedCallback() {
233    switch (this.addEventListener("click", s(this, C), {
234      signal: s(this, y).signal
235    }), s(this, p).status) {
236      case "pending":
237        s(this, p).addEventListener("change", () => g(this, o, $).call(this), {
238          once: !0,
239          signal: s(this, y).signal
240        });
241        break;
242      case "resolved":
243        g(this, o, M).call(this);
244        break;
245      case "rejected":
246        g(this, o, q).call(this);
247        break;
248    }
249  }
250  disconnectedCallback() {
251    s(this, y).abort(), d(this, y, new AbortController());
252  }
253}
254p = new WeakMap(), y = new WeakMap(), o = new WeakSet(), $ = function() {
255  s(this, p).status === "resolved" ? g(this, o, M).call(this) : g(this, o, q).call(this);
256}, C = new WeakMap(), M = function() {
257  var t;
258  for (const e of this.querySelectorAll('button[aria-busy="true"]')) {
259    const r = (t = e.nextElementSibling) == null ? void 0 : t.getAttribute("href"), i = r ? s(this, p).getNodeByPath(r) : null;
260    if (!i)
261      continue;
262    const l = e.hasAttribute("data-queued");
263    e.removeAttribute("aria-busy"), e.removeAttribute("aria-disabled"), e.removeAttribute("data-queued"), e.replaceChildren(), l && g(this, o, P).call(this, e, i);
264  }
265}, /**
266 * The full tree couldn't be loaded, so the collapsed off-branch nodes can
267 * never be expanded. Remove their loading toggles to clear the stuck pen
267ding
268 * state; the static <a> link is the button's sibling and remains navigable.
269 */
270q = function() {
271  for (const t of this.querySelectorAll('button[aria-busy="true"]'))
272    t.remove();
273}, /** @param {HTMLButtonElement} button */
274D = function(t) {
275  const e = t.getAttribute("aria-controls"), r = this.querySelector(`#${CSS.escape(e)}`);
276  if (r !== null) {
277    const i = r.toggleAttribute("hidden");
278    t.setAttribute("aria-expanded", String(!i));
279  }
280}, /**
281 * @param {HTMLButtonElement} button
282 * @param {PageTreeNode} node
283 */
284P = function(t, e) {
285  const r = g(this, o, z).call(this, e);
286  t.closest(".tree-item").append(r), t.setAttribute("aria-controls", r.id), t.setAttribute("aria-expanded", "true");
287}, /**
288 * @param {PageTreeNode} node
289 * @returns {HTMLUListElement}
290 */
291z = function(t) {
292  const e = document.createElement("ul");
293  e.id = crypto.randomUUID();
294  for (const r of s(this, p).getChildren(t.id))
295    e.append(g(this, o, O).call(this, r));
296  return e;
297}, /**
298 * @param {PageTreeNode} node
299 * @returns {HTMLLIElement}
300 */
301O = function(t) {
302  const e = document.createElement("li");
303  e.className = "tree-item";
304  const r = document.createElement("div");
305  r.className = "tree-item-header";
306  const i = document.createElement("a");
307  if (i.href = t.path, i.textContent = t.title, t.id === s(this, p).activeNodeId && i.setAttribute("aria-current", "page"), s(this, p).getChildren(t.id).length) {
308    i.id = crypto.randomUUID();
309    const u = document.createElement("button");
310    u.className = "tree-action", u.type = "button", u.setAttribute("aria-expanded", "false"), u.setAttribute("aria-labelledby", i.id), r.append(u);
311  }
312  return r.append(i), e.append(r), e;
313};
314customElements.define("theme-page-tree", G);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.