@pure-ds/core 0.7.40 → 0.7.41

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 nt=Object.defineProperty;var ot=(e,t)=>{for(var n in t)nt(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}},Le="__PURE_DS_PDS_SINGLETON__",ae=typeof globalThis<"u"?globalThis:window,se=ae?.[Le],r=se&&typeof se.addEventListener=="function"?se:new ie;ae&&(ae[Le]=r);typeof r.log!="function"&&(r.log=(e="log",t,...n)=>{if(typeof console>"u")return;let o=typeof console[e]=="function"?console[e].bind(console):typeof console.log=="function"?console.log.bind(console):null;o&&(n.length>0?o(t,...n):o(t))});typeof r.logHandler!="function"&&(r.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){r.log("error",`Registry: failed to load static ${t}:`,n),r.log("error",`Registry: looking for ${this._staticPaths[t]}`),r.log("error","Registry: make sure you've run 'npm run pds:build' and configured PDS.start() with the correct static.root path");let o=new CSSStyleSheet;return o.replaceSync("/* Failed to load "+t+" */"),o}}get mode(){return this._mode}get isLive(){return this._mode==="live"}},C=new ce;async function Ee(e,t=[],n=null){try{let o=n?.primitivesStylesheet?n.primitivesStylesheet:await C.getStylesheet("primitives");e.adoptedStyleSheets=[o,...t]}catch(o){let c=e.host?.tagName?.toLowerCase()||"unknown";r.log("error",`Adopter: <${c}> failed to adopt primitives:`,o),e.adoptedStyleSheets=t}}async function Ae(e,t=["primitives"],n=[],o=null){let c=Array.isArray(n)?n.filter(Boolean):[];if(c.length){let l=(Array.isArray(e.adoptedStyleSheets)?e.adoptedStyleSheets:[]).filter(y=>!c.includes(y));e.adoptedStyleSheets=[...l,...c]}try{let l=(await Promise.all(t.map(async y=>{if(o)switch(y){case"tokens":return o.tokensStylesheet;case"primitives":return o.primitivesStylesheet;case"components":return o.componentsStylesheet;case"utilities":return o.utilitiesStylesheet;default:break}return C.getStylesheet(y)}))).filter(y=>y!==null);e.adoptedStyleSheets=[...l,...c]}catch(s){let l=e.host?.tagName?.toLowerCase()||"unknown";r.log("error",`Adopter: <${l}> failed to adopt layers:`,s),e.adoptedStyleSheets=c}}function ve(e){let t=new CSSStyleSheet;return t.replaceSync(e),t}var Pe={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 ue={};ot(ue,{deepMerge:()=>Re,fragmentFromTemplateLike:()=>rt,isObject:()=>W,parseHTML:()=>le});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(o=>{W(t[o])?o in e?n[o]=Re(e[o],t[o]):Object.assign(n,{[o]:t[o]}):Object.assign(n,{[o]:t[o]})}),n}function rt(e){let t=Array.isArray(e?.strings)?e.strings:[],n=Array.isArray(e?.values)?e.values:[],o=new Set,c=[],s=/(\s)(\.[\w-]+)=\s*$/;for(let i=0;i<t.length;i+=1){let S=t[i]??"",m=S.match(s);if(m&&i<n.length){let b=m[2].slice(1),A=`pds-val-${i}`;S=S.replace(s,`$1data-pds-prop="${b}:${A}"`),o.add(i)}c.push(S),i<n.length&&!o.has(i)&&c.push(`<!--pds-val-${i}-->`)}let l=document.createElement("template");l.innerHTML=c.join("");let y=(i,S)=>{let m=i.parentNode;if(!m)return;if(S==null){m.removeChild(i);return}let L=b=>{if(b!=null){if(b instanceof Node){m.insertBefore(b,i);return}if(Array.isArray(b)){b.forEach(A=>L(A));return}m.insertBefore(document.createTextNode(String(b)),i)}};L(S),m.removeChild(i)},g=document.createTreeWalker(l.content,NodeFilter.SHOW_COMMENT),u=[];for(;g.nextNode();){let i=g.currentNode;i?.nodeValue?.startsWith("pds-val-")&&u.push(i)}return u.forEach(i=>{let S=Number(i.nodeValue.replace("pds-val-",""));y(i,n[S])}),l.content.querySelectorAll("*").forEach(i=>{let S=i.getAttribute("data-pds-prop");if(!S)return;let[m,L]=S.split(":"),b=Number(String(L).replace("pds-val-",""));m&&Number.isInteger(b)&&(i[m]=n[b]),i.removeAttribute("data-pds-prop")}),l.content}function le(e){return new DOMParser().parseFromString(e,"text/html").body.childNodes}var De="pds",st=/^([a-z][a-z0-9+\-.]*:)?\/\//i,xe=/^[a-z]:/i;function U(e=""){return e.endsWith("/")?e:`${e}/`}function it(e="",t=De){let n=e.replace(/\/+$/,"");return new RegExp(`(?:^|/)${t}$`,"i").test(n)?n:`${n}/${t}`}function at(e){return e.replace(/^\.\/+/,"")}function ct(e){return xe.test(e)?e.replace(xe,"").replace(/^\/+/,""):e}function lt(e){return e.startsWith("public/")?e.substring(7):e}function H(e,t={}){let n=t.segment||De,o=t.defaultRoot||`/assets/${n}/`,c=e?.public&&e.public?.root||e?.static&&e.static?.root||null;if(!c||typeof c!="string")return U(o);let s=c.trim();return s?(s=s.replace(/\\/g,"/"),s=it(s,n),s=U(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,y)=>y===0?l:"/")),U(s))):U(o)}async function ut(...e){let t={};e.length&&typeof e[e.length-1]=="object"&&(t=e.pop()||{});let n=e,{baseURL:o,mapper:c=u=>`${u}.js`,onError:s=(u,a)=>console.error(`[defineWebComponents] ${u}:`,a)}=t,l=o?new URL(o,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),y=u=>u.toLowerCase().replace(/(^|-)([a-z])/g,(a,i,S)=>S.toUpperCase()),g=async u=>{try{if(customElements.get(u))return{tag:u,status:"already-defined"};let a=c(u),S=await import(a instanceof URL?a.href:new URL(a,l).href),m=S?.default??S?.[y(u)];if(!m){if(customElements.get(u))return{tag:u,status:"self-defined"};throw new Error(`No export found for ${u}. Expected default export or named export "${y(u)}".`)}return customElements.get(u)?{tag:u,status:"race-already-defined"}:(customElements.define(u,m),{tag:u,status:"defined"})}catch(a){throw s(u,a),a}};return Promise.all(n.map(g))}var B=class{constructor(t={}){let{baseURL:n,mapper:o,onError:c,predicate:s=()=>!0,attributeModule:l="data-module",root:y=document,scanExisting:g=!0,debounceMs:u=16,observeShadows:a=!0,enhancers:i=[],patchAttachShadow:S=!0}=t,m=new Set,L=new Set,b=new Set,A=new Map,P=new WeakMap,E=new WeakMap,h=0,w=!1,R=null,F=d=>{if(!d||!i.length)return;let p=E.get(d);p||(p=new Set,E.set(d,p));for(let f of i)if(!(!f.selector||!f.run)&&!p.has(f.selector))try{d.matches&&d.matches(f.selector)&&(f.run(d),p.add(f.selector))}catch(v){console.warn(`[AutoDefiner] Error applying enhancer for selector "${f.selector}":`,v)}},M=(d,p)=>{if(!w&&!(!d||!d.includes("-"))&&!customElements.get(d)&&!L.has(d)&&!b.has(d)){if(p&&p.getAttribute){let f=p.getAttribute(l);f&&!A.has(d)&&A.set(d,f)}m.add(d),tt()}},tt=()=>{h||(h=setTimeout(Se,u))},D=d=>{if(d){if(d.nodeType===1){let p=d,f=p.tagName?.toLowerCase();f&&f.includes("-")&&!customElements.get(f)&&s(f,p)&&M(f,p),F(p),a&&p.shadowRoot&&re(p.shadowRoot)}d.querySelectorAll&&d.querySelectorAll("*").forEach(p=>{let f=p.tagName?.toLowerCase();f&&f.includes("-")&&!customElements.get(f)&&s(f,p)&&M(f,p),F(p),a&&p.shadowRoot&&re(p.shadowRoot)})}},re=d=>{if(!d||P.has(d))return;D(d);let p=new MutationObserver(f=>{for(let v of f)v.addedNodes?.forEach(z=>{D(z)}),v.type==="attributes"&&v.target&&D(v.target)});p.observe(d,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[l,...i.map(f=>f.selector).filter(f=>f.startsWith("data-"))]}),P.set(d,p)};async function Se(){if(clearTimeout(h),h=0,!m.size)return;let d=Array.from(m);m.clear(),d.forEach(p=>L.add(p));try{let p=f=>A.get(f)??(o?o(f):`${f}.js`);await ut(...d,{baseURL:n,mapper:p,onError:(f,v)=>{b.add(f),c?.(f,v)}})}catch{}finally{d.forEach(p=>L.delete(p))}}let be=y===document?document.documentElement:y,_e=new MutationObserver(d=>{for(let p of d)p.addedNodes?.forEach(f=>{D(f)}),p.type==="attributes"&&p.target&&D(p.target)});if(_e.observe(be,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[l,...i.map(d=>d.selector).filter(d=>d.startsWith("data-"))]}),a&&S&&Element.prototype.attachShadow){let d=Element.prototype.attachShadow;Element.prototype.attachShadow=function(f){let v=d.call(this,f);if(f&&f.mode==="open"){re(v);let z=this.tagName?.toLowerCase();z&&z.includes("-")&&!customElements.get(z)&&M(z,this)}return v},R=()=>Element.prototype.attachShadow=d}return g&&D(be),{stop(){w=!0,_e.disconnect(),R&&R(),h&&(clearTimeout(h),h=0),P.forEach(d=>d.disconnect())},flush:Se}}static async define(...t){let n={};t.length&&typeof t[t.length-1]=="object"&&(n=t.pop()||{});let o=t,{baseURL:c,mapper:s=a=>`${a}.js`,onError:l=(a,i)=>console.error(`[defineWebComponents] ${a}:`,i)}=n,y=c?new URL(c,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),g=a=>a.toLowerCase().replace(/(^|-)([a-z])/g,(i,S,m)=>m.toUpperCase()),u=async a=>{try{if(customElements.get(a))return{tag:a,status:"already-defined"};let i=s(a),m=await import(i instanceof URL?i.href:new URL(i,y).href),L=m?.default??m?.[g(a)];if(!L){if(customElements.get(a))return{tag:a,status:"self-defined"};throw new Error(`No export found for ${a}. Expected default export or named export "${g(a)}".`)}return customElements.get(a)?{tag:a,status:"race-already-defined"}:(customElements.define(a,L),{tag:a,status:"defined"})}catch(i){throw l(a,i),i}};return Promise.all(o.map(u))}};var dt=/^[a-z][a-z0-9+\-.]*:\/\//i,j=(()=>{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,o=()=>{if(!j)return null;try{return new URL(e,j).href}catch{return null}},c=()=>{if(typeof window>"u"||!window.location?.origin)return null;try{return new URL(e,window.location.origin).href}catch{return null}};return(n?o()||c():c()||o())||e}var ze=(()=>{if(j)try{let e=new URL(j);if(/\/public\/assets\/js\//.test(e.pathname))return new URL("../pds/",j).href}catch{return}})(),Ce=!1;function Te(e){Ce||typeof document>"u"||(Ce=!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:o}){let c="light",s=null;if(e&&typeof window<"u"){try{s=localStorage.getItem(t)||null}catch{s=null}try{n?.(s),o?.(s)}catch{}s?s==="system"?c=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":c=s:c=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}return{resolvedTheme:c,storedTheme:s}}function q(e,{resolvePublicAssetURL:t}){let n=!!(e?.public?.root||e?.static?.root),o=t(e);return!n&&ze&&(o=ze),K(G(o))}async function Me(e,{baseEnhancers:t=[]}={}){let{autoDefineBaseURL:n="/auto-define/",autoDefinePreload:o=[],autoDefineMapper:c=null,enhancers:s=[],autoDefineOverrides:l=null,autoDefinePreferModule:y=!0}=e,g=(()=>{let a=new Map;return(t||[]).forEach(i=>a.set(i.selector,i)),(s||[]).forEach(i=>a.set(i.selector,i)),Array.from(a.values())})(),u=null;if(typeof window<"u"&&typeof document<"u"){let a=B,i=h=>{switch(h){case"pds-tabpanel":return"pds-tabstrip.js";default:return`${h}.js`}},{mapper:S,enhancers:m,...L}=l&&typeof l=="object"?l:{},b=m?Array.isArray(m)?m:typeof m=="object"?Object.values(m):[]:[],A=(()=>{let h=new Map;return(g||[]).forEach(w=>{w?.selector&&h.set(w.selector,w)}),(b||[]).forEach(w=>{if(!w?.selector)return;let R=h.get(w.selector)||null;h.set(w.selector,{...R||{},...w,run:typeof w?.run=="function"?w.run:R?.run})}),Array.from(h.values())})(),E={baseURL:n&&K(G(n,{preferModule:y})),predefine:o,scanExisting:!0,observeShadows:!0,patchAttachShadow:!0,debounceMs:16,enhancers:A,onError:(h,w)=>{if(typeof h=="string"&&h.startsWith("pds-")){let F=["pds-form","pds-drawer"].includes(h),M=w?.message?.includes("#pds/lit")||w?.message?.includes("Failed to resolve module specifier");F&&M?r.log("error",`\u274C PDS component <${h}> 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`):r.log("warn",`\u26A0\uFE0F PDS component <${h}> not found. Assets may not be installed.`)}else r.log("error",`\u274C Auto-define error for <${h}>:`,w)},...L,mapper:h=>{if(customElements.get(h))return null;if(typeof c=="function")try{let w=c(h);return w===void 0?i(h):w}catch(w){return r.log("warn","Custom autoDefine.mapper error; falling back to default:",w?.message||w),i(h)}return i(h)}};u=new a(E),o.length>0&&typeof a.define=="function"&&await a.define(...o,{baseURL:n,mapper:E.mapper,onError:E.onError})}return{autoDefiner:u,mergedEnhancers:g}}var de=["light","dark"],fe=new Set(de);function ft(e){let n=(Array.isArray(e?.themes)?e.themes.map(o=>String(o).toLowerCase()):de).filter(o=>fe.has(o));return n.length?n:de}function pe(e,{preferDocument:t=!0}={}){let n=String(e||"").toLowerCase();if(fe.has(n))return n;if(t&&typeof document<"u"){let o=document.documentElement?.getAttribute("data-theme");if(fe.has(o))return o}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Ue(e,t){let n=pe(t);return ft(e).includes(n)}var pt=new Set(["log","warn","error","debug","info"]),mt="__PURE_DS_PDS_SINGLETON__",me=null,he=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 he=="function")try{let t=ht(he());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 me=="function")try{let t=me();if(typeof t=="function")return t}catch{}let e=Oe();return typeof e?.logHandler=="function"?e.logHandler:null}function je(e,t,...n){if(typeof console>"u")return;let o=typeof console[e]=="function"?console[e].bind(console):typeof console.log=="function"?console.log.bind(console):null;o&&(n.length>0?o(t,...n):o(t))}function St(e,t){let n=t?.debug===!0;return!(t?.mode==="static"&&!n||!n&&e!=="error"&&e!=="warn")}function Ne({getLogger:e,getContext:t}={}){me=typeof e=="function"?e:null,he=typeof t=="function"?t:null}function $e(e="log",t,...n){let o=yt(e),c=gt(),s=wt();if(s)try{s.call(c?.thisArg,o,t,...n);return}catch(l){je("error","Custom log handler failed:",l)}St(o,c)&&je(o,t,...n)}typeof r.initializing!="boolean"&&(r.initializing=!1);"currentPreset"in r||(r.currentPreset=null);typeof r.debug!="boolean"&&(r.debug=!1);"currentConfig"in r||(r.currentConfig=null);"compiled"in r||(r.compiled=null);typeof r.logHandler!="function"&&(r.logHandler=null);"mode"in r||(r.mode=null);var V=null,J=null,Y=null,Q=null,Z=null,X=null,Fe="__pdsLocalizationRuntime";function T(){if(X)return X;let e=r?.[Fe];return e&&typeof e=="object"?(X=e,e):null}function bt(e){let t=e&&typeof e=="object"?e:null;X=t,r[Fe]=t}Ne({getLogger:()=>typeof r.logHandler=="function"?r.logHandler:null,getContext:()=>{let e=r?.mode||r?.compiled?.mode||(r?.registry?.isLive?"live":"static"),t=(r?.debug||r?.currentConfig?.debug||r?.currentConfig?.design?.debug||r?.compiled?.debug||r?.compiled?.design?.debug||!1)===!0;return{mode:e,debug:t,thisArg:r}}});r.log=(e="log",t,...n)=>{$e(e,t,...n)};var _={locale:"en",messages:{},hasProvider:!1},ee=new Set;function We(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,o)=>t(Number(o)))}function Lt(e){if(!e||typeof e!="object")return{};let t={};for(let[n,o]of Object.entries(e)){if(typeof o=="string"){t[n]=o;continue}o&&typeof o=="object"&&typeof o.content=="string"&&(t[n]=o.content)}return t}function Et(e,...t){return{strTag:!0,strings:Array.from(e||[]),values:t,raw:Array.from(e?.raw||[])}}function At(e){if(!e)return"";if(We(e)){let n=He(e.strings||[]),o=_.messages[n]||n;return _t(o,c=>e.values?.[c])}let t=String(e);return _.messages[t]||t}function vt(e){if(!e)return;let t=We(e)?He(e.strings||[]):String(e);typeof t=="string"&&t.length>0&&ee.add(t)}function Be(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=T();return e||(Z||(Z=import($("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 bt(n),Be(n),n}).catch(n=>{throw Z=null,n})),Z)}var Ke=(e,t={})=>{let n=T();return typeof n?.msg=="function"?n.msg(e,t):(vt(e),At(e,t))},Ge=(e,...t)=>{let n=T();return typeof n?.str=="function"?n.str(e,...t):Et(e,...t)},te=(e=null)=>{let t=T();if(typeof t?.configureLocalization=="function")return t.configureLocalization(e);if(!e||typeof e!="object")return _.locale="en",_.messages={},_.hasProvider=!1,{locale:_.locale,messages:{..._.messages},hasProvider:_.hasProvider};typeof e.locale=="string"&&e.locale.trim()&&(_.locale=e.locale.trim()),Object.prototype.hasOwnProperty.call(e,"messages")&&(_.messages=Lt(e.messages));let n=!!(e.provider||e.translate||e.loadLocale||e.setLocale);return _.hasProvider=n,n&&N().then(o=>{o.configureLocalization(e),Be(o)}).catch(()=>{}),{locale:_.locale,messages:{..._.messages},hasProvider:_.hasProvider}},qe=async e=>(await N()).loadLocale(e),Ve=async(e,t={})=>(await N()).setLocale(e,t),Je=()=>{let e=T();return typeof e?.getLocalizationState=="function"?e.getLocalizationState():{locale:_.locale,messages:{..._.messages},hasProvider:_.hasProvider}},Ye=(e={})=>{let t=T();if(typeof t?.createJSONLocalization=="function")return t.createJSONLocalization(e);let n=typeof e?.locale=="string"&&e.locale.trim()?e.locale.trim().toLowerCase():"en",o=Array.isArray(e?.locales)?e.locales.map(g=>String(g||"").trim().toLowerCase()).filter(Boolean):[],c=Array.from(new Set([n,...o])),s=null,l=async()=>(s||(s=N().then(g=>typeof g?.createJSONLocalization=="function"?g.createJSONLocalization(e):null).catch(()=>null)),s),y=async(g="loadLocale")=>{let u=await l();if(!u||typeof u!="object")return null;let a=u.provider;if(!a||typeof a!="object")return null;let i=a[g];return typeof i=="function"?i:g==="setLocale"&&typeof a.loadLocale=="function"?a.loadLocale:null};return{locale:n,locales:[...c],provider:{locales:[...c],async loadLocale(g={}){let u=await y("loadLocale");return typeof u!="function"?{}:u(g)},async setLocale(g={}){let u=await y("setLocale");return typeof u!="function"?{}:u(g)}}}};function $(e,t){return t&&typeof t=="string"?t:`${q(r.currentConfig||{},{resolvePublicAssetURL:H})}core/${e}`}async function Pt(){return Array.isArray(r.defaultEnhancers)&&r.defaultEnhancers.length>0?r.defaultEnhancers:(Q||(Q=import($("pds-enhancers.js",r.currentConfig?.enhancersURL)).then(t=>{let n=Array.isArray(t?.defaultPDSEnhancers)?t.defaultPDSEnhancers:[];return r.defaultEnhancers=n,n}).catch(t=>{throw Q=null,t})),Q)}async function Rt(){return typeof r.ask=="function"&&r.ask!==Qe?r.ask:(J||(J=import($("pds-ask.js",r.currentConfig?.askURL)).then(t=>{let n=t?.ask;if(typeof n!="function")throw new Error("Failed to load ask helper");return r.ask=n,n}).catch(t=>{throw J=null,t})),J)}async function I(){return typeof r.toast=="function"&&r.toast!==k?r.toast:(Y||(Y=import($("pds-toast.js",r.currentConfig?.toastURL)).then(t=>{let n=t?.toast;if(typeof n!="function")throw new Error("Failed to load toast helper");return r.toast=n,n}).catch(t=>{throw Y=null,t})),Y)}async function Qe(...e){return(await Rt())(...e)}async function k(...e){return(await I())(...e)}k.success=async(...e)=>(await I()).success(...e);k.error=async(...e)=>(await I()).error(...e);k.warning=async(...e)=>(await I()).warning(...e);k.info=async(...e)=>(await I()).info(...e);var Ie=function(e="log",t,...n){r.log(e,t,...n)};function ge(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=>ge(n)).filter(n=>n!==void 0);let t={};for(let[n,o]of Object.entries(e)){let c=ge(o);c!==void 0&&(t[n]=c)}return t}function Ze(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))Ze(e[n],t);return e}function we(e){return e==null||typeof e!="object"?e:Ze(structuredClone(ge(e)))}async function xt(e,t={}){if(t?.runtimeConfig===!1||typeof fetch!="function")return null;let n=t?.runtimeConfigURL||`${e}pds-runtime-config.json`;try{let o=await fetch(n,{cache:"no-store"});return o.ok?await o.json():null}catch{return null}}r.registry=C;r.enums=Pe;r.adoptLayers=Ae;r.adoptPrimitives=Ee;r.parse=le;r.createStylesheet=ve;r.isLiveMode=()=>C.isLive;r.ask=Qe;r.toast=k;r.common=ue;r.msg=Ke;r.str=Ge;r.configureLocalization=te;r.loadLocale=qe;r.setLocale=Ve;r.getLocalizationState=Je;r.createJSONLocalization=Ye;r.i18n={msg:Ke,str:Ge,configure:te,loadLocale:qe,setLocale:Ve,getState:Je,createJSONLocalization:Ye};r.AutoComplete=null;r.loadAutoComplete=async()=>{if(r.AutoComplete&&typeof r.AutoComplete.connect=="function")return r.AutoComplete;let e=$("pds-autocomplete.js",r.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 r.AutoComplete=n,n}).catch(t=>{throw V=null,t})),V};function Xe(e){let t=typeof CustomEvent=="function";try{let n=t?new CustomEvent("pds:ready",{detail:e}):new Event("pds:ready");r.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 et(e={}){let t=typeof CustomEvent=="function",n={at:Date.now(),...e};try{let o=t?new CustomEvent("pds:config-changed",{detail:n}):new Event("pds:config-changed");r.dispatchEvent(o)}catch{}if(typeof document<"u")if(t){let o={detail:n,bubbles:!0,composed:!0};try{document.dispatchEvent(new CustomEvent("pds:config-changed",o))}catch{}}else try{document.dispatchEvent(new Event("pds:config-changed"))}catch{}}var ye="pure-ds-theme",x=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 oe(e){try{if(x&&O){try{typeof x.removeEventListener=="function"?x.removeEventListener("change",O):typeof x.removeListener=="function"&&x.removeListener(O)}catch{}x=null,O=null}if(e==="system"&&typeof window<"u"&&window.matchMedia){let t=window.matchMedia("(prefers-color-scheme: dark)"),n=o=>{let c=o?.matches===void 0?t.matches:o.matches;try{let s=c?"dark":"light";document.documentElement.setAttribute("data-theme",s),r.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:s,source:"system"}}))}catch{}};x=t,O=n,typeof t.addEventListener=="function"?t.addEventListener("change",n):typeof t.addListener=="function"&&t.addListener(n)}}catch{}}var Dt=Object.getOwnPropertyDescriptor(r,"theme");Dt||Object.defineProperty(r,"theme",{get(){try{return typeof window>"u"?null:localStorage.getItem(ye)||null}catch{return null}},set(e){try{if(typeof window>"u")return;let t=r.currentConfig?.design||null,n=pe(e);if(t&&!Ue(t,n)){let o=t?.name||r.currentPreset?.name||r.currentConfig?.preset||"current preset";r.log("warn",`PDS theme "${n}" not supported by preset "${o}".`),r.dispatchEvent(new CustomEvent("pds:theme:blocked",{detail:{theme:e,resolvedTheme:n,preset:o}}));return}e==null?localStorage.removeItem(ye):localStorage.setItem(ye,e),ne(e),oe(e),r.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:e,source:"api"}}))}catch{}}});r.defaultEnhancers=[];async function zt(e){r.initializing=!0;try{let t=e&&e.mode||"live",{mode:n,...o}=e||{};r.mode=t,r.logHandler=typeof o?.log=="function"?o.log:null,r.currentConfig=we(o);let c=o&&typeof o.localization=="object"&&o.localization?o.localization:null;c?(await N(),te(c)):te(null);let s;if(t==="static")s=await Ct(o);else{let y=q(o,{resolvePublicAssetURL:H}),g=o?.managerURL||o?.public?.managerURL||o?.manager?.url||new URL("core/pds-manager.js",y).href||new URL("./pds-manager.js",import.meta.url).href,{startLive:u}=await import(g);s=await u(r,o,{emitReady:Xe,emitConfigChanged:et,applyResolvedTheme:ne,setupSystemListenerIfNeeded:oe})}r.compiled=we(s?.config||null);let l=r?.compiled?.design?.icons?.externalPath||"/assets/img/icons/";return r.log("info",`startup ready; external icon path: ${l}`),s}finally{r.initializing=!1}}r.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,o=e.themeStorageKey??"pure-ds-theme",c=e.staticPaths??{},s=q(e,{resolvePublicAssetURL:H}),l=e&&e.autoDefine||null,y;l&&l.baseURL?y=K(G(l.baseURL,{preferModule:!1})):y=`${s}components/`;let g=l&&Array.isArray(l.predefine)&&l.predefine||[],u=l&&typeof l.mapper=="function"&&l.mapper||null;try{Te(r);let{resolvedTheme:a}=ke({manageTheme:n,themeStorageKey:o,applyResolvedTheme:ne,setupSystemListenerIfNeeded:oe}),i=await xt(s,e),S=Array.isArray(e?.enhancers)?e.enhancers:e?.enhancers&&typeof e.enhancers=="object"?Object.values(e.enhancers):[],m=i?.config?{...i.config,...e,design:e?.design||i.config.design,preset:e?.preset||i.config.preset}:{...e},L={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`},b=i?.paths||{};if(c={...L,...b,...c},r.registry.setStaticMode(c),t&&typeof document<"u")try{let E=await r.registry.getStylesheet("styles");if(E){E._pds=!0;let h=(document.adoptedStyleSheets||[]).filter(w=>w._pds!==!0);document.adoptedStyleSheets=[...h,E],et({mode:"static",source:"static:styles-applied"})}}catch(E){Ie.call(r,"warn","Failed to apply static styles:",E)}let A=null,P=[];try{let E=await Pt(),h=await Me({autoDefineBaseURL:y,autoDefinePreload:g,autoDefineMapper:u,enhancers:S,autoDefineOverrides:l||null,autoDefinePreferModule:!(l&&l.baseURL)},{baseEnhancers:E});A=h.autoDefiner,P=h.mergedEnhancers||[]}catch(E){Ie.call(r,"error","\u274C Failed to initialize AutoDefiner/Enhancers (static):",E)}return r.compiled=we({mode:"static",...m,theme:a,enhancers:P}),Xe({mode:"static",config:m,theme:a,autoDefiner:A}),{config:m,theme:a,autoDefiner:A}}catch(a){throw r.dispatchEvent(new CustomEvent("pds:error",{detail:{error:a}})),a}}var tn=ne,nn=oe;export{r as PDS,tn as applyResolvedTheme,te as configureLocalization,Ye as createJSONLocalization,Je as getLocalizationState,qe as loadLocale,Ke as msg,Ve as setLocale,nn as setupSystemListenerIfNeeded,Ge as str};
1
+ var nt=Object.defineProperty;var ot=(e,t)=>{for(var n in t)nt(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}},Le="__PURE_DS_PDS_SINGLETON__",ae=typeof globalThis<"u"?globalThis:window,se=ae?.[Le],r=se&&typeof se.addEventListener=="function"?se:new ie;ae&&(ae[Le]=r);typeof r.log!="function"&&(r.log=(e="log",t,...n)=>{if(typeof console>"u")return;let o=typeof console[e]=="function"?console[e].bind(console):typeof console.log=="function"?console.log.bind(console):null;o&&(n.length>0?o(t,...n):o(t))});typeof r.logHandler!="function"&&(r.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){r.log("error",`Registry: failed to load static ${t}:`,n),r.log("error",`Registry: looking for ${this._staticPaths[t]}`),r.log("error","Registry: make sure you've run 'npm run pds:build' and configured PDS.start() with the correct static.root path");let o=new CSSStyleSheet;return o.replaceSync("/* Failed to load "+t+" */"),o}}get mode(){return this._mode}get isLive(){return this._mode==="live"}},C=new ce;async function Ee(e,t=[],n=null){try{let o=n?.primitivesStylesheet?n.primitivesStylesheet:await C.getStylesheet("primitives");e.adoptedStyleSheets=[o,...t]}catch(o){let c=e.host?.tagName?.toLowerCase()||"unknown";r.log("error",`Adopter: <${c}> failed to adopt primitives:`,o),e.adoptedStyleSheets=t}}async function Ae(e,t=["primitives"],n=[],o=null){let c=Array.isArray(n)?n.filter(Boolean):[];if(c.length){let l=(Array.isArray(e.adoptedStyleSheets)?e.adoptedStyleSheets:[]).filter(g=>!c.includes(g));e.adoptedStyleSheets=[...l,...c]}try{let l=(await Promise.all(t.map(async g=>{if(o)switch(g){case"tokens":return o.tokensStylesheet;case"primitives":return o.primitivesStylesheet;case"components":return o.componentsStylesheet;case"utilities":return o.utilitiesStylesheet;default:break}return C.getStylesheet(g)}))).filter(g=>g!==null);e.adoptedStyleSheets=[...l,...c]}catch(s){let l=e.host?.tagName?.toLowerCase()||"unknown";r.log("error",`Adopter: <${l}> failed to adopt layers:`,s),e.adoptedStyleSheets=c}}function ve(e){let t=new CSSStyleSheet;return t.replaceSync(e),t}var Pe={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 ue={};ot(ue,{deepMerge:()=>Re,fragmentFromTemplateLike:()=>rt,isObject:()=>W,parseHTML:()=>le});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(o=>{W(t[o])?o in e?n[o]=Re(e[o],t[o]):Object.assign(n,{[o]:t[o]}):Object.assign(n,{[o]:t[o]})}),n}function rt(e){let t=Array.isArray(e?.strings)?e.strings:[],n=Array.isArray(e?.values)?e.values:[],o=new Set,c=[],s=/(\s)(\.[\w-]+)=\s*$/;for(let i=0;i<t.length;i+=1){let S=t[i]??"",m=S.match(s);if(m&&i<n.length){let _=m[2].slice(1),A=`pds-val-${i}`;S=S.replace(s,`$1data-pds-prop="${_}:${A}"`),o.add(i)}c.push(S),i<n.length&&!o.has(i)&&c.push(`<!--pds-val-${i}-->`)}let l=document.createElement("template");l.innerHTML=c.join("");let g=(i,S)=>{let m=i.parentNode;if(!m)return;if(S==null){m.removeChild(i);return}let L=_=>{if(_!=null){if(_ instanceof Node){m.insertBefore(_,i);return}if(Array.isArray(_)){_.forEach(A=>L(A));return}m.insertBefore(document.createTextNode(String(_)),i)}};L(S),m.removeChild(i)},y=document.createTreeWalker(l.content,NodeFilter.SHOW_COMMENT),u=[];for(;y.nextNode();){let i=y.currentNode;i?.nodeValue?.startsWith("pds-val-")&&u.push(i)}return u.forEach(i=>{let S=Number(i.nodeValue.replace("pds-val-",""));g(i,n[S])}),l.content.querySelectorAll("*").forEach(i=>{let S=i.getAttribute("data-pds-prop");if(!S)return;let[m,L]=S.split(":"),_=Number(String(L).replace("pds-val-",""));m&&Number.isInteger(_)&&(i[m]=n[_]),i.removeAttribute("data-pds-prop")}),l.content}function le(e){return new DOMParser().parseFromString(e,"text/html").body.childNodes}var De="pds",st=/^([a-z][a-z0-9+\-.]*:)?\/\//i,xe=/^[a-z]:/i;function U(e=""){return e.endsWith("/")?e:`${e}/`}function it(e="",t=De){let n=e.replace(/\/+$/,"");return new RegExp(`(?:^|/)${t}$`,"i").test(n)?n:`${n}/${t}`}function at(e){return e.replace(/^\.\/+/,"")}function ct(e){return xe.test(e)?e.replace(xe,"").replace(/^\/+/,""):e}function lt(e){return e.startsWith("public/")?e.substring(7):e}function H(e,t={}){let n=t.segment||De,o=t.defaultRoot||`/assets/${n}/`,c=e?.public&&e.public?.root||e?.static&&e.static?.root||null;if(!c||typeof c!="string")return U(o);let s=c.trim();return s?(s=s.replace(/\\/g,"/"),s=it(s,n),s=U(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,g)=>g===0?l:"/")),U(s))):U(o)}async function ut(...e){let t={};e.length&&typeof e[e.length-1]=="object"&&(t=e.pop()||{});let n=e,{baseURL:o,mapper:c=u=>`${u}.js`,onError:s=(u,a)=>console.error(`[defineWebComponents] ${u}:`,a)}=t,l=o?new URL(o,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),g=u=>u.toLowerCase().replace(/(^|-)([a-z])/g,(a,i,S)=>S.toUpperCase()),y=async u=>{try{if(customElements.get(u))return{tag:u,status:"already-defined"};let a=c(u),S=await import(a instanceof URL?a.href:new URL(a,l).href),m=S?.default??S?.[g(u)];if(!m){if(customElements.get(u))return{tag:u,status:"self-defined"};throw new Error(`No export found for ${u}. Expected default export or named export "${g(u)}".`)}return customElements.get(u)?{tag:u,status:"race-already-defined"}:(customElements.define(u,m),{tag:u,status:"defined"})}catch(a){throw s(u,a),a}};return Promise.all(n.map(y))}var B=class{constructor(t={}){let{baseURL:n,mapper:o,onError:c,predicate:s=()=>!0,attributeModule:l="data-module",root:g=document,scanExisting:y=!0,debounceMs:u=16,observeShadows:a=!0,enhancers:i=[],patchAttachShadow:S=!0}=t,m=new Set,L=new Set,_=new Set,A=new Map,P=new WeakMap,E=new WeakMap,h=0,w=!1,R=null,F=d=>{if(!d||!i.length)return;let p=E.get(d);p||(p=new Set,E.set(d,p));for(let f of i)if(!(!f.selector||!f.run)&&!p.has(f.selector))try{d.matches&&d.matches(f.selector)&&(f.run(d),p.add(f.selector))}catch(v){console.warn(`[AutoDefiner] Error applying enhancer for selector "${f.selector}":`,v)}},M=(d,p)=>{if(!w&&!(!d||!d.includes("-"))&&!customElements.get(d)&&!L.has(d)&&!_.has(d)){if(p&&p.getAttribute){let f=p.getAttribute(l);f&&!A.has(d)&&A.set(d,f)}m.add(d),tt()}},tt=()=>{h||(h=setTimeout(Se,u))},D=d=>{if(d){if(d.nodeType===1){let p=d,f=p.tagName?.toLowerCase();f&&f.includes("-")&&!customElements.get(f)&&s(f,p)&&M(f,p),F(p),a&&p.shadowRoot&&re(p.shadowRoot)}d.querySelectorAll&&d.querySelectorAll("*").forEach(p=>{let f=p.tagName?.toLowerCase();f&&f.includes("-")&&!customElements.get(f)&&s(f,p)&&M(f,p),F(p),a&&p.shadowRoot&&re(p.shadowRoot)})}},re=d=>{if(!d||P.has(d))return;D(d);let p=new MutationObserver(f=>{for(let v of f)v.addedNodes?.forEach(z=>{D(z)}),v.type==="attributes"&&v.target&&D(v.target)});p.observe(d,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[l,...i.map(f=>f.selector).filter(f=>f.startsWith("data-"))]}),P.set(d,p)};async function Se(){if(clearTimeout(h),h=0,!m.size)return;let d=Array.from(m);m.clear(),d.forEach(p=>L.add(p));try{let p=f=>A.get(f)??(o?o(f):`${f}.js`);await ut(...d,{baseURL:n,mapper:p,onError:(f,v)=>{_.add(f),c?.(f,v)}})}catch{}finally{d.forEach(p=>L.delete(p))}}let _e=g===document?document.documentElement:g,be=new MutationObserver(d=>{for(let p of d)p.addedNodes?.forEach(f=>{D(f)}),p.type==="attributes"&&p.target&&D(p.target)});if(be.observe(_e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[l,...i.map(d=>d.selector).filter(d=>d.startsWith("data-"))]}),a&&S&&Element.prototype.attachShadow){let d=Element.prototype.attachShadow;Element.prototype.attachShadow=function(f){let v=d.call(this,f);if(f&&f.mode==="open"){re(v);let z=this.tagName?.toLowerCase();z&&z.includes("-")&&!customElements.get(z)&&M(z,this)}return v},R=()=>Element.prototype.attachShadow=d}return y&&D(_e),{stop(){w=!0,be.disconnect(),R&&R(),h&&(clearTimeout(h),h=0),P.forEach(d=>d.disconnect())},flush:Se}}static async define(...t){let n={};t.length&&typeof t[t.length-1]=="object"&&(n=t.pop()||{});let o=t,{baseURL:c,mapper:s=a=>`${a}.js`,onError:l=(a,i)=>console.error(`[defineWebComponents] ${a}:`,i)}=n,g=c?new URL(c,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),y=a=>a.toLowerCase().replace(/(^|-)([a-z])/g,(i,S,m)=>m.toUpperCase()),u=async a=>{try{if(customElements.get(a))return{tag:a,status:"already-defined"};let i=s(a),m=await import(i instanceof URL?i.href:new URL(i,g).href),L=m?.default??m?.[y(a)];if(!L){if(customElements.get(a))return{tag:a,status:"self-defined"};throw new Error(`No export found for ${a}. Expected default export or named export "${y(a)}".`)}return customElements.get(a)?{tag:a,status:"race-already-defined"}:(customElements.define(a,L),{tag:a,status:"defined"})}catch(i){throw l(a,i),i}};return Promise.all(o.map(u))}};var dt=/^[a-z][a-z0-9+\-.]*:\/\//i,j=(()=>{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,o=()=>{if(!j)return null;try{return new URL(e,j).href}catch{return null}},c=()=>{if(typeof window>"u"||!window.location?.origin)return null;try{return new URL(e,window.location.origin).href}catch{return null}};return(n?o()||c():c()||o())||e}var ze=(()=>{if(j)try{let e=new URL(j);if(/\/public\/assets\/js\//.test(e.pathname))return new URL("../pds/",j).href}catch{return}})(),Ce=!1;function Te(e){Ce||typeof document>"u"||(Ce=!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:o}){let c="light",s=null;if(e&&typeof window<"u"){try{s=localStorage.getItem(t)||null}catch{s=null}try{n?.(s),o?.(s)}catch{}s?s==="system"?c=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":c=s:c=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}return{resolvedTheme:c,storedTheme:s}}function q(e,{resolvePublicAssetURL:t}){let n=!!(e?.public?.root||e?.static?.root),o=t(e);return!n&&ze&&(o=ze),K(G(o))}async function Me(e,{baseEnhancers:t=[]}={}){let{autoDefineBaseURL:n="/auto-define/",autoDefinePreload:o=[],autoDefineMapper:c=null,enhancers:s=[],autoDefineOverrides:l=null,autoDefinePreferModule:g=!0}=e,y=(()=>{let a=new Map;return(t||[]).forEach(i=>a.set(i.selector,i)),(s||[]).forEach(i=>a.set(i.selector,i)),Array.from(a.values())})(),u=null;if(typeof window<"u"&&typeof document<"u"){let a=B,i=h=>{switch(h){case"pds-tabpanel":return"pds-tabstrip.js";default:return`${h}.js`}},{mapper:S,enhancers:m,...L}=l&&typeof l=="object"?l:{},_=m?Array.isArray(m)?m:typeof m=="object"?Object.values(m):[]:[],A=(()=>{let h=new Map;return(y||[]).forEach(w=>{w?.selector&&h.set(w.selector,w)}),(_||[]).forEach(w=>{if(!w?.selector)return;let R=h.get(w.selector)||null;h.set(w.selector,{...R||{},...w,run:typeof w?.run=="function"?w.run:R?.run})}),Array.from(h.values())})(),E={baseURL:n&&K(G(n,{preferModule:g})),predefine:o,scanExisting:!0,observeShadows:!0,patchAttachShadow:!0,debounceMs:16,enhancers:A,onError:(h,w)=>{if(typeof h=="string"&&h.startsWith("pds-")){let F=["pds-form","pds-drawer"].includes(h),M=w?.message?.includes("#pds/lit")||w?.message?.includes("Failed to resolve module specifier");F&&M?r.log("error",`\u274C PDS component <${h}> 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`):r.log("warn",`\u26A0\uFE0F PDS component <${h}> not found. Assets may not be installed.`)}else r.log("error",`\u274C Auto-define error for <${h}>:`,w)},...L,mapper:h=>{if(customElements.get(h))return null;if(typeof c=="function")try{let w=c(h);return w===void 0?i(h):w}catch(w){return r.log("warn","Custom autoDefine.mapper error; falling back to default:",w?.message||w),i(h)}return i(h)}};u=new a(E),o.length>0&&typeof a.define=="function"&&await a.define(...o,{baseURL:n,mapper:E.mapper,onError:E.onError})}return{autoDefiner:u,mergedEnhancers:y}}var de=["light","dark"],fe=new Set(de);function ft(e){let n=(Array.isArray(e?.themes)?e.themes.map(o=>String(o).toLowerCase()):de).filter(o=>fe.has(o));return n.length?n:de}function pe(e,{preferDocument:t=!0}={}){let n=String(e||"").toLowerCase();if(fe.has(n))return n;if(t&&typeof document<"u"){let o=document.documentElement?.getAttribute("data-theme");if(fe.has(o))return o}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Ue(e,t){let n=pe(t);return ft(e).includes(n)}var pt=new Set(["log","warn","error","debug","info"]),mt="__PURE_DS_PDS_SINGLETON__",me=null,he=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 he=="function")try{let t=ht(he());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 me=="function")try{let t=me();if(typeof t=="function")return t}catch{}let e=Oe();return typeof e?.logHandler=="function"?e.logHandler:null}function je(e,t,...n){if(typeof console>"u")return;let o=typeof console[e]=="function"?console[e].bind(console):typeof console.log=="function"?console.log.bind(console):null;o&&(n.length>0?o(t,...n):o(t))}function St(e,t){let n=t?.debug===!0;return!(t?.mode==="static"&&!n||!n&&e!=="error"&&e!=="warn")}function Ne({getLogger:e,getContext:t}={}){me=typeof e=="function"?e:null,he=typeof t=="function"?t:null}function $e(e="log",t,...n){let o=yt(e),c=gt(),s=wt();if(s)try{s.call(c?.thisArg,o,t,...n);return}catch(l){je("error","Custom log handler failed:",l)}St(o,c)&&je(o,t,...n)}typeof r.initializing!="boolean"&&(r.initializing=!1);"currentPreset"in r||(r.currentPreset=null);typeof r.debug!="boolean"&&(r.debug=!1);"currentConfig"in r||(r.currentConfig=null);"compiled"in r||(r.compiled=null);typeof r.logHandler!="function"&&(r.logHandler=null);"mode"in r||(r.mode=null);var J=null,V=null,Y=null,Q=null,Z=null,X=null,Fe="__pdsLocalizationRuntime";function T(){if(X)return X;let e=r?.[Fe];return e&&typeof e=="object"?(X=e,e):null}function _t(e){let t=e&&typeof e=="object"?e:null;X=t,r[Fe]=t}Ne({getLogger:()=>typeof r.logHandler=="function"?r.logHandler:null,getContext:()=>{let e=r?.mode||r?.compiled?.mode||(r?.registry?.isLive?"live":"static"),t=(r?.debug||r?.currentConfig?.debug||r?.currentConfig?.design?.debug||r?.compiled?.debug||r?.compiled?.design?.debug||!1)===!0;return{mode:e,debug:t,thisArg:r}}});r.log=(e="log",t,...n)=>{$e(e,t,...n)};var b={locale:"en",messages:{},hasProvider:!1},ee=new Set;function We(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 bt(e,t){return String(e).replace(/\{(\d+)\}/g,(n,o)=>t(Number(o)))}function Lt(e){if(!e||typeof e!="object")return{};let t={};for(let[n,o]of Object.entries(e)){if(typeof o=="string"){t[n]=o;continue}o&&typeof o=="object"&&typeof o.content=="string"&&(t[n]=o.content)}return t}function Et(e,...t){return{strTag:!0,strings:Array.from(e||[]),values:t,raw:Array.from(e?.raw||[])}}function At(e){if(!e)return"";if(We(e)){let n=He(e.strings||[]),o=b.messages[n]||n;return bt(o,c=>e.values?.[c])}let t=String(e);return b.messages[t]||t}function vt(e){if(!e)return;let t=We(e)?He(e.strings||[]):String(e);typeof t=="string"&&t.length>0&&ee.add(t)}function Be(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=T();return e||(Z||(Z=import($("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),Be(n),n}).catch(n=>{throw Z=null,n})),Z)}var Ke=(e,t={})=>{let n=T();return typeof n?.msg=="function"?n.msg(e,t):(vt(e),At(e,t))},Ge=(e,...t)=>{let n=T();return typeof n?.str=="function"?n.str(e,...t):Et(e,...t)},te=(e=null)=>{let t=T();if(typeof t?.configureLocalization=="function")return t.configureLocalization(e);if(!e||typeof e!="object")return b.locale="en",b.messages={},b.hasProvider=!1,{locale:b.locale,messages:{...b.messages},hasProvider:b.hasProvider};typeof e.locale=="string"&&e.locale.trim()&&(b.locale=e.locale.trim()),Object.prototype.hasOwnProperty.call(e,"messages")&&(b.messages=Lt(e.messages));let n=!!(e.provider||e.translate||e.loadLocale||e.setLocale);return b.hasProvider=n,n&&N().then(o=>{o.configureLocalization(e),Be(o)}).catch(()=>{}),{locale:b.locale,messages:{...b.messages},hasProvider:b.hasProvider}},qe=async e=>(await N()).loadLocale(e),Je=async(e,t={})=>(await N()).setLocale(e,t),Ve=()=>{let e=T();return typeof e?.getLocalizationState=="function"?e.getLocalizationState():{locale:b.locale,messages:{...b.messages},hasProvider:b.hasProvider}},Ye=(e={})=>{let t=T();if(typeof t?.createJSONLocalization=="function")return t.createJSONLocalization(e);let n=typeof e?.locale=="string"&&e.locale.trim()?e.locale.trim().toLowerCase():"en",o=Array.isArray(e?.locales)?e.locales.map(y=>String(y||"").trim().toLowerCase()).filter(Boolean):[],c=Array.from(new Set([n,...o])),s=null,l=async()=>(s||(s=N().then(y=>typeof y?.createJSONLocalization=="function"?y.createJSONLocalization(e):null).catch(()=>null)),s),g=async(y="loadLocale")=>{let u=await l();if(!u||typeof u!="object")return null;let a=u.provider;if(!a||typeof a!="object")return null;let i=a[y];return typeof i=="function"?i:y==="setLocale"&&typeof a.loadLocale=="function"?a.loadLocale:null};return{locale:n,locales:[...c],provider:{locales:[...c],async loadLocale(y={}){let u=await g("loadLocale");return typeof u!="function"?{}:u(y)},async setLocale(y={}){let u=await g("setLocale");return typeof u!="function"?{}:u(y)}}}};function $(e,t){return t&&typeof t=="string"?t:`${q(r.currentConfig||{},{resolvePublicAssetURL:H})}core/${e}`}async function Pt(){return Array.isArray(r.defaultEnhancers)&&r.defaultEnhancers.length>0?r.defaultEnhancers:(Q||(Q=import($("pds-enhancers.js",r.currentConfig?.enhancersURL)).then(t=>{let n=Array.isArray(t?.defaultPDSEnhancers)?t.defaultPDSEnhancers:[];return r.defaultEnhancers=n,n}).catch(t=>{throw Q=null,t})),Q)}async function Rt(){return typeof r.ask=="function"&&r.ask!==Qe?r.ask:(V||(V=import($("pds-ask.js",r.currentConfig?.askURL)).then(t=>{let n=t?.ask;if(typeof n!="function")throw new Error("Failed to load ask helper");return r.ask=n,n}).catch(t=>{throw V=null,t})),V)}async function I(){return typeof r.toast=="function"&&r.toast!==k?r.toast:(Y||(Y=import($("pds-toast.js",r.currentConfig?.toastURL)).then(t=>{let n=t?.toast;if(typeof n!="function")throw new Error("Failed to load toast helper");return r.toast=n,n}).catch(t=>{throw Y=null,t})),Y)}async function Qe(...e){return(await Rt())(...e)}async function k(...e){return(await I())(...e)}k.success=async(...e)=>(await I()).success(...e);k.error=async(...e)=>(await I()).error(...e);k.warning=async(...e)=>(await I()).warning(...e);k.info=async(...e)=>(await I()).info(...e);var Ie=function(e="log",t,...n){r.log(e,t,...n)};function ge(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=>ge(n)).filter(n=>n!==void 0);let t={};for(let[n,o]of Object.entries(e)){let c=ge(o);c!==void 0&&(t[n]=c)}return t}function Ze(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))Ze(e[n],t);return e}function we(e){return e==null||typeof e!="object"?e:Ze(structuredClone(ge(e)))}async function xt(e,t={}){if(t?.runtimeConfig===!1||typeof fetch!="function")return null;let n=t?.runtimeConfigURL||`${e}pds-runtime-config.json`;try{let o=await fetch(n,{cache:"no-store"});return o.ok?await o.json():null}catch{return null}}r.registry=C;r.enums=Pe;r.adoptLayers=Ae;r.adoptPrimitives=Ee;r.parse=le;r.createStylesheet=ve;r.isLiveMode=()=>C.isLive;r.ask=Qe;r.toast=k;r.common=ue;r.msg=Ke;r.str=Ge;r.configureLocalization=te;r.loadLocale=qe;r.setLocale=Je;r.getLocalizationState=Ve;r.createJSONLocalization=Ye;r.i18n={msg:Ke,str:Ge,configure:te,loadLocale:qe,setLocale:Je,getState:Ve,createJSONLocalization:Ye};r.AutoComplete=null;r.loadAutoComplete=async()=>{if(r.AutoComplete&&typeof r.AutoComplete.connect=="function")return r.AutoComplete;let e=$("pds-autocomplete.js",r.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 r.AutoComplete=n,n}).catch(t=>{throw J=null,t})),J};function Xe(e){let t=typeof CustomEvent=="function";try{let n=t?new CustomEvent("pds:ready",{detail:e}):new Event("pds:ready");r.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 et(e={}){let t=typeof CustomEvent=="function",n={at:Date.now(),...e};try{let o=t?new CustomEvent("pds:config-changed",{detail:n}):new Event("pds:config-changed");r.dispatchEvent(o)}catch{}if(typeof document<"u")if(t){let o={detail:n,bubbles:!0,composed:!0};try{document.dispatchEvent(new CustomEvent("pds:config-changed",o))}catch{}}else try{document.dispatchEvent(new Event("pds:config-changed"))}catch{}}var ye="pure-ds-theme",x=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 oe(e){try{if(x&&O){try{typeof x.removeEventListener=="function"?x.removeEventListener("change",O):typeof x.removeListener=="function"&&x.removeListener(O)}catch{}x=null,O=null}if(e==="system"&&typeof window<"u"&&window.matchMedia){let t=window.matchMedia("(prefers-color-scheme: dark)"),n=o=>{let c=o?.matches===void 0?t.matches:o.matches;try{let s=c?"dark":"light";document.documentElement.setAttribute("data-theme",s),r.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:s,source:"system"}}))}catch{}};x=t,O=n,typeof t.addEventListener=="function"?t.addEventListener("change",n):typeof t.addListener=="function"&&t.addListener(n)}}catch{}}var Dt=Object.getOwnPropertyDescriptor(r,"theme");Dt||Object.defineProperty(r,"theme",{get(){try{return typeof window>"u"?null:localStorage.getItem(ye)||null}catch{return null}},set(e){try{if(typeof window>"u")return;let t=r.currentConfig?.design||null,n=pe(e);if(t&&!Ue(t,n)){let o=t?.name||r.currentPreset?.name||r.currentConfig?.preset||"current preset";r.log("warn",`PDS theme "${n}" not supported by preset "${o}".`),r.dispatchEvent(new CustomEvent("pds:theme:blocked",{detail:{theme:e,resolvedTheme:n,preset:o}}));return}e==null?localStorage.removeItem(ye):localStorage.setItem(ye,e),ne(e),oe(e),r.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:e,source:"api"}}))}catch{}}});r.defaultEnhancers=[];async function zt(e){r.initializing=!0;try{let t=e&&e.mode||"live",{mode:n,...o}=e||{};r.mode=t,r.logHandler=typeof o?.log=="function"?o.log:null,r.currentConfig=we(o);let c=o&&typeof o.localization=="object"&&o.localization?o.localization:null;c?(await N(),te(c)):te(null);let s;if(t==="static")s=await Ct(o);else{let{localization:g,...y}=o||{},u=q(y,{resolvePublicAssetURL:H}),a=y?.managerURL||y?.public?.managerURL||y?.manager?.url||new URL("core/pds-manager.js",u).href||new URL("./pds-manager.js",import.meta.url).href,{startLive:i}=await import(a);s=await i(r,y,{emitReady:Xe,emitConfigChanged:et,applyResolvedTheme:ne,setupSystemListenerIfNeeded:oe})}r.compiled=we(s?.config||null);let l=r?.compiled?.design?.icons?.externalPath||"/assets/img/icons/";return r.log("info",`startup ready; external icon path: ${l}`),s}finally{r.initializing=!1}}r.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,o=e.themeStorageKey??"pure-ds-theme",c=e.staticPaths??{},s=q(e,{resolvePublicAssetURL:H}),l=e&&e.autoDefine||null,g;l&&l.baseURL?g=K(G(l.baseURL,{preferModule:!1})):g=`${s}components/`;let y=l&&Array.isArray(l.predefine)&&l.predefine||[],u=l&&typeof l.mapper=="function"&&l.mapper||null;try{Te(r);let{resolvedTheme:a}=ke({manageTheme:n,themeStorageKey:o,applyResolvedTheme:ne,setupSystemListenerIfNeeded:oe}),i=await xt(s,e),S=Array.isArray(e?.enhancers)?e.enhancers:e?.enhancers&&typeof e.enhancers=="object"?Object.values(e.enhancers):[],m=i?.config?{...i.config,...e,design:e?.design||i.config.design,preset:e?.preset||i.config.preset}:{...e},L={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`},_=i?.paths||{};if(c={...L,..._,...c},r.registry.setStaticMode(c),t&&typeof document<"u")try{let E=await r.registry.getStylesheet("styles");if(E){E._pds=!0;let h=(document.adoptedStyleSheets||[]).filter(w=>w._pds!==!0);document.adoptedStyleSheets=[...h,E],et({mode:"static",source:"static:styles-applied"})}}catch(E){Ie.call(r,"warn","Failed to apply static styles:",E)}let A=null,P=[];try{let E=await Pt(),h=await Me({autoDefineBaseURL:g,autoDefinePreload:y,autoDefineMapper:u,enhancers:S,autoDefineOverrides:l||null,autoDefinePreferModule:!(l&&l.baseURL)},{baseEnhancers:E});A=h.autoDefiner,P=h.mergedEnhancers||[]}catch(E){Ie.call(r,"error","\u274C Failed to initialize AutoDefiner/Enhancers (static):",E)}return r.compiled=we({mode:"static",...m,theme:a,enhancers:P}),Xe({mode:"static",config:m,theme:a,autoDefiner:A}),{config:m,theme:a,autoDefiner:A}}catch(a){throw r.dispatchEvent(new CustomEvent("pds:error",{detail:{error:a}})),a}}var tn=ne,nn=oe;export{r as PDS,tn as applyResolvedTheme,te as configureLocalization,Ye as createJSONLocalization,Ve as getLocalizationState,qe as loadLocale,Ke as msg,Je as setLocale,nn as setupSystemListenerIfNeeded,Ge as str};