@pure-ds/core 0.7.51 → 0.7.53

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.
@@ -1,2 +1,2 @@
1
- var rt=Object.defineProperty;var ot=(e,t)=>{for(var n in t)rt(e,n,{get:t[n],enumerable:!0})};var ie=class extends EventTarget{constructor(){super(),this.mode=null,this.compiled=null,this.log=()=>{},this.logHandler=null}},Ee="__PURE_DS_PDS_SINGLETON__",ae=typeof globalThis<"u"?globalThis:window,se=ae?.[Ee],o=se&&typeof se.addEventListener=="function"?se:new ie;ae&&(ae[Ee]=o);typeof o.log!="function"&&(o.log=(e="log",t,...n)=>{if(typeof console>"u")return;let r=typeof console[e]=="function"?console[e].bind(console):typeof console.log=="function"?console.log.bind(console):null;r&&(n.length>0?r(t,...n):r(t))});typeof o.logHandler!="function"&&(o.logHandler=null);var ce=class{constructor(){this._mode="static",this._staticPaths={tokens:"/assets/pds/styles/pds-tokens.css.js",primitives:"/assets/pds/styles/pds-primitives.css.js",components:"/assets/pds/styles/pds-components.css.js",utilities:"/assets/pds/styles/pds-utilities.css.js",styles:"/assets/pds/styles/pds-styles.css.js"}}setLiveMode(){this._mode="live"}setStaticMode(t={}){this._mode="static",this._staticPaths={...this._staticPaths,...t}}async getStylesheet(t){if(this._mode==="live")return null;try{return(await import(this._staticPaths[t]))[t]}catch(n){o.log("error",`Registry: failed to load static ${t}:`,n),o.log("error",`Registry: looking for ${this._staticPaths[t]}`),o.log("error","Registry: make sure you've run 'npm run pds:build' and configured PDS.start() with the correct static.root path");let r=new CSSStyleSheet;return r.replaceSync("/* Failed to load "+t+" */"),r}}get mode(){return this._mode}get isLive(){return this._mode==="live"}},T=new ce;async function ve(e,t=[],n=null){try{let r=n?.primitivesStylesheet?n.primitivesStylesheet:await T.getStylesheet("primitives");e.adoptedStyleSheets=[r,...t]}catch(r){let a=e.host?.tagName?.toLowerCase()||"unknown";o.log("error",`Adopter: <${a}> failed to adopt primitives:`,r),e.adoptedStyleSheets=t}}async function Ae(e,t=["primitives"],n=[],r=null){let a=Array.isArray(n)?n.filter(Boolean):[];if(a.length){let l=(Array.isArray(e.adoptedStyleSheets)?e.adoptedStyleSheets:[]).filter(S=>!a.includes(S));e.adoptedStyleSheets=[...l,...a]}try{let l=(await Promise.all(t.map(async S=>{if(r)switch(S){case"tokens":return r.tokensStylesheet;case"primitives":return r.primitivesStylesheet;case"components":return r.componentsStylesheet;case"utilities":return r.utilitiesStylesheet;default:break}return T.getStylesheet(S)}))).filter(S=>S!==null);e.adoptedStyleSheets=[...l,...a]}catch(s){let l=e.host?.tagName?.toLowerCase()||"unknown";o.log("error",`Adopter: <${l}> failed to adopt layers:`,s),e.adoptedStyleSheets=a}}function Pe(e){let t=new CSSStyleSheet;return t.replaceSync(e),t}var xe={FontWeights:{light:300,normal:400,medium:500,semibold:600,bold:700},LineHeights:{tight:1.25,normal:1.5,relaxed:1.75},BorderWidths:{hairline:.5,thin:1,medium:2,thick:3},RadiusSizes:{none:0,small:4,medium:8,large:16,xlarge:24,xxlarge:32},ShadowDepths:{none:"none",light:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",medium:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",deep:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",extreme:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"},TransitionSpeeds:{fast:150,normal:250,slow:350},AnimationEasings:{linear:"linear",ease:"ease","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out",bounce:"cubic-bezier(0.68, -0.55, 0.265, 1.55)"},TouchTargetSizes:{compact:36,standard:44,comfortable:48,spacious:56},LinkStyles:{inline:"inline",block:"block",button:"button"},FocusStyles:{ring:"ring",outline:"outline",border:"border",glow:"glow"},TabSizes:{compact:2,standard:4,wide:8},SelectIcons:{chevron:"chevron",arrow:"arrow",caret:"caret",none:"none"},IconSizes:{xs:16,sm:20,md:24,lg:32,xl:48,"2xl":64,"3xl":96}};var de={};ot(de,{deepMerge:()=>Re,fragmentFromTemplateLike:()=>le,isObject:()=>W,parseHTML:()=>ue});function W(e){return e&&typeof e=="object"&&!Array.isArray(e)}function Re(e,t){let n={...e};return W(e)&&W(t)&&Object.keys(t).forEach(r=>{W(t[r])?r in e?n[r]=Re(e[r],t[r]):Object.assign(n,{[r]:t[r]}):Object.assign(n,{[r]:t[r]})}),n}function le(e){let t=Array.isArray(e?.strings)?e.strings:[],n=Array.isArray(e?.values)?e.values:[],r=new Set,a=[],s=/(\s)(\.[\w-]+)=\s*$/,l=/(\s)(@[\w-]+)=\s*$/,S=/(\s)(\?[\w-]+)=\s*$/,g=/(\s)([\w:-]+)=\s*$/;for(let c=0;c<t.length;c+=1){let y=t[c]??"";if(c<n.length){let _=`pds-val-${c}`,v=y.match(s),w=y.match(l),u=y.match(S),b=y.match(g);if(v){let E=v[2].slice(1);y=y.replace(s,`$1data-pds-bind-${c}="prop:${E}:${_}"`),r.add(c)}else if(w){let E=w[2].slice(1);y=y.replace(l,`$1data-pds-bind-${c}="event:${E}:${_}"`),r.add(c)}else if(u){let E=u[2].slice(1);y=y.replace(S,`$1data-pds-bind-${c}="boolean:${E}:${_}"`),r.add(c)}else if(b){let E=b[2];y=y.replace(g,`$1data-pds-bind-${c}="attr:${E}:${_}"`),r.add(c)}}a.push(y),c<n.length&&!r.has(c)&&a.push(`<!--pds-val-${c}-->`)}let d=document.createElement("template");d.innerHTML=a.join("");let i=(c,y)=>{let _=c.parentNode;if(!_)return;if(y==null){_.removeChild(c);return}let v=w=>{if(w!=null){if(w instanceof Node){_.insertBefore(w,c);return}if(Array.isArray(w)){w.forEach(u=>v(u));return}_.insertBefore(document.createTextNode(String(w)),c)}};v(y),_.removeChild(c)},m=document.createTreeWalker(d.content,NodeFilter.SHOW_COMMENT),P=[];for(;m.nextNode();){let c=m.currentNode;c?.nodeValue?.startsWith("pds-val-")&&P.push(c)}return P.forEach(c=>{let y=Number(c.nodeValue.replace("pds-val-",""));i(c,n[y])}),d.content.querySelectorAll("*").forEach(c=>{[...c.attributes].forEach(y=>{if(!y.name.startsWith("data-pds-bind-"))return;let _=y.value.indexOf(":"),v=y.value.lastIndexOf(":");if(_<=0||v<=_){c.removeAttribute(y.name);return}let w=y.value.slice(0,_),u=y.value.slice(_+1,v),b=y.value.slice(v+1),E=Number(String(b).replace("pds-val-","")),x=n[E];if(!u||!Number.isInteger(E)){c.removeAttribute(y.name);return}w==="prop"?c[u]=x:w==="event"?(typeof x=="function"||x&&typeof x.handleEvent=="function")&&c.addEventListener(u,x):w==="boolean"?x?c.setAttribute(u,""):c.removeAttribute(u):w==="attr"&&(x==null||x===!1?c.removeAttribute(u):c.setAttribute(u,String(x))),c.removeAttribute(y.name)})}),d.content}function ue(e,...t){return Array.isArray(e)&&Object.prototype.hasOwnProperty.call(e,"raw")?le({strings:Array.from(e),values:t}).childNodes:Array.isArray(e?.strings)&&Array.isArray(e?.values)?le({strings:e.strings,values:e.values}).childNodes:new DOMParser().parseFromString(String(e??""),"text/html").body.childNodes}var ze="pds",st=/^([a-z][a-z0-9+\-.]*:)?\/\//i,De=/^[a-z]:/i;function j(e=""){return e.endsWith("/")?e:`${e}/`}function it(e="",t=ze){let n=e.replace(/\/+$/,"");return new RegExp(`(?:^|/)${t}$`,"i").test(n)?n:`${n}/${t}`}function at(e){return e.replace(/^\.\/+/,"")}function ct(e){return De.test(e)?e.replace(De,"").replace(/^\/+/,""):e}function lt(e){return e.startsWith("public/")?e.substring(7):e}function B(e,t={}){let n=t.segment||ze,r=t.defaultRoot||`/assets/${n}/`,a=e?.public&&e.public?.root||e?.static&&e.static?.root||null;if(!a||typeof a!="string")return j(r);let s=a.trim();return s?(s=s.replace(/\\/g,"/"),s=it(s,n),s=j(s),st.test(s)?s:(s=at(s),s=ct(s),s.startsWith("/")||(s=lt(s),s.startsWith("/")||(s=`/${s}`),s=s.replace(/\/+/g,(l,S)=>S===0?l:"/")),j(s))):j(r)}async function ut(...e){let t={};e.length&&typeof e[e.length-1]=="object"&&(t=e.pop()||{});let n=e,{baseURL:r,mapper:a=d=>`${d}.js`,onError:s=(d,i)=>console.error(`[defineWebComponents] ${d}:`,i)}=t,l=r?new URL(r,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),S=d=>d.toLowerCase().replace(/(^|-)([a-z])/g,(i,m,P)=>P.toUpperCase()),g=async d=>{try{if(customElements.get(d))return{tag:d,status:"already-defined"};let i=a(d),P=await import(i instanceof URL?i.href:new URL(i,l).href),L=P?.default??P?.[S(d)];if(!L){if(customElements.get(d))return{tag:d,status:"self-defined"};throw new Error(`No export found for ${d}. Expected default export or named export "${S(d)}".`)}return customElements.get(d)?{tag:d,status:"race-already-defined"}:(customElements.define(d,L),{tag:d,status:"defined"})}catch(i){throw s(d,i),i}};return Promise.all(n.map(g))}var H=class{constructor(t={}){let{baseURL:n,mapper:r,onError:a,predicate:s=()=>!0,attributeModule:l="data-module",root:S=document,scanExisting:g=!0,debounceMs:d=16,observeShadows:i=!0,enhancers:m=[],patchAttachShadow:P=!0}=t,L=new Set,c=new Set,y=new Set,_=new Map,v=new WeakMap,w=new WeakMap,u=0,b=!1,E=null,x=f=>{if(!f||!m.length)return;let h=w.get(f);h||(h=new Set,w.set(f,h));for(let p of m)if(!(!p.selector||!p.run)&&!h.has(p.selector))try{f.matches&&f.matches(p.selector)&&(p.run(f),h.add(p.selector))}catch(R){console.warn(`[AutoDefiner] Error applying enhancer for selector "${p.selector}":`,R)}},U=(f,h)=>{if(!b&&!(!f||!f.includes("-"))&&!customElements.get(f)&&!c.has(f)&&!y.has(f)){if(h&&h.getAttribute){let p=h.getAttribute(l);p&&!_.has(f)&&_.set(f,p)}L.add(f),nt()}},nt=()=>{u||(u=setTimeout(Se,d))},z=f=>{if(f){if(f.nodeType===1){let h=f,p=h.tagName?.toLowerCase();p&&p.includes("-")&&!customElements.get(p)&&s(p,h)&&U(p,h),x(h),i&&h.shadowRoot&&oe(h.shadowRoot)}f.querySelectorAll&&f.querySelectorAll("*").forEach(h=>{let p=h.tagName?.toLowerCase();p&&p.includes("-")&&!customElements.get(p)&&s(p,h)&&U(p,h),x(h),i&&h.shadowRoot&&oe(h.shadowRoot)})}},oe=f=>{if(!f||v.has(f))return;z(f);let h=new MutationObserver(p=>{for(let R of p)R.addedNodes?.forEach(C=>{z(C)}),R.type==="attributes"&&R.target&&z(R.target)});h.observe(f,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[l,...m.map(p=>p.selector).filter(p=>p.startsWith("data-"))]}),v.set(f,h)};async function Se(){if(clearTimeout(u),u=0,!L.size)return;let f=Array.from(L);L.clear(),f.forEach(h=>c.add(h));try{let h=p=>_.get(p)??(r?r(p):`${p}.js`);await ut(...f,{baseURL:n,mapper:h,onError:(p,R)=>{y.add(p),a?.(p,R)}})}catch{}finally{f.forEach(h=>c.delete(h))}}let _e=S===document?document.documentElement:S,Le=new MutationObserver(f=>{for(let h of f)h.addedNodes?.forEach(p=>{z(p)}),h.type==="attributes"&&h.target&&z(h.target)});if(Le.observe(_e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[l,...m.map(f=>f.selector).filter(f=>f.startsWith("data-"))]}),i&&P&&Element.prototype.attachShadow){let f=Element.prototype.attachShadow;Element.prototype.attachShadow=function(p){let R=f.call(this,p);if(p&&p.mode==="open"){oe(R);let C=this.tagName?.toLowerCase();C&&C.includes("-")&&!customElements.get(C)&&U(C,this)}return R},E=()=>Element.prototype.attachShadow=f}return g&&z(_e),{stop(){b=!0,Le.disconnect(),E&&E(),u&&(clearTimeout(u),u=0),v.forEach(f=>f.disconnect())},flush:Se}}static async define(...t){let n={};t.length&&typeof t[t.length-1]=="object"&&(n=t.pop()||{});let r=t,{baseURL:a,mapper:s=i=>`${i}.js`,onError:l=(i,m)=>console.error(`[defineWebComponents] ${i}:`,m)}=n,S=a?new URL(a,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),g=i=>i.toLowerCase().replace(/(^|-)([a-z])/g,(m,P,L)=>L.toUpperCase()),d=async i=>{try{if(customElements.get(i))return{tag:i,status:"already-defined"};let m=s(i),L=await import(m instanceof URL?m.href:new URL(m,S).href),c=L?.default??L?.[g(i)];if(!c){if(customElements.get(i))return{tag:i,status:"self-defined"};throw new Error(`No export found for ${i}. Expected default export or named export "${g(i)}".`)}return customElements.get(i)?{tag:i,status:"race-already-defined"}:(customElements.define(i,c),{tag:i,status:"defined"})}catch(m){throw l(i,m),m}};return Promise.all(r.map(d))}};var dt=/^[a-z][a-z0-9+\-.]*:\/\//i,$=(()=>{try{return import.meta.url}catch{return}})(),K=e=>typeof e=="string"&&e.length&&!e.endsWith("/")?`${e}/`:e;function G(e,t={}){if(!e||dt.test(e))return e;let{preferModule:n=!0}=t,r=()=>{if(!$)return null;try{return new URL(e,$).href}catch{return null}},a=()=>{if(typeof window>"u"||!window.location?.origin)return null;try{return new URL(e,window.location.origin).href}catch{return null}};return(n?r()||a():a()||r())||e}var Ce=(()=>{if($)try{let e=new URL($);if(/\/public\/assets\/js\//.test(e.pathname))return new URL("../pds/",$).href}catch{return}})(),Te=!1;function Me(e){Te||typeof document>"u"||(Te=!0,e.addEventListener("pds:ready",t=>{let n=t.detail?.mode;n&&document.documentElement.classList.add(`pds-${n}`,"pds-ready")}))}function ke({manageTheme:e,themeStorageKey:t,applyResolvedTheme:n,setupSystemListenerIfNeeded:r}){let a="light",s=null;if(e&&typeof window<"u"){try{s=localStorage.getItem(t)||null}catch{s=null}try{n?.(s),r?.(s)}catch{}s?s==="system"?a=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":a=s:a=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}return{resolvedTheme:a,storedTheme:s}}function q(e,{resolvePublicAssetURL:t}){let n=!!(e?.public?.root||e?.static?.root),r=t(e);return!n&&Ce&&(r=Ce),K(G(r))}async function Ue(e,{baseEnhancers:t=[]}={}){let{autoDefineBaseURL:n="/auto-define/",autoDefinePreload:r=[],autoDefineMapper:a=null,enhancers:s=[],autoDefineOverrides:l=null,autoDefinePreferModule:S=!0}=e,g=(()=>{let i=new Map;return(t||[]).forEach(m=>i.set(m.selector,m)),(s||[]).forEach(m=>i.set(m.selector,m)),Array.from(i.values())})(),d=null;if(typeof window<"u"&&typeof document<"u"){let i=H,m=u=>{switch(u){case"pds-tabpanel":return"pds-tabstrip.js";default:return`${u}.js`}},{mapper:P,enhancers:L,...c}=l&&typeof l=="object"?l:{},y=L?Array.isArray(L)?L:typeof L=="object"?Object.values(L):[]:[],_=(()=>{let u=new Map;return(g||[]).forEach(b=>{b?.selector&&u.set(b.selector,b)}),(y||[]).forEach(b=>{if(!b?.selector)return;let E=u.get(b.selector)||null;u.set(b.selector,{...E||{},...b,run:typeof b?.run=="function"?b.run:E?.run})}),Array.from(u.values())})(),w={baseURL:n&&K(G(n,{preferModule:S})),predefine:r,scanExisting:!0,observeShadows:!0,patchAttachShadow:!0,debounceMs:16,enhancers:_,onError:(u,b)=>{if(typeof u=="string"&&u.startsWith("pds-")){let x=["pds-form","pds-drawer"].includes(u),U=b?.message?.includes("#pds/lit")||b?.message?.includes("Failed to resolve module specifier");x&&U?o.log("error",`\u274C PDS component <${u}> requires Lit but #pds/lit is not in import map.
2
- See: https://github.com/Pure-Web-Foundation/pure-ds/blob/main/readme.md#lit-components-not-working`):o.log("warn",`\u26A0\uFE0F PDS component <${u}> not found. Assets may not be installed.`)}else o.log("error",`\u274C Auto-define error for <${u}>:`,b)},...c,mapper:u=>{if(customElements.get(u))return null;if(typeof a=="function")try{let b=a(u);return b===void 0?m(u):b}catch(b){return o.log("warn","Custom autoDefine.mapper error; falling back to default:",b?.message||b),m(u)}return m(u)}};d=new i(w),r.length>0&&typeof i.define=="function"&&await i.define(...r,{baseURL:n,mapper:w.mapper,onError:w.onError})}return{autoDefiner:d,mergedEnhancers:g}}var fe=["light","dark"],pe=new Set(fe);function ft(e){let n=(Array.isArray(e?.themes)?e.themes.map(r=>String(r).toLowerCase()):fe).filter(r=>pe.has(r));return n.length?n:fe}function me(e,{preferDocument:t=!0}={}){let n=String(e||"").toLowerCase();if(pe.has(n))return n;if(t&&typeof document<"u"){let r=document.documentElement?.getAttribute("data-theme");if(pe.has(r))return r}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function je(e,t){let n=me(t);return ft(e).includes(n)}var pt=new Set(["log","warn","error","debug","info"]),mt="__PURE_DS_PDS_SINGLETON__",he=null,ye=null;function Oe(){try{let t=(typeof globalThis<"u"?globalThis:window)?.[mt];if(t&&typeof t=="object")return t}catch{return null}return null}function ht(e){return!e||typeof e!="object"?null:{mode:e.mode==="live"||e.mode==="static"?e.mode:null,debug:e.debug===!0,thisArg:e.thisArg}}function yt(e){if(typeof e!="string")return"log";let t=e.toLowerCase();return pt.has(t)?t:"log"}function gt(){if(typeof ye=="function")try{let t=ht(ye());if(t)return t}catch{}let e=Oe();if(e){let t=e?.mode||e?.compiled?.mode||(e?.registry?.isLive?"live":"static"),n=(e?.debug||e?.currentConfig?.debug||e?.currentConfig?.design?.debug||e?.compiled?.debug||e?.compiled?.design?.debug||!1)===!0;return{mode:t,debug:n,thisArg:e}}return{mode:null,debug:!1}}function wt(){if(typeof he=="function")try{let t=he();if(typeof t=="function")return t}catch{}let e=Oe();return typeof e?.logHandler=="function"?e.logHandler:null}function $e(e,t,...n){if(typeof console>"u")return;let r=typeof console[e]=="function"?console[e].bind(console):typeof console.log=="function"?console.log.bind(console):null;r&&(n.length>0?r(t,...n):r(t))}function bt(e,t){let n=t?.debug===!0;return!(t?.mode==="static"&&!n||!n&&e!=="error"&&e!=="warn")}function Ne({getLogger:e,getContext:t}={}){he=typeof e=="function"?e:null,ye=typeof t=="function"?t:null}function Ie(e="log",t,...n){let r=yt(e),a=gt(),s=wt();if(s)try{s.call(a?.thisArg,r,t,...n);return}catch(l){$e("error","Custom log handler failed:",l)}bt(r,a)&&$e(r,t,...n)}typeof o.initializing!="boolean"&&(o.initializing=!1);"currentPreset"in o||(o.currentPreset=null);typeof o.debug!="boolean"&&(o.debug=!1);"currentConfig"in o||(o.currentConfig=null);"compiled"in o||(o.compiled=null);typeof o.logHandler!="function"&&(o.logHandler=null);"mode"in o||(o.mode=null);var J=null,V=null,Y=null,Q=null,Z=null,X=null,We="__pdsLocalizationRuntime";function M(){if(X)return X;let e=o?.[We];return e&&typeof e=="object"?(X=e,e):null}function St(e){let t=e&&typeof e=="object"?e:null;X=t,o[We]=t}Ne({getLogger:()=>typeof o.logHandler=="function"?o.logHandler:null,getContext:()=>{let e=o?.mode||o?.compiled?.mode||(o?.registry?.isLive?"live":"static"),t=(o?.debug||o?.currentConfig?.debug||o?.currentConfig?.design?.debug||o?.compiled?.debug||o?.compiled?.design?.debug||!1)===!0;return{mode:e,debug:t,thisArg:o}}});o.log=(e="log",t,...n)=>{Ie(e,t,...n)};var A={locale:"en",messages:{},hasProvider:!1},ee=new Set;function Be(e){return!!e&&typeof e!="string"&&typeof e=="object"&&"strTag"in e}function He(e=[]){let t="";for(let n=0;n<=e.length-1;n+=1)t+=e[n],n<e.length-1&&(t+=`{${n}}`);return t}function _t(e,t){return String(e).replace(/\{(\d+)\}/g,(n,r)=>t(Number(r)))}function Lt(e){if(!e||typeof e!="object")return{};let t={};for(let[n,r]of Object.entries(e)){if(typeof r=="string"){t[n]=r;continue}r&&typeof r=="object"&&typeof r.content=="string"&&(t[n]=r.content)}return t}function Et(e,...t){return{strTag:!0,strings:Array.from(e||[]),values:t,raw:Array.from(e?.raw||[])}}function vt(e){if(!e)return"";if(Be(e)){let n=He(e.strings||[]),r=A.messages[n]||n;return _t(r,a=>e.values?.[a])}let t=String(e);return A.messages[t]||t}function At(e){if(!e)return;let t=Be(e)?He(e.strings||[]):String(e);typeof t=="string"&&t.length>0&&ee.add(t)}function Ke(e){if(!e||typeof e.msg!="function"||ee.size===0)return;let t=Array.from(ee);ee.clear();for(let n of t)try{e.msg(n)}catch{}}async function N(){let e=M();return e||(Z||(Z=import(I("pds-localization.js")).then(n=>{if(typeof n?.msg!="function"||typeof n?.str!="function"||typeof n?.configureLocalization!="function"||typeof n?.loadLocale!="function"||typeof n?.setLocale!="function"||typeof n?.getLocalizationState!="function")throw new Error("Failed to load localization runtime exports");return St(n),Ke(n),n}).catch(n=>{throw Z=null,n})),Z)}var Ge=(e,t={})=>{let n=M();return typeof n?.msg=="function"?n.msg(e,t):(At(e),vt(e,t))},qe=(e,...t)=>{let n=M();return typeof n?.str=="function"?n.str(e,...t):Et(e,...t)},te=(e=null)=>{let t=M();if(typeof t?.configureLocalization=="function")return t.configureLocalization(e);if(!e||typeof e!="object")return A.locale="en",A.messages={},A.hasProvider=!1,{locale:A.locale,messages:{...A.messages},hasProvider:A.hasProvider};typeof e.locale=="string"&&e.locale.trim()&&(A.locale=e.locale.trim()),Object.prototype.hasOwnProperty.call(e,"messages")&&(A.messages=Lt(e.messages));let n=!!(e.provider||e.translate||e.loadLocale||e.setLocale);return A.hasProvider=n,n&&N().then(r=>{r.configureLocalization(e),Ke(r)}).catch(()=>{}),{locale:A.locale,messages:{...A.messages},hasProvider:A.hasProvider}},Je=async e=>(await N()).loadLocale(e),Ve=async(e,t={})=>(await N()).setLocale(e,t),Ye=()=>{let e=M();return typeof e?.getLocalizationState=="function"?e.getLocalizationState():{locale:A.locale,messages:{...A.messages},hasProvider:A.hasProvider}},Qe=(e={})=>{let t=M();if(typeof t?.createJSONLocalization=="function")return t.createJSONLocalization(e);let n=typeof e?.locale=="string"&&e.locale.trim()?e.locale.trim().toLowerCase():"en",r=Array.isArray(e?.locales)?e.locales.map(g=>String(g||"").trim().toLowerCase()).filter(Boolean):[],a=Array.from(new Set([n,...r])),s=null,l=async()=>(s||(s=N().then(g=>typeof g?.createJSONLocalization=="function"?g.createJSONLocalization(e):null).catch(()=>null)),s),S=async(g="loadLocale")=>{let d=await l();if(!d||typeof d!="object")return null;let i=d.provider;if(!i||typeof i!="object")return null;let m=i[g];return typeof m=="function"?m:g==="setLocale"&&typeof i.loadLocale=="function"?i.loadLocale:null};return{locale:n,locales:[...a],provider:{locales:[...a],async loadLocale(g={}){let d=await S("loadLocale");return typeof d!="function"?{}:d(g)},async setLocale(g={}){let d=await S("setLocale");return typeof d!="function"?{}:d(g)}}}};function I(e,t){return t&&typeof t=="string"?t:`${q(o.currentConfig||{},{resolvePublicAssetURL:B})}core/${e}`}async function Pt(){return Array.isArray(o.defaultEnhancers)&&o.defaultEnhancers.length>0?o.defaultEnhancers:(Q||(Q=import(I("pds-enhancers.js",o.currentConfig?.enhancersURL)).then(t=>{let n=Array.isArray(t?.defaultPDSEnhancers)?t.defaultPDSEnhancers:[];return o.defaultEnhancers=n,n}).catch(t=>{throw Q=null,t})),Q)}async function xt(){return typeof o.ask=="function"&&o.ask!==Ze?o.ask:(V||(V=import(I("pds-ask.js",o.currentConfig?.askURL)).then(t=>{let n=t?.ask;if(typeof n!="function")throw new Error("Failed to load ask helper");return o.ask=n,n}).catch(t=>{throw V=null,t})),V)}async function F(){return typeof o.toast=="function"&&o.toast!==k?o.toast:(Y||(Y=import(I("pds-toast.js",o.currentConfig?.toastURL)).then(t=>{let n=t?.toast;if(typeof n!="function")throw new Error("Failed to load toast helper");return o.toast=n,n}).catch(t=>{throw Y=null,t})),Y)}async function Ze(...e){return(await xt())(...e)}async function k(...e){return(await F())(...e)}k.success=async(...e)=>(await F()).success(...e);k.error=async(...e)=>(await F()).error(...e);k.warning=async(...e)=>(await F()).warning(...e);k.info=async(...e)=>(await F()).info(...e);var Fe=function(e="log",t,...n){o.log(e,t,...n)};function we(e){if(e==null)return e;if(typeof e=="function")return;if(typeof e!="object")return e;if(Array.isArray(e))return e.map(n=>we(n)).filter(n=>n!==void 0);let t={};for(let[n,r]of Object.entries(e)){let a=we(r);a!==void 0&&(t[n]=a)}return t}function Xe(e,t=new WeakSet){if(!e||typeof e!="object"||t.has(e))return e;t.add(e),Object.freeze(e);for(let n of Object.keys(e))Xe(e[n],t);return e}function be(e){return e==null||typeof e!="object"?e:Xe(structuredClone(we(e)))}async function Rt(e,t={}){if(t?.runtimeConfig===!1||typeof fetch!="function")return null;let n=t?.runtimeConfigURL||`${e}pds-runtime-config.json`;try{let r=await fetch(n,{cache:"no-store"});return r.ok?await r.json():null}catch{return null}}o.registry=T;o.enums=xe;o.adoptLayers=Ae;o.adoptPrimitives=ve;o.parse=ue;o.createStylesheet=Pe;o.isLiveMode=()=>T.isLive;o.ask=Ze;o.toast=k;o.common=de;o.msg=Ge;o.str=qe;o.configureLocalization=te;o.loadLocale=Je;o.setLocale=Ve;o.getLocalizationState=Ye;o.createJSONLocalization=Qe;o.i18n={msg:Ge,str:qe,configure:te,loadLocale:Je,setLocale:Ve,getState:Ye,createJSONLocalization:Qe};o.AutoComplete=null;o.loadAutoComplete=async()=>{if(o.AutoComplete&&typeof o.AutoComplete.connect=="function")return o.AutoComplete;let e=I("pds-autocomplete.js",o.currentConfig?.autoCompleteURL);return J||(J=import(e).then(t=>{let n=t?.AutoComplete||t?.default?.AutoComplete||t?.default||null;if(!n)throw new Error("AutoComplete export not found in module");return o.AutoComplete=n,n}).catch(t=>{throw J=null,t})),J};function et(e){let t=typeof CustomEvent=="function";try{let n=t?new CustomEvent("pds:ready",{detail:e}):new Event("pds:ready");o.dispatchEvent(n)}catch{}if(typeof document<"u")if(t){let n={detail:e,bubbles:!0,composed:!0};try{document.dispatchEvent(new CustomEvent("pds:ready",n))}catch{}try{document.dispatchEvent(new CustomEvent("pds-ready",n))}catch{}}else{try{document.dispatchEvent(new Event("pds:ready"))}catch{}try{document.dispatchEvent(new Event("pds-ready"))}catch{}}}function tt(e={}){let t=typeof CustomEvent=="function",n={at:Date.now(),...e};try{let r=t?new CustomEvent("pds:config-changed",{detail:n}):new Event("pds:config-changed");o.dispatchEvent(r)}catch{}if(typeof document<"u")if(t){let r={detail:n,bubbles:!0,composed:!0};try{document.dispatchEvent(new CustomEvent("pds:config-changed",r))}catch{}}else try{document.dispatchEvent(new Event("pds:config-changed"))}catch{}}var ge="pure-ds-theme",D=null,O=null;function ne(e){try{if(typeof document>"u")return;let t="light";e?e==="system"?t=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t=e:t=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",document.documentElement.setAttribute("data-theme",t)}catch{}}function re(e){try{if(D&&O){try{typeof D.removeEventListener=="function"?D.removeEventListener("change",O):typeof D.removeListener=="function"&&D.removeListener(O)}catch{}D=null,O=null}if(e==="system"&&typeof window<"u"&&window.matchMedia){let t=window.matchMedia("(prefers-color-scheme: dark)"),n=r=>{let a=r?.matches===void 0?t.matches:r.matches;try{let s=a?"dark":"light";document.documentElement.setAttribute("data-theme",s),o.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:s,source:"system"}}))}catch{}};D=t,O=n,typeof t.addEventListener=="function"?t.addEventListener("change",n):typeof t.addListener=="function"&&t.addListener(n)}}catch{}}var Dt=Object.getOwnPropertyDescriptor(o,"theme");Dt||Object.defineProperty(o,"theme",{get(){try{return typeof window>"u"?null:localStorage.getItem(ge)||null}catch{return null}},set(e){try{if(typeof window>"u")return;let t=o.currentConfig?.design||null,n=me(e);if(t&&!je(t,n)){let r=t?.name||o.currentPreset?.name||o.currentConfig?.preset||"current preset";o.log("warn",`PDS theme "${n}" not supported by preset "${r}".`),o.dispatchEvent(new CustomEvent("pds:theme:blocked",{detail:{theme:e,resolvedTheme:n,preset:r}}));return}e==null?localStorage.removeItem(ge):localStorage.setItem(ge,e),ne(e),re(e),o.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:e,source:"api"}}))}catch{}}});o.defaultEnhancers=[];async function zt(e){o.initializing=!0;try{let t=e&&e.mode||"live",{mode:n,...r}=e||{};o.mode=t,o.logHandler=typeof r?.log=="function"?r.log:null,o.currentConfig=be(r);let a=r&&typeof r.localization=="object"&&r.localization?r.localization:null;a?(await N(),te(a)):te(null);let s;if(t==="static")s=await Ct(r);else{let{localization:S,...g}=r||{},d=q(g,{resolvePublicAssetURL:B}),i=g?.managerURL||g?.public?.managerURL||g?.manager?.url||new URL("core/pds-manager.js",d).href||new URL("./pds-manager.js",import.meta.url).href,{startLive:m}=await import(i);s=await m(o,g,{emitReady:et,emitConfigChanged:tt,applyResolvedTheme:ne,setupSystemListenerIfNeeded:re})}o.compiled=be(s?.config||null);let l=o?.compiled?.design?.icons?.externalPath||"/assets/img/icons/";return o.log("info",`startup ready; external icon path: ${l}`),s}finally{o.initializing=!1}}o.start=zt;async function Ct(e){if(!e||typeof e!="object")throw new Error("PDS.start({ mode: 'static', ... }) requires a valid configuration object");let t=e.applyGlobalStyles??!0,n=e.manageTheme??!0,r=e.themeStorageKey??"pure-ds-theme",a=e.staticPaths??{},s=q(e,{resolvePublicAssetURL:B}),l=e&&e.autoDefine||null,S;l&&l.baseURL?S=K(G(l.baseURL,{preferModule:!1})):S=`${s}components/`;let g=l&&Array.isArray(l.predefine)&&l.predefine||[],d=l&&typeof l.mapper=="function"&&l.mapper||null;try{Me(o);let{resolvedTheme:i}=ke({manageTheme:n,themeStorageKey:r,applyResolvedTheme:ne,setupSystemListenerIfNeeded:re}),m=await Rt(s,e),P=Array.isArray(e?.enhancers)?e.enhancers:e?.enhancers&&typeof e.enhancers=="object"?Object.values(e.enhancers):[],L=m?.config?{...m.config,...e,design:e?.design||m.config.design,preset:e?.preset||m.config.preset}:{...e},c={tokens:`${s}styles/pds-tokens.css.js`,primitives:`${s}styles/pds-primitives.css.js`,components:`${s}styles/pds-components.css.js`,utilities:`${s}styles/pds-utilities.css.js`,styles:`${s}styles/pds-styles.css.js`},y=m?.paths||{};if(a={...c,...y,...a},o.registry.setStaticMode(a),t&&typeof document<"u")try{let w=await o.registry.getStylesheet("styles");if(w){w._pds=!0;let u=(document.adoptedStyleSheets||[]).filter(b=>b._pds!==!0);document.adoptedStyleSheets=[...u,w],tt({mode:"static",source:"static:styles-applied"})}}catch(w){Fe.call(o,"warn","Failed to apply static styles:",w)}let _=null,v=[];try{let w=await Pt(),u=await Ue({autoDefineBaseURL:S,autoDefinePreload:g,autoDefineMapper:d,enhancers:P,autoDefineOverrides:l||null,autoDefinePreferModule:!(l&&l.baseURL)},{baseEnhancers:w});_=u.autoDefiner,v=u.mergedEnhancers||[]}catch(w){Fe.call(o,"error","\u274C Failed to initialize AutoDefiner/Enhancers (static):",w)}return o.compiled=be({mode:"static",...L,theme:i,enhancers:v}),et({mode:"static",config:L,theme:i,autoDefiner:_}),{config:L,theme:i,autoDefiner:_}}catch(i){throw o.dispatchEvent(new CustomEvent("pds:error",{detail:{error:i}})),i}}var tn=ne,nn=re;export{o as PDS,tn as applyResolvedTheme,te as configureLocalization,Qe as createJSONLocalization,Ye as getLocalizationState,Je as loadLocale,Ge as msg,Ve as setLocale,nn as setupSystemListenerIfNeeded,qe as str};
1
+ var ot=Object.defineProperty;var st=(e,t)=>{for(var n in t)ot(e,n,{get:t[n],enumerable:!0})};var ae=class extends EventTarget{constructor(){super(),this.mode=null,this.compiled=null,this.log=()=>{},this.logHandler=null}},ve="__PURE_DS_PDS_SINGLETON__",ce=typeof globalThis<"u"?globalThis:window,ie=ce?.[ve],o=ie&&typeof ie.addEventListener=="function"?ie:new ae;ce&&(ce[ve]=o);typeof o.log!="function"&&(o.log=(e="log",t,...n)=>{if(typeof console>"u")return;let r=typeof console[e]=="function"?console[e].bind(console):typeof console.log=="function"?console.log.bind(console):null;r&&(n.length>0?r(t,...n):r(t))});typeof o.logHandler!="function"&&(o.logHandler=null);var le=class{constructor(){this._mode="static",this._staticPaths={tokens:"/assets/pds/styles/pds-tokens.css.js",primitives:"/assets/pds/styles/pds-primitives.css.js",components:"/assets/pds/styles/pds-components.css.js",utilities:"/assets/pds/styles/pds-utilities.css.js",styles:"/assets/pds/styles/pds-styles.css.js"}}setLiveMode(){this._mode="live"}setStaticMode(t={}){this._mode="static",this._staticPaths={...this._staticPaths,...t}}async getStylesheet(t){if(this._mode==="live")return null;try{return(await import(this._staticPaths[t]))[t]}catch(n){o.log("error",`Registry: failed to load static ${t}:`,n),o.log("error",`Registry: looking for ${this._staticPaths[t]}`),o.log("error","Registry: make sure you've run 'npm run pds:build' and configured PDS.start() with the correct static.root path");let r=new CSSStyleSheet;return r.replaceSync("/* Failed to load "+t+" */"),r}}get mode(){return this._mode}get isLive(){return this._mode==="live"}},C=new le;async function Ae(e,t=[],n=null){try{let r=n?.primitivesStylesheet?n.primitivesStylesheet:await C.getStylesheet("primitives");e.adoptedStyleSheets=[r,...t]}catch(r){let a=e.host?.tagName?.toLowerCase()||"unknown";o.log("error",`Adopter: <${a}> failed to adopt primitives:`,r),e.adoptedStyleSheets=t}}async function Pe(e,t=["primitives"],n=[],r=null){let a=Array.isArray(n)?n.filter(Boolean):[];if(a.length){let l=(Array.isArray(e.adoptedStyleSheets)?e.adoptedStyleSheets:[]).filter(S=>!a.includes(S));e.adoptedStyleSheets=[...l,...a]}try{let l=(await Promise.all(t.map(async S=>{if(r)switch(S){case"tokens":return r.tokensStylesheet;case"primitives":return r.primitivesStylesheet;case"components":return r.componentsStylesheet;case"utilities":return r.utilitiesStylesheet;default:break}return C.getStylesheet(S)}))).filter(S=>S!==null);e.adoptedStyleSheets=[...l,...a]}catch(s){let l=e.host?.tagName?.toLowerCase()||"unknown";o.log("error",`Adopter: <${l}> failed to adopt layers:`,s),e.adoptedStyleSheets=a}}function xe(e){let t=new CSSStyleSheet;return t.replaceSync(e),t}var Re={FontWeights:{light:300,normal:400,medium:500,semibold:600,bold:700},LineHeights:{tight:1.25,normal:1.5,relaxed:1.75},BorderWidths:{hairline:.5,thin:1,medium:2,thick:3},RadiusSizes:{none:0,small:4,medium:8,large:16,xlarge:24,xxlarge:32},ShadowDepths:{none:"none",light:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",medium:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",deep:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",extreme:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"},TransitionSpeeds:{fast:150,normal:250,slow:350},AnimationEasings:{linear:"linear",ease:"ease","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out",bounce:"cubic-bezier(0.68, -0.55, 0.265, 1.55)"},TouchTargetSizes:{compact:36,standard:44,comfortable:48,spacious:56},LinkStyles:{inline:"inline",block:"block",button:"button"},FocusStyles:{ring:"ring",outline:"outline",border:"border",glow:"glow"},TabSizes:{compact:2,standard:4,wide:8},SelectIcons:{chevron:"chevron",arrow:"arrow",caret:"caret",none:"none"},IconSizes:{xs:16,sm:20,md:24,lg:32,xl:48,"2xl":64,"3xl":96}};var fe={};st(fe,{deepMerge:()=>De,fragmentFromTemplateLike:()=>ue,isObject:()=>W,parseFragment:()=>B,parseHTML:()=>de});function W(e){return e&&typeof e=="object"&&!Array.isArray(e)}function De(e,t){let n={...e};return W(e)&&W(t)&&Object.keys(t).forEach(r=>{W(t[r])?r in e?n[r]=De(e[r],t[r]):Object.assign(n,{[r]:t[r]}):Object.assign(n,{[r]:t[r]})}),n}function ue(e){let t=Array.isArray(e?.strings)?e.strings:[],n=Array.isArray(e?.values)?e.values:[],r=new Set,a=[],s=/(\s)(\.[\w-]+)=\s*$/,l=/(\s)(@[\w-]+)=\s*$/,S=/(\s)(\?[\w-]+)=\s*$/,g=/(\s)([\w:-]+)=\s*$/;for(let c=0;c<t.length;c+=1){let y=t[c]??"";if(c<n.length){let _=`pds-val-${c}`,v=y.match(s),w=y.match(l),u=y.match(S),b=y.match(g);if(v){let E=v[2].slice(1);y=y.replace(s,`$1data-pds-bind-${c}="prop:${E}:${_}"`),r.add(c)}else if(w){let E=w[2].slice(1);y=y.replace(l,`$1data-pds-bind-${c}="event:${E}:${_}"`),r.add(c)}else if(u){let E=u[2].slice(1);y=y.replace(S,`$1data-pds-bind-${c}="boolean:${E}:${_}"`),r.add(c)}else if(b){let E=b[2];y=y.replace(g,`$1data-pds-bind-${c}="attr:${E}:${_}"`),r.add(c)}}a.push(y),c<n.length&&!r.has(c)&&a.push(`<!--pds-val-${c}-->`)}let d=document.createElement("template");d.innerHTML=a.join("");let i=(c,y)=>{let _=c.parentNode;if(!_)return;if(y==null){_.removeChild(c);return}let v=w=>{if(w!=null){if(w instanceof Node){_.insertBefore(w,c);return}if(Array.isArray(w)){w.forEach(u=>v(u));return}_.insertBefore(document.createTextNode(String(w)),c)}};v(y),_.removeChild(c)},m=document.createTreeWalker(d.content,NodeFilter.SHOW_COMMENT),P=[];for(;m.nextNode();){let c=m.currentNode;c?.nodeValue?.startsWith("pds-val-")&&P.push(c)}return P.forEach(c=>{let y=Number(c.nodeValue.replace("pds-val-",""));i(c,n[y])}),d.content.querySelectorAll("*").forEach(c=>{[...c.attributes].forEach(y=>{if(!y.name.startsWith("data-pds-bind-"))return;let _=y.value.indexOf(":"),v=y.value.lastIndexOf(":");if(_<=0||v<=_){c.removeAttribute(y.name);return}let w=y.value.slice(0,_),u=y.value.slice(_+1,v),b=y.value.slice(v+1),E=Number(String(b).replace("pds-val-","")),x=n[E];if(!u||!Number.isInteger(E)){c.removeAttribute(y.name);return}w==="prop"?c[u]=x:w==="event"?(typeof x=="function"||x&&typeof x.handleEvent=="function")&&c.addEventListener(u,x):w==="boolean"?x?c.setAttribute(u,""):c.removeAttribute(u):w==="attr"&&(x==null||x===!1?c.removeAttribute(u):c.setAttribute(u,String(x))),c.removeAttribute(y.name)})}),d.content}function B(e,...t){if(Array.isArray(e)&&Object.prototype.hasOwnProperty.call(e,"raw"))return ue({strings:Array.from(e),values:t});if(Array.isArray(e?.strings)&&Array.isArray(e?.values))return ue({strings:e.strings,values:e.values});let r=document.createElement("template");return r.innerHTML=String(e??""),r.content}function de(e,...t){return B(e,...t).childNodes}var ze="pds",it=/^([a-z][a-z0-9+\-.]*:)?\/\//i,Te=/^[a-z]:/i;function j(e=""){return e.endsWith("/")?e:`${e}/`}function at(e="",t=ze){let n=e.replace(/\/+$/,"");return new RegExp(`(?:^|/)${t}$`,"i").test(n)?n:`${n}/${t}`}function ct(e){return e.replace(/^\.\/+/,"")}function lt(e){return Te.test(e)?e.replace(Te,"").replace(/^\/+/,""):e}function ut(e){return e.startsWith("public/")?e.substring(7):e}function H(e,t={}){let n=t.segment||ze,r=t.defaultRoot||`/assets/${n}/`,a=e?.public&&e.public?.root||e?.static&&e.static?.root||null;if(!a||typeof a!="string")return j(r);let s=a.trim();return s?(s=s.replace(/\\/g,"/"),s=at(s,n),s=j(s),it.test(s)?s:(s=ct(s),s=lt(s),s.startsWith("/")||(s=ut(s),s.startsWith("/")||(s=`/${s}`),s=s.replace(/\/+/g,(l,S)=>S===0?l:"/")),j(s))):j(r)}async function dt(...e){let t={};e.length&&typeof e[e.length-1]=="object"&&(t=e.pop()||{});let n=e,{baseURL:r,mapper:a=d=>`${d}.js`,onError:s=(d,i)=>console.error(`[defineWebComponents] ${d}:`,i)}=t,l=r?new URL(r,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),S=d=>d.toLowerCase().replace(/(^|-)([a-z])/g,(i,m,P)=>P.toUpperCase()),g=async d=>{try{if(customElements.get(d))return{tag:d,status:"already-defined"};let i=a(d),P=await import(i instanceof URL?i.href:new URL(i,l).href),L=P?.default??P?.[S(d)];if(!L){if(customElements.get(d))return{tag:d,status:"self-defined"};throw new Error(`No export found for ${d}. Expected default export or named export "${S(d)}".`)}return customElements.get(d)?{tag:d,status:"race-already-defined"}:(customElements.define(d,L),{tag:d,status:"defined"})}catch(i){throw s(d,i),i}};return Promise.all(n.map(g))}var K=class{constructor(t={}){let{baseURL:n,mapper:r,onError:a,predicate:s=()=>!0,attributeModule:l="data-module",root:S=document,scanExisting:g=!0,debounceMs:d=16,observeShadows:i=!0,enhancers:m=[],patchAttachShadow:P=!0}=t,L=new Set,c=new Set,y=new Set,_=new Map,v=new WeakMap,w=new WeakMap,u=0,b=!1,E=null,x=f=>{if(!f||!m.length)return;let h=w.get(f);h||(h=new Set,w.set(f,h));for(let p of m)if(!(!p.selector||!p.run)&&!h.has(p.selector))try{f.matches&&f.matches(p.selector)&&(p.run(f),h.add(p.selector))}catch(R){console.warn(`[AutoDefiner] Error applying enhancer for selector "${p.selector}":`,R)}},U=(f,h)=>{if(!b&&!(!f||!f.includes("-"))&&!customElements.get(f)&&!c.has(f)&&!y.has(f)){if(h&&h.getAttribute){let p=h.getAttribute(l);p&&!_.has(f)&&_.set(f,p)}L.add(f),rt()}},rt=()=>{u||(u=setTimeout(_e,d))},T=f=>{if(f){if(f.nodeType===1){let h=f,p=h.tagName?.toLowerCase();p&&p.includes("-")&&!customElements.get(p)&&s(p,h)&&U(p,h),x(h),i&&h.shadowRoot&&se(h.shadowRoot)}f.querySelectorAll&&f.querySelectorAll("*").forEach(h=>{let p=h.tagName?.toLowerCase();p&&p.includes("-")&&!customElements.get(p)&&s(p,h)&&U(p,h),x(h),i&&h.shadowRoot&&se(h.shadowRoot)})}},se=f=>{if(!f||v.has(f))return;T(f);let h=new MutationObserver(p=>{for(let R of p)R.addedNodes?.forEach(z=>{T(z)}),R.type==="attributes"&&R.target&&T(R.target)});h.observe(f,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[l,...m.map(p=>p.selector).filter(p=>p.startsWith("data-"))]}),v.set(f,h)};async function _e(){if(clearTimeout(u),u=0,!L.size)return;let f=Array.from(L);L.clear(),f.forEach(h=>c.add(h));try{let h=p=>_.get(p)??(r?r(p):`${p}.js`);await dt(...f,{baseURL:n,mapper:h,onError:(p,R)=>{y.add(p),a?.(p,R)}})}catch{}finally{f.forEach(h=>c.delete(h))}}let Le=S===document?document.documentElement:S,Ee=new MutationObserver(f=>{for(let h of f)h.addedNodes?.forEach(p=>{T(p)}),h.type==="attributes"&&h.target&&T(h.target)});if(Ee.observe(Le,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[l,...m.map(f=>f.selector).filter(f=>f.startsWith("data-"))]}),i&&P&&Element.prototype.attachShadow){let f=Element.prototype.attachShadow;Element.prototype.attachShadow=function(p){let R=f.call(this,p);if(p&&p.mode==="open"){se(R);let z=this.tagName?.toLowerCase();z&&z.includes("-")&&!customElements.get(z)&&U(z,this)}return R},E=()=>Element.prototype.attachShadow=f}return g&&T(Le),{stop(){b=!0,Ee.disconnect(),E&&E(),u&&(clearTimeout(u),u=0),v.forEach(f=>f.disconnect())},flush:_e}}static async define(...t){let n={};t.length&&typeof t[t.length-1]=="object"&&(n=t.pop()||{});let r=t,{baseURL:a,mapper:s=i=>`${i}.js`,onError:l=(i,m)=>console.error(`[defineWebComponents] ${i}:`,m)}=n,S=a?new URL(a,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),g=i=>i.toLowerCase().replace(/(^|-)([a-z])/g,(m,P,L)=>L.toUpperCase()),d=async i=>{try{if(customElements.get(i))return{tag:i,status:"already-defined"};let m=s(i),L=await import(m instanceof URL?m.href:new URL(m,S).href),c=L?.default??L?.[g(i)];if(!c){if(customElements.get(i))return{tag:i,status:"self-defined"};throw new Error(`No export found for ${i}. Expected default export or named export "${g(i)}".`)}return customElements.get(i)?{tag:i,status:"race-already-defined"}:(customElements.define(i,c),{tag:i,status:"defined"})}catch(m){throw l(i,m),m}};return Promise.all(r.map(d))}};var ft=/^[a-z][a-z0-9+\-.]*:\/\//i,$=(()=>{try{return import.meta.url}catch{return}})(),G=e=>typeof e=="string"&&e.length&&!e.endsWith("/")?`${e}/`:e;function q(e,t={}){if(!e||ft.test(e))return e;let{preferModule:n=!0}=t,r=()=>{if(!$)return null;try{return new URL(e,$).href}catch{return null}},a=()=>{if(typeof window>"u"||!window.location?.origin)return null;try{return new URL(e,window.location.origin).href}catch{return null}};return(n?r()||a():a()||r())||e}var Ce=(()=>{if($)try{let e=new URL($);if(/\/public\/assets\/js\//.test(e.pathname))return new URL("../pds/",$).href}catch{return}})(),Me=!1;function ke(e){Me||typeof document>"u"||(Me=!0,e.addEventListener("pds:ready",t=>{let n=t.detail?.mode;n&&document.documentElement.classList.add(`pds-${n}`,"pds-ready")}))}function Ue({manageTheme:e,themeStorageKey:t,applyResolvedTheme:n,setupSystemListenerIfNeeded:r}){let a="light",s=null;if(e&&typeof window<"u"){try{s=localStorage.getItem(t)||null}catch{s=null}try{n?.(s),r?.(s)}catch{}s?s==="system"?a=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":a=s:a=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}return{resolvedTheme:a,storedTheme:s}}function J(e,{resolvePublicAssetURL:t}){let n=!!(e?.public?.root||e?.static?.root),r=t(e);return!n&&Ce&&(r=Ce),G(q(r))}async function je(e,{baseEnhancers:t=[]}={}){let{autoDefineBaseURL:n="/auto-define/",autoDefinePreload:r=[],autoDefineMapper:a=null,enhancers:s=[],autoDefineOverrides:l=null,autoDefinePreferModule:S=!0}=e,g=(()=>{let i=new Map;return(t||[]).forEach(m=>i.set(m.selector,m)),(s||[]).forEach(m=>i.set(m.selector,m)),Array.from(i.values())})(),d=null;if(typeof window<"u"&&typeof document<"u"){let i=K,m=u=>{switch(u){case"pds-tabpanel":return"pds-tabstrip.js";default:return`${u}.js`}},{mapper:P,enhancers:L,...c}=l&&typeof l=="object"?l:{},y=L?Array.isArray(L)?L:typeof L=="object"?Object.values(L):[]:[],_=(()=>{let u=new Map;return(g||[]).forEach(b=>{b?.selector&&u.set(b.selector,b)}),(y||[]).forEach(b=>{if(!b?.selector)return;let E=u.get(b.selector)||null;u.set(b.selector,{...E||{},...b,run:typeof b?.run=="function"?b.run:E?.run})}),Array.from(u.values())})(),w={baseURL:n&&G(q(n,{preferModule:S})),predefine:r,scanExisting:!0,observeShadows:!0,patchAttachShadow:!0,debounceMs:16,enhancers:_,onError:(u,b)=>{if(typeof u=="string"&&u.startsWith("pds-")){let x=["pds-form","pds-drawer"].includes(u),U=b?.message?.includes("#pds/lit")||b?.message?.includes("Failed to resolve module specifier");x&&U?o.log("error",`\u274C PDS component <${u}> requires Lit but #pds/lit is not in import map.
2
+ See: https://github.com/Pure-Web-Foundation/pure-ds/blob/main/readme.md#lit-components-not-working`):o.log("warn",`\u26A0\uFE0F PDS component <${u}> not found. Assets may not be installed.`)}else o.log("error",`\u274C Auto-define error for <${u}>:`,b)},...c,mapper:u=>{if(customElements.get(u))return null;if(typeof a=="function")try{let b=a(u);return b===void 0?m(u):b}catch(b){return o.log("warn","Custom autoDefine.mapper error; falling back to default:",b?.message||b),m(u)}return m(u)}};d=new i(w),r.length>0&&typeof i.define=="function"&&await i.define(...r,{baseURL:n,mapper:w.mapper,onError:w.onError})}return{autoDefiner:d,mergedEnhancers:g}}var pe=["light","dark"],me=new Set(pe);function pt(e){let n=(Array.isArray(e?.themes)?e.themes.map(r=>String(r).toLowerCase()):pe).filter(r=>me.has(r));return n.length?n:pe}function he(e,{preferDocument:t=!0}={}){let n=String(e||"").toLowerCase();if(me.has(n))return n;if(t&&typeof document<"u"){let r=document.documentElement?.getAttribute("data-theme");if(me.has(r))return r}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function $e(e,t){let n=he(t);return pt(e).includes(n)}var mt=new Set(["log","warn","error","debug","info"]),ht="__PURE_DS_PDS_SINGLETON__",ye=null,ge=null;function Ne(){try{let t=(typeof globalThis<"u"?globalThis:window)?.[ht];if(t&&typeof t=="object")return t}catch{return null}return null}function yt(e){return!e||typeof e!="object"?null:{mode:e.mode==="live"||e.mode==="static"?e.mode:null,debug:e.debug===!0,thisArg:e.thisArg}}function gt(e){if(typeof e!="string")return"log";let t=e.toLowerCase();return mt.has(t)?t:"log"}function wt(){if(typeof ge=="function")try{let t=yt(ge());if(t)return t}catch{}let e=Ne();if(e){let t=e?.mode||e?.compiled?.mode||(e?.registry?.isLive?"live":"static"),n=(e?.debug||e?.currentConfig?.debug||e?.currentConfig?.design?.debug||e?.compiled?.debug||e?.compiled?.design?.debug||!1)===!0;return{mode:t,debug:n,thisArg:e}}return{mode:null,debug:!1}}function bt(){if(typeof ye=="function")try{let t=ye();if(typeof t=="function")return t}catch{}let e=Ne();return typeof e?.logHandler=="function"?e.logHandler:null}function Oe(e,t,...n){if(typeof console>"u")return;let r=typeof console[e]=="function"?console[e].bind(console):typeof console.log=="function"?console.log.bind(console):null;r&&(n.length>0?r(t,...n):r(t))}function St(e,t){let n=t?.debug===!0;return!(t?.mode==="static"&&!n||!n&&e!=="error"&&e!=="warn")}function Ie({getLogger:e,getContext:t}={}){ye=typeof e=="function"?e:null,ge=typeof t=="function"?t:null}function Fe(e="log",t,...n){let r=gt(e),a=wt(),s=bt();if(s)try{s.call(a?.thisArg,r,t,...n);return}catch(l){Oe("error","Custom log handler failed:",l)}St(r,a)&&Oe(r,t,...n)}typeof o.initializing!="boolean"&&(o.initializing=!1);"currentPreset"in o||(o.currentPreset=null);typeof o.debug!="boolean"&&(o.debug=!1);"currentConfig"in o||(o.currentConfig=null);"compiled"in o||(o.compiled=null);typeof o.logHandler!="function"&&(o.logHandler=null);"mode"in o||(o.mode=null);var V=null,Y=null,Q=null,Z=null,X=null,ee=null,Be="__pdsLocalizationRuntime";function M(){if(ee)return ee;let e=o?.[Be];return e&&typeof e=="object"?(ee=e,e):null}function _t(e){let t=e&&typeof e=="object"?e:null;ee=t,o[Be]=t}Ie({getLogger:()=>typeof o.logHandler=="function"?o.logHandler:null,getContext:()=>{let e=o?.mode||o?.compiled?.mode||(o?.registry?.isLive?"live":"static"),t=(o?.debug||o?.currentConfig?.debug||o?.currentConfig?.design?.debug||o?.compiled?.debug||o?.compiled?.design?.debug||!1)===!0;return{mode:e,debug:t,thisArg:o}}});o.log=(e="log",t,...n)=>{Fe(e,t,...n)};var A={locale:"en",messages:{},hasProvider:!1},te=new Set;function He(e){return!!e&&typeof e!="string"&&typeof e=="object"&&"strTag"in e}function Ke(e=[]){let t="";for(let n=0;n<=e.length-1;n+=1)t+=e[n],n<e.length-1&&(t+=`{${n}}`);return t}function Lt(e,t){return String(e).replace(/\{(\d+)\}/g,(n,r)=>t(Number(r)))}function Et(e){if(!e||typeof e!="object")return{};let t={};for(let[n,r]of Object.entries(e)){if(typeof r=="string"){t[n]=r;continue}r&&typeof r=="object"&&typeof r.content=="string"&&(t[n]=r.content)}return t}function vt(e,...t){return{strTag:!0,strings:Array.from(e||[]),values:t,raw:Array.from(e?.raw||[])}}function At(e){if(!e)return"";if(He(e)){let n=Ke(e.strings||[]),r=A.messages[n]||n;return Lt(r,a=>e.values?.[a])}let t=String(e);return A.messages[t]||t}function Pt(e){if(!e)return;let t=He(e)?Ke(e.strings||[]):String(e);typeof t=="string"&&t.length>0&&te.add(t)}function Ge(e){if(!e||typeof e.msg!="function"||te.size===0)return;let t=Array.from(te);te.clear();for(let n of t)try{e.msg(n)}catch{}}async function N(){let e=M();return e||(X||(X=import(I("pds-localization.js")).then(n=>{if(typeof n?.msg!="function"||typeof n?.str!="function"||typeof n?.configureLocalization!="function"||typeof n?.loadLocale!="function"||typeof n?.setLocale!="function"||typeof n?.getLocalizationState!="function")throw new Error("Failed to load localization runtime exports");return _t(n),Ge(n),n}).catch(n=>{throw X=null,n})),X)}var qe=(e,t={})=>{let n=M();return typeof n?.msg=="function"?n.msg(e,t):(Pt(e),At(e,t))},Je=(e,...t)=>{let n=M();return typeof n?.str=="function"?n.str(e,...t):vt(e,...t)},ne=(e=null)=>{let t=M();if(typeof t?.configureLocalization=="function")return t.configureLocalization(e);if(!e||typeof e!="object")return A.locale="en",A.messages={},A.hasProvider=!1,{locale:A.locale,messages:{...A.messages},hasProvider:A.hasProvider};typeof e.locale=="string"&&e.locale.trim()&&(A.locale=e.locale.trim()),Object.prototype.hasOwnProperty.call(e,"messages")&&(A.messages=Et(e.messages));let n=!!(e.provider||e.translate||e.loadLocale||e.setLocale);return A.hasProvider=n,n&&N().then(r=>{r.configureLocalization(e),Ge(r)}).catch(()=>{}),{locale:A.locale,messages:{...A.messages},hasProvider:A.hasProvider}},Ve=async e=>(await N()).loadLocale(e),Ye=async(e,t={})=>(await N()).setLocale(e,t),Qe=()=>{let e=M();return typeof e?.getLocalizationState=="function"?e.getLocalizationState():{locale:A.locale,messages:{...A.messages},hasProvider:A.hasProvider}},Ze=(e={})=>{let t=M();if(typeof t?.createJSONLocalization=="function")return t.createJSONLocalization(e);let n=typeof e?.locale=="string"&&e.locale.trim()?e.locale.trim().toLowerCase():"en",r=Array.isArray(e?.locales)?e.locales.map(g=>String(g||"").trim().toLowerCase()).filter(Boolean):[],a=Array.from(new Set([n,...r])),s=null,l=async()=>(s||(s=N().then(g=>typeof g?.createJSONLocalization=="function"?g.createJSONLocalization(e):null).catch(()=>null)),s),S=async(g="loadLocale")=>{let d=await l();if(!d||typeof d!="object")return null;let i=d.provider;if(!i||typeof i!="object")return null;let m=i[g];return typeof m=="function"?m:g==="setLocale"&&typeof i.loadLocale=="function"?i.loadLocale:null};return{locale:n,locales:[...a],provider:{locales:[...a],async loadLocale(g={}){let d=await S("loadLocale");return typeof d!="function"?{}:d(g)},async setLocale(g={}){let d=await S("setLocale");return typeof d!="function"?{}:d(g)}}}};function I(e,t){return t&&typeof t=="string"?t:`${J(o.currentConfig||{},{resolvePublicAssetURL:H})}core/${e}`}async function xt(){return Array.isArray(o.defaultEnhancers)&&o.defaultEnhancers.length>0?o.defaultEnhancers:(Z||(Z=import(I("pds-enhancers.js",o.currentConfig?.enhancersURL)).then(t=>{let n=Array.isArray(t?.defaultPDSEnhancers)?t.defaultPDSEnhancers:[];return o.defaultEnhancers=n,n}).catch(t=>{throw Z=null,t})),Z)}async function Rt(){return typeof o.ask=="function"&&o.ask!==Xe?o.ask:(Y||(Y=import(I("pds-ask.js",o.currentConfig?.askURL)).then(t=>{let n=t?.ask;if(typeof n!="function")throw new Error("Failed to load ask helper");return o.ask=n,n}).catch(t=>{throw Y=null,t})),Y)}async function F(){return typeof o.toast=="function"&&o.toast!==k?o.toast:(Q||(Q=import(I("pds-toast.js",o.currentConfig?.toastURL)).then(t=>{let n=t?.toast;if(typeof n!="function")throw new Error("Failed to load toast helper");return o.toast=n,n}).catch(t=>{throw Q=null,t})),Q)}async function Xe(...e){return(await Rt())(...e)}async function k(...e){return(await F())(...e)}k.success=async(...e)=>(await F()).success(...e);k.error=async(...e)=>(await F()).error(...e);k.warning=async(...e)=>(await F()).warning(...e);k.info=async(...e)=>(await F()).info(...e);var We=function(e="log",t,...n){o.log(e,t,...n)};function be(e){if(e==null)return e;if(typeof e=="function")return;if(typeof e!="object")return e;if(Array.isArray(e))return e.map(n=>be(n)).filter(n=>n!==void 0);let t={};for(let[n,r]of Object.entries(e)){let a=be(r);a!==void 0&&(t[n]=a)}return t}function et(e,t=new WeakSet){if(!e||typeof e!="object"||t.has(e))return e;t.add(e),Object.freeze(e);for(let n of Object.keys(e))et(e[n],t);return e}function Se(e){return e==null||typeof e!="object"?e:et(structuredClone(be(e)))}async function Dt(e,t={}){if(t?.runtimeConfig===!1||typeof fetch!="function")return null;let n=t?.runtimeConfigURL||`${e}pds-runtime-config.json`;try{let r=await fetch(n,{cache:"no-store"});return r.ok?await r.json():null}catch{return null}}o.registry=C;o.enums=Re;o.adoptLayers=Pe;o.adoptPrimitives=Ae;var Tt=de;o.parse=Tt;var zt=B;o.html=zt;o.createStylesheet=xe;o.isLiveMode=()=>C.isLive;o.ask=Xe;o.toast=k;o.common=fe;o.msg=qe;o.str=Je;o.configureLocalization=ne;o.loadLocale=Ve;o.setLocale=Ye;o.getLocalizationState=Qe;o.createJSONLocalization=Ze;o.i18n={msg:qe,str:Je,configure:ne,loadLocale:Ve,setLocale:Ye,getState:Qe,createJSONLocalization:Ze};o.AutoComplete=null;o.loadAutoComplete=async()=>{if(o.AutoComplete&&typeof o.AutoComplete.connect=="function")return o.AutoComplete;let e=I("pds-autocomplete.js",o.currentConfig?.autoCompleteURL);return V||(V=import(e).then(t=>{let n=t?.AutoComplete||t?.default?.AutoComplete||t?.default||null;if(!n)throw new Error("AutoComplete export not found in module");return o.AutoComplete=n,n}).catch(t=>{throw V=null,t})),V};function tt(e){let t=typeof CustomEvent=="function";try{let n=t?new CustomEvent("pds:ready",{detail:e}):new Event("pds:ready");o.dispatchEvent(n)}catch{}if(typeof document<"u")if(t){let n={detail:e,bubbles:!0,composed:!0};try{document.dispatchEvent(new CustomEvent("pds:ready",n))}catch{}try{document.dispatchEvent(new CustomEvent("pds-ready",n))}catch{}}else{try{document.dispatchEvent(new Event("pds:ready"))}catch{}try{document.dispatchEvent(new Event("pds-ready"))}catch{}}}function nt(e={}){let t=typeof CustomEvent=="function",n={at:Date.now(),...e};try{let r=t?new CustomEvent("pds:config-changed",{detail:n}):new Event("pds:config-changed");o.dispatchEvent(r)}catch{}if(typeof document<"u")if(t){let r={detail:n,bubbles:!0,composed:!0};try{document.dispatchEvent(new CustomEvent("pds:config-changed",r))}catch{}}else try{document.dispatchEvent(new Event("pds:config-changed"))}catch{}}var we="pure-ds-theme",D=null,O=null;function re(e){try{if(typeof document>"u")return;let t="light";e?e==="system"?t=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t=e:t=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",document.documentElement.setAttribute("data-theme",t)}catch{}}function oe(e){try{if(D&&O){try{typeof D.removeEventListener=="function"?D.removeEventListener("change",O):typeof D.removeListener=="function"&&D.removeListener(O)}catch{}D=null,O=null}if(e==="system"&&typeof window<"u"&&window.matchMedia){let t=window.matchMedia("(prefers-color-scheme: dark)"),n=r=>{let a=r?.matches===void 0?t.matches:r.matches;try{let s=a?"dark":"light";document.documentElement.setAttribute("data-theme",s),o.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:s,source:"system"}}))}catch{}};D=t,O=n,typeof t.addEventListener=="function"?t.addEventListener("change",n):typeof t.addListener=="function"&&t.addListener(n)}}catch{}}var Ct=Object.getOwnPropertyDescriptor(o,"theme");Ct||Object.defineProperty(o,"theme",{get(){try{return typeof window>"u"?null:localStorage.getItem(we)||null}catch{return null}},set(e){try{if(typeof window>"u")return;let t=o.currentConfig?.design||null,n=he(e);if(t&&!$e(t,n)){let r=t?.name||o.currentPreset?.name||o.currentConfig?.preset||"current preset";o.log("warn",`PDS theme "${n}" not supported by preset "${r}".`),o.dispatchEvent(new CustomEvent("pds:theme:blocked",{detail:{theme:e,resolvedTheme:n,preset:r}}));return}e==null?localStorage.removeItem(we):localStorage.setItem(we,e),re(e),oe(e),o.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:e,source:"api"}}))}catch{}}});o.defaultEnhancers=[];async function Mt(e){o.initializing=!0;try{let t=e&&e.mode||"live",{mode:n,...r}=e||{};o.mode=t,o.logHandler=typeof r?.log=="function"?r.log:null,o.currentConfig=Se(r);let a=r&&typeof r.localization=="object"&&r.localization?r.localization:null;a?(await N(),ne(a)):ne(null);let s;if(t==="static")s=await kt(r);else{let{localization:S,...g}=r||{},d=J(g,{resolvePublicAssetURL:H}),i=g?.managerURL||g?.public?.managerURL||g?.manager?.url||new URL("core/pds-manager.js",d).href||new URL("./pds-manager.js",import.meta.url).href,{startLive:m}=await import(i);s=await m(o,g,{emitReady:tt,emitConfigChanged:nt,applyResolvedTheme:re,setupSystemListenerIfNeeded:oe})}o.compiled=Se(s?.config||null);let l=o?.compiled?.design?.icons?.externalPath||"/assets/img/icons/";return o.log("info",`startup ready; external icon path: ${l}`),s}finally{o.initializing=!1}}o.start=Mt;async function kt(e){if(!e||typeof e!="object")throw new Error("PDS.start({ mode: 'static', ... }) requires a valid configuration object");let t=e.applyGlobalStyles??!0,n=e.manageTheme??!0,r=e.themeStorageKey??"pure-ds-theme",a=e.staticPaths??{},s=J(e,{resolvePublicAssetURL:H}),l=e&&e.autoDefine||null,S;l&&l.baseURL?S=G(q(l.baseURL,{preferModule:!1})):S=`${s}components/`;let g=l&&Array.isArray(l.predefine)&&l.predefine||[],d=l&&typeof l.mapper=="function"&&l.mapper||null;try{ke(o);let{resolvedTheme:i}=Ue({manageTheme:n,themeStorageKey:r,applyResolvedTheme:re,setupSystemListenerIfNeeded:oe}),m=await Dt(s,e),P=Array.isArray(e?.enhancers)?e.enhancers:e?.enhancers&&typeof e.enhancers=="object"?Object.values(e.enhancers):[],L=m?.config?{...m.config,...e,design:e?.design||m.config.design,preset:e?.preset||m.config.preset}:{...e},c={tokens:`${s}styles/pds-tokens.css.js`,primitives:`${s}styles/pds-primitives.css.js`,components:`${s}styles/pds-components.css.js`,utilities:`${s}styles/pds-utilities.css.js`,styles:`${s}styles/pds-styles.css.js`},y=m?.paths||{};if(a={...c,...y,...a},o.registry.setStaticMode(a),t&&typeof document<"u")try{let w=await o.registry.getStylesheet("styles");if(w){w._pds=!0;let u=(document.adoptedStyleSheets||[]).filter(b=>b._pds!==!0);document.adoptedStyleSheets=[...u,w],nt({mode:"static",source:"static:styles-applied"})}}catch(w){We.call(o,"warn","Failed to apply static styles:",w)}let _=null,v=[];try{let w=await xt(),u=await je({autoDefineBaseURL:S,autoDefinePreload:g,autoDefineMapper:d,enhancers:P,autoDefineOverrides:l||null,autoDefinePreferModule:!(l&&l.baseURL)},{baseEnhancers:w});_=u.autoDefiner,v=u.mergedEnhancers||[]}catch(w){We.call(o,"error","\u274C Failed to initialize AutoDefiner/Enhancers (static):",w)}return o.compiled=Se({mode:"static",...L,theme:i,enhancers:v}),tt({mode:"static",config:L,theme:i,autoDefiner:_}),{config:L,theme:i,autoDefiner:_}}catch(i){throw o.dispatchEvent(new CustomEvent("pds:error",{detail:{error:i}})),i}}var on=re,sn=oe;export{o as PDS,on as applyResolvedTheme,ne as configureLocalization,Ze as createJSONLocalization,Qe as getLocalizationState,zt as html,Ve as loadLocale,qe as msg,Tt as parse,Ye as setLocale,sn as setupSystemListenerIfNeeded,Je as str};
@@ -175,6 +175,30 @@ export function fragmentFromTemplateLike(templateLike) {
175
175
  return tpl.content;
176
176
  }
177
177
 
178
+ /**
179
+ * Parses either an HTML string or tagged template into a DocumentFragment.
180
+ * Useful when you want direct appendChild(fragment) ergonomics.
181
+ * @param {string | TemplateStringsArray | {strings: string[], values: unknown[]}} html
182
+ * @param {...unknown} values
183
+ * @returns {DocumentFragment}
184
+ */
185
+ export function parseFragment(html, ...values) {
186
+ const isTaggedTemplate =
187
+ Array.isArray(html) && Object.prototype.hasOwnProperty.call(html, "raw");
188
+
189
+ if (isTaggedTemplate) {
190
+ return fragmentFromTemplateLike({ strings: Array.from(html), values });
191
+ }
192
+
193
+ if (Array.isArray(html?.strings) && Array.isArray(html?.values)) {
194
+ return fragmentFromTemplateLike({ strings: html.strings, values: html.values });
195
+ }
196
+
197
+ const tpl = document.createElement("template");
198
+ tpl.innerHTML = String(html ?? "");
199
+ return tpl.content;
200
+ }
201
+
178
202
  /**
179
203
  * Parses either an HTML string or a tagged template into DOM nodes.
180
204
  *
@@ -191,20 +215,5 @@ export function fragmentFromTemplateLike(templateLike) {
191
215
  * @returns {NodeListOf<ChildNode>}
192
216
  */
193
217
  export function parseHTML(html, ...values) {
194
- // Tagged template mode: html is TemplateStringsArray
195
- const isTaggedTemplate =
196
- Array.isArray(html) && Object.prototype.hasOwnProperty.call(html, "raw");
197
-
198
- if (isTaggedTemplate) {
199
- return fragmentFromTemplateLike({ strings: Array.from(html), values }).childNodes;
200
- }
201
-
202
- // Object mode: {strings, values} prepared shape
203
- if (Array.isArray(html?.strings) && Array.isArray(html?.values)) {
204
- return fragmentFromTemplateLike({ strings: html.strings, values: html.values }).childNodes;
205
- }
206
-
207
- // String mode: plain HTML string (no binding support)
208
- // This is the backward-compatible path
209
- return new DOMParser().parseFromString(String(html ?? ""), "text/html").body.childNodes;
218
+ return parseFragment(html, ...values).childNodes;
210
219
  }
@@ -3399,6 +3399,15 @@ a.btn-working {
3399
3399
  .skeleton {
3400
3400
  --skeleton-base: color-mix(in oklab, var(--color-text-primary) 8%, transparent);
3401
3401
  --skeleton-highlight: color-mix(in oklab, var(--color-text-primary) 16%, transparent);
3402
+ --skeleton-child-offset: 0ms;
3403
+ --skeleton-type-offset: 0ms;
3404
+ --skeleton-parent-offset: 0ms;
3405
+ --skeleton-delay: calc(
3406
+ 220ms +
3407
+ var(--skeleton-child-offset) +
3408
+ var(--skeleton-type-offset) +
3409
+ var(--skeleton-parent-offset)
3410
+ );
3402
3411
  background: linear-gradient(
3403
3412
  90deg,
3404
3413
  var(--skeleton-base) 0%,
@@ -3408,7 +3417,7 @@ a.btn-working {
3408
3417
  background-size: 200% 100%;
3409
3418
  animation:
3410
3419
  pds-skeleton-fade-in 220ms ease-out both,
3411
- pds-skeleton 1.5s ease-in-out infinite 220ms;
3420
+ pds-skeleton 1.5s ease-in-out infinite var(--skeleton-delay);
3412
3421
  border-radius: var(--radius-sm);
3413
3422
 
3414
3423
  &::before {
@@ -3416,6 +3425,33 @@ a.btn-working {
3416
3425
  }
3417
3426
  }
3418
3427
 
3428
+ /* Deterministic stagger so large skeleton groups do not animate in lockstep. */
3429
+ :where(.skeleton:nth-child(11n + 1)) { --skeleton-child-offset: 0ms; }
3430
+ :where(.skeleton:nth-child(11n + 2)) { --skeleton-child-offset: 17ms; }
3431
+ :where(.skeleton:nth-child(11n + 3)) { --skeleton-child-offset: 34ms; }
3432
+ :where(.skeleton:nth-child(11n + 4)) { --skeleton-child-offset: 51ms; }
3433
+ :where(.skeleton:nth-child(11n + 5)) { --skeleton-child-offset: 68ms; }
3434
+ :where(.skeleton:nth-child(11n + 6)) { --skeleton-child-offset: 85ms; }
3435
+ :where(.skeleton:nth-child(11n + 7)) { --skeleton-child-offset: 102ms; }
3436
+ :where(.skeleton:nth-child(11n + 8)) { --skeleton-child-offset: 119ms; }
3437
+ :where(.skeleton:nth-child(11n + 9)) { --skeleton-child-offset: 136ms; }
3438
+ :where(.skeleton:nth-child(11n + 10)) { --skeleton-child-offset: 153ms; }
3439
+ :where(.skeleton:nth-child(11n + 11)) { --skeleton-child-offset: 170ms; }
3440
+
3441
+ :where(.skeleton:nth-of-type(7n + 1)) { --skeleton-type-offset: 0ms; }
3442
+ :where(.skeleton:nth-of-type(7n + 2)) { --skeleton-type-offset: 11ms; }
3443
+ :where(.skeleton:nth-of-type(7n + 3)) { --skeleton-type-offset: 22ms; }
3444
+ :where(.skeleton:nth-of-type(7n + 4)) { --skeleton-type-offset: 33ms; }
3445
+ :where(.skeleton:nth-of-type(7n + 5)) { --skeleton-type-offset: 44ms; }
3446
+ :where(.skeleton:nth-of-type(7n + 6)) { --skeleton-type-offset: 55ms; }
3447
+ :where(.skeleton:nth-of-type(7n + 7)) { --skeleton-type-offset: 66ms; }
3448
+
3449
+ :where(*:nth-child(5n + 1) > .skeleton) { --skeleton-parent-offset: 0ms; }
3450
+ :where(*:nth-child(5n + 2) > .skeleton) { --skeleton-parent-offset: 9ms; }
3451
+ :where(*:nth-child(5n + 3) > .skeleton) { --skeleton-parent-offset: 18ms; }
3452
+ :where(*:nth-child(5n + 4) > .skeleton) { --skeleton-parent-offset: 27ms; }
3453
+ :where(*:nth-child(5n + 5) > .skeleton) { --skeleton-parent-offset: 36ms; }
3454
+
3419
3455
  @keyframes pds-skeleton-fade-in {
3420
3456
  from { opacity: 0; }
3421
3457
  to { opacity: 1; }
package/src/js/pds.d.ts CHANGED
@@ -283,6 +283,13 @@ export interface AskOptions {
283
283
  [key: string]: any;
284
284
  }
285
285
 
286
+ export type PDSParseTemplateLike = TemplateStringsArray | {
287
+ strings: string[];
288
+ values: unknown[];
289
+ };
290
+
291
+ export type PDSParseInput = string | PDSParseTemplateLike;
292
+
286
293
  export class PDS extends EventTarget {
287
294
  // Static surface
288
295
  static registry: PDSRegistry;
@@ -332,7 +339,8 @@ export class PDS extends EventTarget {
332
339
  static ontology?: any;
333
340
  static enums?: Record<string, any>;
334
341
  static common?: Record<string, any>;
335
- static parse?: (html: string) => Element[];
342
+ static parse?: (html: PDSParseInput, ...values: unknown[]) => NodeListOf<ChildNode>;
343
+ static html?: (html: PDSParseInput, ...values: unknown[]) => DocumentFragment;
336
344
  static msg: (template: string | PDSStrResult, options?: Record<string, any>) => string;
337
345
  static str: (strings: TemplateStringsArray, ...values: any[]) => PDSStrResult;
338
346
  static configureLocalization: (config?: PDSLocalizationConfig | null) => {
@@ -740,3 +748,6 @@ export class SchemaForm extends HTMLElement {
740
748
  options?: boolean | EventListenerOptions
741
749
  ): void;
742
750
  }
751
+
752
+ export function parse(html: PDSParseInput, ...values: unknown[]): NodeListOf<ChildNode>;
753
+ export function html(html: PDSParseInput, ...values: unknown[]): DocumentFragment;
package/src/js/pds.js CHANGED
@@ -638,8 +638,13 @@ PDS.adoptLayers = adoptLayers;
638
638
  /** Convenience to adopt only primitives into a ShadowRoot */
639
639
  PDS.adoptPrimitives = adoptPrimitives;
640
640
 
641
- /** Parse an HTML string into a NodeList */
642
- PDS.parse = common.parseHTML;
641
+ /** Parse HTML strings or tagged templates into a NodeList */
642
+ export const parse = common.parseHTML;
643
+ PDS.parse = parse;
644
+
645
+ /** Parse HTML or tagged templates into a DocumentFragment */
646
+ export const html = common.parseFragment;
647
+ PDS.html = html;
643
648
 
644
649
  /** Create a constructable CSSStyleSheet from a CSS string */
645
650
  PDS.createStylesheet = createStylesheet;