@hsfx/attr 2.0.25 → 2.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ import{q as e,a as t,g as r,b as n,c as o}from"./hsfxutilsCm-S93Uw.js";function s(){return function(){const e=window.location.origin,t=e=>{const t=document.querySelector(`[data-hs-replace="${e}"]`);return t?.textContent?.trim()||""},r=t("company"),n=t("phone"),o=t("email"),s=t("city"),i=t("state"),a=t("zipcode"),c={"@context":"https://schema.org","@type":"LocalBusiness",name:r,url:e,telephone:n,email:o},l=document.querySelector('[data-hs-replace="business-logo"] img');l&&l.src&&(c.image=l.src);const u={"@type":"PostalAddress",addressLocality:s,addressRegion:i,postalCode:a,addressCountry:"US"},d=t("street-address");d&&(u.streetAddress=d),c.address=u;const m=t("business-latitude"),p=t("business-longitude");m&&p&&(c.geo={"@type":"GeoCoordinates",latitude:m,longitude:p});const h=["facebook","instagram","linkedin","pinterest","tiktok","x","youtube"].map(e=>(e=>{const t=document.querySelector(`[data-hs-replace="${e}"]`);return t?.href||""})(e)).filter(e=>e&&""!==e.trim()&&!e.includes("placeholder"));h.length>0&&(c.sameAs=h);const f=document.querySelector('[data-hs-schema="services"]');if(f){const e=f.querySelectorAll('[data-hs-schema-list="item"]'),t=Array.from(e).map(e=>e.textContent?.trim()).filter(e=>e&&""!==e);t.length>0&&(c.serviceType=t)}const y=document.querySelector('[data-hs-schema="areas"]');if(y){const e=y.querySelectorAll('[data-hs-schema-list="item"]'),t=Array.from(e).map(e=>({"@type":"City",name:e.textContent?.trim()||""})).filter(e=>e.name&&""!==e.name);t.length>0&&(c.areaServed=t)}const g=document.createElement("script");g.type="application/ld+json",g.text=JSON.stringify(c),document.head.appendChild(g);const b=document.querySelector('[data-hs-schema="breadcrumb"]')?.textContent?.trim()||"",A=window.location.pathname.split("/").filter(e=>""!==e);if(A.length>0){const t={"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:[{"@type":"ListItem",position:1,name:"Home",item:e}]},r=A[0],n=r.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");t.itemListElement.push({"@type":"ListItem",position:2,name:n,item:e+"/"+r}),b&&t.itemListElement.push({"@type":"ListItem",position:3,name:b,item:window.location.href});const o=document.createElement("script");o.type="application/ld+json",o.text=JSON.stringify(t),document.head.appendChild(o)}if(document.querySelector('[data-hs-accordion-type="faq"]')){const e=[];if(document.querySelectorAll('[data-hs-accordion="list"]').forEach(t=>{t.querySelectorAll('[data-hs-accordion-type="faq"]').forEach(t=>{const r=t.querySelector('[data-hs-accordion="toggle"]'),n=t.querySelector('[data-hs-accordion="content"]');if(r&&n){const t=r.textContent?.trim(),o=n.innerHTML.trim();e.push({"@type":"Question",name:t,acceptedAnswer:{"@type":"Answer",text:o}})}})}),e.length>0){const t={"@context":"https://schema.org","@type":"FAQPage",mainEntity:e},r=document.createElement("script");r.type="application/ld+json",r.text=JSON.stringify(t),document.head.appendChild(r)}}const S=document.querySelector('[data-hs-schema-service="name"]'),x=document.querySelector('[data-hs-schema-service="description"]');if(S&&x){const e=S.textContent?.trim()||"",t=x.textContent?.trim()||"";if(e&&t){const r={"@context":"https://schema.org","@type":"Service",name:e,description:t},n=document.createElement("script");n.type="application/ld+json",n.text=JSON.stringify(r),document.head.appendChild(n)}}else(S||x)&&console.warn('[schema] Service page schema requires both "name" and "description" elements');const E=document.querySelector('[data-hs-schema-faq="question"]'),q=document.querySelector('[data-hs-schema-faq="answer"]'),C=document.querySelector('[data-hs-schema-faq="published"]'),w=document.querySelector('[data-hs-schema-faq="modified"]');if(E&&q&&C&&w){const e=E.textContent?.trim()||"",t=q.innerHTML.trim(),r=C.textContent?.trim()||"",n=w.textContent?.trim()||"";if(e&&t&&r&&n){const o={"@context":"https://schema.org","@type":"QAPage",mainEntity:{"@type":"Question",name:e,text:e,answerCount:1,datePublished:r,dateModified:n,acceptedAnswer:{"@type":"Answer",text:t}}},s=document.createElement("script");s.type="application/ld+json",s.text=JSON.stringify(o),document.head.appendChild(s)}}else if(E||q||C||w){const e=[];E||e.push("question"),q||e.push("answer"),C||e.push("published"),w||e.push("modified"),console.warn(`[schema] FAQ page schema missing required fields: ${e.join(", ")}`)}const v=document.querySelector('[data-hs-schema-blog="name"]'),$=document.querySelector('[data-hs-schema-blog="published"]'),N=document.querySelector('[data-hs-schema-blog="modified"]'),F=document.querySelector('[data-hs-schema-blog="summary"]'),L=document.querySelector('[data-hs-schema-blog="author-name"]'),j=document.querySelector('[data-hs-schema-blog="author-type"]');if(v&&$&&N&&F&&L&&j){const e=v.textContent?.trim()||"",r=$.textContent?.trim()||"",n=N.textContent?.trim()||"",o=F.textContent?.trim()||"",s=L.textContent?.trim()||"",i=j.textContent?.trim()||"Organization",a=document.querySelector('[data-hs-schema-blog="author-role"]'),c=document.querySelector('[data-hs-schema-blog="author-image"]'),l=a?.textContent?.trim()||"",u=c?.src||"",d=t("company"),m=document.querySelector('[data-hs-replace="business-logo"] img'),p=m?m.src:"";let h;"Person"===i?(h={"@type":"Person",name:s},l&&(h.jobTitle=l),u&&(h.image=u)):(h={"@type":"Organization",name:s},p&&(h.logo=p));const f={"@context":"https://schema.org","@type":"BlogPosting",headline:e,description:o,datePublished:r,dateModified:n,author:h,publisher:{"@type":"Organization",name:d||s,logo:{"@type":"ImageObject",url:p}},mainEntityOfPage:{"@type":"WebPage","@id":window.location.href}},y=document.createElement("script");y.type="application/ld+json",y.text=JSON.stringify(f),document.head.appendChild(y)}else if(v||$||N||F||L||j){const e=[];v||e.push("name"),$||e.push("published"),N||e.push("modified"),F||e.push("summary"),L||e.push("author-name"),j||e.push("author-type"),console.warn(`[schema] Blog page schema missing required fields: ${e.join(", ")}`)}}(),{result:"schema initialized",destroy:()=>{}}}function i(e,t,r){const n="{{sync.id}}",o=`${t}-${r}`;Array.from(e.attributes).forEach(t=>{t.value.includes(n)&&e.setAttribute(t.name,t.value.split(n).join(o))}),e.querySelectorAll("*").forEach(e=>{Array.from(e.attributes).forEach(t=>{t.value.includes(n)&&e.setAttribute(t.name,t.value.split(n).join(o))})})}function a(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let n;for(;n=r.nextNode();)n.nodeValue?.trim()&&t.push(n);return t}function c(e){const t=[];return e.hasAttribute("href")&&t.push(e),t.push(...Array.from(e.querySelectorAll("[href]"))),t}function l(e){if(e.hasAttribute("src")){if(e.getAttribute("src"))return e}const t=e.querySelector("[src]");if(t){if(t.getAttribute("src"))return t}return null}function u(e,t,r,n){if(function(e,t){const r=t.attributes.properties.syncField,n=e.querySelectorAll(`[${r}]`);return Array.from(n).some(e=>{const t=e.getAttribute(r);return t&&""!==t.trim()})}(t,r))return void function(e,t,r,n){const o=r.attributes.properties.syncField;t.querySelectorAll(`[${o}="sync-index"]`).forEach(e=>{const t=a(e);t.length>0?t[0].nodeValue=String(n+1):e.textContent=String(n+1)}),e.querySelectorAll(`[${o}]`).forEach(e=>{const r=e.getAttribute(o),n=t.querySelectorAll(`[${o}="${r}"]`);0!==n.length&&n.forEach(t=>{const r=l(e),n=l(t);if(r&&n){const e=r.getAttribute("src");e&&n.setAttribute("src",e)}else if(e.hasAttribute("href")&&t.hasAttribute("href")){const r=e.getAttribute("href");r&&t.setAttribute("href",r)}else{const r=a(e),n=r.length>0?r[0].nodeValue:e.textContent.trim();if(n){const e=a(t);e.length>0?e[0].nodeValue=n:t.textContent=n}}})})}(e,t,r,n);const o=a(e),s=o.length>0?o[0].nodeValue:"",i=c(e),u=i.length>0?i[0].getAttribute("href"):"";if(s){a(t).forEach(e=>{e.nodeValue=s})}if(u){c(t).forEach(e=>{e.setAttribute("href",u)})}}const d="hs-dupe-no-transition";let m=!1;async function p(t){!function(){if(m)return;const e=document.createElement("style");e.textContent=`\n .${d},\n .${d} * {\n transition: none !important;\n animation: none !important;\n }\n `,document.head.appendChild(e),m=!0}();const r={processedElements:[]};return e(t,"wrapper").forEach(e=>{const t=e.getAttribute("data-hs-dupe");if(!t||"child"!==t&&"self"!==t)return void console.warn('[dupe] Invalid mode. Use "child" or "self":',e);const n=e.getAttribute("data-hs-dupe-count");let o=n?parseInt(n,10):1;(isNaN(o)||o<1)&&(console.warn("[dupe] Invalid count, using default of 1:",e),o=1),o>20&&(console.warn(`[dupe] Count of ${o} exceeds maximum of 20. Capping at 20.`),o=20);const s={hidden:e.hasAttribute("data-hs-dupe-hidden"),noSelect:e.hasAttribute("data-hs-dupe-no-select")};"child"===t?function(e,t,r,n){const o=e.children[0];if(!o)return;const s=[];for(let i=0;i<t;i++){const t=o.cloneNode(!0);t.classList.add(d),h(t,r),e.appendChild(t),s.push(t),t.offsetHeight,requestAnimationFrame(()=>{t.classList.remove(d)})}n.processedElements.push({element:e,mode:"child",clones:s})}(e,o,s,r):"self"===t&&function(e,t,r,n){const o=e.parentNode;if(!o)return void console.warn("[dupe] Element has no parent, cannot duplicate self:",e);const s=[];let i=e;for(let a=0;a<t;a++){const t=e.cloneNode(!0);t.classList.add(d),t.removeAttribute("data-hs-dupe"),t.removeAttribute("data-hs-dupe-count"),t.removeAttribute("data-hs-dupe-hidden"),t.removeAttribute("data-hs-dupe-no-select"),h(t,r),i.nextSibling?o.insertBefore(t,i.nextSibling):o.appendChild(t),s.push(t),i=t,t.offsetHeight,requestAnimationFrame(()=>{t.classList.remove(d)})}n.processedElements.push({element:e,mode:"self",clones:s})}(e,o,s,r)}),{result:`dupe processed ${r.processedElements.length} elements`,destroy:()=>{}}}function h(e,t){if(t.hidden&&e.setAttribute("aria-hidden","true"),t.noSelect){const t=e;t.style.userSelect="none",t.style.webkitUserSelect="none",t.style.msUserSelect="none"}}async function f(){const a={destroyFunctions:[]},c=o.normalize;try{const d=s();d&&"destroy"in d&&"function"==typeof d.destroy&&a.destroyFunctions.push(d.destroy);const m=(l=o.normalize?.replace,function(){const e=new Map,t=n(l,"element");document.querySelectorAll(t).forEach(t=>{const r=t.cloneNode(!0),o=n(l,"hide");r.querySelectorAll(o).forEach(e=>{const t=l.attributes.elements.hide.primary.match(/data-hs-replace-hide/)[0],r=e.getAttribute(t);r&&r.split(" ").filter(e=>e.trim()).some(t=>e.classList.contains(t))&&e.remove()});const s=l.attributes.elements.element.primary.match(/data-hs-replace/)[0],i=t.getAttribute(s),a=r.textContent?.trim()||null,c=t.getAttribute("href");if(i&&(a||c)){const t={text:a,href:c};if(e.has(i)){const r=e.get(i);Array.isArray(r)?r.push(t):e.set(i,[r,t])}else e.set(i,t)}});const r="hsfx-form-persist";try{const t=localStorage.getItem(r);if(t){const n=JSON.parse(t),o=parseInt(n.timestamp,10);Date.now()-o>864e5?localStorage.removeItem(r):Object.entries(n).forEach(([t,r])=>{"timestamp"!==t&&"string"==typeof r&&e.set(`form.${t}`,{text:r,href:null})})}}catch{}const o=(new Date).getFullYear().toString(),s=["January","February","March","April","May","June","July","August","September","October","November","December"][(new Date).getMonth()];e.set("year",{text:o,href:null}),e.set("month",{text:s,href:null});const i=/\{\{[^}]+\}\}/,a=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT,{acceptNode:e=>{const t=e.textContent||"";return i.test(t)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}}),c=[];let u;for(;u=a.nextNode();)c.push(u);c.forEach(t=>{let r=t.textContent||"",n=!1;for(const[s,i]of e.entries()){const e=`{{${s}}}`;if(r.includes(e)){let t=null;t=Array.isArray(i)?i.map(e=>e.text||e.href).filter(Boolean).join(", "):i.text||i.href,t&&(r=r.replace(new RegExp(e,"g"),t),n=!0)}}const o=/\{\{[^}]+\}\}/g;o.test(r)&&(r=r.replace(o,""),n=!0),n&&(t.textContent=r)}),document.querySelectorAll("a[href]").forEach(t=>{let r=t.getAttribute("href")||"",n=!1;for(const[s,i]of e.entries()){const e=`{{${s}}}`;if(r.includes(e)){let t=null;if(Array.isArray(i)){const e=i[0];t=e.href||e.text}else{if(i.href){t=i.href,r=i.href,n=!0;break}i.text&&(t=i.text)}t&&!n&&(r=r.replace(new RegExp(e,"g"),t),n=!0)}}const o=/\{\{[^}]+\}\}/g;o.test(r)&&(r=r.replace(o,""),n=!0),n&&t.setAttribute("href",r)});const d=document.querySelector("[data-hs-replace-test]");if(d){const t={};for(const[n,o]of e.entries()){const e=`{{${n}}}`;if(Array.isArray(o)){const r=o.map(e=>e.text||e.href).filter(Boolean).join(", ");t[n]={placeholder:e,value:r,type:`Array (${o.length} items)`,items:o.map(e=>e.text||e.href||"(empty)")}}else{const r=o.text||o.href||"(empty)";t[n]={placeholder:e,value:r,...o.text&&{text:o.text},...o.href&&{href:o.href}}}}const r=document.createElement("pre");r.textContent=JSON.stringify(t,null,2),d.innerHTML="",d.appendChild(document.createTextNode(`Replace Module Debug (${e.size} replacements):`)),d.appendChild(r)}document.querySelector("[data-hs-form-persist-clear]")&&localStorage.removeItem(r)}(),{result:"replace initialized",destroy:()=>{}});m&&"destroy"in m&&"function"==typeof m.destroy&&a.destroyFunctions.push(m.destroy);const h=await async function(r){const n=e(r,"source"),o=new Map,s=new Map;n.forEach(e=>{const t=e.getAttribute(r.attributes.properties.syncId),n=e.getAttribute(r.attributes.properties.syncField);t&&o.set(t,e),n&&s.set(n,e)});const a=e(r,"target");let c=0,l=0;return a.forEach(n=>{const a=n.getAttribute(r.attributes.properties.syncId),d=n.getAttribute(r.attributes.properties.syncField),m=n.getAttribute(r.attributes.properties.syncValue);let p;if(d&&m){if(p=s.get(d),!p)return void l++}else{if(!a||""===a.trim())return void l++;if(p=o.get(a),!p)return void l++}const h=t(r,"item",n);if(!h){const e=d||a||"unknown";return void console.warn(`[sync] Target list "${e}" missing item template`)}const f="child"===h.getAttribute(r.attributes.properties.syncMode),y=t(r,"ignore",n);let g,b;if(m){const t=e(r,"item",p),n=Array.from(t).find(e=>e.getAttribute(r.attributes.properties.syncValue)===m);if(!n)return void console.warn(`[sync] No source item found with value "${m}" in field "${d}"`);g=[n]}else if(g=Array.from(e(r,"item",p)),0===g.length)return void console.warn(`[sync] Source list "${a}" has no items`);if(f){const e=h.firstElementChild;if(!e)return void console.warn(`[sync] Target list "${a}" has sync-mode="child" but item wrapper has no children`);b=e.cloneNode(!0)}else b=h.cloneNode(!0),b.removeAttribute(r.attributes.elements.item.primary.split("=")[0]);let A=!1;if(y){let e=y.nextElementSibling;for(;e;){if(e===h){A=!0;break}e=e.nextElementSibling}}if(f){for(;h.firstChild;)h.removeChild(h.firstChild);g.forEach((e,t)=>{const n=b.cloneNode(!0);u(e,n,r,t),a&&i(n,a,t),h.appendChild(n)}),h.removeAttribute(r.attributes.elements.item.primary.split("=")[0])}else{Array.from(n.children).forEach(e=>{e!==y&&e.remove()});const e=Array.from(g).map((e,t)=>{const n=b.cloneNode(!0);return u(e,n,r,t),a&&i(n,a,t),n});y?A?e.forEach(e=>{n.appendChild(e)}):e.forEach(e=>{n.insertBefore(e,y)}):e.forEach(e=>{n.appendChild(e)})}c++}),{result:`sync initialized (${c} synced, ${l} skipped)`,destroy:()=>{}}}(c.sync);h&&"destroy"in h&&"function"==typeof h.destroy&&a.destroyFunctions.push(h.destroy);const f=await p(c.dupe);f&&"destroy"in f&&"function"==typeof f.destroy&&a.destroyFunctions.push(f.destroy);const y=await async function(){const t={processedWrappers:[]};return e(r.clickable,"wrapper").forEach(e=>{const r=e.querySelector(":scope > button"),n=e.querySelector(":scope > a");if(!r||!n)return;const o=n.getAttribute("href");let s,i;o&&""!==o&&"#"!==o?(s=n,i=r):(s=r,i=n);const a="button"===s.getAttribute("data-hs-clickable");a||s.setAttribute("data-hs-clickable","button"),i.remove(),t.processedWrappers.push({wrapper:e,keptElement:s,wasLink:s===n,addedAttribute:!a})}),{result:`clickable processed ${t.processedWrappers.length} wrappers`,destroy:()=>{}}}();return y&&"destroy"in y&&"function"==typeof y.destroy&&a.destroyFunctions.push(y.destroy),{result:"normalize initialized",destroy:()=>{a.destroyFunctions.reverse().forEach(e=>{try{e()}catch(t){console.error("[normalize] Error during cleanup:",t)}}),a.destroyFunctions.length=0}}}catch(d){throw console.error("[normalize] Initialization failed:",d),a.destroyFunctions.reverse().forEach(e=>{try{e()}catch(t){console.error("[normalize] Error during error cleanup:",t)}}),d}var l}export{f as init};
package/dist/main.js CHANGED
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./assets/hsfxnormalizeWk_QT7bQ.js","./assets/hsfxutilsCm-S93Uw.js","./assets/hsfxdefaultmzleUy4_.js","./assets/hsfxanimationsB0vls1Xd.js"])))=>i.map(i=>d[i]);
2
- import{c as e}from"./assets/hsfxutilsCm-S93Uw.js";const t={},s=function(e,s,o){let r=Promise.resolve();if(s&&s.length>0){let e=function(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:"fulfilled",value:e}),e=>({status:"rejected",reason:e}))))};const a=document.getElementsByTagName("link"),n=document.querySelector("meta[property=csp-nonce]"),l=n?.nonce||n?.getAttribute("nonce");r=e(s.map(e=>{if(e=function(e,t){return new URL(e,t).href}(e,o),e in t)return;t[e]=!0;const s=e.endsWith(".css"),r=s?'[rel="stylesheet"]':"";if(o)for(let t=a.length-1;t>=0;t--){const o=a[t];if(o.href===e&&(!s||"stylesheet"===o.rel))return}else if(document.querySelector(`link[href="${e}"]${r}`))return;const n=document.createElement("link");return n.rel=s?"stylesheet":"modulepreload",s||(n.as="script"),n.crossOrigin="",n.href=e,l&&n.setAttribute("nonce",l),document.head.appendChild(n),s?new Promise((t,s)=>{n.addEventListener("load",t),n.addEventListener("error",()=>s(new Error(`Unable to preload CSS for ${e}`)))}):void 0}))}function a(e){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(const e of t||[])"rejected"===e.status&&a(e.reason);return e().catch(a)})},o=e._global.apiName;(async()=>{if(window[o]&&!Array.isArray(window[o])&&window[o].loaded)return;const t=Array.isArray(window[o])?window[o]:[],r={normalize:()=>s(()=>import("./assets/hsfxnormalizeWk_QT7bQ.js"),__vite__mapDeps([0,1]),import.meta.url),default:()=>s(()=>import("./assets/hsfxdefaultmzleUy4_.js"),__vite__mapDeps([2,1]),import.meta.url),animations:()=>s(()=>import("./assets/hsfxanimationsB0vls1Xd.js"),__vite__mapDeps([3,1]),import.meta.url)};let a=[...document.querySelectorAll(`script[type="module"][src="${import.meta.url}"]`)];0===a.length&&(a=[...document.querySelectorAll('script[type="module"][src*="@hsfx/attr"]')].filter(e=>{const t=e.src,s=import.meta.url,o=t.match(/@hsfx\/attr(@[\d.]+)?/)?.[0],r=s.match(/@hsfx\/attr(@[\d.]+)?/)?.[0];return o&&r&&o.split("@")[0]===r.split("@")[0]}));const n={isSPA:a.some(e=>"true"===e.getAttribute("data-hs-spa"))},l={normalize:{modules:["normalize"],parallel:!1},default:{modules:["default"],parallel:!0}},i=async e=>{const t=window[o];if(t.process.has(e))return t.modules[e]?.loading;t.process.add(e);const s=t.modules[e]||{};let a;t.modules[e]=s,s.loading=new Promise((e,t)=>{s.resolve=e,s.reject=t});try{const{init:o}=await r[e](),n=await o()||{};a=n.destroy;const l=n.result;return Object.assign(s,n),s.destroy=()=>{a?.(),t.process.delete(e)},s.restart=()=>{s.destroy?.(),t.load(e)},s.resolve?.(l),delete s.resolve,delete s.reject,l}catch(n){throw a?.(),s.reject?.(n),t.process.delete(e),n}},d=async e=>{const t=l[e];if(t.parallel){const e=t.modules.map(e=>i(e));await Promise.allSettled(e)}else for(const s of t.modules)await i(s)},c=async()=>{await Promise.allSettled([r.normalize(),r.default(),r.animations()]),await d("normalize");const e=d("default"),t=i("animations");await e,(()=>{const e=new CustomEvent(`${o}:dom-ready`);window.dispatchEvent(e)})();const{initScrollAnimations:a}=await s(async()=>{const{initScrollAnimations:e}=await import("./assets/hsfxutilsCm-S93Uw.js").then(e=>e.u);return{initScrollAnimations:e}},[],import.meta.url);Promise.all([t,a()]).catch(e=>{console.error(`[${o}] Phase 3 (animations + scroll trigger) failed:`,e)})},u=[];window[o]={scripts:a,settings:n,modules:{},process:new Set,load:i,loaded:!1,push(...e){for(const[t,s]of e)"function"==typeof s?this.modules[t]?.loading?.then(s):this.load(t)},destroy(){for(const e in this.modules)this.modules[e]?.destroy?.()},async reinitialize(){this.loaded=!1,this.destroy(),this.modules={},this.process=new Set,await this.scanForEmbedModules(),await c(),this.loaded=!0},async scanForEmbedModules(){document.querySelectorAll(".w-embed").forEach(e=>{e.querySelectorAll("script[data-hs-module]").forEach(e=>{const t=e.getAttribute("data-hs-module-type"),s=e.getAttribute("data-hs-module");if(t&&s){const e=`data-hs-${t}-${s}`;r[e]&&this.load(e)}})})},ready(e){"function"==typeof e&&(this.loaded?e():u.push(e))},status(e){return e?{loaded:!!this.modules[e],loading:this.process.has(e)}:{loaded:Object.keys(this.modules),loading:[...this.process],phases:l}}};(async()=>{window[o].push(...t),document.querySelectorAll("iframe").forEach(e=>{const t=e.src;t&&(e.src="",e.src=t)}),await c(),window[o].loaded=!0,document.documentElement.classList.add(e._global.classes.ready),u.forEach(e=>{try{e()}catch{}}),u.length=0})().catch(()=>{})})();export{s as _};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./assets/hsfxnormalizeBzoHSE0l.js","./assets/hsfxutilsCm-S93Uw.js","./assets/hsfxdefaultmzleUy4_.js","./assets/hsfxanimationsB0vls1Xd.js"])))=>i.map(i=>d[i]);
2
+ import{c as e}from"./assets/hsfxutilsCm-S93Uw.js";const t={},s=function(e,s,o){let r=Promise.resolve();if(s&&s.length>0){let e=function(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:"fulfilled",value:e}),e=>({status:"rejected",reason:e}))))};const a=document.getElementsByTagName("link"),n=document.querySelector("meta[property=csp-nonce]"),l=n?.nonce||n?.getAttribute("nonce");r=e(s.map(e=>{if(e=function(e,t){return new URL(e,t).href}(e,o),e in t)return;t[e]=!0;const s=e.endsWith(".css"),r=s?'[rel="stylesheet"]':"";if(o)for(let t=a.length-1;t>=0;t--){const o=a[t];if(o.href===e&&(!s||"stylesheet"===o.rel))return}else if(document.querySelector(`link[href="${e}"]${r}`))return;const n=document.createElement("link");return n.rel=s?"stylesheet":"modulepreload",s||(n.as="script"),n.crossOrigin="",n.href=e,l&&n.setAttribute("nonce",l),document.head.appendChild(n),s?new Promise((t,s)=>{n.addEventListener("load",t),n.addEventListener("error",()=>s(new Error(`Unable to preload CSS for ${e}`)))}):void 0}))}function a(e){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(const e of t||[])"rejected"===e.status&&a(e.reason);return e().catch(a)})},o=e._global.apiName;(async()=>{if(window[o]&&!Array.isArray(window[o])&&window[o].loaded)return;const t=Array.isArray(window[o])?window[o]:[],r={normalize:()=>s(()=>import("./assets/hsfxnormalizeBzoHSE0l.js"),__vite__mapDeps([0,1]),import.meta.url),default:()=>s(()=>import("./assets/hsfxdefaultmzleUy4_.js"),__vite__mapDeps([2,1]),import.meta.url),animations:()=>s(()=>import("./assets/hsfxanimationsB0vls1Xd.js"),__vite__mapDeps([3,1]),import.meta.url)};let a=[...document.querySelectorAll(`script[type="module"][src="${import.meta.url}"]`)];0===a.length&&(a=[...document.querySelectorAll('script[type="module"][src*="@hsfx/attr"]')].filter(e=>{const t=e.src,s=import.meta.url,o=t.match(/@hsfx\/attr(@[\d.]+)?/)?.[0],r=s.match(/@hsfx\/attr(@[\d.]+)?/)?.[0];return o&&r&&o.split("@")[0]===r.split("@")[0]}));const n={isSPA:a.some(e=>"true"===e.getAttribute("data-hs-spa"))},l={normalize:{modules:["normalize"],parallel:!1},default:{modules:["default"],parallel:!0}},i=async e=>{const t=window[o];if(t.process.has(e))return t.modules[e]?.loading;t.process.add(e);const s=t.modules[e]||{};let a;t.modules[e]=s,s.loading=new Promise((e,t)=>{s.resolve=e,s.reject=t});try{const{init:o}=await r[e](),n=await o()||{};a=n.destroy;const l=n.result;return Object.assign(s,n),s.destroy=()=>{a?.(),t.process.delete(e)},s.restart=()=>{s.destroy?.(),t.load(e)},s.resolve?.(l),delete s.resolve,delete s.reject,l}catch(n){throw a?.(),s.reject?.(n),t.process.delete(e),n}},d=async e=>{const t=l[e];if(t.parallel){const e=t.modules.map(e=>i(e));await Promise.allSettled(e)}else for(const s of t.modules)await i(s)},c=async()=>{await Promise.allSettled([r.normalize(),r.default(),r.animations()]),await d("normalize");const e=d("default"),t=i("animations");await e,(()=>{const e=new CustomEvent(`${o}:dom-ready`);window.dispatchEvent(e)})();const{initScrollAnimations:a}=await s(async()=>{const{initScrollAnimations:e}=await import("./assets/hsfxutilsCm-S93Uw.js").then(e=>e.u);return{initScrollAnimations:e}},[],import.meta.url);Promise.all([t,a()]).catch(e=>{console.error(`[${o}] Phase 3 (animations + scroll trigger) failed:`,e)})},u=[];window[o]={scripts:a,settings:n,modules:{},process:new Set,load:i,loaded:!1,push(...e){for(const[t,s]of e)"function"==typeof s?this.modules[t]?.loading?.then(s):this.load(t)},destroy(){for(const e in this.modules)this.modules[e]?.destroy?.()},async reinitialize(){this.loaded=!1,this.destroy(),this.modules={},this.process=new Set,await this.scanForEmbedModules(),await c(),this.loaded=!0},async scanForEmbedModules(){document.querySelectorAll(".w-embed").forEach(e=>{e.querySelectorAll("script[data-hs-module]").forEach(e=>{const t=e.getAttribute("data-hs-module-type"),s=e.getAttribute("data-hs-module");if(t&&s){const e=`data-hs-${t}-${s}`;r[e]&&this.load(e)}})})},ready(e){"function"==typeof e&&(this.loaded?e():u.push(e))},status(e){return e?{loaded:!!this.modules[e],loading:this.process.has(e)}:{loaded:Object.keys(this.modules),loading:[...this.process],phases:l}}};(async()=>{window[o].push(...t),document.querySelectorAll("iframe").forEach(e=>{const t=e.src;t&&(e.src="",e.src=t)}),await c(),window[o].loaded=!0,document.documentElement.classList.add(e._global.classes.ready),u.forEach(e=>{try{e()}catch{}}),u.length=0})().catch(()=>{})})();export{s as _};
package/dist/main.js.br CHANGED
Binary file
package/dist/main.js.gz CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hsfx/attr",
3
- "version": "2.0.25",
3
+ "version": "2.0.26",
4
4
  "type": "module",
5
5
  "main": "dist/main.js",
6
6
  "license": "UNLICENSED",
@@ -1 +0,0 @@
1
- import{q as e,a as t,g as r,b as n,c as o}from"./hsfxutilsCm-S93Uw.js";function s(){return function(){const e=window.location.origin,t=e=>{const t=document.querySelector(`[data-hs-replace="${e}"]`);return t?.textContent?.trim()||""},r=t("company"),n=t("phone"),o=t("email"),s=t("city"),i=t("state"),a=t("zipcode"),c={"@context":"https://schema.org","@type":"LocalBusiness",name:r,url:e,telephone:n,email:o},l=document.querySelector('[data-hs-replace="business-logo"] img');l&&l.src&&(c.image=l.src);const u={"@type":"PostalAddress",addressLocality:s,addressRegion:i,postalCode:a,addressCountry:"US"},d=t("street-address");d&&(u.streetAddress=d),c.address=u;const m=t("business-latitude"),p=t("business-longitude");m&&p&&(c.geo={"@type":"GeoCoordinates",latitude:m,longitude:p});const h=["facebook","instagram","linkedin","pinterest","tiktok","x","youtube"].map(e=>(e=>{const t=document.querySelector(`[data-hs-replace="${e}"]`);return t?.href||""})(e)).filter(e=>e&&""!==e.trim()&&!e.includes("placeholder"));h.length>0&&(c.sameAs=h);const f=document.querySelector('[data-hs-schema="services"]');if(f){const e=f.querySelectorAll('[data-hs-schema-list="item"]'),t=Array.from(e).map(e=>e.textContent?.trim()).filter(e=>e&&""!==e);t.length>0&&(c.serviceType=t)}const y=document.querySelector('[data-hs-schema="areas"]');if(y){const e=y.querySelectorAll('[data-hs-schema-list="item"]'),t=Array.from(e).map(e=>({"@type":"City",name:e.textContent?.trim()||""})).filter(e=>e.name&&""!==e.name);t.length>0&&(c.areaServed=t)}const g=document.createElement("script");g.type="application/ld+json",g.text=JSON.stringify(c),document.head.appendChild(g);const b=document.querySelector('[data-hs-schema="breadcrumb"]')?.textContent?.trim()||"",A=window.location.pathname.split("/").filter(e=>""!==e);if(A.length>0){const t={"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:[{"@type":"ListItem",position:1,name:"Home",item:e}]},r=A[0],n=r.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");t.itemListElement.push({"@type":"ListItem",position:2,name:n,item:e+"/"+r}),b&&t.itemListElement.push({"@type":"ListItem",position:3,name:b,item:window.location.href});const o=document.createElement("script");o.type="application/ld+json",o.text=JSON.stringify(t),document.head.appendChild(o)}if(document.querySelector('[data-hs-accordion-type="faq"]')){const e=[];if(document.querySelectorAll('[data-hs-accordion="list"]').forEach(t=>{t.querySelectorAll('[data-hs-accordion-type="faq"]').forEach(t=>{const r=t.querySelector('[data-hs-accordion="toggle"]'),n=t.querySelector('[data-hs-accordion="content"]');if(r&&n){const t=r.textContent?.trim(),o=n.innerHTML.trim();e.push({"@type":"Question",name:t,acceptedAnswer:{"@type":"Answer",text:o}})}})}),e.length>0){const t={"@context":"https://schema.org","@type":"FAQPage",mainEntity:e},r=document.createElement("script");r.type="application/ld+json",r.text=JSON.stringify(t),document.head.appendChild(r)}}const S=document.querySelector('[data-hs-schema-service="name"]'),x=document.querySelector('[data-hs-schema-service="description"]');if(S&&x){const e=S.textContent?.trim()||"",t=x.textContent?.trim()||"";if(e&&t){const r={"@context":"https://schema.org","@type":"Service",name:e,description:t},n=document.createElement("script");n.type="application/ld+json",n.text=JSON.stringify(r),document.head.appendChild(n)}}else(S||x)&&console.warn('[schema] Service page schema requires both "name" and "description" elements');const E=document.querySelector('[data-hs-schema-faq="question"]'),q=document.querySelector('[data-hs-schema-faq="answer"]'),C=document.querySelector('[data-hs-schema-faq="published"]'),w=document.querySelector('[data-hs-schema-faq="modified"]');if(E&&q&&C&&w){const e=E.textContent?.trim()||"",t=q.innerHTML.trim(),r=C.textContent?.trim()||"",n=w.textContent?.trim()||"";if(e&&t&&r&&n){const o={"@context":"https://schema.org","@type":"QAPage",mainEntity:{"@type":"Question",name:e,text:e,answerCount:1,datePublished:r,dateModified:n,acceptedAnswer:{"@type":"Answer",text:t}}},s=document.createElement("script");s.type="application/ld+json",s.text=JSON.stringify(o),document.head.appendChild(s)}}else if(E||q||C||w){const e=[];E||e.push("question"),q||e.push("answer"),C||e.push("published"),w||e.push("modified"),console.warn(`[schema] FAQ page schema missing required fields: ${e.join(", ")}`)}const v=document.querySelector('[data-hs-schema-blog="name"]'),$=document.querySelector('[data-hs-schema-blog="published"]'),N=document.querySelector('[data-hs-schema-blog="modified"]'),F=document.querySelector('[data-hs-schema-blog="summary"]'),L=document.querySelector('[data-hs-schema-blog="author-name"]'),j=document.querySelector('[data-hs-schema-blog="author-type"]');if(v&&$&&N&&F&&L&&j){const e=v.textContent?.trim()||"",r=$.textContent?.trim()||"",n=N.textContent?.trim()||"",o=F.textContent?.trim()||"",s=L.textContent?.trim()||"",i=j.textContent?.trim()||"Organization",a=document.querySelector('[data-hs-schema-blog="author-role"]'),c=document.querySelector('[data-hs-schema-blog="author-image"]'),l=a?.textContent?.trim()||"",u=c?.src||"",d=t("company"),m=document.querySelector('[data-hs-replace="business-logo"] img'),p=m?m.src:"";let h;"Person"===i?(h={"@type":"Person",name:s},l&&(h.jobTitle=l),u&&(h.image=u)):(h={"@type":"Organization",name:s},p&&(h.logo=p));const f={"@context":"https://schema.org","@type":"BlogPosting",headline:e,description:o,datePublished:r,dateModified:n,author:h,publisher:{"@type":"Organization",name:d||s,logo:{"@type":"ImageObject",url:p}},mainEntityOfPage:{"@type":"WebPage","@id":window.location.href}},y=document.createElement("script");y.type="application/ld+json",y.text=JSON.stringify(f),document.head.appendChild(y)}else if(v||$||N||F||L||j){const e=[];v||e.push("name"),$||e.push("published"),N||e.push("modified"),F||e.push("summary"),L||e.push("author-name"),j||e.push("author-type"),console.warn(`[schema] Blog page schema missing required fields: ${e.join(", ")}`)}}(),{result:"schema initialized",destroy:()=>{}}}function i(e,t,r){const n="{{sync.id}}",o=`${t}-${r}`;Array.from(e.attributes).forEach(t=>{t.value.includes(n)&&e.setAttribute(t.name,t.value.split(n).join(o))}),e.querySelectorAll("*").forEach(e=>{Array.from(e.attributes).forEach(t=>{t.value.includes(n)&&e.setAttribute(t.name,t.value.split(n).join(o))})})}function a(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let n;for(;n=r.nextNode();)n.nodeValue?.trim()&&t.push(n);return t}function c(e){const t=[];return e.hasAttribute("href")&&t.push(e),t.push(...Array.from(e.querySelectorAll("[href]"))),t}function l(e){if(e.hasAttribute("src")){if(e.getAttribute("src"))return e}const t=e.querySelector("[src]");if(t){if(t.getAttribute("src"))return t}return null}function u(e,t,r,n){if(function(e,t){const r=t.attributes.properties.syncField;return null!==e.querySelector(`[${r}]`)}(t,r))return void function(e,t,r,n){const o=r.attributes.properties.syncField;t.querySelectorAll(`[${o}="sync-index"]`).forEach(e=>{const t=a(e);t.length>0?t[0].nodeValue=String(n+1):e.textContent=String(n+1)}),e.querySelectorAll(`[${o}]`).forEach(e=>{const r=e.getAttribute(o),n=t.querySelectorAll(`[${o}="${r}"]`);0!==n.length&&n.forEach(t=>{const r=l(e),n=l(t);if(r&&n){const e=r.getAttribute("src");e&&n.setAttribute("src",e)}else if(e.hasAttribute("href")&&t.hasAttribute("href")){const r=e.getAttribute("href");r&&t.setAttribute("href",r)}else{const r=a(e),n=r.length>0?r[0].nodeValue:e.textContent.trim();if(n){const e=a(t);e.length>0?e[0].nodeValue=n:t.textContent=n}}})})}(e,t,r,n);const o=a(e),s=o.length>0?o[0].nodeValue:"",i=c(e),u=i.length>0?i[0].getAttribute("href"):"";if(s){a(t).forEach(e=>{e.nodeValue=s})}if(u){c(t).forEach(e=>{e.setAttribute("href",u)})}}const d="hs-dupe-no-transition";let m=!1;async function p(t){!function(){if(m)return;const e=document.createElement("style");e.textContent=`\n .${d},\n .${d} * {\n transition: none !important;\n animation: none !important;\n }\n `,document.head.appendChild(e),m=!0}();const r={processedElements:[]};return e(t,"wrapper").forEach(e=>{const t=e.getAttribute("data-hs-dupe");if(!t||"child"!==t&&"self"!==t)return void console.warn('[dupe] Invalid mode. Use "child" or "self":',e);const n=e.getAttribute("data-hs-dupe-count");let o=n?parseInt(n,10):1;(isNaN(o)||o<1)&&(console.warn("[dupe] Invalid count, using default of 1:",e),o=1),o>20&&(console.warn(`[dupe] Count of ${o} exceeds maximum of 20. Capping at 20.`),o=20);const s={hidden:e.hasAttribute("data-hs-dupe-hidden"),noSelect:e.hasAttribute("data-hs-dupe-no-select")};"child"===t?function(e,t,r,n){const o=e.children[0];if(!o)return;const s=[];for(let i=0;i<t;i++){const t=o.cloneNode(!0);t.classList.add(d),h(t,r),e.appendChild(t),s.push(t),t.offsetHeight,requestAnimationFrame(()=>{t.classList.remove(d)})}n.processedElements.push({element:e,mode:"child",clones:s})}(e,o,s,r):"self"===t&&function(e,t,r,n){const o=e.parentNode;if(!o)return void console.warn("[dupe] Element has no parent, cannot duplicate self:",e);const s=[];let i=e;for(let a=0;a<t;a++){const t=e.cloneNode(!0);t.classList.add(d),t.removeAttribute("data-hs-dupe"),t.removeAttribute("data-hs-dupe-count"),t.removeAttribute("data-hs-dupe-hidden"),t.removeAttribute("data-hs-dupe-no-select"),h(t,r),i.nextSibling?o.insertBefore(t,i.nextSibling):o.appendChild(t),s.push(t),i=t,t.offsetHeight,requestAnimationFrame(()=>{t.classList.remove(d)})}n.processedElements.push({element:e,mode:"self",clones:s})}(e,o,s,r)}),{result:`dupe processed ${r.processedElements.length} elements`,destroy:()=>{}}}function h(e,t){if(t.hidden&&e.setAttribute("aria-hidden","true"),t.noSelect){const t=e;t.style.userSelect="none",t.style.webkitUserSelect="none",t.style.msUserSelect="none"}}async function f(){const a={destroyFunctions:[]},c=o.normalize;try{const d=s();d&&"destroy"in d&&"function"==typeof d.destroy&&a.destroyFunctions.push(d.destroy);const m=(l=o.normalize?.replace,function(){const e=new Map,t=n(l,"element");document.querySelectorAll(t).forEach(t=>{const r=t.cloneNode(!0),o=n(l,"hide");r.querySelectorAll(o).forEach(e=>{const t=l.attributes.elements.hide.primary.match(/data-hs-replace-hide/)[0],r=e.getAttribute(t);r&&r.split(" ").filter(e=>e.trim()).some(t=>e.classList.contains(t))&&e.remove()});const s=l.attributes.elements.element.primary.match(/data-hs-replace/)[0],i=t.getAttribute(s),a=r.textContent?.trim()||null,c=t.getAttribute("href");if(i&&(a||c)){const t={text:a,href:c};if(e.has(i)){const r=e.get(i);Array.isArray(r)?r.push(t):e.set(i,[r,t])}else e.set(i,t)}});const r="hsfx-form-persist";try{const t=localStorage.getItem(r);if(t){const n=JSON.parse(t),o=parseInt(n.timestamp,10);Date.now()-o>864e5?localStorage.removeItem(r):Object.entries(n).forEach(([t,r])=>{"timestamp"!==t&&"string"==typeof r&&e.set(`form.${t}`,{text:r,href:null})})}}catch{}const o=(new Date).getFullYear().toString(),s=["January","February","March","April","May","June","July","August","September","October","November","December"][(new Date).getMonth()];e.set("year",{text:o,href:null}),e.set("month",{text:s,href:null});const i=/\{\{[^}]+\}\}/,a=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT,{acceptNode:e=>{const t=e.textContent||"";return i.test(t)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}}),c=[];let u;for(;u=a.nextNode();)c.push(u);c.forEach(t=>{let r=t.textContent||"",n=!1;for(const[s,i]of e.entries()){const e=`{{${s}}}`;if(r.includes(e)){let t=null;t=Array.isArray(i)?i.map(e=>e.text||e.href).filter(Boolean).join(", "):i.text||i.href,t&&(r=r.replace(new RegExp(e,"g"),t),n=!0)}}const o=/\{\{[^}]+\}\}/g;o.test(r)&&(r=r.replace(o,""),n=!0),n&&(t.textContent=r)}),document.querySelectorAll("a[href]").forEach(t=>{let r=t.getAttribute("href")||"",n=!1;for(const[s,i]of e.entries()){const e=`{{${s}}}`;if(r.includes(e)){let t=null;if(Array.isArray(i)){const e=i[0];t=e.href||e.text}else{if(i.href){t=i.href,r=i.href,n=!0;break}i.text&&(t=i.text)}t&&!n&&(r=r.replace(new RegExp(e,"g"),t),n=!0)}}const o=/\{\{[^}]+\}\}/g;o.test(r)&&(r=r.replace(o,""),n=!0),n&&t.setAttribute("href",r)});const d=document.querySelector("[data-hs-replace-test]");if(d){const t={};for(const[n,o]of e.entries()){const e=`{{${n}}}`;if(Array.isArray(o)){const r=o.map(e=>e.text||e.href).filter(Boolean).join(", ");t[n]={placeholder:e,value:r,type:`Array (${o.length} items)`,items:o.map(e=>e.text||e.href||"(empty)")}}else{const r=o.text||o.href||"(empty)";t[n]={placeholder:e,value:r,...o.text&&{text:o.text},...o.href&&{href:o.href}}}}const r=document.createElement("pre");r.textContent=JSON.stringify(t,null,2),d.innerHTML="",d.appendChild(document.createTextNode(`Replace Module Debug (${e.size} replacements):`)),d.appendChild(r)}document.querySelector("[data-hs-form-persist-clear]")&&localStorage.removeItem(r)}(),{result:"replace initialized",destroy:()=>{}});m&&"destroy"in m&&"function"==typeof m.destroy&&a.destroyFunctions.push(m.destroy);const h=await async function(r){const n=e(r,"source"),o=new Map,s=new Map;n.forEach(e=>{const t=e.getAttribute(r.attributes.properties.syncId),n=e.getAttribute(r.attributes.properties.syncField);t&&o.set(t,e),n&&s.set(n,e)});const a=e(r,"target");let c=0,l=0;return a.forEach(n=>{const a=n.getAttribute(r.attributes.properties.syncId),d=n.getAttribute(r.attributes.properties.syncField),m=n.getAttribute(r.attributes.properties.syncValue);let p;if(d&&m){if(p=s.get(d),!p)return void l++}else{if(!a||""===a.trim())return void l++;if(p=o.get(a),!p)return void l++}const h=t(r,"item",n);if(!h){const e=d||a||"unknown";return void console.warn(`[sync] Target list "${e}" missing item template`)}const f="child"===h.getAttribute(r.attributes.properties.syncMode),y=t(r,"ignore",n);let g,b;if(m){const t=e(r,"item",p),n=Array.from(t).find(e=>e.getAttribute(r.attributes.properties.syncValue)===m);if(!n)return void console.warn(`[sync] No source item found with value "${m}" in field "${d}"`);g=[n]}else if(g=Array.from(e(r,"item",p)),0===g.length)return void console.warn(`[sync] Source list "${a}" has no items`);if(f){const e=h.firstElementChild;if(!e)return void console.warn(`[sync] Target list "${a}" has sync-mode="child" but item wrapper has no children`);b=e.cloneNode(!0)}else b=h.cloneNode(!0),b.removeAttribute(r.attributes.elements.item.primary.split("=")[0]);let A=!1;if(y){let e=y.nextElementSibling;for(;e;){if(e===h){A=!0;break}e=e.nextElementSibling}}if(f){for(;h.firstChild;)h.removeChild(h.firstChild);g.forEach((e,t)=>{const n=b.cloneNode(!0);u(e,n,r,t),a&&i(n,a,t),h.appendChild(n)}),h.removeAttribute(r.attributes.elements.item.primary.split("=")[0])}else{Array.from(n.children).forEach(e=>{e!==y&&e.remove()});const e=Array.from(g).map((e,t)=>{const n=b.cloneNode(!0);return u(e,n,r,t),a&&i(n,a,t),n});y?A?e.forEach(e=>{n.appendChild(e)}):e.forEach(e=>{n.insertBefore(e,y)}):e.forEach(e=>{n.appendChild(e)})}c++}),{result:`sync initialized (${c} synced, ${l} skipped)`,destroy:()=>{}}}(c.sync);h&&"destroy"in h&&"function"==typeof h.destroy&&a.destroyFunctions.push(h.destroy);const f=await p(c.dupe);f&&"destroy"in f&&"function"==typeof f.destroy&&a.destroyFunctions.push(f.destroy);const y=await async function(){const t={processedWrappers:[]};return e(r.clickable,"wrapper").forEach(e=>{const r=e.querySelector(":scope > button"),n=e.querySelector(":scope > a");if(!r||!n)return;const o=n.getAttribute("href");let s,i;o&&""!==o&&"#"!==o?(s=n,i=r):(s=r,i=n);const a="button"===s.getAttribute("data-hs-clickable");a||s.setAttribute("data-hs-clickable","button"),i.remove(),t.processedWrappers.push({wrapper:e,keptElement:s,wasLink:s===n,addedAttribute:!a})}),{result:`clickable processed ${t.processedWrappers.length} wrappers`,destroy:()=>{}}}();return y&&"destroy"in y&&"function"==typeof y.destroy&&a.destroyFunctions.push(y.destroy),{result:"normalize initialized",destroy:()=>{a.destroyFunctions.reverse().forEach(e=>{try{e()}catch(t){console.error("[normalize] Error during cleanup:",t)}}),a.destroyFunctions.length=0}}}catch(d){throw console.error("[normalize] Initialization failed:",d),a.destroyFunctions.reverse().forEach(e=>{try{e()}catch(t){console.error("[normalize] Error during error cleanup:",t)}}),d}var l}export{f as init};