@hsfx/attr 2.0.30 → 2.0.31

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.
package/README.md CHANGED
@@ -91,16 +91,19 @@ The inline helper script creates a temporary `window.hsfx.ready()` shim immediat
91
91
 
92
92
  When injecting new DOM elements after hsfx has initialized (e.g., CMS-driven mockups, dynamic content loaders), use `refresh()` to reinitialize all attribute handlers on the new elements. This re-dupes elements, restarts marquee animations, and re-wires interactive modules — without breaking form state or replaying page transitions.
93
93
 
94
- **Full flow for dynamic content with marquees/duped elements:**
94
+ **Full flow for dynamic content with clickable buttons/links, marquees, and duped elements:**
95
95
 
96
96
  ```javascript
97
- // 1. Remove existing dupe clones before injecting new content
97
+ // 1. Restore removed button/link pairs (clickable normalization removed one)
98
+ window.hsfx.modules.normalize.clickable.destroy();
99
+
100
+ // 2. Remove existing dupe clones
98
101
  window.hsfx.modules.normalize.dupe.destroy();
99
102
 
100
- // 2. Inject your dynamic content
103
+ // 3. Inject your dynamic content (templates now have full button+link structure)
101
104
  await populateMockup(cmsData);
102
105
 
103
- // 3. Refresh everything (re-dupe → re-marquee → restart all safe modules)
106
+ // 4. Refresh everything (re-dupe → re-clickable → re-marquee → restart all safe modules)
104
107
  await window.hsfx.refresh();
105
108
  ```
106
109
 
@@ -128,10 +131,11 @@ window.dispatchEvent(new CustomEvent('hsfx:refresh', {
128
131
  **What `refresh()` does internally (in order):**
129
132
 
130
133
  1. Re-runs dupe (idempotent — destroys existing clones first, then re-scans)
131
- 2. Restarts marquee animation (destroys old GSAP timelines, re-initializes with new content)
132
- 3. Restarts all safe default modules (accordion, tabs, navbar, etc.)
134
+ 2. Re-runs clickable normalization (re-evaluates button/link pairs based on new hrefs)
135
+ 3. Restarts marquee animation (destroys old GSAP timelines, re-initializes with new content)
136
+ 4. Restarts all safe default modules (accordion, tabs, navbar, etc.)
133
137
 
134
- Pages without dupe or marquee skip steps 1-2 automatically.
138
+ Pages without dupe, clickable, or marquee skip those steps automatically.
135
139
 
136
140
  **Safe modules** (restarted by default): `smooth-scroll`, `navbar`, `accordion`, `toc`, `pagination`, `comparison`, `tabs`, `modal`, `link-prefetch`, `active-link`, `lightbox`, `slider`, `theme-animator`
137
141
 
@@ -0,0 +1 @@
1
+ import{q as e,a as t,g as r,b as n,c as o}from"./hsfxutilsCA-d9TUm.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 d={"@type":"PostalAddress",addressLocality:s,addressRegion:i,postalCode:a,addressCountry:"US"},u=t("street-address");u&&(d.streetAddress=u),c.address=d;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"]'),k=document.querySelector('[data-hs-schema-blog="author-name"]'),L=document.querySelector('[data-hs-schema-blog="author-type"]');if(v&&$&&N&&F&&k&&L){const e=v.textContent?.trim()||"",r=$.textContent?.trim()||"",n=N.textContent?.trim()||"",o=F.textContent?.trim()||"",s=k.textContent?.trim()||"",i=L.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()||"",d=c?.src||"",u=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),d&&(h.image=d)):(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:u||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||k||L){const e=[];v||e.push("name"),$||e.push("published"),N||e.push("modified"),F||e.push("summary"),k||e.push("author-name"),L||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 d(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),d=i.length>0?i[0].getAttribute("href"):"";if(s){a(t).forEach(e=>{e.nodeValue=s})}if(d){c(t).forEach(e=>{e.setAttribute("href",d)})}}async function u(){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,removedElement:i,wasLink:s===n,addedAttribute:!a})}),{result:`clickable processed ${t.processedWrappers.length} wrappers`,destroy:()=>{t.processedWrappers.forEach(({wrapper:e,keptElement:t,removedElement:r,addedAttribute:n})=>{e.isConnected&&(e.appendChild(r),n&&t.removeAttribute("data-hs-clickable"))}),t.processedWrappers.length=0}}}const m="hs-dupe-no-transition";let p=!1;async function h(t){!function(){if(p)return;const e=document.createElement("style");e.textContent=`\n .${m},\n .${m} * {\n transition: none !important;\n animation: none !important;\n }\n `,document.head.appendChild(e),p=!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(m),f(t,r),e.appendChild(t),s.push(t),t.offsetHeight,requestAnimationFrame(()=>{t.classList.remove(m)})}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(m),t.removeAttribute("data-hs-dupe"),t.removeAttribute("data-hs-dupe-count"),t.removeAttribute("data-hs-dupe-hidden"),t.removeAttribute("data-hs-dupe-no-select"),f(t,r),i.nextSibling?o.insertBefore(t,i.nextSibling):o.appendChild(t),s.push(t),i=t,t.offsetHeight,requestAnimationFrame(()=>{t.classList.remove(m)})}n.processedElements.push({element:e,mode:"self",clones:s})}(e,o,s,r)}),{result:`dupe processed ${r.processedElements.length} elements`,destroy:()=>{r.processedElements.forEach(({clones:e})=>{e.forEach(e=>{e.parentNode?.removeChild(e)})}),r.processedElements.length=0}}}function f(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"}}function y(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}async function g(){const r={destroyFunctions:[]},a=o.normalize;try{const l=s();l&&"destroy"in l&&"function"==typeof l.destroy&&r.destroyFunctions.push(l.destroy);const m=(c=o.normalize?.replace,function(){const e=new Map,t=n(c,"element");document.querySelectorAll(t).forEach(t=>{const r=t.cloneNode(!0),o=n(c,"hide");r.querySelectorAll(o).forEach(e=>{const t=c.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=c.attributes.elements.element.primary.match(/data-hs-replace/)[0],i=t.getAttribute(s),a=r.textContent?.trim()||null,l=t.getAttribute("href");if(i&&(a||l)){const t={text:a,href:l};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}}),l=[];let d;for(;d=a.nextNode();)l.push(d);l.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(y(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(y(e),"g"),t),n=!0)}}const o=/\{\{[^}]+\}\}/g;o.test(r)&&(r=r.replace(o,""),n=!0),n&&t.setAttribute("href",r)});const u=document.querySelector("[data-hs-replace-test]");if(u){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),u.innerHTML="",u.appendChild(document.createTextNode(`Replace Module Debug (${e.size} replacements):`)),u.appendChild(r)}document.querySelector("[data-hs-form-persist-clear]")&&localStorage.removeItem(r)}(),{result:"replace initialized",destroy:()=>{}});m&&"destroy"in m&&"function"==typeof m.destroy&&r.destroyFunctions.push(m.destroy);const p=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),u=n.getAttribute(r.attributes.properties.syncField),m=n.getAttribute(r.attributes.properties.syncValue);let p;if(u&&m){if(p=s.get(u),!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=u||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),g=p.getAttribute(r.attributes.properties.syncSource);let b,A;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 "${u}"`);b=[n]}else if("list"===g){if(b=Array.from(p.querySelectorAll("li")),0===b.length)return void console.warn(`[sync] Source list "${a}" has no <li> elements`)}else if(b=Array.from(e(r,"item",p)),0===b.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`);A=e.cloneNode(!0)}else A=h.cloneNode(!0),A.removeAttribute(r.attributes.elements.item.primary.split("=")[0]);let S=!1;if(y){let e=y.nextElementSibling;for(;e;){if(e===h){S=!0;break}e=e.nextElementSibling}}if(f){for(;h.firstChild;)h.removeChild(h.firstChild);b.forEach((e,t)=>{const n=A.cloneNode(!0);d(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(b).map((e,t)=>{const n=A.cloneNode(!0);return d(e,n,r,t),a&&i(n,a,t),n});y?S?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:()=>{}}}(a.sync);p&&"destroy"in p&&"function"==typeof p.destroy&&r.destroyFunctions.push(p.destroy);const f=a.dupe;let g;const b=await h(f);let A;b?.destroy&&(g=b.destroy),r.destroyFunctions.push(()=>g?.());const S=await u();S?.destroy&&(A=S.destroy),r.destroyFunctions.push(()=>A?.());return{result:"normalize initialized",dupe:{destroy:()=>{g?.()},init:async()=>{g?.();const e=await h(f);e?.destroy&&(g=e.destroy)}},clickable:{destroy:()=>{A?.()},init:async()=>{A?.();const e=await u();e?.destroy&&(A=e.destroy)}},destroy:()=>{r.destroyFunctions.reverse().forEach(e=>{try{e()}catch(t){console.error("[normalize] Error during cleanup:",t)}}),r.destroyFunctions.length=0}}}catch(l){throw console.error("[normalize] Initialization failed:",l),r.destroyFunctions.reverse().forEach(e=>{try{e()}catch(t){console.error("[normalize] Error during error cleanup:",t)}}),l}var c}export{g 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/hsfxnormalizeDXwZ2WoI.js","./assets/hsfxutilsCA-d9TUm.js","./assets/hsfxdefaultBsyRSqps.js","./assets/hsfxanimationsCoWsjG-c.js"])))=>i.map(i=>d[i]);
2
- import{c as e}from"./assets/hsfxutilsCA-d9TUm.js";const t={},s=function(e,s,r){let o=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]"),i=n?.nonce||n?.getAttribute("nonce");o=e(s.map(e=>{if(e=function(e,t){return new URL(e,t).href}(e,r),e in t)return;t[e]=!0;const s=e.endsWith(".css"),o=s?'[rel="stylesheet"]':"";if(r)for(let t=a.length-1;t>=0;t--){const r=a[t];if(r.href===e&&(!s||"stylesheet"===r.rel))return}else if(document.querySelector(`link[href="${e}"]${o}`))return;const n=document.createElement("link");return n.rel=s?"stylesheet":"modulepreload",s||(n.as="script"),n.crossOrigin="",n.href=e,i&&n.setAttribute("nonce",i),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 o.then(t=>{for(const e of t||[])"rejected"===e.status&&a(e.reason);return e().catch(a)})},r=e._global.apiName,o=["smooth-scroll","navbar","accordion","toc","pagination","comparison","tabs","modal","link-prefetch","active-link","lightbox","slider","theme-animator"];(async()=>{if(window[r]&&!Array.isArray(window[r])&&window[r].loaded)return;const t=Array.isArray(window[r])?window[r]:[],a={normalize:()=>s(()=>import("./assets/hsfxnormalizeDXwZ2WoI.js"),__vite__mapDeps([0,1]),import.meta.url),default:()=>s(()=>import("./assets/hsfxdefaultBsyRSqps.js"),__vite__mapDeps([2,1]),import.meta.url),animations:()=>s(()=>import("./assets/hsfxanimationsCoWsjG-c.js"),__vite__mapDeps([3,1]),import.meta.url)};let n=[...document.querySelectorAll(`script[type="module"][src="${import.meta.url}"]`)];0===n.length&&(n=[...document.querySelectorAll('script[type="module"][src*="@hsfx/attr"]')].filter(e=>{const t=e.src,s=import.meta.url,r=t.match(/@hsfx\/attr(@[\d.]+)?/)?.[0],o=s.match(/@hsfx\/attr(@[\d.]+)?/)?.[0];return r&&o&&r.split("@")[0]===o.split("@")[0]}));const i={isSPA:n.some(e=>"true"===e.getAttribute("data-hs-spa"))},l={normalize:{modules:["normalize"],parallel:!1},default:{modules:["default"],parallel:!0}},d=async e=>{const t=window[r];if(t.process.has(e))return t.modules[e]?.loading;t.process.add(e);const s=t.modules[e]||{};let o;t.modules[e]=s,s.loading=new Promise((e,t)=>{s.resolve=e,s.reject=t});try{const{init:r}=await a[e](),n=await r()||{};o=n.destroy;const i=n.result;return Object.assign(s,n),s.destroy=()=>{o?.(),t.process.delete(e)},s.restart=()=>{s.destroy?.(),t.load(e)},s.resolve?.(i),delete s.resolve,delete s.reject,i}catch(n){throw o?.(),s.reject?.(n),t.process.delete(e),n}},c=async e=>{const t=l[e];if(t.parallel){const e=t.modules.map(e=>d(e));await Promise.allSettled(e)}else for(const s of t.modules)await d(s)},u=async()=>{await Promise.allSettled([a.normalize(),a.default(),a.animations()]),await c("normalize");const e=c("default"),t=d("animations");await e,(()=>{const e=new CustomEvent(`${r}:dom-ready`);window.dispatchEvent(e)})();const{initScrollAnimations:o}=await s(async()=>{const{initScrollAnimations:e}=await import("./assets/hsfxutilsCA-d9TUm.js").then(e=>e.u);return{initScrollAnimations:e}},[],import.meta.url);Promise.all([t,o()]).catch(e=>{console.error(`[${r}] Phase 3 (animations + scroll trigger) failed:`,e)})},m=[];let h=null;window[r]={scripts:n,settings:i,modules:{},process:new Set,load:d,loaded:!1,push(...e){for(const[t,s]of e)"function"==typeof s?this.modules[t]?.loading?.then(s):this.load(t)},destroy(){h&&(window.removeEventListener(`${r}:refresh`,h),h=null);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 u(),this.loaded=!0},async refresh(e){const t=this.modules.normalize;if(t?.dupe?.init)try{await t.dupe.init()}catch(i){console.error(`[${r}] Error re-running dupe during refresh:`,i)}const s=this.modules.animations;if(s?.restart)try{await s.restart("marquee")}catch(i){console.error(`[${r}] Error restarting marquee during refresh:`,i)}const a=this.modules.default;if(!a)return;const n=e||o;await Promise.allSettled(n.map(async e=>{a[e]?.restart&&await a[e].restart()}))},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}`;a[e]&&this.load(e)}})})},ready(e){"function"==typeof e&&(this.loaded?e():m.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[r].push(...t),document.querySelectorAll("iframe").forEach(e=>{const t=e.src;t&&(e.src="",e.src=t)}),await u(),window[r].loaded=!0,document.documentElement.classList.add(e._global.classes.ready),h=e=>{const t=e.detail?.modules;window[r].refresh(Array.isArray(t)?t:void 0)},window.addEventListener(`${r}:refresh`,h),m.forEach(e=>{try{e()}catch{}}),m.length=0})().catch(()=>{})})();export{s as _};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./assets/hsfxnormalizeBvPmJHK4.js","./assets/hsfxutilsCA-d9TUm.js","./assets/hsfxdefaultBsyRSqps.js","./assets/hsfxanimationsCoWsjG-c.js"])))=>i.map(i=>d[i]);
2
+ import{c as e}from"./assets/hsfxutilsCA-d9TUm.js";const t={},r=function(e,r,s){let o=Promise.resolve();if(r&&r.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]"),i=n?.nonce||n?.getAttribute("nonce");o=e(r.map(e=>{if(e=function(e,t){return new URL(e,t).href}(e,s),e in t)return;t[e]=!0;const r=e.endsWith(".css"),o=r?'[rel="stylesheet"]':"";if(s)for(let t=a.length-1;t>=0;t--){const s=a[t];if(s.href===e&&(!r||"stylesheet"===s.rel))return}else if(document.querySelector(`link[href="${e}"]${o}`))return;const n=document.createElement("link");return n.rel=r?"stylesheet":"modulepreload",r||(n.as="script"),n.crossOrigin="",n.href=e,i&&n.setAttribute("nonce",i),document.head.appendChild(n),r?new Promise((t,r)=>{n.addEventListener("load",t),n.addEventListener("error",()=>r(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 o.then(t=>{for(const e of t||[])"rejected"===e.status&&a(e.reason);return e().catch(a)})},s=e._global.apiName,o=["smooth-scroll","navbar","accordion","toc","pagination","comparison","tabs","modal","link-prefetch","active-link","lightbox","slider","theme-animator"];(async()=>{if(window[s]&&!Array.isArray(window[s])&&window[s].loaded)return;const t=Array.isArray(window[s])?window[s]:[],a={normalize:()=>r(()=>import("./assets/hsfxnormalizeBvPmJHK4.js"),__vite__mapDeps([0,1]),import.meta.url),default:()=>r(()=>import("./assets/hsfxdefaultBsyRSqps.js"),__vite__mapDeps([2,1]),import.meta.url),animations:()=>r(()=>import("./assets/hsfxanimationsCoWsjG-c.js"),__vite__mapDeps([3,1]),import.meta.url)};let n=[...document.querySelectorAll(`script[type="module"][src="${import.meta.url}"]`)];0===n.length&&(n=[...document.querySelectorAll('script[type="module"][src*="@hsfx/attr"]')].filter(e=>{const t=e.src,r=import.meta.url,s=t.match(/@hsfx\/attr(@[\d.]+)?/)?.[0],o=r.match(/@hsfx\/attr(@[\d.]+)?/)?.[0];return s&&o&&s.split("@")[0]===o.split("@")[0]}));const i={isSPA:n.some(e=>"true"===e.getAttribute("data-hs-spa"))},l={normalize:{modules:["normalize"],parallel:!1},default:{modules:["default"],parallel:!0}},c=async e=>{const t=window[s];if(t.process.has(e))return t.modules[e]?.loading;t.process.add(e);const r=t.modules[e]||{};let o;t.modules[e]=r,r.loading=new Promise((e,t)=>{r.resolve=e,r.reject=t});try{const{init:s}=await a[e](),n=await s()||{};o=n.destroy;const i=n.result;return Object.assign(r,n),r.destroy=()=>{o?.(),t.process.delete(e)},r.restart=()=>{r.destroy?.(),t.load(e)},r.resolve?.(i),delete r.resolve,delete r.reject,i}catch(n){throw o?.(),r.reject?.(n),t.process.delete(e),n}},d=async e=>{const t=l[e];if(t.parallel){const e=t.modules.map(e=>c(e));await Promise.allSettled(e)}else for(const r of t.modules)await c(r)},u=async()=>{await Promise.allSettled([a.normalize(),a.default(),a.animations()]),await d("normalize");const e=d("default"),t=c("animations");await e,(()=>{const e=new CustomEvent(`${s}:dom-ready`);window.dispatchEvent(e)})();const{initScrollAnimations:o}=await r(async()=>{const{initScrollAnimations:e}=await import("./assets/hsfxutilsCA-d9TUm.js").then(e=>e.u);return{initScrollAnimations:e}},[],import.meta.url);Promise.all([t,o()]).catch(e=>{console.error(`[${s}] Phase 3 (animations + scroll trigger) failed:`,e)})},m=[];let h=null;window[s]={scripts:n,settings:i,modules:{},process:new Set,load:c,loaded:!1,push(...e){for(const[t,r]of e)"function"==typeof r?this.modules[t]?.loading?.then(r):this.load(t)},destroy(){h&&(window.removeEventListener(`${s}:refresh`,h),h=null);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 u(),this.loaded=!0},async refresh(e){const t=this.modules.normalize;if(t?.dupe?.init)try{await t.dupe.init()}catch(i){console.error(`[${s}] Error re-running dupe during refresh:`,i)}if(t?.clickable?.init)try{await t.clickable.init()}catch(i){console.error(`[${s}] Error re-running clickable during refresh:`,i)}const r=this.modules.animations;if(r?.restart)try{await r.restart("marquee")}catch(i){console.error(`[${s}] Error restarting marquee during refresh:`,i)}const a=this.modules.default;if(!a)return;const n=e||o;await Promise.allSettled(n.map(async e=>{a[e]?.restart&&await a[e].restart()}))},async scanForEmbedModules(){document.querySelectorAll(".w-embed").forEach(e=>{e.querySelectorAll("script[data-hs-module]").forEach(e=>{const t=e.getAttribute("data-hs-module-type"),r=e.getAttribute("data-hs-module");if(t&&r){const e=`data-hs-${t}-${r}`;a[e]&&this.load(e)}})})},ready(e){"function"==typeof e&&(this.loaded?e():m.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[s].push(...t),document.querySelectorAll("iframe").forEach(e=>{const t=e.src;t&&(e.src="",e.src=t)}),await u(),window[s].loaded=!0,document.documentElement.classList.add(e._global.classes.ready),h=e=>{const t=e.detail?.modules;window[s].refresh(Array.isArray(t)?t:void 0)},window.addEventListener(`${s}:refresh`,h),m.forEach(e=>{try{e()}catch{}}),m.length=0})().catch(()=>{})})();export{r 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.30",
3
+ "version": "2.0.31",
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"./hsfxutilsCA-d9TUm.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:()=>{r.processedElements.forEach(({clones:e})=>{e.forEach(e=>{e.parentNode?.removeChild(e)})}),r.processedElements.length=0}}}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"}}function f(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}async function y(){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(f(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(f(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),g=p.getAttribute(r.attributes.properties.syncSource);let b,A;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}"`);b=[n]}else if("list"===g){if(b=Array.from(p.querySelectorAll("li")),0===b.length)return void console.warn(`[sync] Source list "${a}" has no <li> elements`)}else if(b=Array.from(e(r,"item",p)),0===b.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`);A=e.cloneNode(!0)}else A=h.cloneNode(!0),A.removeAttribute(r.attributes.elements.item.primary.split("=")[0]);let S=!1;if(y){let e=y.nextElementSibling;for(;e;){if(e===h){S=!0;break}e=e.nextElementSibling}}if(f){for(;h.firstChild;)h.removeChild(h.firstChild);b.forEach((e,t)=>{const n=A.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(b).map((e,t)=>{const n=A.cloneNode(!0);return u(e,n,r,t),a&&i(n,a,t),n});y?S?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 y=c.dupe;let g;const b=await p(y);b?.destroy&&(g=b.destroy),a.destroyFunctions.push(()=>g?.());const A=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:()=>{}}}();A&&"destroy"in A&&"function"==typeof A.destroy&&a.destroyFunctions.push(A.destroy);return{result:"normalize initialized",dupe:{destroy:()=>{g?.()},init:async()=>{g?.();const e=await p(y);e?.destroy&&(g=e.destroy)}},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{y as init};