1import { c as commonjsGlobal, j as jsxRuntimeExports, g as getDefaultExportFromCjs, u as useGetMainMenuQuery, r as reactExports, a as createRoot, P as Provider_default, s as store } from './chunks/jsx-runtime-BQbN5z7g.js'; 2 3var dist = {}; 4 5var linkset = {}; 6 7var __assign$1 = commonjsGlobal && commonjsGlobal.__assign || function () { 8 __assign$1 = Object.assign || function (t) { 9 for (var s, i = 1, n = arguments.length; i < n; i++) { 10 s = arguments[i]; 11 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; 12 } 13 return t; 14 }; 15 return __assign$1.apply(this, arguments); 16}; 17var __rest$2 = commonjsGlobal && commonjsGlobal.__rest || function (s, e) { 18 var t = {}; 19 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; 20 if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { 21 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; 22 } 23 return t; 24}; 25var __spreadArray = commonjsGlobal && commonjsGlobal.__spreadArray || function (to, from) { 26 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) to[j] = from[i]; 27 return to; 28}; 29Object.defineProperty(linkset, "__esModule", { 30 value: true 31}); 32linkset.Linkset = void 0; 33/** 34 * A set of links. 35 * @internal 36 */ 37var Linkset = /** @class */function () { 38 function Linkset(links) { 39 this.elements = links; 40 this.size = links.length; 41 } 42 /** 43 * {@inheritDoc LinksetInterface.hasLinkTo} 44 */ 45 Linkset.prototype.hasLinkTo = function (relationType) { 46 return this.elements.some(function (link) { 47 return link.rel === relationType; 48 }); 49 }; 50 /** 51 * {@inheritDoc LinksetInterface.linkTo} 52 */ 53 Linkset.prototype.linkTo = function (relationType) { 54 return this.elements.find(function (link) { 55 return link.rel === relationType; 56 }); 57 }; 58 /** 59 * {@inheritDoc LinksetInterface.linksTo} 60 */ 61 Linkset.prototype.linksTo = function (relationType) { 62 return new Linkset(this.elements.filter(function (link) { 63 return link.rel === relationType; 64 })); 65 }; 66 /** 67 * {@inheritDoc LinksetInterface.linksFrom} 68 */ 69 Linkset.prototype.linksFrom = function (anchor) { 70 return new Linkset(this.elements.filter(function (link) { 71 return link.anchor === anchor; 72 })); 73 }; 74 /** 75 * {@inheritdoc LinksetInterface.linksWithAttribute} 76 */ 77 Linkset.prototype.linksWithAttribute = function (name) { 78 return new Linkset(this.elements.filter(function (link) { 79 return Object.prototype.hasOwnProperty.call(link.attributes, name); 80 })); 81 }; 82 /** 83 * {@inheritdoc LinksetInterface.linksWithAttributeValue} 84 */ 85 Linkset.prototype.linksWithAttributeValue = function (name, value) { 86 return new Linkset(this.linksWithAttribute(name).elements.filter(function (link) { 87 var values = Array.isArray(link.attributes[name]) ? link.attributes[name] : [link.attributes[name]]; 88 return values.some(function (v) { 89 return isAttributeEqual(v, value); 90 }); 91 })); 92 }; 93 /** 94 * Implements the iterable protocol. 95 */ 96 Linkset.prototype[Symbol.iterator] = function () { 97 var elems = this.elements; 98 var pointer = 0; 99 return { 100 next: function () { 101 if (pointer < elems.length) { 102 return { 103 value: elems[pointer++], 104 done: false 105 }; 106 } else { 107 return { 108 value: undefined, 109 done: true 110 }; 111 } 112 } 113 }; 114 }; 115 /** 116 * {@inheritDoc NormalizableLinksetInterface.normalize} 117 */ 118 Linkset.prototype.normalize = function () { 119 var contexts = {}; 120 this.elements.forEach(function (_a) { 121 var anchor = _a.anchor, 122 rel = _a.rel, 123 target = __rest$2(_a, ["anchor", "rel"]); 124 if (!Object.hasOwnProperty.call(contexts, anchor)) contexts[anchor] = {}; 125 if (!Object.hasOwnProperty.call(contexts[anchor], rel)) contexts[anchor][rel] = []; 126 var href = target.href, 127 attributes = target.attributes; 128 var targetObject = __assign$1({ 129 href: href 130 }, attributes);
131 contexts[anchor][rel].push(targetObject); 132 }); 133 return { 134 linkset: Object.entries(contexts).reduce(function (carry, _a) { 135 var anchor = _a[0], 136 rels = _a[1]; 137 return __spreadArray(__spreadArray([], carry), [__assign$1({ 138 anchor: anchor 139 }, rels)]); 140 }, []) 141 }; 142 }; 143 return Linkset; 144}(); 145linkset.Linkset = Linkset; 146/** 147 * Checks target attribute values for equality, respecting that a value may be internationalized. 148 * @param a - A target attribute value. 149 * @param b - Another target attribute value. 150 * @returns boolean 151 * True if both values are strictly equivalent. If the input values are internationalized, both the value and language 152 * must match. 153 * {@see {@link TargetAttributeValue}} 154 */ 155function isAttributeEqual(a, b) { 156 if (typeof a !== typeof b) { 157 return false; 158 } 159 if (typeof a === 'string' && typeof b === 'string') { 160 return a === b; 161 } 162 return a.value === a.value && a.language === a.language; 163} 164 165var link = {}; 166 167var __rest$1 = commonjsGlobal && commonjsGlobal.__rest || function (s, e) { 168 var t = {}; 169 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; 170 if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { 171 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; 172 } 173 return t; 174}; 175Object.defineProperty(link, "__esModule", { 176 value: true 177}); 178link.Link = void 0; 179/** 180 * A web link. 181 * @internal 182 */ 183var Link = /** @class */function () { 184 /** 185 * Constructs a new link. 186 * @param parameters - the link's parameters. 187 * @see {@link LinkParameters} 188 */ 189 function Link(parameters) { 190 var anchor = parameters.anchor, 191 rel = parameters.rel, 192 href = parameters.href, 193 attributes = __rest$1(parameters, ["anchor", "rel", "href"]); 194 this.anchor = anchor; 195 this.rel = rel; 196 this.href = href; 197 this.attributes = attributes; 198 } 199 return Link; 200}(); 201link.Link = Link; 202 203var __assign = commonjsGlobal && commonjsGlobal.__assign || function () { 204 __assign = Object.assign || function (t) { 205 for (var s, i = 1, n = arguments.length; i < n; i++) { 206 s = arguments[i]; 207 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; 208 } 209 return t; 210 }; 211 return __assign.apply(this, arguments); 212}; 213var __rest = commonjsGlobal && commonjsGlobal.__rest || function (s, e) { 214 var t = {}; 215 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; 216 if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { 217 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; 218 } 219 return t; 220}; 221Object.defineProperty(dist, "__esModule", { 222 value: true 223}); 224var denormalize_1 = dist.denormalize = dist.parse = void 0; 225var linkset_1 = linkset; 226var link_1 = link; 227/** 228 * Denormalizes a set of links into an instance of a Linkset. 229 * {@inheritDoc Linkset.from} 230 * {@see {@link NormalizedLinksetInterface}} 231 */ 232function denormalize(normalized) { 233 var links = []; 234 normalized.linkset.forEach(function (contextObject) { 235 var anchor = contextObject.anchor, 236 rels = __rest(contextObject, ["anchor"]); 237 Object.keys(rels).forEach(function (rel) { 238 contextObject[rel].forEach(function (targetObject) { 239 links.push(new link_1.Link(__assign({ 240 anchor: anchor, 241 rel: rel 242 }, targetObject))); 243 }); 244 }); 245 }); 246 return new linkset_1.Linkset(links); 247} 248denormalize_1 = dist.denormalize = denormalize; 249/** 250 * Parses an application/linkset+json document into a Linkset instance. 251 * {@see {@link denormalize}} 252 */ 253function parse(json) { 254 return denormalize(JSON.parse(json)); 255} 256dist.parse = parse; 257 258class DrupalLinkset { 259 /** 260 * The full list of links, processed via denormalize(). 261 */ 262 263 /** 264 * The currently viewed pages href. 265 */ 266 267 /** 268 * The currently viewed pages hierarchy array.
269 */ 270 271 /** 272 * The currently viewed section. 273 */ 274 275 /** 276 * Create a DrupalLinkset. 277 * 278 * @param links 279 * The response returned from a linkset endpoint. 280 * @param href 281 * The currently viewed pages href. 282 */ 283 constructor(links, href) { 284 this.links = denormalize_1(links); 285 this.href = href; 286 this.family = this.getByHref()?.attributes.hierarchy; 287 this.relatives = this.getRelatives(); 288 } 289 290 /** 291 * Get the currently viewed page by filtering via href. 292 */ 293 getByHref() { 294 const currentLink = this.links.elements.filter(item => item.href === this.href)[0]; 295 if (!currentLink) { 296 return this.links.elements[0]; 297 } 298 return currentLink; 299 } 300 301 /** 302 * Get the currently viewed section by filtering via the first hierarchy number. 303 */ 304 getRelatives() { 305 return this.links.elements.filter(item => item.attributes.hierarchy[0] === this.family[0]); 306 } 307 308 /** 309 * Get children (if present) by filtering by each member of a hierarchy array. 310 * 311 * @param family 312 * The hierarchy array to filter by. 313 */ 314 getChildren(family) { 315 return this.links.elements.filter(item => 316 // Children will have a hierarchy array that is 1 level deeper. 317 item.attributes.hierarchy.length === family.length + 1 && 318 // Each element in a child hierarchy array will match the parents. 319 family.every((element, index) => element === item.attributes.hierarchy[index])); 320 } 321 322 /** 323 * Get the ancestors of the currently viewed page. 324 */ 325 getAncestors() { 326 const ancestors = []; 327 328 // Get the parents hierarchy array by removing the last element from the 329 // current family. 330 const ancestorIndexes = this.family.slice(0, -1); 331 332 // Get each ancestor one by one, by filtering from each ancestorIndex combination. 333 let currentIndexes = []; 334 for (const value of ancestorIndexes.values()) { 335 currentIndexes.push(value); 336 const ancestor = this.relatives.filter(item => currentIndexes.every((element, index) => element === item.attributes.hierarchy[index]))[0]; 337 ancestors.push(DrupalLinkset.getDrupalLinkset(ancestor.href, ancestor.attributes.title)); 338 } 339 return ancestors; 340 } 341 342 /** 343 * Get any siblings of the currently viewed page. 344 */ 345 getSiblings() { 346 // Get the siblings hierarchy array by removing the last element from the 347 // current family. 348 const siblingIndexes = this.family.slice(0, -1); 349 350 // Get all siblings by filtering against the above hierarchy array. 351 let siblingLinksets; 352 // Top level links. 353 if (siblingIndexes.length === 0) { 354 siblingLinksets = this.links.elements.filter(item => item.attributes.hierarchy.length === 1); 355 } 356 // All other levels. 357 else { 358 siblingLinksets = this.relatives.filter(item => item.attributes.hierarchy.length === this.family.length && siblingIndexes.every((element, index) => element === item.attributes.hierarchy[index])); 359 } 360 361 // Build out the siblings array by search each sibling for any children. 362 const siblings = []; 363 siblingLinksets.forEach(item => { 364 const childrenLinksets = this.getChildren(item.attributes.hierarchy); 365 const isActive = item.href === this.href; 366 const sibling = DrupalLinkset.getDrupalLinkset(item.href, item.attributes.title, !!childrenLinksets.length, isActive); 367 368 // Only show the children if this is the active sibling. 369 if (isActive) { 370 const children = []; 371 childrenLinksets.forEach(child => { 372 const grandchildrenLinksets = this.getChildren(child.attributes.hierarchy); 373 children.push(DrupalLinkset.getDrupalLinkset(child.href, child.attributes.title, !!grandchildrenLinksets.length)); 374 }); 375 sibling.children = children; 376 } 377 siblings.push(sibling); 378 }); 379 return siblings; 380 } 381 382 /** 383 * Output a correctly formatted DrupalLinksetInterface. 384 */ 385 static getDrupalLinkset(href, title, hasChildren, isActive) { 386 return { 387 id: `${href} ${title}`, 388 href, 389 title, 390 hasChildren, 391 isActive 392 }; 393 } 394} 395 396const LocalNavChildren = _ref => { 397 let { 398 children 399 } = _ref; 400 return /*#__PURE__*/jsxRuntimeExports.jsx("ul", { 401 className: "uq-local-nav__children", 402 children: children 403 }); 404}; 405 406var classnames = {exports: {}}; 407 408/*! 409 Copyright (c) 2018 Jed Watson. 410 Licensed under the MIT License (MIT), see 411 http://jedwatson.github.io/classnames 412*/ 413(function (module) { 414 /* global define */ 415 416 (function () { 417 418 var hasOwn = {}.hasOwnProperty; 419 function classNames() { 420 var classes = ''; 421 for (var i = 0; i < arguments.length; i++) { 422 var arg = arguments[i]; 423 if (arg) {
424 classes = appendClass(classes, parseValue(arg)); 425 } 426 } 427 return classes; 428 } 429 function parseValue(arg) { 430 if (typeof arg === 'string' || typeof arg === 'number') { 431 return arg; 432 } 433 if (typeof arg !== 'object') { 434 return ''; 435 } 436 if (Array.isArray(arg)) { 437 return classNames.apply(null, arg); 438 } 439 if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) { 440 return arg.toString(); 441 } 442 var classes = ''; 443 for (var key in arg) { 444 if (hasOwn.call(arg, key) && arg[key]) { 445 classes = appendClass(classes, key); 446 } 447 } 448 return classes; 449 } 450 function appendClass(value, newClass) { 451 if (!newClass) { 452 return value; 453 } 454 if (value) { 455 return value + ' ' + newClass; 456 } 457 return value + newClass; 458 } 459 if (module.exports) { 460 classNames.default = classNames; 461 module.exports = classNames; 462 } else { 463 window.classNames = classNames; 464 } 465 })(); 466})(classnames); 467var classnamesExports = classnames.exports; 468var classNames = /*@__PURE__*/getDefaultExportFromCjs(classnamesExports); 469 470const LocalNavLink = _ref => { 471 let { 472 href, 473 title, 474 isActive = false 475 } = _ref; 476 return /*#__PURE__*/jsxRuntimeExports.jsx("a", { 477 href: href, 478 className: classNames("uq-local-nav__link", { 479 "uq-local-nav--active-link": isActive 480 }), 481 children: title 482 }); 483}; 484 485const LocalNavChild = _ref => { 486 let { 487 children, 488 href, 489 title, 490 hasChildren = false, 491 isCurrent = false, 492 isActive = false 493 } = _ref; 494 return /*#__PURE__*/jsxRuntimeExports.jsxs("li", { 495 className: classNames("uq-local-nav__child", { 496 "uq-local-nav--has-children": hasChildren, 497 "uq-local-nav--current-child": isCurrent 498 }), 499 children: [/*#__PURE__*/jsxRuntimeExports.jsx(LocalNavLink, { 500 href: href, 501 title: title, 502 isActive: isActive 503 }), children] 504 }); 505}; 506 507const LocalNavGrandchildren = _ref => { 508 let { 509 children 510 } = _ref; 511 return /*#__PURE__*/jsxRuntimeExports.jsx("ul", { 512 className: "uq-local-nav__grandchildren", 513 children: children 514 }); 515}; 516 517const LocalNavGrandchild = _ref => { 518 let { 519 href, 520 title, 521 hasChildren = false 522 } = _ref; 523 return /*#__PURE__*/jsxRuntimeExports.jsx("li", { 524 className: classNames("uq-local-nav__grandchild", { 525 "uq-local-nav--has-children": hasChildren 526 }), 527 children: /*#__PURE__*/jsxRuntimeExports.jsx(LocalNavLink, { 528 href: href, 529 title: title 530 }) 531 }); 532}; 533 534const LocalNavGrandparent = _ref => { 535 let { 536 href, 537 title 538 } = _ref; 539 return /*#__PURE__*/jsxRuntimeExports.jsx("div", { 540 className: "uq-local-nav__grandparent", 541 children: /*#__PURE__*/jsxRuntimeExports.jsx(LocalNavLink, { 542 href: href, 543 title: title 544 }) 545 }); 546}; 547 548const LocalNavParent = _ref => { 549 let { 550 href, 551 title 552 } = _ref; 553 return /*#__PURE__*/jsxRuntimeExports.jsx("div", { 554 className: "uq-local-nav__parent", 555 children: /*#__PURE__*/jsxRuntimeExports.jsx(LocalNavLink, { 556 href: href, 557 title: title 558 }) 559 }); 560}; 561 562const LocalNavAncestors = _ref => { 563 let { 564 grandparents, 565 parent 566 } = _ref; 567 return /*#__PURE__*/jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { 568 children: [grandparents && grandparents.map(ancestor => /*#__PURE__*/jsxRuntimeExports.jsx(LocalNavGrandparent, { 569 href: ancestor.href, 570 title: ancestor.title 571 }, ancestor.id)), parent && /*#__PURE__*/jsxRuntimeExports.jsx(LocalNavParent, { 572 href: parent.href, 573 title: parent.title 574 })] 575 }); 576}; 577 578const LocalNav = _ref => { 579 let { 580 grandparents, 581 parent, 582 children 583 } = _ref; 584 return /*#__PURE__*/jsxRuntimeExports.jsxs("nav", { 585 className: "uq-local-nav", 586 "aria-label": "Local navigation", 587 children: [/*#__PURE__*/jsxRuntimeExports.jsx(LocalNavAncestors, { 588 grandparents: grandparents, 589 parent: parent 590 }), children && /*#__PURE__*/jsxRuntimeExports.jsx(LocalNavChildren, { 591 children: children.map((child, index) => /*#__PURE__*/jsxRuntimeExports.jsx(LocalNavChild, { 592 href: child.href, 593 title: child.title, 594 isCurrent: child.isActive, 595 isActive: child.isActive, 596 hasChildren: child.hasChildren, 597 children: child.isActive && child.children && /*#__PURE__*/jsxRuntimeExports.jsx(LocalNavGrandchildren, { 598 children: child.children.map((grandchild, index) => /*#__PURE__*/jsxRuntimeExports.jsx(LocalNavGrandchild, { 599 href: grandchild.href, 600 title: grandchild.title, 601 hasChildren: grandchild.hasChildren 602 }, grandchild.id)) 603 }) 604 }, child.id)) 605 })] 606 }); 607}; 608 609const LocalNavApp = _ref => { 610 let { 611 pageHref, 612 isHomeSite, 613 homeUrl, 614 homeTitle, 615 frontTitle, 616 frontUrl 617 } = _ref; 618 const { 619 data, 620 error, 621 isLoading 622 } = useGetMainMenuQuery(); 623 const { 624 grandparents, 625 parent, 626 children 627 } = reactExports.useMemo(() => { 628 if (!data) return {}; 629 630 // Add static links for UQ home and the front page. 631 const home = DrupalLinkset.getDrupalLinkset(homeUrl, homeTitle); 632 const frontPage = DrupalLinkset.getDrupalLinkset(frontUrl, frontTitle); 633 const linkset = new DrupalLinkset(data, pageHref); 634 const children = linkset.getSiblings(); 635 const ancestors = [home, ...(!isHomeSite ? [frontPage] : []), ...linkset.getAncestors()]; 636 let parent = ancestors.pop(); 637 return { 638 grandparents: ancestors, 639 parent, 640 children 641 }; 642 }, [data]); 643 return /*#__PURE__*/jsxRuntimeExports.jsx(LocalNav, { 644 grandparents: grandparents, 645 parent: parent, 646 children: children 647 }); 648}; 649 650Drupal.behaviors["uqLocalNav"] = { 651 attach(context) { 652 const [app] = once("local-nav", "#local-nav-app"); 653 if (app) { 654 const root = createRoot(app); 655 const { 656 pageHref, 657 isHomeSite, 658 homeUrl, 659 homeTitle, 660 frontTitle, 661 frontUrl 662 } = drupalSettings.localNavApp; 663 root.render( /*#__PURE__*/jsxRuntimeExports.jsx(Provider_default, { 664 store: store, 665 children: /*#__PURE__*/jsxRuntimeExports.jsx(LocalNavApp, { 666 pageHref: pageHref, 667 isHomeSite: isHomeSite, 668 homeUrl: homeUrl, 669 homeTitle: homeTitle, 670 frontTitle: frontTitle, 671 frontUrl: frontUrl 672 }) 673 })); 674 } 675 } 676};
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.