1var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,s=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,l=(t,n,s)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s,a=(e,t,n)=>l(e,"symbol"!=typeof t?t+"":t,n),r=(e,t,n)=>new Promise((s,i)=>{var o=e=>{try{a(n.next(e))}catch(t){i(t)}},l=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=e=>e.done?s(e.value):Promise.resolve(e.value).then(o,l);a((n=n.apply(e,t)).next())});import{h as m,x as p}from"./index.cz83wh4sws6slzdm.js";import{a as c,A as d}from"./index.fwy4myo0zwt1lnjt.js";const h="hme-dialog-elements__item-properties-item";class u extends c{init(){this.elements.deleteButton.addEventListener("click",()=>{this.elements.self.remove(),this.elements.self.dispatchEvent(new CustomEvent("item-deleted",{bubbles:!0}))})}fillData(e,t,n){const s=document.createElement("select"),i=[{value:"UNSET",label:"Unset"},{value:"VISIBLE",label:"Visible"},{value:"HIDDEN",label:"Hidden"}],o=m(`${e.parentResourceType}|defaultPolicy`);s.name=o;for(const m of i){const t=document.createElement("option");t.value=m.value,t.textContent=m.label,e.defaultPolicy===m.value&&(t.selected=!0),s.appendChild(t)}this.elements.defaultPolicy.textContent="Default Policy: ",this.elements.defaultPolicy.appendChild(s);const l=document.createElement("select"),a=[{value:"false",label:"False"},{value:"true",label:"True"}],r=m(`${e.parentResourceType}|finalProperty`);l.name=r;for(const m of a){const t=document.createElement("option");t.value=m.value,t.textContent=m.label;const n=Boolean(e.finalProperty);("true"===m.value&&n||"false"===m.value&&!n)&&(t.selected=!0),l.appendChild(t)}this.elements.finalProperty.textContent="Final Property: ",this.elements.finalProperty.appendChild(l);const p=this.resolveParentResourceTypeName(e.parentResourceType,n);this.elements.parentResourceType.textContent=`Parent element: ${p||"(none)"}`,e.parentResourceType&&(this.elements.parentResourceType.title=e.parentResourceType),this.elements.self.dataset.resourceType=e.parentResourceType||"",this.elements.propertiesList.innerHTML="";const c=this.buildDialogTree(t);this.renderDialogTree(c,this.elements.propertiesList,e)}buildDialogTree(e){const t=[];for(const n of e){const e=n.name.split(" > ");let s=t;for(let t=0;t<e.length;t++){const i=e[t],o=t===e.length-1;let l=s.find(e=>e.label===i);l||(l={label:i,path:o?n.path:void 0,children:[]},s.push(l)),o&&!l.path&&(l.path=n.path),s=l.children}}return t}renderDialogTree(e,t,n){for(const s of e){const e=document.createElement("li");e.className=h;const i=document.createElement("span");if(i.className="hme-dialog-elements__item-properties-name",i.textContent=s.label,s.path){e.dataset.path=s.path;const t=n.visibleProperties.includes(s.path),o=n.hiddenProperties.includes(s.path),l=m(`${n.parentResourceType}|${s.path}`),a=document.createElement("input");a.type="radio",a.name=l,a.value="unset";const r=document.createElement("input");r.type="radio",r.name=l,r.value="visible";const p=document.createElement("input");p.type="radio",p.name=l,p.value="hidden",t?r.checked=!0:o?p.checked=!0:a.checked=!0,e.appendChild(i),e.appendChild(a),e.appendChild(r),e.appendChild(p)}else e.appendChild(i);if(s.children.length>0){const t=document.createElement("details");t.className="hme-dialog-elements__item-properties-details";const i=document.createElement("summary");for(i.className="hme-dialog-elements__item-properties-summary";e.firstChild;)i.appendChild(e.firstChild);const o=document.createElement("ul");o.className="hme-dialog-elements__item-properties-list hme-dialog-elements__item-properties-list--nested",this.renderDialogTree(s.children,o,n),t.appendChild(i),t.appendChild(o),e.appendChild(t)}t.appendChild(e)}}serialize(){var e,t,n;const s=this.elements.self,i=s.querySelector(".hme-dialog-elements__item-default-policy select"),o=s.querySelector(".hme-dialog-elements__item-final-property select"),l=null!=(e=null==i?void 0:i.value)?e:"UNSET",a=null!=(t=null==o?void 0:o.value)?t:"false",r=null!=(n=s.dataset.resourceType)?n:"",m=[],p=[],c=Array.from(s.querySelectorAll(`.${h}`));for(const d of c){const e=d.dataset.path;if(!e)continue;const t=this.getRadioGroupNameForPath(e,r),n=s.querySelector(`input[type="radio"][name="${t}"]:checked`);n&&("visible"===n.value?m.push(e):"hidden"===n.value&&p.push(e))}return{defaultPolicy:l,finalProperty:"true"===a,hiddenProperties:p,parentResourceType:r,visibleProperties:m}}getRadioGroupNameForPath(e,t){return m(`${t}|${e}`)}resolveParentResourceTypeName(e,t){if(!e)return"";let n=t.find(t=>t.path===e);if(!n){const s=e.split("/").pop()||"";n=t.find(e=>e.path.endsWith(`/${s}`))}return(null==n?void 0:n.name)||e}}a(u,"NS","hme"),a(u,"IS","dialog-elements-item");const f="dialog-elements",y=`[data-hme-is="${f}"]`;class g extends d{constructor(){super(...arguments),a(this,"itemTemplate"),a(this,"componentsList",[]),a(this,"allComponentsList",[]),a(this,"groupedComponentsList",{}),a(this,"componentDialogPaths",[]),a(this,"dynamicElements"),a(this,"dialogElementItems",[])}init(){return r(this,null,function*(){this.options.componentListPath="/apps/honda/components/hme-core.1.json",this.options.compositesListPath="/apps/honda/components/hme-composite.1.json",this.options.componentDialogPath="/apps/honda/components/hme-core/{0}/_cq_dialog.infinity.json",this.options.componentDialogElementsPath="/apps/honda/components/hme-core/{0}/dynamicElements.json",this.itemTemplate=document.createElement("template"),this.itemTemplate.innerHTML='<div class="hme-dialog-elements__item">\n <div class="hme-dialog-elements__item-header">\n <span class="hme-dialog-elements__item-parent-resource-type"\n data-hme-hook-template-dialog-elements-item="parentResourceType"></span>\n <label class="hme-dialog-elements__item-default-policy"\n data-hme-hook-template-dialog-elements-item="defaultPolicy"></label>\n <label class="hme-dialog-elements__item-final-property"\n data-hme-hook-template-dialog-elements-item="finalProperty"></label>\n <button class="hme-dialog-elements__item-delete" data-hme-hook-template-dialog-elements-item="deleteButton"\n type="button">Delete</button>\n </div>\n <div class="hme-dialog-elements__item-properties">\n <div class="hme-dialog-elements__item-dialog-elements">\n <div class="hme-dialog-elements__item-properties-legend">
1\n <span class="hme-dialog-elements__item-properties-legend-label">Property</span>\n <span class="hme-dialog-elements__item-properties-legend-option">Unset</span>\n <span class="hme-dialog-elements__item-properties-legend-option">Visible</span>\n <span class="hme-dialog-elements__item-properties-legend-option">Hidden</span>\n </div>\n <ul class="hme-dialog-elements__item-properties-list"\n data-hme-hook-template-dialog-elements-item="propertiesList"></ul>\n </div>\n </div>\n</div>\n',this.populateComponentList(),this.addEventHandlers(),this.updateItemNewComponentList()})}populateComponentList(){return r(this,null,function*(){if(yield this.fetchComponentList(),this.componentsList&&this.elements.componentList){this.elements.componentList.innerHTML='<option value="">Select a component</option>';for(const e of this.componentsList){const t=document.createElement("option");t.value=e.path,t.textContent=e.name,this.elements.componentList.appendChild(t)}}})}fetchComponentList(){return r(this,null,function*(){try{const e=[],t=[],n=this.options.componentListPath.replace(".1.json",""),s=yield fetch(this.options.componentListPath),i=yield s.json();for(const[r,m]of Object.entries(i))r.startsWith("hme")&&m&&"object"==typeof m&&"jcr:title"in m&&e.push({name:m["jcr:title"],path:`${n}/${r}`});e.sort((e,t)=>e.name.localeCompare(t.name));const o=this.options.compositesListPath.replace(".1.json",""),l=yield fetch(this.options.compositesListPath),a=yield l.json();for(const[r,m]of Object.entries(a))r.startsWith("hme")&&m&&"object"==typeof m&&"jcr:title"in m&&t.push({name:m["jcr:title"],path:`${o}/${r}`});t.sort((e,t)=>e.name.localeCompare(t.name)),this.componentsList=e,this.allComponentsList=[...e,...t],this.groupedComponentsList={Components:e,Composites:t}}catch(e){console.error("Error fetching component list:",e)}})}fetchComponentDialogElements(e){return r(this,null,function*(){try{let n=function(e){return"string"==typeof e.text&&e.text?e.text:"string"==typeof e.fieldLabel&&e.fieldLabel?e.fieldLabel:"string"==typeof e["jcr:title"]&&e["jcr:title"]?e["jcr:title"]:void 0},s=function(e,t=[],o=[],l){if("object"!=typeof e||null===e||Array.isArray(e))Array.isArray(e)&&e.forEach((e,n)=>{s(e,[...t,n.toString()],o,l)});else{const a=e,m=0===t.length?void 0:n(a),p=m?[...o,m]:o;if("granite/ui/components/coral/foundation/include"===a["sling:resourceType"]){const e=a.path;return void(e&&r.push({includePath:e,basePath:t,nameParts:p}))}if("granite:rendercondition"in a){const e=l?`${l}/${t.join("/")}`:`/${t.join("/")}`;i.push({name:p.join(" > "),path:e})}for(const e of Object.keys(a))s(a[e],[...t,e],p,l)}};const i=[],o=`${e}/_cq_dialog.infinity.json`,l=yield fetch(o);if(!l.ok)return void(this.componentDialogPaths=[]);const a=yield l.json(),r=[];s(a);for(const e of r)try{const t=yield(yield fetch(`${e.includePath}.infinity.json`)).json();s(t,[],e.nameParts,e.includePath)}catch(t){console.warn(`Failed to fetch include: ${e.includePath}`,t)}this.componentDialogPaths=i}catch(n){console.error("Error fetching dialog elements data:",n)}})}fetchDynamicElements(e){return r(this,null,function*(){try{const a=`${e}/dynamicElements.json`,r=yield fetch(a);if(!r.ok)return void(this.dynamicElements=void 0);const m=yield r.json();this.dynamicElements=m.map(e=>{var a,r,m,p;return m=((e,t)=>{for(var n in t||(t={}))i.call(t,n)&&l(e,n,t[n]);if(s)for(var n of s(t))o.call(t,n)&&l(e,n,t[n]);return e})({},e),p={parentResourceType:null!=(r=null==(a=e.parentResourceType)?void 0:a.replace(/^\/apps\//,""))?r:""},t(m,n(p))})}catch(a){console.error("Error fetching dynamic elements data:",a),this.dynamicElements=void 0}})}renderDynamicElements(){this.elements.itemWrapper.innerHTML="",this.dialogElementItems=[],this.dynamicElements&&Array.isArray(this.dynamicElements)&&(this.dynamicElements.forEach(e=>{const t=p(u,this.itemTemplate);t.fillData(e,this.componentDialogPaths||[],this.allComponentsList||[]),t.elements.self.addEventListener("item-deleted",()=>this.handleItemDeleted(t)),this.elements.itemWrapper.appendChild(t.elements.self),this.dialogElementItems.push(t)}),this.updateItemNewComponentList())}addNewItem(e){const t={defaultPolicy:"UNSET",finalProperty:!1,hiddenProperties:[],parentResourceType:e,visibleProperties:[]},n=p(u,this.itemTemplate);n.fillData(t,this.componentDialogPaths||[],this.allComponentsList||[]),n.elements.self.addEventListener("item-deleted",()=>this.handleItemDeleted(n)),this.elements.itemWrapper.appendChild(n.elements.self),this.dialogElementItems.push(n),this.updateItemNewComponentList()}handleItemDeleted(e){const t=this.dialogElementItems.indexOf(e);t>-1&&this.dialogElementItems.splice(t,1),this.updateItemNewComponentList()}getUsedComponentNames(){var e;const t=new Set;for(const n of this.dialogElementItems){const s=null!=(e=n.elements.self.dataset.resourceType)?e:"";if(""===s)t.add("");else{const e=s.split("/").pop()||"";t.add(e)}}return t}updateItemNewComponentList(){const e=this.elements.itemNewComponentList;if(!e)return;const t=this.getUsedComponentNames();if(t.has("")?e.innerHTML="":e.innerHTML='<option value="">(none)</option>',this.groupedComponentsList)for(const[n,s]of Object.entries(this.groupedComponentsList)){const i=document.createElement("optgroup");i.label=n;for(const e of s){const n=e.path.split("/").pop()||"";if(!t.has(n)){const t=document.createElement("option");t.value=e.path,t.textContent=e.name,i.appendChild(t)}}i.children.length>
10&&e.appendChild(i)}}updateItemNewVisibility(){const e=""!==this.elements.componentList.value;this.elements.itemNew.classList.toggle("hme-dialog-elements__item-new--visible",e)}addEventHandlers(){var e;this.elements.componentList.addEventListener("change",e=>r(this,null,function*(){const t=e.target.value;if(this.updateItemNewVisibility(),!t)return this.elements.itemWrapper.innerHTML="",void(this.dialogElementItems=[]);yield Promise.all([this.fetchComponentDialogElements(t),this.fetchDynamicElements(t)]),this.renderDynamicElements()})),this.elements.clipboard.addEventListener("click",()=>r(this,null,function*(){const e=this.dialogElementItems.map(e=>e.serialize()),t=JSON.stringify(e,null,2),n=`${this.elements.componentList.value}/dynamicElements.json`;try{yield navigator.clipboard.writeText(t),this.elements.dialogHeader.textContent=`Copied to clipboard! Save to: ${n}`,this.elements.dialogContent.textContent=t,this.elements.dialog.showModal()}catch(s){this.elements.dialogHeader.textContent=`Save to: ${n}`,this.elements.dialogContent.textContent=t,this.elements.dialog.showModal()}}));const t=this.elements.dialog.querySelector("button");t&&t.addEventListener("click",()=>{this.elements.dialog.close()}),null==(e=this.elements.itemAdd)||e.addEventListener("click",()=>{const e=this.elements.itemNewComponentList.value;e&&(this.addNewItem(e),this.elements.itemNewComponentList.value="")}
1)}}a(g,"SELF",y),a(g,"NS","hme"),a(g,"IS",f);export{y as SELF,g as default};
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.