efficient-storefront-blocks 0.25.1 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +69 -0
- package/README.md +53 -5
- package/dist/chunks/{EditorPreviewCheckout-URFSPLP6.js → EditorPreviewCheckout-74ZL6KSE.js} +1 -1
- package/dist/chunks/PreviewFooter-IE25M3OO.js +1 -0
- package/dist/chunks/SiteEditorProvider-A24N444B.js +1 -0
- package/dist/chunks/chunk-4CEJDQT6.js +154 -0
- package/dist/chunks/{chunk-5FWFXNTA.js → chunk-AT54VAHN.js} +1 -1
- package/dist/chunks/chunk-JMPXWSWW.js +16 -0
- package/dist/chunks/chunk-TPQS7R54.js +1 -0
- package/dist/chunks/chunk-TZQUVG3U.js +230 -0
- package/dist/chunks/{fitment-data-QCRJYMQI.js → fitment-data-D2XKX2FH.js} +1 -1
- package/dist/chunks/{render-client-IM6ELUPU.js → render-client-7TWSIUW2.js} +1 -1
- package/dist/editor.css +1 -1
- package/dist/index.d.ts +27 -0
- package/dist/index.js +124 -314
- package/dist/links.d.ts +5 -3
- package/dist/links.js +1 -1
- package/dist/words.d.ts +1911 -0
- package/dist/words.js +11 -0
- package/package.json +10 -3
- package/dist/chunks/PreviewFooter-FMWOXIAI.js +0 -1
- package/dist/chunks/SiteEditorProvider-ZSJ42NW3.js +0 -1
- package/dist/chunks/chunk-D42IBF3T.js +0 -230
- package/dist/chunks/chunk-E27PWVTV.js +0 -16
- package/dist/chunks/chunk-ITVNHQAU.js +0 -154
- package/dist/chunks/chunk-RVAMC6AG.js +0 -1
- /package/dist/chunks/{SectionEditorShell-KPJJGNME.js → SectionEditorShell-B33EV72Q.js} +0 -0
- /package/dist/chunks/{chunk-ITVNHQAU.js.LEGAL.txt → chunk-4CEJDQT6.js.LEGAL.txt} +0 -0
- /package/dist/chunks/{chunk-XMRDC5JK.js → chunk-5ARJ7ZNM.js} +0 -0
- /package/dist/chunks/{chunk-E27PWVTV.js.LEGAL.txt → chunk-JMPXWSWW.js.LEGAL.txt} +0 -0
- /package/dist/chunks/{chunk-BXKNNBHR.js → chunk-PT6SNSRB.js} +0 -0
package/dist/links.d.ts
CHANGED
|
@@ -101,13 +101,15 @@ export type LinkPickerKind = {
|
|
|
101
101
|
hint?: string;
|
|
102
102
|
hideWhenEmpty?: boolean;
|
|
103
103
|
};
|
|
104
|
-
/** The URL rules the picker is handed (efficient-easel `LinkRules
|
|
104
|
+
/** The URL rules the picker is handed (efficient-easel `LinkRules`, the
|
|
105
|
+
* shell's). `isSafe` is optional there since efficient-shell 7: the picker
|
|
106
|
+
* falls back to its own rule. {@link LinkPickerSetup} always carries it. */
|
|
105
107
|
export type LinkPickerRules = {
|
|
106
108
|
kindOf: (url: string) => string;
|
|
107
109
|
targetOf: (url: string) => string;
|
|
108
110
|
readFilter: (url: string) => ListingFilter;
|
|
109
111
|
withFilter: (url: string, filter: ListingFilter) => string;
|
|
110
|
-
isSafe
|
|
112
|
+
isSafe?: (url: string) => boolean;
|
|
111
113
|
};
|
|
112
114
|
export type LinkPickerSetupInput = {
|
|
113
115
|
/** The pages a link may point at (no system pages); `docs` = published, then draft. */
|
|
@@ -121,7 +123,7 @@ export type LinkPickerSetupInput = {
|
|
|
121
123
|
};
|
|
122
124
|
export type LinkPickerSetup = {
|
|
123
125
|
kinds: LinkPickerKind[];
|
|
124
|
-
rules: LinkPickerRules
|
|
126
|
+
rules: Required<LinkPickerRules>;
|
|
125
127
|
filtersFor: (target: string) => readonly { param: string; label: string; values: readonly LinkPickerOption[] }[] | null;
|
|
126
128
|
};
|
|
127
129
|
/**
|
package/dist/links.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var h={bold:{open:"**",close:"**",placeholder:"bold text"},italic:{open:"_",close:"_",placeholder:"italic text"},strike:{open:"~~",close:"~~",placeholder:"struck out"},code:{open:"`",close:"`",placeholder:"code"},highlight:{open:"==",close:"==",placeholder:"highlighted text"},quiet:{open:"^^",close:"^^",placeholder:"quiet text"},underline:{open:"[",close:"]{underline}",placeholder:"underlined text"},sup:{open:"[",close:"]{sup}",placeholder:"superscript"},sub:{open:"[",close:"]{sub}",placeholder:"subscript"}};var Ke={bold:h.bold.placeholder,italic:h.italic.placeholder,strike:h.strike.placeholder,code:h.code.placeholder,highlight:h.highlight.placeholder,quiet:h.quiet.placeholder,link:"link text",underline:h.underline.placeholder,sup:h.sup.placeholder,sub:h.sub.placeholder,color:"colored text"};var Z=[{style:"bold",label:"B",name:"Strong",title:"Strong \xB7 **words** \xB7 \u2318B",shortcut:"b"},{style:"italic",label:"I",name:"Italic",title:"Italic \xB7 _words_ \xB7 \u2318I",shortcut:"i"},{style:"strike",label:"S",name:"Strikethrough",title:"Strikethrough \xB7 ~~words~~"},{style:"highlight",label:"\u25C6",name:"Emphasis",title:"Emphasis \xB7 ==words=="},{style:"quiet",label:"a",name:"Quiet",title:"Quiet \xB7 ^^words^^"},{style:"code",label:"\u2039\u203A",name:"Code",title:"Code"},{style:"link",label:"\u{1F517}",name:"Link",title:"Link \xB7 [words](https://\u2026) \xB7 \u2318K",shortcut:"k"},{style:"bullet",label:"\u2022",name:"Bulleted list",title:"Bulleted list"},{style:"number",label:"1.",name:"Numbered list",title:"Numbered list"},{style:"quote",label:"\u275D",name:"Quote",title:"Quote"},{style:"clear",label:"T\xD7",name:"Clear marks",title:"Clear marks \xB7 \u2318\u21E7X",shortcut:"shift+x"}];var S=[{open:"**",close:"**",kind:"bold"},{open:"==",close:"==",kind:"highlight"},{open:"~~",close:"~~",kind:"strike"},{open:"_",close:"_",kind:"italic",wordBoundary:!0},{open:"^^",close:"^^",kind:"quiet"},{open:"@@",close:"@@",kind:"highlight"},{open:"++",close:"++",kind:"bold",wordStart:!0}],Q=["highlight","quiet"],Ce=Z.map(e=>e.style).filter(e=>S.some(n=>n.kind===e)).filter(e=>!Q.includes(e)),Oe=[...S,{open:"*",close:"*",kind:"accent"}],Ne=[...S,{open:"*",close:"*",kind:"accent"},{open:"#",close:"#",kind:"bold",notBefore:"0123456789"},{open:"[",close:"]",kind:"italic",notBefore:"(",notBeforeBlock:!0}];var ve=["http","https","mailto","tel"];function N(e){if(e===""||/[\s\u0000-\u001f\u007f]/.test(e))return!1;let n=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);return!n||ve.includes(n[1].toLowerCase())}var X=["width","profile","rim"];var Me=/^\s*(\d{2,3})\s*\/\s*(\d{2,3})\s*[A-Za-z]*\s*(\d{2}(?:\.\d+)?)\s*$/,ze={width:[100,500],profile:[20,100],rim:[10,30]};function v(e){let n=Me.exec(e??"");if(!n)return null;let t={width:Number(n[1]),profile:Number(n[2]),rim:Number(n[3])};return X.every(l=>{let[s,a]=ze[l];return t[l]>=s&&t[l]<=a})?t:null}function x(e){if(e.width==null)return"";if(e.profile==null)return String(e.width);let n=`${e.width}/${e.profile}`;return e.rim==null?n:`${n} R${e.rim}`}function J(e){return[x({width:e.width}),x({width:e.width,profile:e.profile}),x(e)]}var b=["alloy-wheel","tyre"],ee=["alloy-wheel"],L={"alloy-wheel":"Alloy wheels",tyre:"Tyres"};var Dn=b.map(e=>({value:e,label:L[e]}));function M(e){return e==null?[...ee]:Array.isArray(e)?b.filter(n=>e.includes(n)):[...ee]}var f=e=>e;function d(e){return f(e).kind==="tyre"?"tyre":"alloy-wheel"}function z(e){return f(e).brand??""}function ne(e){return f(e).prices??void 0}function te(e){return f(e).inStock!==!1}function re(e){let n=f(e),t=d(e)==="tyre"?n.rimDiameters:n.sizes;return Array.isArray(t)?t.filter(r=>typeof r=="number"&&Number.isFinite(r)):[]}function U(e){return d(e)==="tyre"?[]:(f(e).finishes??[]).filter(n=>typeof n?.family=="string").map(n=>({family:n.family,color:n.color??null}))}function ie(e){return U(e).map(n=>n.family)}function le(e){if(d(e)==="tyre")return[];let n=f(e),t=n.categories;return t&&t.length>0?t:n.process?[n.process]:[]}function oe(e){return d(e)==="tyre"?[]:f(e).spec?.pcds??[]}function se(e){return d(e)!=="tyre"?[]:f(e).tyreTypes??[]}function ae(e){return d(e)!=="tyre"?[]:f(e).speedRatings??[]}function ue(e){if(d(e)!=="tyre")return[];let n=f(e).sizes;return Array.isArray(n)?n.map(t=>v(typeof t=="string"?t:null)).filter(t=>t!==null):[]}var ce="homepage";function pe(e){return(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}var w=[{value:"page",label:"Page"},{value:"anchor",label:"Anchor"},{value:"blog",label:"Blog post",needs:"service"},{value:"product",label:"Product",needs:"commerce"},{value:"custom",label:"Custom URL"}];function F(e){return e.offersCommerce&&e.offersService?w:w.filter(n=>!n.needs||(n.needs==="commerce"?e.offersCommerce:e.offersService))}function g(e){return e===ce?"/":`/${e}`}function T(e){return`/journal/${e}`}function _(e){return`/wheels/${e}`}function A(e,n){return`${g(e)}#${n}`}function D(e){return pe(e)}function Ue(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.text=="string"?e.text.trim():""}function R(...e){let n=new Set,t=[];for(let r of e)for(let l of r?.content??[]){let s=Ue(l?.props?.anchor);if(!s)continue;let a=D(s);!a||n.has(a)||(n.add(a),t.push({slug:a,name:s}))}return t}var P={choosePage:"Choose a page",chooseSection:"Choose a section",noSections:"No section anchors yet",sectionHint:"Jumps to a section on that page.",choosePost:"Choose a post",chooseProduct:"Choose a product"};function E(e,n,t){if(!e)return"page";if(e.startsWith("/journal/"))return"blog";if(e.startsWith("/wheels/"))return"product";if(e.includes("#")){let r=e.slice(0,e.indexOf("#"));if(r===""||r==="/"||n.includes(r))return"anchor"}return e==="/"||n.includes(e)||t&&t.listingPaths.includes(t.targetOf(e))?"page":"custom"}function de(e,n){let t=e.pages.map(i=>({value:g(i.slug),label:i.title})),r=n?.pageOptions?n.pageOptions(t):t,l=r.map(i=>i.value),s=e.pages.map(i=>({label:i.title,options:R(...i.docs).map(u=>({value:A(i.slug,u.slug),label:u.name}))})).filter(i=>i.options.length>0),a=i=>{switch(i){case"page":return{type:"select",options:r,placeholder:P.choosePage};case"anchor":return{type:"groups",groups:s,placeholder:s.length?P.chooseSection:P.noSections};case"blog":return{type:"select",options:e.posts.map(u=>({value:T(u.slug),label:u.title||u.slug})),placeholder:P.choosePost};case"product":return{type:"select",options:e.products.map(u=>({value:u.href,label:u.name||u.href})),placeholder:P.chooseProduct};case"custom":return{type:"text"}}},c=F(e.offers).map(i=>({value:i.value,label:i.label,target:a(i.value),...i.value==="anchor"?{hint:P.sectionHint}:{},...i.value==="blog"||i.value==="product"?{hideWhenEmpty:!0}:{}}));if(!n)return{kinds:c,rules:{kindOf:i=>E(i,l),targetOf:i=>i,readFilter:()=>null,withFilter:i=>i}};let o=i=>{let u=n.withFilter(i,null);return n.listingPaths.includes(u)?u:i};return{kinds:c,rules:{kindOf:i=>E(i,l,{listingPaths:n.listingPaths,targetOf:o}),targetOf:o,readFilter:n.readFilter,withFilter:n.withFilter},filtersFor:i=>n.listingPaths.includes(i)?n.filtersFor(i):null}}function B(e,n){return e.length===0?e:e.filter(t=>t.kind===void 0||t.kind===n)}function fe(e,n){let t=n==="filter"?"filterOrder":"cardOrder",r=new Map;for(let l of e){let s=l[t];if(typeof s!="number"||!Number.isFinite(s))continue;let a=r.get(l.fieldKey);(a===void 0||s<a)&&r.set(l.fieldKey,s)}return l=>l?r.get(l):void 0}function me(e,n,t,r){let l=new Map;for(let o of t){let i=o[r];typeof i=="number"&&l.set(o.fieldKey,i)}if(l.size===0)return e;let s=[],a=[];e.forEach((o,i)=>{let u=n(o);u&&(s.push(i),a.push({item:o,index:i,order:l.get(u)}))}),a.sort((o,i)=>o.order!==void 0&&i.order!==void 0?o.order-i.order||o.index-i.index:o.order!==void 0?-1:i.order!==void 0?1:o.index-i.index);let c=[...e];return s.forEach((o,i)=>{c[o]=a[i].item}),c.every((o,i)=>o===e[i])?e:c}function he(e){return Be(e,"filter")}var De="collection";function $(e,n){return{tyreSizes:{},brands:{"alloy-wheel":"brand",tyre:"brand"},finishes:{"alloy-wheel":"wheel_finish_ref"},diameters:{"alloy-wheel":"diameter",tyre:"rim_diameter"},collections:{"alloy-wheel":De},pcds:{"alloy-wheel":"pcd"},tyreTypes:{tyre:"tire_type"},speedRatings:{tyre:"speed_rating"}}[e]?.[n]}function Be(e,n){let t=new Set(e.filter(r=>r[n]===!1).map(r=>r.fieldKey));return r=>!r||!t.has(r)}function $e(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function ge(e,n){let t=e?.[n];return $e(t)?t:null}function ye(e,n,t,r){if(t==null&&r==null)return!0;let l=ge(e,n);return!(l===null||t!=null&&l<t||r!=null&&l>r)}var We={recommended:"Recommended","price-asc":"Price \xB7 low to high","price-desc":"Price \xB7 high to low",new:"Newest",name:"Name A\u2013Z"},yt=Object.keys(We);var Pe=["tyreSizes","brands","finishes","diameters","collections","pcds","tyreTypes","speedRatings"],Ye={tyreSizes:["tyre"],brands:["alloy-wheel","tyre"],finishes:["alloy-wheel"],diameters:["alloy-wheel","tyre"],collections:["alloy-wheel"],pcds:["alloy-wheel"],tyreTypes:["tyre"],speedRatings:["tyre"]},Ge={diameters:"tyreSizes"};function qe(e){if(e.length===0)return[];let n=Pe.filter(t=>e.every(r=>Ye[t].includes(r)));return n.filter(t=>{let r=Ge[t];return!r||!n.includes(r)})}function He(e){let n=new Set;for(let t of e)n.add(d(t));return[...n]}var be={tyreSizes:[],brands:[],finishes:[],diameters:[],collections:[],pcds:[],tyreTypes:[],speedRatings:[],priceMax:null,inStockOnly:!1,kind:null,sort:"recommended",page:1};function je(e,n,t,r=null){if(r!=="kind"&&n.kind&&d(e)!==n.kind)return!1;for(let l of Pe){if(r===l)continue;let s=n[l];if(s.length===0)continue;let a=s.map(String);if(!ke(e,l).some(c=>a.includes(c)))return!1}return!(r!=="price"&&!ye(ne(e),t,null,n.priceMax)||r!=="inStock"&&n.inStockOnly&&!te(e))}var Ve={tyreSizes:"Size",brands:"Brand",finishes:"Colour",diameters:"Size \xB7 diameter",collections:"Collection",pcds:"PCD \xB7 fitment",tyreTypes:"Tyre type",speedRatings:"Speed rating"};function ke(e,n){switch(n){case"tyreSizes":return[...new Set(ue(e).flatMap(J))];case"brands":return z(e)?[z(e)]:[];case"finishes":return ie(e);case"diameters":return re(e).map(String);case"collections":return le(e);case"pcds":return oe(e);case"tyreTypes":return se(e);case"speedRatings":return ae(e)}}function Ze(e){let n=new Map;for(let t of e)for(let r of U(t))r.color&&!n.has(r.family)&&n.set(r.family,r.color);return n}function Se(e,n,t,r=He(e),l=[]){let s=i=>Xe(i,r,l),a=Ze(e),c=qe(r).filter(i=>i!=="tyreSizes").filter(s).map(i=>{let u=n[i].map(String),V=new Set,O=new Map,k=new Map;for(let p of e){let y=ke(p,i);for(let m of y)V.add(m);for(let m of new Set(y))k.set(m,(k.get(m)??0)+1);if(je(p,n,t,i))for(let m of new Set(y))O.set(m,(O.get(m)??0)+1)}let Ie=[...V].map(p=>({value:p,label:i==="diameters"?`${p}\u2033`:p,count:O.get(p)??0,checked:u.includes(p),swatch:i==="finishes"?a.get(p)??null:null})).sort((p,y)=>{if(i==="diameters")return Number(p.value)-Number(y.value);let m=(k.get(y.value)??0)-(k.get(p.value)??0);return m!==0?m:p.value.localeCompare(y.value)});return{key:i,label:Ve[i],options:Ie}}).filter(i=>i.options.length>Qe),o=[];for(let i of c){let u=Je(i.key,r,l);u!==void 0&&o.push({fieldKey:i.key,filterOrder:u})}return[...me(c,i=>i.key,o,"filterOrder")]}var Qe=1;function xe(e){return e.showCollection===!1?["collections"]:[]}function Xe(e,n,t){return n.length===0||t.length===0?!0:n.some(r=>he(B(t,r))($(e,r)))}function Je(e,n,t){if(t.length===0)return;let r;for(let l of n){let s=fe(B(t,l),"filter")($(e,l));s!==void 0&&(r===void 0||s<r)&&(r=s)}return r}var W={tyreSizes:"tyreSize",brands:"brand",finishes:"colour",diameters:"size",collections:"collection",pcds:"pcd",tyreTypes:"tyreType",speedRatings:"speed"},Y="type";var Le="AlloyWheelsListing";function we(e){return N(e.trim())}var I="/wheels",K="Products";function Fe(e,n){return n>1?`${K} \xB7 ${e}`:K}function G(...e){for(let n of e){let t=(n?.content??[]).find(r=>r?.type===Le);if(t)return t.props??{}}return null}function C(...e){return G(...e)!==null}function Te(e,n){let t=e.filter(r=>C(...r.docs)).map(r=>g(r.slug));return t.length===0&&n.fallback?[I]:t}var q=[Y,...Object.entries(W).filter(([e])=>e!=="tyreSizes").map(([,e])=>e)];function _e(e){let n=e.indexOf("#"),t=n===-1?"":e.slice(n),r=n===-1?e:e.slice(0,n),l=r.indexOf("?");return{path:l===-1?r:r.slice(0,l),query:l===-1?"":r.slice(l+1),hash:t}}function en(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return e}}function Ae(e){let n=new URLSearchParams(_e(e).query);for(let t of q){let r=n.get(t);if(r)return{param:t,value:r}}return null}function H(e,n){let{path:t,query:r,hash:l}=_e(e),s=r.split("&").filter(a=>a&&!q.includes(en(a.split("=")[0])));return n?.value&&s.push(`${encodeURIComponent(n.param)}=${encodeURIComponent(n.value)}`),`${t}${s.length?`?${s.join("&")}`:""}${l}`}function Re(e,n){let t=H(e,null);return n.includes(t)?t:e}function nn(e,n,t=[]){return E(e,n,{listingPaths:t,targetOf:r=>Re(r,t)})}function tn(e){return Array.isArray(e)?e.filter(n=>typeof n?.kind=="string"&&typeof n.field_key=="string").map(n=>({kind:n.kind,fieldKey:n.field_key,...typeof n.filter=="boolean"?{filter:n.filter}:{},filterOrder:n.filter_order??null})):[]}var Ee="Product type",rn="AUD";function j(e,n){let t=n.listing??{},r=M(t.kinds),l=e.filter(o=>r.includes(d(o))),s=xe(t),a=Se(l,be,rn,r,n.fieldUsage).filter(o=>!s.includes(o.key)).map(o=>({param:W[o.key],label:o.label,values:o.options.filter(i=>!i.value.includes(",")).map(i=>({value:i.value,label:i.label}))})).filter(o=>o.values.length>0),c=b.filter(o=>r.includes(o)&&l.some(i=>d(i)===o));return c.length>1&&a.unshift({param:Y,label:Ee,values:c.map(o=>({value:o,label:L[o]}))}),a}function ln(e){return n=>{let t=Te(n,{fallback:e.offersCommerce}),r=n.filter(l=>C(...l.docs)).length;return{listingPaths:t,pageOptions:l=>{let s=l.map(a=>{let c=n.find(o=>g(o.slug)===a.value);return c&&C(...c.docs)?{...a,label:Fe(c.title,r)}:a});return r===0&&e.offersCommerce&&!s.some(a=>a.value===I)&&s.push({value:I,label:K}),s},filtersFor:l=>{if(!t.includes(l))return null;let s=n.find(a=>g(a.slug)===l);return j(e.catalogue,{listing:s?G(...s.docs):null,fieldUsage:e.fieldUsage})},readFilter:Ae,withFilter:H}}}function on(e){let n=ln({catalogue:e.catalogue,fieldUsage:e.fieldUsage,offersCommerce:e.offers.offersCommerce})(e.pages),t=de({pages:e.pages,posts:e.posts,products:e.products.map(r=>({href:_(r.slug),name:r.name||r.slug})),offers:e.offers},n);return{...t,rules:{...t.rules,isSafe:we},filtersFor:t.filtersFor??(()=>null)}}function Ot(e,n){return j(e,n)}export{I as BUILT_IN_LISTING_PATH,w as LINK_KINDS,q as LISTING_FILTER_PARAMS,K as LISTING_PAGE_LABEL,Ee as PRODUCT_TYPE_FILTER_LABEL,A as anchorPath,tn as fieldUsageFromAdminRows,nn as inferLinkKind,C as isProductListingPage,we as isSafeLink,F as linkKindsFor,on as linkPickerSetup,Ot as listingFilterFields,G as listingNode,Fe as listingPageLabel,Re as listingTarget,R as pageAnchors,g as pagePath,T as postPath,Te as productListingPaths,Ae as readListingFilter,D as slugifyAnchor,_ as wheelPath,H as withListingFilter};
|
|
1
|
+
var g={bold:{open:"**",close:"**",placeholder:"bold text"},italic:{open:"_",close:"_",placeholder:"italic text"},strike:{open:"~~",close:"~~",placeholder:"struck out"},code:{open:"`",close:"`",placeholder:"code"},highlight:{open:"==",close:"==",placeholder:"highlighted text"},quiet:{open:"^^",close:"^^",placeholder:"quiet text"},underline:{open:"[",close:"]{underline}",placeholder:"underlined text"},sup:{open:"[",close:"]{sup}",placeholder:"superscript"},sub:{open:"[",close:"]{sub}",placeholder:"subscript"}};var Oe={bold:g.bold.placeholder,italic:g.italic.placeholder,strike:g.strike.placeholder,code:g.code.placeholder,highlight:g.highlight.placeholder,quiet:g.quiet.placeholder,link:"link text",underline:g.underline.placeholder,sup:g.sup.placeholder,sub:g.sub.placeholder,color:"colored text"};var V=[{style:"bold",label:"B",name:"Strong",title:"Strong \xB7 **words** \xB7 \u2318B",shortcut:"b"},{style:"italic",label:"I",name:"Italic",title:"Italic \xB7 _words_ \xB7 \u2318I",shortcut:"i"},{style:"strike",label:"S",name:"Strikethrough",title:"Strikethrough \xB7 ~~words~~"},{style:"highlight",label:"\u25C6",name:"Emphasis",title:"Emphasis \xB7 ==words=="},{style:"quiet",label:"a",name:"Quiet",title:"Quiet \xB7 ^^words^^"},{style:"code",label:"\u2039\u203A",name:"Code",title:"Code"},{style:"link",label:"\u{1F517}",name:"Link",title:"Link \xB7 [words](https://\u2026) \xB7 \u2318K",shortcut:"k"},{style:"bullet",label:"\u2022",name:"Bulleted list",title:"Bulleted list"},{style:"number",label:"1.",name:"Numbered list",title:"Numbered list"},{style:"quote",label:"\u275D",name:"Quote",title:"Quote"},{style:"clear",label:"T\xD7",name:"Clear marks",title:"Clear marks \xB7 \u2318\u21E7X",shortcut:"shift+x"}];var x=[{open:"**",close:"**",kind:"bold"},{open:"==",close:"==",kind:"highlight"},{open:"~~",close:"~~",kind:"strike"},{open:"_",close:"_",kind:"italic",wordBoundary:!0},{open:"^^",close:"^^",kind:"quiet"},{open:"@@",close:"@@",kind:"highlight"},{open:"++",close:"++",kind:"bold",wordStart:!0}],Q=["highlight","quiet"],Ne=V.map(e=>e.style).filter(e=>x.some(n=>n.kind===e)).filter(e=>!Q.includes(e)),ve=[...x,{open:"*",close:"*",kind:"accent"}],Me=[...x,{open:"*",close:"*",kind:"accent"},{open:"#",close:"#",kind:"bold",notBefore:"0123456789"},{open:"[",close:"]",kind:"italic",notBefore:"(",notBeforeBlock:!0}];var ze=["http","https","mailto","tel"];function v(e){if(e===""||/[\s\u0000-\u001f\u007f]/.test(e))return!1;let n=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);return!n||ze.includes(n[1].toLowerCase())}var X=["width","profile","rim"];var Ue=/^\s*(\d{2,3})\s*\/\s*(\d{2,3})\s*[A-Za-z]*\s*(\d{2}(?:\.\d+)?)\s*$/,De={width:[100,500],profile:[20,100],rim:[10,30]};function M(e){let n=Ue.exec(e??"");if(!n)return null;let t={width:Number(n[1]),profile:Number(n[2]),rim:Number(n[3])};return X.every(i=>{let[a,u]=De[i];return t[i]>=a&&t[i]<=u})?t:null}function L(e){if(e.width==null)return"";if(e.profile==null)return String(e.width);let n=`${e.width}/${e.profile}`;return e.rim==null?n:`${n} R${e.rim}`}function J(e){return[L({width:e.width}),L({width:e.width,profile:e.profile}),L(e)]}var k=["alloy-wheel","tyre"],ee=["alloy-wheel"],w={"alloy-wheel":"Alloy wheels",tyre:"Tyres"};var Wn=k.map(e=>({value:e,label:w[e]}));function z(e){return e==null?[...ee]:Array.isArray(e)?k.filter(n=>e.includes(n)):[...ee]}var m=e=>e;function f(e){return m(e).kind==="tyre"?"tyre":"alloy-wheel"}function U(e){return m(e).brand??""}function ne(e){return m(e).prices??void 0}function te(e){return m(e).inStock!==!1}function re(e){let n=m(e),t=f(e)==="tyre"?n.rimDiameters:n.sizes;return Array.isArray(t)?t.filter(r=>typeof r=="number"&&Number.isFinite(r)):[]}function D(e){return f(e)==="tyre"?[]:(m(e).finishes??[]).filter(n=>typeof n?.family=="string").map(n=>({family:n.family,color:n.color??null}))}function ie(e){return D(e).map(n=>n.family)}function le(e){if(f(e)==="tyre")return[];let n=m(e),t=n.categories;return t&&t.length>0?t:n.process?[n.process]:[]}function oe(e){return f(e)==="tyre"?[]:m(e).spec?.pcds??[]}function se(e){return f(e)!=="tyre"?[]:m(e).tyreTypes??[]}function ae(e){return f(e)!=="tyre"?[]:m(e).speedRatings??[]}function ue(e){if(f(e)!=="tyre")return[];let n=m(e).sizes;return Array.isArray(n)?n.map(t=>M(typeof t=="string"?t:null)).filter(t=>t!==null):[]}var ce=null;function pe(e,n){return n?e.replace(/\{([A-Za-z][A-Za-z0-9_]*)\}/g,(t,r)=>Object.prototype.hasOwnProperty.call(n,r)?String(n[r]):t):e}function P(e,n){let t=ce?ce[e]:void 0;if(typeof t=="function"){try{let r=t(n??{});if(typeof r=="string"&&r)return r}catch{}return pe(e,n)}return pe(typeof t=="string"&&t?t:e,n)}var de="homepage";function fe(e){return(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}var F=[{value:"page",label:"Page"},{value:"anchor",label:"Anchor"},{value:"blog",label:"Blog post",needs:"service"},{value:"product",label:"Product",needs:"commerce"},{value:"custom",label:"Custom URL"}];function T(e){return e.offersCommerce&&e.offersService?F:F.filter(n=>!n.needs||(n.needs==="commerce"?e.offersCommerce:e.offersService))}function y(e){return e===de?"/":`/${e}`}function _(e){return`/journal/${e}`}function A(e){return`/wheels/${e}`}function E(e,n){return`${y(e)}#${n}`}function B(e){return fe(e)}function Be(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.text=="string"?e.text.trim():""}function R(...e){let n=new Set,t=[];for(let r of e)for(let i of r?.content??[]){let a=Be(i?.props?.anchor);if(!a)continue;let u=B(a);!u||n.has(u)||(n.add(u),t.push({slug:u,name:a}))}return t}var $e=()=>({choosePage:P("Choose a page"),chooseSection:P("Choose a section"),noSections:P("No section anchors yet"),sectionHint:P("Jumps to a section on that page."),choosePost:P("Choose a post"),chooseProduct:P("Choose a product")});function I(e,n,t){if(!e)return"page";if(e.startsWith("/journal/"))return"blog";if(e.startsWith("/wheels/"))return"product";if(e.includes("#")){let r=e.slice(0,e.indexOf("#"));if(r===""||r==="/"||n.includes(r))return"anchor"}return e==="/"||n.includes(e)||t&&t.listingPaths.includes(t.targetOf(e))?"page":"custom"}function me(e,n){let t=$e(),r=e.pages.map(o=>({value:y(o.slug),label:o.title})),i=n?.pageOptions?n.pageOptions(r):r,a=i.map(o=>o.value),u=e.pages.map(o=>({label:o.title,options:R(...o.docs).map(p=>({value:E(o.slug,p.slug),label:p.name}))})).filter(o=>o.options.length>0),c=o=>{switch(o){case"page":return{type:"select",options:i,placeholder:t.choosePage};case"anchor":return{type:"groups",groups:u,placeholder:u.length?t.chooseSection:t.noSections};case"blog":return{type:"select",options:e.posts.map(p=>({value:_(p.slug),label:p.title||p.slug})),placeholder:t.choosePost};case"product":return{type:"select",options:e.products.map(p=>({value:p.href,label:p.name||p.href})),placeholder:t.chooseProduct};case"custom":return{type:"text"}}},s=T(e.offers).map(o=>({value:o.value,label:P(o.label),target:c(o.value),...o.value==="anchor"?{hint:t.sectionHint}:{},...o.value==="blog"||o.value==="product"?{hideWhenEmpty:!0}:{}}));if(!n)return{kinds:s,rules:{kindOf:o=>I(o,a),targetOf:o=>o,readFilter:()=>null,withFilter:o=>o}};let l=o=>{let p=n.withFilter(o,null);return n.listingPaths.includes(p)?p:o};return{kinds:s,rules:{kindOf:o=>I(o,a,{listingPaths:n.listingPaths,targetOf:l}),targetOf:l,readFilter:n.readFilter,withFilter:n.withFilter},filtersFor:o=>n.listingPaths.includes(o)?n.filtersFor(o):null}}function $(e,n){return e.length===0?e:e.filter(t=>t.kind===void 0||t.kind===n)}function he(e,n){let t=n==="filter"?"filterOrder":"cardOrder",r=new Map;for(let i of e){let a=i[t];if(typeof a!="number"||!Number.isFinite(a))continue;let u=r.get(i.fieldKey);(u===void 0||a<u)&&r.set(i.fieldKey,a)}return i=>i?r.get(i):void 0}function ge(e,n,t,r){let i=new Map;for(let s of t){let l=s[r];typeof l=="number"&&i.set(s.fieldKey,l)}if(i.size===0)return e;let a=[],u=[];e.forEach((s,l)=>{let o=n(s);o&&(a.push(l),u.push({item:s,index:l,order:i.get(o)}))}),u.sort((s,l)=>s.order!==void 0&&l.order!==void 0?s.order-l.order||s.index-l.index:s.order!==void 0?-1:l.order!==void 0?1:s.index-l.index);let c=[...e];return a.forEach((s,l)=>{c[s]=u[l].item}),c.every((s,l)=>s===e[l])?e:c}function ye(e){return Ye(e,"filter")}var We="collection";function W(e,n){return{tyreSizes:{},brands:{"alloy-wheel":"brand",tyre:"brand"},finishes:{"alloy-wheel":"wheel_finish_ref"},diameters:{"alloy-wheel":"diameter",tyre:"rim_diameter"},collections:{"alloy-wheel":We},pcds:{"alloy-wheel":"pcd"},tyreTypes:{tyre:"tire_type"},speedRatings:{tyre:"speed_rating"}}[e]?.[n]}function Ye(e,n){let t=new Set(e.filter(r=>r[n]===!1).map(r=>r.fieldKey));return r=>!r||!t.has(r)}function Ge(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Pe(e,n){let t=e?.[n];return Ge(t)?t:null}function be(e,n,t,r){if(t==null&&r==null)return!0;let i=Pe(e,n);return!(i===null||t!=null&&i<t||r!=null&&i>r)}var qe={recommended:"Recommended","price-asc":"Price \xB7 low to high","price-desc":"Price \xB7 high to low",new:"Newest",name:"Name A\u2013Z"},xt=Object.keys(qe);var ke=["tyreSizes","brands","finishes","diameters","collections","pcds","tyreTypes","speedRatings"],He={tyreSizes:["tyre"],brands:["alloy-wheel","tyre"],finishes:["alloy-wheel"],diameters:["alloy-wheel","tyre"],collections:["alloy-wheel"],pcds:["alloy-wheel"],tyreTypes:["tyre"],speedRatings:["tyre"]},je={diameters:"tyreSizes"};function Ze(e){if(e.length===0)return[];let n=ke.filter(t=>e.every(r=>He[t].includes(r)));return n.filter(t=>{let r=je[t];return!r||!n.includes(r)})}function Ve(e){let n=new Set;for(let t of e)n.add(f(t));return[...n]}var Se={tyreSizes:[],brands:[],finishes:[],diameters:[],collections:[],pcds:[],tyreTypes:[],speedRatings:[],priceMax:null,inStockOnly:!1,kind:null,sort:"recommended",page:1};function Qe(e,n,t,r=null){if(r!=="kind"&&n.kind&&f(e)!==n.kind)return!1;for(let i of ke){if(r===i)continue;let a=n[i];if(a.length===0)continue;let u=a.map(String);if(!xe(e,i).some(c=>u.includes(c)))return!1}return!(r!=="price"&&!be(ne(e),t,null,n.priceMax)||r!=="inStock"&&n.inStockOnly&&!te(e))}var Xe={tyreSizes:"Size",brands:"Brand",finishes:"Colour",diameters:"Size \xB7 diameter",collections:"Collection",pcds:"PCD \xB7 fitment",tyreTypes:"Tyre type",speedRatings:"Speed rating"};function xe(e,n){switch(n){case"tyreSizes":return[...new Set(ue(e).flatMap(J))];case"brands":return U(e)?[U(e)]:[];case"finishes":return ie(e);case"diameters":return re(e).map(String);case"collections":return le(e);case"pcds":return oe(e);case"tyreTypes":return se(e);case"speedRatings":return ae(e)}}function Je(e){let n=new Map;for(let t of e)for(let r of D(t))r.color&&!n.has(r.family)&&n.set(r.family,r.color);return n}function Le(e,n,t,r=Ve(e),i=[]){let a=l=>nn(l,r,i),u=Je(e),c=Ze(r).filter(l=>l!=="tyreSizes").filter(a).map(l=>{let o=n[l].map(String),p=new Set,N=new Map,S=new Map;for(let d of e){let b=xe(d,l);for(let h of b)p.add(h);for(let h of new Set(b))S.set(h,(S.get(h)??0)+1);if(Qe(d,n,t,l))for(let h of new Set(b))N.set(h,(N.get(h)??0)+1)}let Ce=[...p].map(d=>({value:d,label:l==="diameters"?`${d}\u2033`:d,count:N.get(d)??0,checked:o.includes(d),swatch:l==="finishes"?u.get(d)??null:null})).sort((d,b)=>{if(l==="diameters")return Number(d.value)-Number(b.value);let h=(S.get(b.value)??0)-(S.get(d.value)??0);return h!==0?h:d.value.localeCompare(b.value)});return{key:l,label:Xe[l],options:Ce}}).filter(l=>l.options.length>en),s=[];for(let l of c){let o=tn(l.key,r,i);o!==void 0&&s.push({fieldKey:l.key,filterOrder:o})}return[...ge(c,l=>l.key,s,"filterOrder")]}var en=1;function we(e){return e.showCollection===!1?["collections"]:[]}function nn(e,n,t){return n.length===0||t.length===0?!0:n.some(r=>ye($(t,r))(W(e,r)))}function tn(e,n,t){if(t.length===0)return;let r;for(let i of n){let a=he($(t,i),"filter")(W(e,i));a!==void 0&&(r===void 0||a<r)&&(r=a)}return r}var Y={tyreSizes:"tyreSize",brands:"brand",finishes:"colour",diameters:"size",collections:"collection",pcds:"pcd",tyreTypes:"tyreType",speedRatings:"speed"},G="type";var Fe="AlloyWheelsListing";function Te(e){return v(e.trim())}var K="/wheels",C="Products";function _e(e,n){return n>1?`${C} \xB7 ${e}`:C}function q(...e){for(let n of e){let t=(n?.content??[]).find(r=>r?.type===Fe);if(t)return t.props??{}}return null}function O(...e){return q(...e)!==null}function Ae(e,n){let t=e.filter(r=>O(...r.docs)).map(r=>y(r.slug));return t.length===0&&n.fallback?[K]:t}var H=[G,...Object.entries(Y).filter(([e])=>e!=="tyreSizes").map(([,e])=>e)];function Ee(e){let n=e.indexOf("#"),t=n===-1?"":e.slice(n),r=n===-1?e:e.slice(0,n),i=r.indexOf("?");return{path:i===-1?r:r.slice(0,i),query:i===-1?"":r.slice(i+1),hash:t}}function rn(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return e}}function Re(e){let n=new URLSearchParams(Ee(e).query);for(let t of H){let r=n.get(t);if(r)return{param:t,value:r}}return null}function j(e,n){let{path:t,query:r,hash:i}=Ee(e),a=r.split("&").filter(u=>u&&!H.includes(rn(u.split("=")[0])));return n?.value&&a.push(`${encodeURIComponent(n.param)}=${encodeURIComponent(n.value)}`),`${t}${a.length?`?${a.join("&")}`:""}${i}`}function Ie(e,n){let t=j(e,null);return n.includes(t)?t:e}function ln(e,n,t=[]){return I(e,n,{listingPaths:t,targetOf:r=>Ie(r,t)})}function on(e){return Array.isArray(e)?e.filter(n=>typeof n?.kind=="string"&&typeof n.field_key=="string").map(n=>({kind:n.kind,fieldKey:n.field_key,...typeof n.filter=="boolean"?{filter:n.filter}:{},filterOrder:n.filter_order??null})):[]}var Ke="Product type",sn="AUD";function Z(e,n){let t=n.listing??{},r=z(t.kinds),i=e.filter(s=>r.includes(f(s))),a=we(t),u=Le(i,Se,sn,r,n.fieldUsage).filter(s=>!a.includes(s.key)).map(s=>({param:Y[s.key],label:s.label,values:s.options.filter(l=>!l.value.includes(",")).map(l=>({value:l.value,label:l.label}))})).filter(s=>s.values.length>0),c=k.filter(s=>r.includes(s)&&i.some(l=>f(l)===s));return c.length>1&&u.unshift({param:G,label:Ke,values:c.map(s=>({value:s,label:w[s]}))}),u}function an(e){return n=>{let t=Ae(n,{fallback:e.offersCommerce}),r=n.filter(i=>O(...i.docs)).length;return{listingPaths:t,pageOptions:i=>{let a=i.map(u=>{let c=n.find(s=>y(s.slug)===u.value);return c&&O(...c.docs)?{...u,label:_e(c.title,r)}:u});return r===0&&e.offersCommerce&&!a.some(u=>u.value===K)&&a.push({value:K,label:C}),a},filtersFor:i=>{if(!t.includes(i))return null;let a=n.find(u=>y(u.slug)===i);return Z(e.catalogue,{listing:a?q(...a.docs):null,fieldUsage:e.fieldUsage})},readFilter:Re,withFilter:j}}}function un(e){let n=an({catalogue:e.catalogue,fieldUsage:e.fieldUsage,offersCommerce:e.offers.offersCommerce})(e.pages),t=me({pages:e.pages,posts:e.posts,products:e.products.map(r=>({href:A(r.slug),name:r.name||r.slug})),offers:e.offers},n);return{...t,rules:{...t.rules,isSafe:Te},filtersFor:t.filtersFor??(()=>null)}}function Ut(e,n){return Z(e,n)}export{K as BUILT_IN_LISTING_PATH,F as LINK_KINDS,H as LISTING_FILTER_PARAMS,C as LISTING_PAGE_LABEL,Ke as PRODUCT_TYPE_FILTER_LABEL,E as anchorPath,on as fieldUsageFromAdminRows,ln as inferLinkKind,O as isProductListingPage,Te as isSafeLink,T as linkKindsFor,un as linkPickerSetup,Ut as listingFilterFields,q as listingNode,_e as listingPageLabel,Ie as listingTarget,R as pageAnchors,y as pagePath,_ as postPath,Ae as productListingPaths,Re as readListingFilter,B as slugifyAnchor,A as wheelPath,j as withListingFilter};
|