UNPKG

ecfr-navigator

Version:

A lightweight, reusable Vue 3 component with Pinia integration for navigating hierarchical eCFR-style content in existing Vue applications.

1 lines 365 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("pinia"),require("vue"),require("uuid")):"function"==typeof define&&define.amd?define(["exports","pinia","vue","uuid"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ECFRNavigator={},e.Pinia,e.Vue,e.uuid)}(this,(function(e,t,a,r){"use strict";const o=t.defineStore("ecfr",{state:()=>({rootItems:[],currentPath:[],currentItem:null,expandedItems:new Set,metadataRegistry:new Map,metadataProcessors:new Map}),getters:{breadcrumbPath(){return this.currentPath},isItemExpanded(){return e=>this.expandedItems.has(e)},getItemMetadata(){return(e,t)=>{if(!this.metadataRegistry.has(e))return null;const a=this.metadataRegistry.get(e);return t&&"object"==typeof a?a[t]||null:a}},currentItemMetadata(){return e=>this.currentItem&&this.currentItem.id?this.getItemMetadata(this.currentItem.id,e):null},allMetadataProcessors(){return this.metadataProcessors}},actions:{setRootItems(e){this.rootItems=e,e.length>0&&!this.currentItem&&this.selectItem(e[0],0)},selectItem(e,t,a=[]){const r=[...a,{item:e,index:t}];this.currentPath=r,this.currentItem=e,e.children&&e.children.length>0&&this.expandItem(e.id)},navigateToPath(e){e.length>0&&(this.currentPath=e,this.currentItem=e[e.length-1].item)},expandItem(e){this.expandedItems.add(e)},collapseItem(e){this.expandedItems.delete(e)},toggleItemExpansion(e){this.expandedItems.has(e)?this.expandedItems.delete(e):this.expandedItems.add(e)},expandAll(){const e=t=>{for(const a of t)this.expandedItems.add(a.id),a.children&&e(a.children)};e(this.rootItems)},collapseAll(){this.expandedItems.clear()},registerMetadataProcessor(e,t){"function"==typeof t?this.metadataProcessors.set(e,t):console.error(`Metadata processor for '${e}' must be a function`)},unregisterMetadataProcessor(e){this.metadataProcessors.delete(e)},setItemMetadata(e,t,a){if(!e)return void console.error("Cannot set metadata: Item ID is required");this.metadataRegistry.has(e)||this.metadataRegistry.set(e,{});const r=this.metadataRegistry.get(e);a?r[a]=t:"object"==typeof t?Object.assign(r,t):console.error("Invalid metadata format: must be an object")},processItemMetadata(e,t){const a=this.getItemMetadata(e,t);if(!a)return null;if(!t){const t={};for(const[r,o]of Object.entries(a))if(this.metadataProcessors.has(r)){const a=this.metadataProcessors.get(r);t[r]=a(o,e)}else t[r]=o;return t}if(this.metadataProcessors.has(t)){return this.metadataProcessors.get(t)(a,e)}return a},removeItemMetadata(e,t){if(!this.metadataRegistry.has(e))return;if(!t)return void this.metadataRegistry.delete(e);const a=this.metadataRegistry.get(e);a&&a[t]&&delete a[t]}}}),n=(e,t)=>{const a=e.__vccOpts||e;for(const[r,o]of t)a[r]=o;return a},l={name:"ECFRBreadcrumb",props:{path:{type:Array,required:!0},darkMode:{type:Boolean,default:!1},options:{type:Object,default:()=>({})}},computed:{defaultOptions:()=>({rootLabel:"Home",hideRootLink:!1,truncate:!1,truncateLabels:!1,maxVisible:3,visibleItems:2,highlightLast:!0,maxItemWidth:"12rem",separatorType:"icon",separator:"/",style:"clean",type:"wrap",useIcons:!1,textSize:"",bgColor:"",maxWidth:""}),mergedOptions(){return{...this.defaultOptions,...this.options}},visibleLastItems(){if(!this.path.length)return[];const e=this.mergedOptions.visibleItems||2,t=Math.max(this.path.length-e,1);return this.path.slice(t).map(((e,a)=>({...e,index:t+a})))}},methods:{formatBreadcrumbLabel(e){return e?"numbered"===this.mergedOptions.labelFormat&&e.type&&e.number?`${e.type.charAt(0).toUpperCase()+e.type.slice(1)} ${e.number}${e.title?": "+e.title:""}`:"title-only"===this.mergedOptions.labelFormat?e.title||"":"number-only"===this.mergedOptions.labelFormat&&e.number?e.number:"type-number"===this.mergedOptions.labelFormat&&e.type&&e.number?`${e.type.charAt(0).toUpperCase()+e.type.slice(1)} ${e.number}`:e.type&&e.number?`${e.type.charAt(0).toUpperCase()+e.type.slice(1)} ${e.number}${e.title?": "+e.title:""}`:e.title||"":""},isLastItem(e){return e===this.path.length-1},isLastVisibleItem(e){return e===this.visibleLastItems.length-1},navigateToRoot(){this.$emit("navigate",null)},navigateToIndex(e){this.path&&this.path[e]&&this.$emit("navigate",this.path[e])},showPrefix:e=>e&&e.type&&"root"!==e.type,getItemPrefix(e){if(!e||!e.type)return"";if(e.citationPrefix)return e.citationPrefix;return{title:"Title",part:"Part",section:"Section",subpart:"Subpart",chapter:"Chapter",paragraph:"Para.",subparagraph:"Subpara."}[e.type]||e.type.charAt(0).toUpperCase()+e.type.slice(1)}}},s={key:0,class:"inline-flex items-center shrink-0"},i=["title"],c={key:0,class:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20"},d={class:"flex items-center"},u={class:"mx-1 flex-shrink-0","aria-hidden":"true"},m=["onClick","title"],p={class:"shrink-0"},h={class:"flex items-center"},g={class:"mx-1 flex-shrink-0","aria-hidden":"true"},y=["title"],f={class:"shrink-0"},b={class:"flex items-center"},v={class:"mx-1 flex-shrink-0","aria-hidden":"true"},k={class:"flex items-center"},x={class:"mx-1 flex-shrink-0","aria-hidden":"true"},w=["onClick","title"];const C=n(l,[["render",function(e,t,r,o,n,l){return a.openBlock(),a.createElementBlock("nav",{class:a.normalizeClass(["flex text-sm overflow-x-auto",[r.darkMode?"text-gray-300":"text-gray-600","compact"===r.options.style?"py-1 px-2":"py-2 px-3","clean"===r.options.style?"bg-white border-b border-gray-200":"","boxed"===r.options.style?"rounded-md shadow-sm border bg-opacity-50":"",r.darkMode&&"boxed"===r.options.style?"border-gray-700 bg-gray-800":"",r.darkMode||"boxed"!==r.options.style?"":"border-gray-200 bg-gray-50",r.options.bgColor?r.options.bgColor:"",r.options.textSize?r.options.textSize:""]]),"aria-label":"Breadcrumb",style:a.normalizeStyle({maxWidth:r.options.maxWidth||"none"})},[a.createElementVNode("ol",{class:a.normalizeClass(["inline-flex items-center min-w-full",["scrollable"===r.options.type?"flex-nowrap":"flex-wrap"]])},[r.options.hideRootLink?a.createCommentVNode("",!0):(a.openBlock(),a.createElementBlock("li",s,[a.createElementVNode("a",{href:"#",class:a.normalizeClass(["transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50 rounded whitespace-nowrap",[r.darkMode?"hover:text-blue-300":"hover:text-blue-600","button"===r.options.style?"px-2 py-1 rounded hover:bg-opacity-10 hover:bg-blue-500":"hover:underline"]]),onClick:t[0]||(t[0]=a.withModifiers(((...e)=>l.navigateToRoot&&l.navigateToRoot(...e)),["prevent"])),title:r.options.rootLabel},[r.options.useIcons?(a.openBlock(),a.createElementBlock("svg",c,t[2]||(t[2]=[a.createElementVNode("path",{d:"M10.707 2.293a1 1 0 00-1.414 0l-7 7a1 1 0 001.414 1.414L4 10.414V17a1 1 0 001 1h2a1 1 0 001-1v-2a1 1 0 011-1h2a1 1 0 011 1v2a1 1 0 001 1h2a1 1 0 001-1v-6.586l.293.293a1 1 0 001.414-1.414l-7-7z"},null,-1)]))):(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},[a.createTextVNode(a.toDisplayString(r.options.rootLabel),1)],64))],10,i)])),!r.options.truncate||r.path.length<=(r.options.maxVisible||3)?(a.openBlock(!0),a.createElementBlock(a.Fragment,{key:1},a.renderList(r.path,((e,o)=>(a.openBlock(),a.createElementBlock("li",{key:`breadcrumb-path-${o}-${e.id||o}`,class:"shrink-0"},[a.createElementVNode("div",d,[a.createElementVNode("div",u,["icon"===r.options.separatorType?(a.openBlock(),a.createElementBlock("svg",{key:0,class:a.normalizeClass(["w-4 h-4",[r.darkMode?"text-gray-400":"text-gray-500"]]),fill:"currentColor",viewBox:"0 0 20 20"},t[3]||(t[3]=[a.createElementVNode("path",{"fill-rule":"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z","clip-rule":"evenodd"},null,-1)]),2)):"text"===r.options.separatorType?(a.openBlock(),a.createElementBlock("span",{key:1,class:a.normalizeClass([r.darkMode?"text-gray-500":"text-gray-400"])},a.toDisplayString(r.options.separator||"/"),3)):a.createCommentVNode("",!0)]),a.createElementVNode("a",{href:"#",class:a.normalizeClass(["transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50 rounded truncate",[r.darkMode?"hover:text-blue-300":"hover:text-blue-600","button"===r.options.style?"px-2 py-1 rounded hover:bg-opacity-10 hover:bg-blue-500":"hover:underline",l.isLastItem(o)&&r.options.highlightLast?"font-medium":"",r.options.maxItemWidth?"max-w-["+r.options.maxItemWidth+"]":""]]),onClick:a.withModifiers((e=>l.navigateToIndex(o)),["prevent"]),title:l.formatBreadcrumbLabel(e)},[a.createElementVNode("span",{class:a.normalizeClass({truncate:r.options.truncateLabels})},a.toDisplayString(l.formatBreadcrumbLabel(e)),3)],10,m)])])))),128)):(a.openBlock(),a.createElementBlock(a.Fragment,{key:2},[a.createElementVNode("li",p,[a.createElementVNode("div",h,[a.createElementVNode("div",g,["icon"===r.options.separatorType?(a.openBlock(),a.createElementBlock("svg",{key:0,class:a.normalizeClass(["w-4 h-4",[r.darkMode?"text-gray-400":"text-gray-500"]]),fill:"currentColor",viewBox:"0 0 20 20"},t[4]||(t[4]=[a.createElementVNode("path",{"fill-rule":"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z","clip-rule":"evenodd"},null,-1)]),2)):"text"===r.options.separatorType?(a.openBlock(),a.createElementBlock("span",{key:1,class:a.normalizeClass([r.darkMode?"text-gray-500":"text-gray-400"])},a.toDisplayString(r.options.separator||"/"),3)):a.createCommentVNode("",!0)]),a.createElementVNode("a",{href:"#",class:a.normalizeClass(["transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50 rounded truncate",[r.darkMode?"hover:text-blue-300":"hover:text-blue-600","button"===r.options.style?"px-2 py-1 rounded hover:bg-opacity-10 hover:bg-blue-500":"hover:underline"]]),onClick:t[1]||(t[1]=a.withModifiers((e=>l.navigateToIndex(0)),["prevent"])),title:l.formatBreadcrumbLabel(r.path[0])},[a.createElementVNode("span",{class:a.normalizeClass({truncate:r.options.truncateLabels})},a.toDisplayString(l.formatBreadcrumbLabel(r.path[0])),3)],10,y)])]),a.createElementVNode("li",f,[a.createElementVNode("div",b,[a.createElementVNode("div",v,["icon"===r.options.separatorType?(a.openBlock(),a.createElementBlock("svg",{key:0,class:a.normalizeClass(["w-4 h-4",[r.darkMode?"text-gray-400":"text-gray-500"]]),fill:"currentColor",viewBox:"0 0 20 20"},t[5]||(t[5]=[a.createElementVNode("path",{"fill-rule":"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z","clip-rule":"evenodd"},null,-1)]),2)):"text"===r.options.separatorType?(a.openBlock(),a.createElementBlock("span",{key:1,class:a.normalizeClass([r.darkMode?"text-gray-500":"text-gray-400"])},a.toDisplayString(r.options.separator||"/"),3)):a.createCommentVNode("",!0)]),a.createElementVNode("span",{class:a.normalizeClass(["px-2 py-1",[r.darkMode?"text-gray-400":"text-gray-500"]])}," ... ",2)])]),(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(l.visibleLastItems,((e,o)=>(a.openBlock(),a.createElementBlock("li",{key:`breadcrumb-last-${o}-${e.id||o}`,class:"shrink-0"},[a.createElementVNode("div",k,[a.createElementVNode("div",x,["icon"===r.options.separatorType?(a.openBlock(),a.createElementBlock("svg",{key:0,class:a.normalizeClass(["w-4 h-4",[r.darkMode?"text-gray-400":"text-gray-500"]]),fill:"currentColor",viewBox:"0 0 20 20"},t[6]||(t[6]=[a.createElementVNode("path",{"fill-rule":"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z","clip-rule":"evenodd"},null,-1)]),2)):"text"===r.options.separatorType?(a.openBlock(),a.createElementBlock("span",{key:1,class:a.normalizeClass([r.darkMode?"text-gray-500":"text-gray-400"])},a.toDisplayString(r.options.separator||"/"),3)):a.createCommentVNode("",!0)]),a.createElementVNode("a",{href:"#",class:a.normalizeClass(["transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50 rounded truncate",[r.darkMode?"hover:text-blue-300":"hover:text-blue-600","button"===r.options.style?"px-2 py-1 rounded hover:bg-opacity-10 hover:bg-blue-500":"hover:underline",l.isLastVisibleItem(o)&&r.options.highlightLast?"font-medium":"",r.options.maxItemWidth?"max-w-["+r.options.maxItemWidth+"]":""]]),onClick:a.withModifiers((t=>l.navigateToIndex(e.index)),["prevent"]),title:l.formatBreadcrumbLabel(e)},[a.createElementVNode("span",{class:a.normalizeClass({truncate:r.options.truncateLabels})},a.toDisplayString(l.formatBreadcrumbLabel(e)),3)],10,w)])])))),128))],64))],2)],6)}]]),S={name:"ECFRSection",props:{item:{type:Object,required:!0},index:{type:Number,required:!0},level:{type:Number,required:!0},parentPath:{type:Array,default:()=>[]},darkMode:{type:Boolean,default:!1},options:{type:Object,default:()=>({})}},data:()=>({ecfrStore:o()}),computed:{defaultOptions:()=>({display:{showTypeIcon:!0,showItemNumbers:!0,indentItems:!0,hideEmptyItems:!1,viewMode:"standard",showDescription:!1,showMetadataBadges:!1,itemSpacing:"medium",maxTitleLength:null},navigation:{preserveState:!0,scrollToSelected:!0,autoExpandParents:!0,autoCollapseOthers:!1}}),mergedOptions(){return{...this.defaultOptions,...this.options,display:{...this.defaultOptions.display,...this.options.display||{}},navigation:{...this.defaultOptions.navigation,...this.options.navigation||{}}}},hasChildren(){return this.item.children&&this.item.children.length>0},shouldHideItem(){return this.mergedOptions.display.hideEmptyItems&&!this.hasChildren&&!this.item.content},isExpanded(){return this.ecfrStore.isItemExpanded(this.item.id)},currentPath(){return[...this.parentPath,{item:this.item,index:this.index}]},isSelected(){var e;return(null==(e=this.ecfrStore.currentItem)?void 0:e.id)===this.item.id},viewModeClasses(){const e=this.mergedOptions.display.viewMode;return"compact"===e?"compact-mode py-0.5":"detailed"===e?"detailed-mode py-2":"styleless"===e?"styleless-mode":"standard-mode py-1"},spacingClasses(){const e=this.mergedOptions.display.itemSpacing;return"tight"===e?"mb-0.5":"loose"===e?"mb-2":"mb-1"},isCompactMode(){return"compact"===this.mergedOptions.display.viewMode},isDetailedMode(){return"detailed"===this.mergedOptions.display.viewMode},displayTitle(){const e=this.mergedOptions.display.maxTitleLength;return!e||!this.item.title||this.item.title.length<=e?this.item.title:this.item.title.substring(0,e)+"..."},hasMetadata(){return!!this.ecfrStore.getItemMetadata(this.item.id)},metadataTypes(){const e=this.ecfrStore.getItemMetadata(this.item.id);return e?Object.keys(e):[]},contentPreview(){if(!this.item.content)return"";const e=this.item.content.replace(/<[^>]*>/g,"");return e.length<=150?e:e.substring(0,150)+"..."}},methods:{toggleExpand(e){e.stopPropagation(),this.ecfrStore.toggleItemExpansion(this.item.id)},handleSelect(){this.ecfrStore.selectItem(this.item,this.index,this.parentPath),this.hasChildren&&!this.isExpanded&&this.ecfrStore.expandItem(this.item.id),this.mergedOptions.navigation.autoCollapseOthers&&this.hasChildren&&this.collapseOthers(this.item.id),this.mergedOptions.navigation.scrollToSelected&&this.$nextTick((()=>{const e=document.querySelector(".ecfr-section .bg-blue-100, .ecfr-section .bg-blue-900");e&&e.scrollIntoView({behavior:"smooth",block:"nearest"})}))},collapseOthers(e){if(0===this.level&&this.item.id!==e)return void this.ecfrStore.collapseItem(this.item.id);const t=this.parentPath.length>0?this.parentPath[this.parentPath.length-1].item.children:this.ecfrStore.rootItems;t&&t.forEach((t=>{t.id!==e&&this.ecfrStore.collapseItem(t.id)}))}}},E={key:1,class:"mr-2 h-5 w-5 flex-shrink-0"},B={class:"flex-1"},V={class:"flex items-baseline"},N={key:1,class:"mr-2"},M={key:1,class:"flex items-start"},I={class:"flex-1"},D={class:"flex items-baseline flex-wrap"},T={key:1,class:"mr-2"},z={key:2,class:"ml-2 flex flex-wrap gap-1"},F={key:1,class:"text-sm mt-2 text-gray-600 dark:text-gray-400 max-w-prose"},$=["innerHTML"],A={key:1,class:"pt-1"};const L=n(S,[["render",function(e,t,r,o,n,l){const s=a.resolveComponent("ECFRSection",!0);return l.shouldHideItem?a.createCommentVNode("",!0):(a.openBlock(),a.createElementBlock("div",{key:0,class:a.normalizeClass(["ecfr-section",[r.darkMode?"border-gray-600":"border-gray-200",r.level>0&&l.mergedOptions.display.indentItems?`pl-${Math.min(4*r.level,12)}`:"",l.mergedOptions.display.indentItems?"border-l-2":"",l.viewModeClasses,l.spacingClasses]])},[a.createElementVNode("div",{class:a.normalizeClass(["styleless"!==l.mergedOptions.display.viewMode?"flex items-start cursor-pointer p-2 hover:bg-opacity-10 transition-colors duration-200 rounded":"flex items-start cursor-pointer","styleless"!==l.mergedOptions.display.viewMode&&l.isSelected?r.darkMode?"bg-blue-900 bg-opacity-20":"bg-blue-100":"",l.hasChildren?"group":"","styleless"!==l.mergedOptions.display.viewMode?r.darkMode?"hover:bg-gray-700":"hover:bg-gray-100":""]),onClick:t[1]||(t[1]=(...e)=>l.handleSelect&&l.handleSelect(...e))},[l.hasChildren?(a.openBlock(),a.createElementBlock("div",{key:0,onClick:t[0]||(t[0]=a.withModifiers(((...e)=>l.toggleExpand&&l.toggleExpand(...e)),["stop"])),class:a.normalizeClass(["mr-2 h-5 w-5 flex-shrink-0 mt-0.5 transition-transform duration-200",[l.isExpanded?"transform rotate-90":""]])},[(a.openBlock(),a.createElementBlock("svg",{viewBox:"0 0 20 20",fill:"currentColor",class:a.normalizeClass([[r.darkMode?"text-gray-400":"text-gray-500"],"h-5 w-5 group-hover:text-blue-500 transition-colors duration-200"])},t[2]||(t[2]=[a.createElementVNode("path",{"fill-rule":"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z","clip-rule":"evenodd"},null,-1)]),2))],2)):(a.openBlock(),a.createElementBlock("div",E)),a.createElementVNode("div",B,[l.isDetailedMode?(a.openBlock(),a.createElementBlock("div",M,[a.createElementVNode("div",I,[a.createElementVNode("div",D,[r.item.number&&l.mergedOptions.display.showItemNumbers?(a.openBlock(),a.createElementBlock("span",{key:0,class:a.normalizeClass(["font-semibold mr-2",[r.darkMode?"text-blue-300":"text-blue-600"]])},a.toDisplayString(r.item.citationPrefix||r.item.type)+" "+a.toDisplayString(r.item.number),3)):a.createCommentVNode("",!0),l.mergedOptions.display.showTypeIcon&&r.item.type?(a.openBlock(),a.createElementBlock("span",T,["title"===r.item.type?(a.openBlock(),a.createElementBlock("svg",{key:0,class:a.normalizeClass(["h-4 w-4 inline-block",[r.darkMode?"text-blue-300":"text-blue-600"]]),viewBox:"0 0 24 24"},t[6]||(t[6]=[a.createElementVNode("path",{fill:"currentColor",d:"M5 4v3h5.5v12h3V7H19V4z"},null,-1)]),2)):"part"===r.item.type?(a.openBlock(),a.createElementBlock("svg",{key:1,class:a.normalizeClass(["h-4 w-4 inline-block",[r.darkMode?"text-green-300":"text-green-600"]]),viewBox:"0 0 24 24"},t[7]||(t[7]=[a.createElementVNode("path",{fill:"currentColor",d:"M14,10H2V12H14V10M14,6H2V8H14V6M2,16H10V14H2V16M21.5,11.5L23,13L16,20L11.5,15.5L13,14L16,17L21.5,11.5Z"},null,-1)]),2)):"section"===r.item.type?(a.openBlock(),a.createElementBlock("svg",{key:2,class:a.normalizeClass(["h-4 w-4 inline-block",[r.darkMode?"text-amber-300":"text-amber-600"]]),viewBox:"0 0 24 24"},t[8]||(t[8]=[a.createElementVNode("path",{fill:"currentColor",d:"M3,4H7V8H3V4M9,5V7H21V5H9M3,10H7V14H3V10M9,11V13H21V11H9M3,16H7V20H3V16M9,17V19H21V17H9"},null,-1)]),2)):a.createCommentVNode("",!0)])):a.createCommentVNode("",!0),a.createElementVNode("span",{class:a.normalizeClass(["font-medium",[r.darkMode?"text-gray-200":"text-gray-800"]])},a.toDisplayString(r.item.title),3),l.hasMetadata&&l.mergedOptions.display.showMetadataBadges?(a.openBlock(),a.createElementBlock("div",z,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(l.metadataTypes,(e=>(a.openBlock(),a.createElementBlock("span",{key:e,class:a.normalizeClass(["px-1.5 py-0.5 rounded text-xs",[r.darkMode?"bg-blue-900 text-blue-200":"bg-blue-100 text-blue-700"]])},a.toDisplayString(e),3)))),128))])):a.createCommentVNode("",!0)]),r.item.subtitle?(a.openBlock(),a.createElementBlock("div",{key:0,class:a.normalizeClass(["text-sm mt-1",[r.darkMode?"text-gray-400":"text-gray-600"]])},a.toDisplayString(r.item.subtitle),3)):a.createCommentVNode("",!0),l.mergedOptions.display.showDescription&&l.contentPreview?(a.openBlock(),a.createElementBlock("div",F,a.toDisplayString(l.contentPreview),1)):a.createCommentVNode("",!0)])])):(a.openBlock(),a.createElementBlock(a.Fragment,{key:0},[a.createElementVNode("div",V,[r.item.number&&l.mergedOptions.display.showItemNumbers?(a.openBlock(),a.createElementBlock("span",{key:0,class:a.normalizeClass(["font-semibold mr-2",[r.darkMode?"text-blue-300":"text-blue-600",l.isCompactMode?"text-xs":""]])},a.toDisplayString(r.item.citationPrefix||r.item.type)+" "+a.toDisplayString(r.item.number),3)):a.createCommentVNode("",!0),l.mergedOptions.display.showTypeIcon&&r.item.type&&!l.isCompactMode?(a.openBlock(),a.createElementBlock("span",N,["title"===r.item.type?(a.openBlock(),a.createElementBlock("svg",{key:0,class:a.normalizeClass(["h-4 w-4 inline-block",[r.darkMode?"text-blue-300":"text-blue-600"]]),viewBox:"0 0 24 24"},t[3]||(t[3]=[a.createElementVNode("path",{fill:"currentColor",d:"M5 4v3h5.5v12h3V7H19V4z"},null,-1)]),2)):"part"===r.item.type?(a.openBlock(),a.createElementBlock("svg",{key:1,class:a.normalizeClass(["h-4 w-4 inline-block",[r.darkMode?"text-green-300":"text-green-600"]]),viewBox:"0 0 24 24"},t[4]||(t[4]=[a.createElementVNode("path",{fill:"currentColor",d:"M14,10H2V12H14V10M14,6H2V8H14V6M2,16H10V14H2V16M21.5,11.5L23,13L16,20L11.5,15.5L13,14L16,17L21.5,11.5Z"},null,-1)]),2)):"section"===r.item.type?(a.openBlock(),a.createElementBlock("svg",{key:2,class:a.normalizeClass(["h-4 w-4 inline-block",[r.darkMode?"text-amber-300":"text-amber-600"]]),viewBox:"0 0 24 24"},t[5]||(t[5]=[a.createElementVNode("path",{fill:"currentColor",d:"M3,4H7V8H3V4M9,5V7H21V5H9M3,10H7V14H3V10M9,11V13H21V11H9M3,16H7V20H3V16M9,17V19H21V17H9"},null,-1)]),2)):a.createCommentVNode("",!0)])):a.createCommentVNode("",!0),a.createElementVNode("span",{class:a.normalizeClass(["font-medium truncate",[r.darkMode?"text-gray-200":"text-gray-800",l.isCompactMode?"text-sm":""]])},a.toDisplayString(l.displayTitle),3),l.hasMetadata&&l.mergedOptions.display.showMetadataBadges?(a.openBlock(),a.createElementBlock("span",{key:2,class:a.normalizeClass(["ml-2 px-1.5 py-0.5 rounded text-xs",[r.darkMode?"bg-blue-900 text-blue-200":"bg-blue-100 text-blue-700"]])},a.toDisplayString(l.metadataTypes.length),3)):a.createCommentVNode("",!0)]),r.item.subtitle&&!l.isCompactMode?(a.openBlock(),a.createElementBlock("div",{key:0,class:a.normalizeClass(["text-sm mt-1",[r.darkMode?"text-gray-400":"text-gray-600"]])},a.toDisplayString(r.item.subtitle),3)):a.createCommentVNode("",!0)],64))])],2),r.item.content&&(l.isExpanded||l.isSelected)?(a.openBlock(),a.createElementBlock("div",{key:0,class:a.normalizeClass(["px-3 py-2 my-1 rounded",[r.darkMode?"bg-gray-800 text-gray-300":"bg-gray-50 text-gray-700"]])},[a.createElementVNode("div",{class:"prose max-w-none text-sm",innerHTML:r.item.content},null,8,$)],2)):a.createCommentVNode("",!0),l.hasChildren&&l.isExpanded?(a.openBlock(),a.createElementBlock("div",A,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(r.item.children,((e,t)=>(a.openBlock(),a.createBlock(s,{key:e.id,item:e,index:t,level:r.level+1,"parent-path":l.currentPath,"dark-mode":r.darkMode},null,8,["item","index","level","parent-path","dark-mode"])))),128))])):a.createCommentVNode("",!0)],2))}]]);function P(e){return Array.isArray?Array.isArray(e):"[object Array]"===H(e)}function O(e){return"string"==typeof e}function R(e){return"number"==typeof e}function j(e){return!0===e||!1===e||function(e){return _(e)&&null!==e}(e)&&"[object Boolean]"==H(e)}function _(e){return"object"==typeof e}function U(e){return null!=e}function q(e){return!e.trim().length}function H(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const W=Object.prototype.hasOwnProperty;class J{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach((e=>{let a=K(e);this._keys.push(a),this._keyMap[a.id]=a,t+=a.weight})),this._keys.forEach((e=>{e.weight/=t}))}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function K(e){let t=null,a=null,r=null,o=1,n=null;if(O(e)||P(e))r=e,t=Q(e),a=X(e);else{if(!W.call(e,"name"))throw new Error((e=>`Missing ${e} property in key`)("name"));const l=e.name;if(r=l,W.call(e,"weight")&&(o=e.weight,o<=0))throw new Error((e=>`Property 'weight' in key '${e}' must be a positive integer`)(l));t=Q(l),a=X(l),n=e.getFn}return{path:t,id:a,weight:o,src:r,getFn:n}}function Q(e){return P(e)?e:e.split(".")}function X(e){return P(e)?e.join("."):e}var Y={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1,includeMatches:!1,findAllMatches:!1,minMatchCharLength:1,location:0,threshold:.6,distance:100,...{useExtendedSearch:!1,getFn:function(e,t){let a=[],r=!1;const o=(e,t,n)=>{if(U(e))if(t[n]){const l=e[t[n]];if(!U(l))return;if(n===t.length-1&&(O(l)||R(l)||j(l)))a.push(function(e){return null==e?"":function(e){if("string"==typeof e)return e;let t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(e)}(l));else if(P(l)){r=!0;for(let e=0,a=l.length;e<a;e+=1)o(l[e],t,n+1)}else t.length&&o(l,t,n+1)}else a.push(e)};return o(e,O(t)?t.split("."):t,0),r?a:a[0]},ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}};const Z=/[^ ]+/g;class G{constructor({getFn:e=Y.getFn,fieldNormWeight:t=Y.fieldNormWeight}={}){this.norm=function(e=1,t=3){const a=new Map,r=Math.pow(10,t);return{get(t){const o=t.match(Z).length;if(a.has(o))return a.get(o);const n=1/Math.pow(o,.5*e),l=parseFloat(Math.round(n*r)/r);return a.set(o,l),l},clear(){a.clear()}}}(t,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach(((e,t)=>{this._keysMap[e.id]=t}))}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,O(this.docs[0])?this.docs.forEach(((e,t)=>{this._addString(e,t)})):this.docs.forEach(((e,t)=>{this._addObject(e,t)})),this.norm.clear())}add(e){const t=this.size();O(e)?this._addString(e,t):this._addObject(e,t)}removeAt(e){this.records.splice(e,1);for(let t=e,a=this.size();t<a;t+=1)this.records[t].i-=1}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size(){return this.records.length}_addString(e,t){if(!U(e)||q(e))return;let a={v:e,i:t,n:this.norm.get(e)};this.records.push(a)}_addObject(e,t){let a={i:t,$:{}};this.keys.forEach(((t,r)=>{let o=t.getFn?t.getFn(e):this.getFn(e,t.path);if(U(o))if(P(o)){let e=[];const t=[{nestedArrIndex:-1,value:o}];for(;t.length;){const{nestedArrIndex:a,value:r}=t.pop();if(U(r))if(O(r)&&!q(r)){let t={v:r,i:a,n:this.norm.get(r)};e.push(t)}else P(r)&&r.forEach(((e,a)=>{t.push({nestedArrIndex:a,value:e})}))}a.$[r]=e}else if(O(o)&&!q(o)){let e={v:o,n:this.norm.get(o)};a.$[r]=e}})),this.records.push(a)}toJSON(){return{keys:this.keys,records:this.records}}}function ee(e,t,{getFn:a=Y.getFn,fieldNormWeight:r=Y.fieldNormWeight}={}){const o=new G({getFn:a,fieldNormWeight:r});return o.setKeys(e.map(K)),o.setSources(t),o.create(),o}function te(e,{errors:t=0,currentLocation:a=0,expectedLocation:r=0,distance:o=Y.distance,ignoreLocation:n=Y.ignoreLocation}={}){const l=t/e.length;if(n)return l;const s=Math.abs(r-a);return o?l+s/o:s?1:l}const ae=32;function re(e,t,a,{location:r=Y.location,distance:o=Y.distance,threshold:n=Y.threshold,findAllMatches:l=Y.findAllMatches,minMatchCharLength:s=Y.minMatchCharLength,includeMatches:i=Y.includeMatches,ignoreLocation:c=Y.ignoreLocation}={}){if(t.length>ae)throw new Error(`Pattern length exceeds max of ${ae}.`);const d=t.length,u=e.length,m=Math.max(0,Math.min(r,u));let p=n,h=m;const g=s>1||i,y=g?Array(u):[];let f;for(;(f=e.indexOf(t,h))>-1;){let e=te(t,{currentLocation:f,expectedLocation:m,distance:o,ignoreLocation:c});if(p=Math.min(e,p),h=f+d,g){let e=0;for(;e<d;)y[f+e]=1,e+=1}}h=-1;let b=[],v=1,k=d+u;const x=1<<d-1;for(let C=0;C<d;C+=1){let r=0,n=k;for(;r<n;){te(t,{errors:C,currentLocation:m+n,expectedLocation:m,distance:o,ignoreLocation:c})<=p?r=n:k=n,n=Math.floor((k-r)/2+r)}k=n;let s=Math.max(1,m-n+1),i=l?u:Math.min(m+n,u)+d,f=Array(i+2);f[i+1]=(1<<C)-1;for(let l=i;l>=s;l-=1){let r=l-1,n=a[e.charAt(r)];if(g&&(y[r]=+!!n),f[l]=(f[l+1]<<1|1)&n,C&&(f[l]|=(b[l+1]|b[l])<<1|1|b[l+1]),f[l]&x&&(v=te(t,{errors:C,currentLocation:r,expectedLocation:m,distance:o,ignoreLocation:c}),v<=p)){if(p=v,h=r,h<=m)break;s=Math.max(1,2*m-h)}}if(te(t,{errors:C+1,currentLocation:m,expectedLocation:m,distance:o,ignoreLocation:c})>p)break;b=f}const w={isMatch:h>=0,score:Math.max(.001,v)};if(g){const e=function(e=[],t=Y.minMatchCharLength){let a=[],r=-1,o=-1,n=0;for(let l=e.length;n<l;n+=1){let l=e[n];l&&-1===r?r=n:l||-1===r||(o=n-1,o-r+1>=t&&a.push([r,o]),r=-1)}return e[n-1]&&n-r>=t&&a.push([r,n-1]),a}(y,s);e.length?i&&(w.indices=e):w.isMatch=!1}return w}function oe(e){let t={};for(let a=0,r=e.length;a<r;a+=1){const o=e.charAt(a);t[o]=(t[o]||0)|1<<r-a-1}return t}const ne=String.prototype.normalize?e=>e.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,""):e=>e;class le{constructor(e,{location:t=Y.location,threshold:a=Y.threshold,distance:r=Y.distance,includeMatches:o=Y.includeMatches,findAllMatches:n=Y.findAllMatches,minMatchCharLength:l=Y.minMatchCharLength,isCaseSensitive:s=Y.isCaseSensitive,ignoreDiacritics:i=Y.ignoreDiacritics,ignoreLocation:c=Y.ignoreLocation}={}){if(this.options={location:t,threshold:a,distance:r,includeMatches:o,findAllMatches:n,minMatchCharLength:l,isCaseSensitive:s,ignoreDiacritics:i,ignoreLocation:c},e=s?e:e.toLowerCase(),e=i?ne(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const d=(e,t)=>{this.chunks.push({pattern:e,alphabet:oe(e),startIndex:t})},u=this.pattern.length;if(u>ae){let e=0;const t=u%ae,a=u-t;for(;e<a;)d(this.pattern.substr(e,ae),e),e+=ae;if(t){const e=u-ae;d(this.pattern.substr(e),e)}}else d(this.pattern,0)}searchIn(e){const{isCaseSensitive:t,ignoreDiacritics:a,includeMatches:r}=this.options;if(e=t?e:e.toLowerCase(),e=a?ne(e):e,this.pattern===e){let t={isMatch:!0,score:0};return r&&(t.indices=[[0,e.length-1]]),t}const{location:o,distance:n,threshold:l,findAllMatches:s,minMatchCharLength:i,ignoreLocation:c}=this.options;let d=[],u=0,m=!1;this.chunks.forEach((({pattern:t,alphabet:a,startIndex:p})=>{const{isMatch:h,score:g,indices:y}=re(e,t,a,{location:o+p,distance:n,threshold:l,findAllMatches:s,minMatchCharLength:i,includeMatches:r,ignoreLocation:c});h&&(m=!0),u+=g,h&&y&&(d=[...d,...y])}));let p={isMatch:m,score:m?u/this.chunks.length:1};return m&&r&&(p.indices=d),p}}class se{constructor(e){this.pattern=e}static isMultiMatch(e){return ie(e,this.multiRegex)}static isSingleMatch(e){return ie(e,this.singleRegex)}search(){}}function ie(e,t){const a=e.match(t);return a?a[1]:null}class ce extends se{constructor(e,{location:t=Y.location,threshold:a=Y.threshold,distance:r=Y.distance,includeMatches:o=Y.includeMatches,findAllMatches:n=Y.findAllMatches,minMatchCharLength:l=Y.minMatchCharLength,isCaseSensitive:s=Y.isCaseSensitive,ignoreDiacritics:i=Y.ignoreDiacritics,ignoreLocation:c=Y.ignoreLocation}={}){super(e),this._bitapSearch=new le(e,{location:t,threshold:a,distance:r,includeMatches:o,findAllMatches:n,minMatchCharLength:l,isCaseSensitive:s,ignoreDiacritics:i,ignoreLocation:c})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class de extends se{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let t,a=0;const r=[],o=this.pattern.length;for(;(t=e.indexOf(this.pattern,a))>-1;)a=t+o,r.push([t,a-1]);const n=!!r.length;return{isMatch:n,score:n?0:1,indices:r}}}const ue=[class extends se{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const t=e===this.pattern;return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}},de,class extends se{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const t=e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}},class extends se{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const t=!e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},class extends se{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const t=!e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},class extends se{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const t=e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[e.length-this.pattern.length,e.length-1]}}},class extends se{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const t=-1===e.indexOf(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},ce],me=ue.length,pe=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/;const he=new Set([ce.type,de.type]);class ge{constructor(e,{isCaseSensitive:t=Y.isCaseSensitive,ignoreDiacritics:a=Y.ignoreDiacritics,includeMatches:r=Y.includeMatches,minMatchCharLength:o=Y.minMatchCharLength,ignoreLocation:n=Y.ignoreLocation,findAllMatches:l=Y.findAllMatches,location:s=Y.location,threshold:i=Y.threshold,distance:c=Y.distance}={}){this.query=null,this.options={isCaseSensitive:t,ignoreDiacritics:a,includeMatches:r,minMatchCharLength:o,findAllMatches:l,ignoreLocation:n,location:s,threshold:i,distance:c},e=t?e:e.toLowerCase(),e=a?ne(e):e,this.pattern=e,this.query=function(e,t={}){return e.split("|").map((e=>{let a=e.trim().split(pe).filter((e=>e&&!!e.trim())),r=[];for(let o=0,n=a.length;o<n;o+=1){const e=a[o];let n=!1,l=-1;for(;!n&&++l<me;){const a=ue[l];let o=a.isMultiMatch(e);o&&(r.push(new a(o,t)),n=!0)}if(!n)for(l=-1;++l<me;){const a=ue[l];let o=a.isSingleMatch(e);if(o){r.push(new a(o,t));break}}}return r}))}(this.pattern,this.options)}static condition(e,t){return t.useExtendedSearch}searchIn(e){const t=this.query;if(!t)return{isMatch:!1,score:1};const{includeMatches:a,isCaseSensitive:r,ignoreDiacritics:o}=this.options;e=r?e:e.toLowerCase(),e=o?ne(e):e;let n=0,l=[],s=0;for(let i=0,c=t.length;i<c;i+=1){const r=t[i];l.length=0,n=0;for(let t=0,o=r.length;t<o;t+=1){const o=r[t],{isMatch:i,indices:c,score:d}=o.search(e);if(!i){s=0,n=0,l.length=0;break}if(n+=1,s+=d,a){const e=o.constructor.type;he.has(e)?l=[...l,...c]:l.push(c)}}if(n){let e={isMatch:!0,score:s/n};return a&&(e.indices=l),e}}return{isMatch:!1,score:1}}}const ye=[];function fe(e,t){for(let a=0,r=ye.length;a<r;a+=1){let r=ye[a];if(r.condition(e,t))return new r(e,t)}return new le(e,t)}const be="$and",ve="$or",ke="$path",xe="$val",we=e=>!(!e[be]&&!e[ve]),Ce=e=>({[be]:Object.keys(e).map((t=>({[t]:e[t]})))});function Se(e,t,{auto:a=!0}={}){const r=e=>{let o=Object.keys(e);const n=(e=>!!e[ke])(e);if(!n&&o.length>1&&!we(e))return r(Ce(e));if((e=>!P(e)&&_(e)&&!we(e))(e)){const r=n?e[ke]:o[0],l=n?e[xe]:e[r];if(!O(l))throw new Error((e=>`Invalid value for key ${e}`)(r));const s={keyId:X(r),pattern:l};return a&&(s.searcher=fe(l,t)),s}let l={children:[],operator:o[0]};return o.forEach((t=>{const a=e[t];P(a)&&a.forEach((e=>{l.children.push(r(e))}))})),l};return we(e)||(e=Ce(e)),r(e)}function Ee(e,t){const a=e.matches;t.matches=[],U(a)&&a.forEach((e=>{if(!U(e.indices)||!e.indices.length)return;const{indices:a,value:r}=e;let o={indices:a,value:r};e.key&&(o.key=e.key.src),e.idx>-1&&(o.refIndex=e.idx),t.matches.push(o)}))}function Be(e,t){t.score=e.score}class Ve{constructor(e,t={},a){this.options={...Y,...t},this.options.useExtendedSearch,this._keyStore=new J(this.options.keys),this.setCollection(e,a)}setCollection(e,t){if(this._docs=e,t&&!(t instanceof G))throw new Error("Incorrect 'index' type");this._myIndex=t||ee(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){U(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const t=[];for(let a=0,r=this._docs.length;a<r;a+=1){const o=this._docs[a];e(o,a)&&(this.removeAt(a),a-=1,r-=1,t.push(o))}return t}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:t=-1}={}){const{includeMatches:a,includeScore:r,shouldSort:o,sortFn:n,ignoreFieldNorm:l}=this.options;let s=O(e)?O(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return function(e,{ignoreFieldNorm:t=Y.ignoreFieldNorm}){e.forEach((e=>{let a=1;e.matches.forEach((({key:e,norm:r,score:o})=>{const n=e?e.weight:null;a*=Math.pow(0===o&&n?Number.EPSILON:o,(n||1)*(t?1:r))})),e.score=a}))}(s,{ignoreFieldNorm:l}),o&&s.sort(n),R(t)&&t>-1&&(s=s.slice(0,t)),function(e,t,{includeMatches:a=Y.includeMatches,includeScore:r=Y.includeScore}={}){const o=[];return a&&o.push(Ee),r&&o.push(Be),e.map((e=>{const{idx:a}=e,r={item:t[a],refIndex:a};return o.length&&o.forEach((t=>{t(e,r)})),r}))}(s,this._docs,{includeMatches:a,includeScore:r})}_searchStringList(e){const t=fe(e,this.options),{records:a}=this._myIndex,r=[];return a.forEach((({v:e,i:a,n:o})=>{if(!U(e))return;const{isMatch:n,score:l,indices:s}=t.searchIn(e);n&&r.push({item:e,idx:a,matches:[{score:l,value:e,norm:o,indices:s}]})})),r}_searchLogical(e){const t=Se(e,this.options),a=(e,t,r)=>{if(!e.children){const{keyId:a,searcher:o}=e,n=this._findMatches({key:this._keyStore.get(a),value:this._myIndex.getValueForItemAtKeyId(t,a),searcher:o});return n&&n.length?[{idx:r,item:t,matches:n}]:[]}const o=[];for(let n=0,l=e.children.length;n<l;n+=1){const l=e.children[n],s=a(l,t,r);if(s.length)o.push(...s);else if(e.operator===be)return[]}return o},r=this._myIndex.records,o={},n=[];return r.forEach((({$:e,i:r})=>{if(U(e)){let l=a(t,e,r);l.length&&(o[r]||(o[r]={idx:r,item:e,matches:[]},n.push(o[r])),l.forEach((({matches:e})=>{o[r].matches.push(...e)})))}})),n}_searchObjectList(e){const t=fe(e,this.options),{keys:a,records:r}=this._myIndex,o=[];return r.forEach((({$:e,i:r})=>{if(!U(e))return;let n=[];a.forEach(((a,r)=>{n.push(...this._findMatches({key:a,value:e[r],searcher:t}))})),n.length&&o.push({idx:r,item:e,matches:n})})),o}_findMatches({key:e,value:t,searcher:a}){if(!U(t))return[];let r=[];if(P(t))t.forEach((({v:t,i:o,n:n})=>{if(!U(t))return;const{isMatch:l,score:s,indices:i}=a.searchIn(t);l&&r.push({score:s,key:e,value:t,idx:o,norm:n,indices:i})}));else{const{v:o,n:n}=t,{isMatch:l,score:s,indices:i}=a.searchIn(o);l&&r.push({score:s,key:e,value:o,norm:n,indices:i})}return r}}Ve.version="7.1.0",Ve.createIndex=ee,Ve.parseIndex=function(e,{getFn:t=Y.getFn,fieldNormWeight:a=Y.fieldNormWeight}={}){const{keys:r,records:o}=e,n=new G({getFn:t,fieldNormWeight:a});return n.setKeys(r),n.setIndexRecords(o),n},Ve.config=Y,Ve.parseQuery=Se,function(...e){ye.push(...e)}(ge);const Ne={class:"flex flex-wrap mb-2 sm:mb-0 items-center"},Me={class:"flex mr-4"},Ie={class:"flex items-center mr-2"},De={class:"inline-flex items-center"},Te={class:"flex items-center mr-2"},ze={class:"inline-flex items-center"},Fe={class:"flex items-center mr-2"},$e={class:"inline-flex items-center"},Ae={class:"flex items-center"},Le={class:"inline-flex items-center"},Pe={class:"w-full sm:w-auto relative max-w-full"},Oe={class:"flex items-center"},Re={class:"relative flex-grow"},je={class:"mb-2"},_e={class:"flex flex-wrap gap-1"},Ue=["onClick"],qe={key:0,class:"mb-2"},He=["value"],We={key:1,class:"mb-2"},Je={class:"mb-3"},Ke={class:"flex justify-between"},Qe={key:0,class:"flex justify-center items-center py-4"},Xe={key:1},Ye={class:"flex justify-between items-center mb-2"},Ze={class:"flex items-center"},Ge={class:"flex items-center"},et={class:"flex items-center mr-2"},tt={key:0,class:"mb-2 px-1"},at={class:"flex justify-between items-center text-xs mb-1"},rt={class:"max-h-40 overflow-y-auto"},ot=["onClick","onMouseenter"],nt={class:"font-medium"},lt={class:"text-sm font-medium mb-2"},st={key:0,class:"absolute inset-0 flex items-center justify-center z-30 bg-white/80 dark:bg-gray-900/80"},it={class:"text-center p-4 rounded-lg bg-white dark:bg-gray-800 shadow-lg"},ct={class:"font-medium text-gray-700 dark:text-gray-200"},dt={key:1,class:"absolute inset-0 flex items-center justify-center z-30 bg-white/80 dark:bg-gray-900/80"},ut={class:"max-w-md p-4 rounded-lg bg-white dark:bg-gray-800 shadow-lg border-l-4 border-red-500"},mt={class:"text-sm text-gray-700 dark:text-gray-300 list-disc pl-5"},pt={key:2,class:"flex justify-center items-center py-8"},ht={key:3,class:"text-center py-12"},gt={key:4};const yt=n({name:"ECFRNavigator",components:{ECFRBreadcrumb:C,ECFRSection:L},props:{items:{type:Array,default:()=>[]},dataUrl:{type:String,default:null},dataUrls:{type:Array,default:()=>[]},options:{type:Object,default:()=>({})},itemMetadata:{type:Object,default:()=>({})},metadataUrl:{type:String,default:null},initialSelectedItemId:{type:String,default:null}},emits:["item-selected","path-changed","search-completed","update:options","metadata-changed"],data:()=>({ecfrStore:o(),isLoading:!1,dataLoading:!1,metadataLoading:!1,loadedData:[],loadedMetadata:{},loadingErrors:[],searchQuery:"",searchResults:[],showSearchResults:!1,fuseInstance:null,searchData:[],fuzzyThresholdStep:4,currentViewMode:"standard",currentItemSpacing:"medium",currentFontSize:"medium",showMetadataBadges:!1,showAdvancedSearch:!1,selectedTypeFilters:[],selectedAgency:"",selectedDateRange:"",keywordFilter:"",availableTypes:["title","part","section","chapter","subpart"],availableAgencies:[],activeTooltipId:null,tooltipTimeout:null,defaultOptions:{showBreadcrumb:!1,expandAll:!1,hideContentOnNavigation:!1,theme:"light",showControls:!1,breadcrumb:{rootLabel:"Home",truncate:!0,visibleItems:2,maxVisible:3,type:"scrollable",style:"clean",separatorType:"icon",truncateLabels:!0,highlightLast:!0},fuzzySearch:{enabled:!0,threshold:.4,distance:100},display:{showTypeIcon:!0,showItemNumbers:!0,indentItems:!0,hideEmptyItems:!1,viewMode:"compact",showDescription:!1,showMetadataBadges:!1,itemSpacing:"medium",maxTitleLength:null,animations:!0,enhancedMobile:!0,fontScaling:{enabled:!0,baseSize:"medium",scaleWithWidth:!0,scaleWithViewMode:!0,minSize:"12px",maxSize:"18px",responsive:!0}},filters:{enabled:!0,showTypeFilter:!0,showAgencyFilter:!0,showDateFilter:!0,showKeywordFilter:!0,autoUpdateResults:!0,persistFilters:!0,agencies:[]},pagination:{enabled:!1,itemsPerPage:20},navigation:{preserveState:!0,scrollToSelected:!0,autoExpandParents:!0,autoCollapseOthers:!1},printing:{enablePrintView:!0,includeChildrenWhenPrinting:!0}}}),computed:{mergedOptions(){return{...this.defaultOptions,...this.options}},rootItems(){return this.ecfrStore.rootItems},breadcrumbPath(){return this.ecfrStore.breadcrumbPath},currentItem(){return this.ecfrStore.currentItem},hasActiveFilters(){return this.selectedTypeFilters.length>0||""!==this.selectedAgency||""!==this.selectedDateRange||""!==this.keywordFilter.trim()}},watch:{items:{handler(e){e&&e.length>0&&(this.ecfrStore.setRootItems(e),this.mergedOptions.expandAll&&this.ecfrStore.expandAll(),this.buildSearchIndex(e))},immediate:!0},"ecfrStore.currentItem":{handler(e){if(e){const t=this.ecfrStore.getItemMetadata(e.id),a=t?this.ecfrStore.processItemMetadata(e.id):null;this.$emit("item-selected",{item:e,path:this.ecfrStore.breadcrumbPath,metadata:t,processedMetadata:a})}}},"ecfrStore.breadcrumbPath":{handler(e){this.$emit("path-changed",e)}},itemMetadata:{handler(e){e&&"object"==typeof e&&Object.entries(e).forEach((([e,t])=>{this.ecfrStore.setItemMetadata(e,t)}))},deep:!0},initialSelectedItemId:{handler(e){e&&this.$nextTick((()=>{this.navigateTo(e)}))}},options:{handler(e){e.display&&(e.display.viewMode&&(this.currentViewMode=e.display.viewMode),e.display.itemSpacing&&(this.currentItemSpacing=e.display.itemSpacing),void 0!==e.display.showMetadataBadges&&(this.showMetadataBadges=e.display.showMetadataBadges))},deep:!0,immediate:!0}},mounted(){this.mergedOptions.display&&this.mergedOptions.display.fontScaling&&this.mergedOptions.display.fontScaling.enabled&&(this.mergedOptions.display.fontScaling.scaleWithWidth&&this.mergedOptions.display.fontScaling.responsive?this.currentFontSize="adaptive":this.currentFontSize=this.mergedOptions.display.fontScaling.baseSize||"medium",this.$nextTick((()=>{this.applyFontSizeClass()}))),this.mergedOptions.display&&this.mergedOptions.display.itemSpacing&&(this.currentItemSpacing=this.mergedOptions.display.itemSpacing),this.mergedOptions.display&&this.mergedOptions.display.viewMode&&(this.currentViewMode=this.mergedOptions.display.viewMode),this.mergedOptions.display&&void 0!==this.mergedOptions.display.showMetadataBadges&&(this.showMetadataBadges=this.mergedOptions.display.showMetadataBadges);this.dataUrl||this.dataUrls&&this.dataUrls.length>0?this.loadDataFromUrls().then((()=>{this.initializeComponent()})).catch((e=>{console.error("Error loading data from URLs:",e),this.items&&this.items.length>0&&this.initializeComponent()})):this.items&&this.items.length>0&&this.initializeComponent(),this.metadataUrl&&this.loadMetadataFromUrl()},methods:{initializeComponent(){const e=this.loadedData.length>0?this.loadedData:this.items;e&&e.length>0&&(this.ecfrStore.setRootItems(e),this.mergedOptions.expandAll&&this.ecfrStore.expandAll(),this.itemMetadata&&"object"==typeof this.itemMetadata&&Object.entries(this.itemMetadata).forEach((([e,t])=>{this.ecfrStore.setItemMetadata(e,t)})),Object.keys(this.loadedMetadata).length>0&&Object.entries(this.loadedMetadata).forEach((([e,t])=>{this.ecfrStore.setItemMetadata(e,t)})),this.initialSelectedItemId&&this.$nextTick((()=>{this.navigateTo(this.initialSelectedItemId)})))},loadDataFromUrls(){this.dataLoading=!0,this.loadingErrors=[],this.loadedData=[];const e=[];if(this.dataUrl&&e.push(this.dataUrl),this.dataUrls&&this.dataUrls.length>0&&e.push(...this.dataUrls),0===e.length)return this.dataLoading=!1,Promise.resolve();const t=e.map(((e,t)=>this.fetchJsonData(e,`data-${t}`))),a=new Set,o=(e,t)=>Array.isArray(e)?e.map((e=>{if(e.id){if(a.has(e.id)){const t=e.id;(e={...e}).id=r.v4(),console.log(`Duplicate ID detected: '${t}'. Generated UUID: '${e.id}'`)}}else(e={...e}).id=r.v4(),console.log(`Missing ID detected. Generated UUID: '${e.id}'`);return a.add(e.id),e.children&&Array.isArray(e.children)&&(e.children=o(e.children)),e})):[];return Promise.all(t).then((e=>(e.forEach(((e,t)=>{if(Array.isArray(e)){const t=o(e);this.loadedData.push(...t)}else if(e&&Array.isArray(e.items)){const t=o(e.items);this.loadedData.push(...t)}else if(e&&"object"==typeof e){const t=JSON.parse(JSON.stringify(e));if(t.id){if(a.has(t.id)){const e=t.id;t.id=r.v4(),console.log(`Duplicate ID detected: '${e}'. Generated UUID: '${t.id}'`)}}else t.id=r.v4(),console.log(`Missing ID detected in root object. Generated UUID: '${t.id}'`);a.add(t.id),t.children&&Array.isArray(t.children)&&(t.children=o(t.children)),this.loadedData.push(t)}})),this.dataLoading=!1,this.loadedData))).catch((e=>{throw this.loadingErrors.push(`Error loading data: ${e.message}`),this.dataLoading=!1,e}))},loadMetadataFromUrl(){return this.metadataUrl?(this.metadataLoading=!0,this.fetchJsonData(this.metadataUrl,"metadata").then((e=>(e&&"object"==typeof e&&(this.loadedMetadata=e,this.ecfrStore.rootItems.lengt