@paroicms/content-loading-plugin 0.10.0 → 0.12.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.
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.getPartials = getPartials;
|
|
5
|
-
exports.toNodeId = toNodeId;
|
|
6
|
-
const data_formatters_lib_1 = require("@paroi/data-formatters-lib");
|
|
7
|
-
const public_anywhere_lib_1 = require("@paroicms/public-anywhere-lib");
|
|
8
|
-
async function makeSearch(service, query, req, res) {
|
|
1
|
+
import { isDef } from "@paroi/data-formatters-lib";
|
|
2
|
+
import { parseNodelId } from "@paroicms/public-anywhere-lib";
|
|
3
|
+
export async function makeSearch(service, query, req, res) {
|
|
9
4
|
const { q, language, limit, start, tpl } = query;
|
|
10
5
|
const words = q.split(/\s+/).filter((word) => word.length >= 2);
|
|
11
6
|
if (words.length === 0)
|
|
@@ -20,10 +15,10 @@ async function makeSearch(service, query, req, res) {
|
|
|
20
15
|
templateName: tpl,
|
|
21
16
|
});
|
|
22
17
|
}
|
|
23
|
-
async function getPartials(service, req, res, params, labeledById) {
|
|
18
|
+
export async function getPartials(service, req, res, params, labeledById) {
|
|
24
19
|
const documentId = params["children-of"];
|
|
25
|
-
const parentId =
|
|
26
|
-
const labeledByTermId =
|
|
20
|
+
const parentId = parseNodelId(documentId);
|
|
21
|
+
const labeledByTermId = isDef(labeledById) ? toNodeId(labeledById) : undefined;
|
|
27
22
|
const payload = {
|
|
28
23
|
templateName: params.templateName,
|
|
29
24
|
documentId,
|
|
@@ -38,6 +33,6 @@ async function getPartials(service, req, res, params, labeledById) {
|
|
|
38
33
|
labeledByTermId,
|
|
39
34
|
});
|
|
40
35
|
}
|
|
41
|
-
function toNodeId(nodeOrNodelId) {
|
|
42
|
-
return nodeOrNodelId.indexOf(":") !== -1 ?
|
|
36
|
+
export function toNodeId(nodeOrNodelId) {
|
|
37
|
+
return nodeOrNodelId.indexOf(":") !== -1 ? parseNodelId(nodeOrNodelId).nodeId : nodeOrNodelId;
|
|
43
38
|
}
|
package/backend/dist/plugin.js
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const version = (0, data_formatters_lib_1.strVal)(require((0, node_path_1.join)(packageDir, "package.json")).version);
|
|
1
|
+
import { strVal } from "@paroi/data-formatters-lib";
|
|
2
|
+
import { escapeHtml, resolveModuleDirectory, } from "@paroicms/public-server-lib";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { getPartials, makeSearch } from "./controller.js";
|
|
6
|
+
const projectDir = resolveModuleDirectory(import.meta.url, { parent: true });
|
|
7
|
+
const packageDir = dirname(projectDir);
|
|
8
|
+
const version = strVal(JSON.parse(readFileSync(join(packageDir, "package.json"), "utf-8")).version);
|
|
10
9
|
const plugin = {
|
|
11
10
|
version,
|
|
12
11
|
slug: "content-loading",
|
|
13
12
|
async siteInit(service) {
|
|
14
|
-
service.setPublicAssetsDirectory(
|
|
15
|
-
service.addHeadTag(`<link rel="stylesheet" href="${
|
|
13
|
+
service.setPublicAssetsDirectory(join(packageDir, "public-front", "dist"));
|
|
14
|
+
service.addHeadTag(`<link rel="stylesheet" href="${escapeHtml(`${service.pluginAssetsUrl}/public-front-plugin.css`)}">`, `<script type="module" src="${escapeHtml(`${service.pluginAssetsUrl}/public-front-plugin.mjs`)}"></script>`);
|
|
16
15
|
service.setPublicApiHandler(async (ctx, req, res, relativePath) => {
|
|
17
16
|
if (relativePath === "/search") {
|
|
18
|
-
await
|
|
17
|
+
await makeSearch(ctx, req.query, req, res);
|
|
19
18
|
return;
|
|
20
19
|
}
|
|
21
20
|
if (relativePath === "/partials") {
|
|
22
21
|
const labeledById = req.query.labeledById;
|
|
23
|
-
await
|
|
22
|
+
await getPartials(ctx, req, res, req.query, labeledById);
|
|
24
23
|
return;
|
|
25
24
|
}
|
|
26
25
|
res.append("Content-Type", "application/json; charset=utf-8");
|
|
@@ -29,4 +28,4 @@ const plugin = {
|
|
|
29
28
|
});
|
|
30
29
|
},
|
|
31
30
|
};
|
|
32
|
-
|
|
31
|
+
export default plugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paroicms/content-loading-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Content loading plugin for ParoiCMS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"paroicms",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"build": "npm run build:backend && npm run build:public",
|
|
21
21
|
"build:backend": "(cd backend && tsc)",
|
|
22
22
|
"build:public": "(cd public-front && tsc && vite build && npm run minify:public)",
|
|
23
|
-
"minify:public": "terser
|
|
23
|
+
"minify:public": "terser public-front/dist/public-front-plugin.mjs --output public-front/dist/public-front-plugin.mjs",
|
|
24
24
|
"build:public:watch": "(cd public-front && tsc && vite build --watch)",
|
|
25
25
|
"clear": "rimraf backend/dist/* public-front/dist/*"
|
|
26
26
|
},
|
|
@@ -32,21 +32,22 @@
|
|
|
32
32
|
"@paroicms/public-server-lib": "0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@paroicms/public-anywhere-lib": "0.
|
|
36
|
-
"@paroicms/public-server-lib": "0.
|
|
37
|
-
"@paroicms/tiny-modal": "0.
|
|
35
|
+
"@paroicms/public-anywhere-lib": "0.19.0",
|
|
36
|
+
"@paroicms/public-server-lib": "0.26.0",
|
|
37
|
+
"@paroicms/tiny-modal": "0.3.0",
|
|
38
38
|
"@solid-primitives/i18n": "~2.1.1",
|
|
39
39
|
"@solidjs/router": "~0.14.1",
|
|
40
|
-
"@types/node": "~22.10
|
|
40
|
+
"@types/node": "~22.13.10",
|
|
41
41
|
"rimraf": "~6.0.1",
|
|
42
|
-
"sass": "~1.
|
|
42
|
+
"sass": "~1.84.0",
|
|
43
43
|
"solid-devtools": "~0.33.0",
|
|
44
44
|
"solid-js": "1.9.4",
|
|
45
|
-
"typescript": "~5.
|
|
46
|
-
"vite": "~6.0
|
|
45
|
+
"typescript": "~5.8.2",
|
|
46
|
+
"vite": "~6.1.0",
|
|
47
47
|
"vite-plugin-solid": "~2.11.0",
|
|
48
48
|
"terser": "~5.37.0"
|
|
49
49
|
},
|
|
50
|
+
"type": "module",
|
|
50
51
|
"main": "backend/dist/plugin.js",
|
|
51
52
|
"files": [
|
|
52
53
|
"backend/dist",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@charset "UTF-8";._SearchForm_1a5n6_1{height:40px;margin:32px 0;text-align:center}._SearchForm_1a5n6_1>input{height:100%;width:400px}._SearchForm_1a5n6_1>button{height:100%;margin-left:16px;padding:0 10px}@media screen and (max-width: 640px){._SearchForm_1a5n6_1>input{width:300px}._SearchForm_1a5n6_1>button{margin-left:0;margin-top:16px}}.TinyModal{background:transparent;border:none;margin:0;max-width:none;padding:0}.TinyModal::backdrop{background-color:transparent}.TinyModal-closeBtn{align-items:center;background-color:#bbb;border-radius:50%;cursor:pointer;display:flex;font-size:30px;font-weight:700;height:40px;justify-content:center;line-height:1;position:absolute;right:50px;top:10px;width:40px;z-index:2}.TinyModal-closeBtn:before{content:"×"}.TinyModal-closeBtn:hover,.TinyModal-closeBtn:focus{background-color:#888}.HiddenForTinyModal{display:none!important}.SearchOpener{background-color:#000000a1;display:flex;height:100%;justify-content:center;left:0;position:fixed;max-height:100vh;
|
|
1
|
+
@charset "UTF-8";._SearchForm_1a5n6_1{height:40px;margin:32px 0;text-align:center}._SearchForm_1a5n6_1>input{height:100%;width:400px}._SearchForm_1a5n6_1>button{height:100%;margin-left:16px;padding:0 10px}@media screen and (max-width: 640px){._SearchForm_1a5n6_1>input{width:300px}._SearchForm_1a5n6_1>button{margin-left:0;margin-top:16px}}.TinyModal{background:transparent;border:none;margin:0;max-width:none;padding:0}.TinyModal::backdrop{background-color:transparent}.TinyModal-closeBtn{align-items:center;background-color:#bbb;border-radius:50%;cursor:pointer;display:flex;font-size:30px;font-weight:700;height:40px;justify-content:center;line-height:1;position:absolute;right:50px;top:10px;width:40px;z-index:2}.TinyModal-closeBtn:before{content:"×"}.TinyModal-closeBtn:hover,.TinyModal-closeBtn:focus{background-color:#888}.HiddenForTinyModal{display:none!important}.SearchOpener{background-color:#000000a1;display:flex;height:100%;justify-content:center;left:0;position:fixed;max-height:100vh;top:0;transition:height .1s;width:100%;z-index:10000}.SearchForm{align-items:center;border-radius:5px;display:flex;height:55px;margin-top:150px}@media not screen and (min-width: 1023px){.SearchForm{width:90%}}.SearchForm-input{border:none;height:100%;padding:0 20px;width:450px}@media not (min-width: 1023px){.SearchForm-input{width:80%}}.SearchForm-btn{background-color:var(--siteAppBtnBgColor, #777);color:var(--siteAppBtnFgColor, #fff);height:100%;padding:0 20px}.SearchOpenerBtn{cursor:pointer}.SearchOpenerBtn-svg{fill:var(--siteAppBtnBgColor, #000)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{delegateEvents as te,insert as E,setAttribute as K,template as S,isServer as k,getRequestEvent as Y,createComponent as $,memo as me,effect as F,className as pe,render as ge}from"https://esm.sh/solid-js@1.9.4/web";import{createMemo as C,getOwner as we,runWithOwner as ye,createContext as ve,useContext as be,createSignal as A,createRenderEffect as He,on as B,startTransition as Ve,resetErrorBoundaries as Ge,batch as Ke,untrack as $e,createComponent as ze,children as Re,mergeProps as Je,Show as T,createRoot as Qe,onCleanup as Se,sharedConfig as J,createEffect as ne}from"https://esm.sh/solid-js@1.9.4";function Z(e){return e.varName?` for '${e.varName}'`:""}function Xe(e){return!isNaN(e)&&!isNaN(parseFloat(e))}function Ye(e,t={}){if(e==null||e===""&&!t.allowEmpty)throw new Error(`Missing string value${Z(t)}`);return typeof e=="string"?e:e.toString()}function H(e,t={}){return e==null||e===""&&!t.allowEmpty?void 0:Ye(e,t)}function Ze(e,t={}){if(typeof e=="number")return e;if(e==null)throw new Error(`Missing number value${Z(t)}`);if(typeof e=="string"&&Xe(e))return Number(e);throw new Error(`Cannot convert to number the value of type '${typeof e}'${Z(t)}`)}function V(e,t={}){return e==null?void 0:Ze(e,t)}function et(e){let t=e;const r=t.indexOf("?");r!==-1&&(t=t.substring(0,r));const o=t.indexOf("#");o!==-1&&(t=t.substring(0,o));const n=t.lastIndexOf("/");return n===-1?void 0:t.slice(0,n)}const Le="/api/plugin/content-loading",Ee=et(import.meta.url);async function tt(e){const t=`${Le}${e}`,r=await fetch(t);if(r.status!==200)throw new Error(`api error ${r.status}`);return await r.text()}var Ce=e=>e!=null&&(e=Object.getPrototypeOf(e),e===Array.prototype||e===Object.prototype);function Ae(e,t,r){for(const[o,n]of Object.entries(t)){const a=`${r}.${o}`;e[a]=n,Ce(n)&&Ae(e,n,a)}}function nt(e){const t={...e};for(const[r,o]of Object.entries(e))Ce(o)&&Ae(t,o,r);return t}var rt=(e,t)=>{if(t)for(const[r,o]of Object.entries(t))e=e.replace(new RegExp(`{{\\s*${r}\\s*}}`,"g"),o);return e},ot=e=>e;function at(e,t=ot){return(r,...o)=>{r[0]==="."&&(r=r.slice(1));const n=e()?.[r];switch(typeof n){case"function":return n(...o);case"string":return t(n,o[0]);default:return n}}}const st={nothingGet:"No results found for",search:"Search"},it={loadMore:"Load more"},ct={searchApp:st,infiniteLoading:it},lt={nothingGet:"Aucun résultat trouvé pour",search:"Rechercher"},ut={loadMore:"Charger la suite"},dt={searchApp:lt,infiniteLoading:ut},le={en:ct,fr:dt};function z(e){const t=C((()=>{const o=e in le?e:"en";return nt(le[o])}));return{t:at(t,rt)}}var ft=S("<button class=InfiniteLoading-btn type=button>"),ht=S("<div class=InfiniteLoading-actionArea>"),mt=S("<img class=InfiniteLoading-spinner width=50 height=50 alt=…>");function pt(e,{language:t}){const r=V(e.dataset.start),o=V(e.dataset.total),n=V(e.dataset.limit),a=H(e.dataset.parentId),s=H(e.dataset.template),i=H(e.dataset.labeledById);if(!(r===void 0||o===void 0||a===void 0||n===void 0||s===void 0)){if(!t)throw new Error("Missing language");gt({language:t,limit:n,parentId:a,root:e,start:r,total:o,templateName:s,labeledById:i})}}function gt({language:e,limit:t,root:r,start:o,total:n,parentId:a,templateName:s,labeledById:i}){const{t:l}=z(e);let c=o;if(c>=n)return;const d=(()=>{var y=ft();return y.$$click=g,E(y,(()=>l("infiniteLoading.loadMore"))),y})(),m=(()=>{var y=ht();return E(y,d),y})(),h=(()=>{var y=mt();return K(y,"src",`${Ee}/spinner.svg`),y})();r.appendChild(m);async function g(){r.appendChild(h);const y=await wt({limit:t,newStart:c,parentId:a,templateName:s,labeledById:i});for(const u of y)r.insertBefore(u,m);c+=t,c>=n&&m.remove(),h.remove()}}async function wt({limit:e,newStart:t,parentId:r,templateName:o,labeledById:n}){const a=n?`?labeled=${encodeURIComponent(n)}`:"",s=`/partials?templateName=${encodeURIComponent(o)}&children-of=${encodeURIComponent(r)}&start=${encodeURIComponent(t)}&limit=${encodeURIComponent(e)}${a}`,i=await tt(s),l=document.createElement("div");return l.innerHTML=i,[...l.children]}te(["click"]);function Pe(){let e=new Set;function t(n){return e.add(n),()=>e.delete(n)}let r=!1;function o(n,a){if(r)return!(r=!1);const s={to:n,options:a,defaultPrevented:!1,preventDefault:()=>s.defaultPrevented=!0};for(const i of e)i.listener({...s,from:i.location,retry:l=>{l&&(r=!0),i.navigate(n,{...a,resolve:!1})}});return!s.defaultPrevented}return{subscribe:t,confirm:o}}let ee;function re(){(!window.history.state||window.history.state._depth==null)&&window.history.replaceState({...window.history.state,_depth:window.history.length-1},""),ee=window.history.state._depth}k||re();function yt(e){return{...e,_depth:window.history.state&&window.history.state._depth}}function vt(e,t){let r=!1;return()=>{const o=ee;re();const n=o==null?null:ee-o;if(r){r=!1;return}n&&t(n)?(r=!0,window.history.go(-n)):e()}}const bt=/^(?:[a-z0-9]+:)?\/\//i,$t=/^\/+|(\/)\/+$/g,_e="http://sr";function N(e,t=!1){const r=e.replace($t,"$1");return r?t||/^[?#]/.test(r)?r:"/"+r:""}function G(e,t,r){if(bt.test(t))return;const o=N(e),n=r&&N(r);let a="";return!n||t.startsWith("/")?a=o:n.toLowerCase().indexOf(o.toLowerCase())!==0?a=o+n:a=n,(a||"/")+N(t,!a)}function Rt(e,t){if(e==null)throw new Error(t);return e}function St(e,t){return N(e).replace(/\/*(\*.*)?$/g,"")+N(t)}function xe(e){const t={};return e.searchParams.forEach(((r,o)=>{o in t?Array.isArray(t[o])?t[o].push(r):t[o]=[t[o],r]:t[o]=r})),t}function Lt(e,t,r){const[o,n]=e.split("/*",2),a=o.split("/").filter(Boolean),s=a.length;return i=>{const l=i.split("/").filter(Boolean),c=l.length-s;if(c<0||c>0&&n===void 0&&!t)return null;const d={path:s?"":"/",params:{}},m=h=>r===void 0?void 0:r[h];for(let h=0;h<s;h++){const g=a[h],y=g[0]===":",u=y?l[h]:l[h].toLowerCase(),f=y?g.slice(1):g.toLowerCase();if(y&&Q(u,m(f)))d.params[f]=u;else if(y||!Q(u,f))return null;d.path+=`/${u}`}if(n){const h=c?l.slice(-c).join("/"):"";if(Q(h,m(n)))d.params[n]=h;else return null}return d}}function Q(e,t){const r=o=>o===e;return t===void 0?!0:typeof t=="string"?r(t):typeof t=="function"?t(e):Array.isArray(t)?t.some(r):t instanceof RegExp?t.test(e):!1}function Et(e){const[t,r]=e.pattern.split("/*",2),o=t.split("/").filter(Boolean);return o.reduce(((n,a)=>n+(a.startsWith(":")?2:3)),o.length-(r===void 0?0:1))}function Ue(e){const t=new Map,r=we();return new Proxy({},{get(o,n){return t.has(n)||ye(r,(()=>t.set(n,C((()=>e()[n]))))),t.get(n)()},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}},ownKeys(){return Reflect.ownKeys(e())}})}function Ie(e){let t=/(\/?\:[^\/]+)\?/.exec(e);if(!t)return[e];let r=e.slice(0,t.index),o=e.slice(t.index+t[0].length);const n=[r,r+=t[1]];for(;t=/^(\/\:[^\/]+)\?/.exec(o);)n.push(r+=t[1]),o=o.slice(t[0].length);return Ie(o).reduce(((a,s)=>[...a,...n.map((i=>i+s))]),[])}const Ct=100,Oe=ve(),Fe=ve(),oe=()=>Rt(be(Oe),"<A> and 'use' router primitives can be only used inside a Route."),Me=()=>oe().navigatorFactory(),At=()=>oe().location,Pt=()=>oe().params;function _t(e,t=""){const{component:r,preload:o,load:n,children:a,info:s}=e,i=!a||Array.isArray(a)&&!a.length,l={key:e,component:r,preload:o||n,info:s};return ke(e.path).reduce(((c,d)=>{for(const m of Ie(d)){const h=St(t,m);let g=i?h:h.split("/*",1)[0];g=g.split("/").map((y=>y.startsWith(":")||y.startsWith("*")?y:encodeURIComponent(y))).join("/"),c.push({...l,originalPath:d,pattern:g,matcher:Lt(g,!i,e.matchFilters)})}return c}),[])}function xt(e,t=0){return{routes:e,score:Et(e[e.length-1])*1e4-t,matcher(r){const o=[];for(let n=e.length-1;n>=0;n--){const a=e[n],s=a.matcher(r);if(!s)return null;o.unshift({...s,route:a})}return o}}}function ke(e){return Array.isArray(e)?e:[e]}function Te(e,t="",r=[],o=[]){const n=ke(e);for(let a=0,s=n.length;a<s;a++){const i=n[a];if(i&&typeof i=="object"){i.hasOwnProperty("path")||(i.path="");const l=_t(i,t);for(const c of l){r.push(c);const d=Array.isArray(i.children)&&i.children.length===0;if(i.children&&!d)Te(i.children,c.pattern,r,o);else{const m=xt([...r],o.length);o.push(m)}r.pop()}}}return r.length?o:o.sort(((a,s)=>s.score-a.score))}function q(e,t){for(let r=0,o=e.length;r<o;r++){const n=e[r].matcher(t);if(n)return n}return[]}function Ut(e,t,r){const o=new URL(_e),n=C((d=>{const m=e();try{return new URL(m,o)}catch{return console.error(`Invalid path ${m}`),d}}),o,{equals:(d,m)=>d.href===m.href}),a=C((()=>n().pathname)),s=C((()=>n().search),!0),i=C((()=>n().hash)),l=()=>"",c=B(s,(()=>xe(n())));return{get pathname(){return a()},get search(){return s()},get hash(){return i()},get state(){return t()},get key(){return l()},query:r?r(c):Ue(c)}}let x;function It(){return x}function Ot(e,t,r,o={}){const{signal:[n,a],utils:s={}}=e,i=s.parsePath||(w=>w),l=s.renderPath||(w=>w),c=s.beforeLeave||Pe(),d=G("",o.base||"");if(d===void 0)throw new Error(`${d} is not a valid base path`);d&&!n().value&&a({value:d,replace:!0,scroll:!1});const[m,h]=A(!1);let g;const y=(w,v)=>{v.value===u()&&v.state===b()||(g===void 0&&h(!0),x=w,g=v,Ve((()=>{g===v&&(f(g.value),p(g.state),Ge(),k||_[1]([]))})).finally((()=>{g===v&&Ke((()=>{x=void 0,w==="navigate"&&je(g),h(!1),g=void 0}))})))},[u,f]=A(n().value),[b,p]=A(n().state),P=Ut(u,b,s.queryWrapper),R=[],_=A(k?We():[]),M=C((()=>typeof o.transformUrl=="function"?q(t(),o.transformUrl(P.pathname)):q(t(),P.pathname))),ae=()=>{const w=M(),v={};for(let L=0;L<w.length;L++)Object.assign(v,w[L].params);return v},Ne=s.paramsWrapper?s.paramsWrapper(ae,t):Ue(ae),se={pattern:d,path:()=>d,outlet:()=>null,resolvePath(w){return G(d,w)}};return He(B(n,(w=>y("native",w)),{defer:!0})),{base:se,location:P,params:Ne,isRouting:m,renderPath:l,parsePath:i,navigatorFactory:Be,matches:M,beforeLeave:c,preloadRoute:De,singleFlight:o.singleFlight===void 0?!0:o.singleFlight,submissions:_};function qe(w,v,L){$e((()=>{if(typeof v=="number"){v&&(s.go?s.go(v):console.warn("Router integration does not support relative routing"));return}const j=!v||v[0]==="?",{replace:D,resolve:U,scroll:W,state:I}={replace:!1,resolve:!j,scroll:!0,...L},O=U?w.resolvePath(v):G(j&&P.pathname||"",v);if(O===void 0)throw new Error(`Path '${v}' is not a routable path`);if(R.length>=Ct)throw new Error("Too many redirects");const ie=u();if(O!==ie||I!==b())if(k){const ce=Y();ce&&(ce.response={status:302,headers:new Headers({Location:O})}),a({value:O,replace:D,scroll:W,state:I})}else c.confirm(O,L)&&(R.push({value:ie,replace:D,scroll:W,state:b()}),y("navigate",{value:O,state:I}))}))}function Be(w){return w=w||be(Fe)||se,(v,L)=>qe(w,v,L)}function je(w){const v=R[0];v&&(a({...w,replace:v.replace,scroll:v.scroll}),R.length=0)}function De(w,v){const L=q(t(),w.pathname),j=x;x="preload";for(let D in L){const{route:U,params:W}=L[D];U.component&&U.component.preload&&U.component.preload();const{preload:I}=U;v&&I&&ye(r(),(()=>I({params:W,location:{pathname:w.pathname,search:w.search,hash:w.hash,query:xe(w),state:null,key:""},intent:"preload"})))}x=j}function We(){const w=Y();return w&&w.router&&w.router.submission?[w.router.submission]:[]}}function Ft(e,t,r,o){const{base:n,location:a,params:s}=e,{pattern:i,component:l,preload:c}=o().route,d=C((()=>o().path));l&&l.preload&&l.preload();const m=c?c({params:s,location:a,intent:x||"initial"}):void 0;return{parent:t,pattern:i,path:d,outlet:()=>l?ze(l,{params:s,location:a,data:m,get children(){return r()}}):r(),resolvePath(g){return G(n.path(),g,d())}}}const Mt=e=>t=>{const{base:r}=t,o=Re((()=>t.children)),n=C((()=>Te(o(),t.base||"")));let a;const s=Ot(e,n,(()=>a),{base:r,singleFlight:t.singleFlight,transformUrl:t.transformUrl});return e.create&&e.create(s),$(Oe.Provider,{value:s,get children(){return $(kt,{routerState:s,get root(){return t.root},get preload(){return t.rootPreload||t.rootLoad},get children(){return[me((()=>(a=we())&&null)),$(Tt,{routerState:s,get branches(){return n()}})]}})}})};function kt(e){const t=e.routerState.location,r=e.routerState.params,o=C((()=>e.preload&&$e((()=>{e.preload({params:r,location:t,intent:It()||"initial"})}))));return $(T,{get when(){return e.root},keyed:!0,get fallback(){return e.children},children:n=>$(n,{params:r,location:t,get data(){return o()},get children(){return e.children}})})}function Tt(e){if(k){const n=Y();if(n&&n.router&&n.router.dataOnly){Nt(n,e.routerState,e.branches);return}n&&((n.router||(n.router={})).matches||(n.router.matches=e.routerState.matches().map((({route:a,path:s,params:i})=>({path:a.originalPath,pattern:a.pattern,match:s,params:i,info:a.info})))))}const t=[];let r;const o=C(B(e.routerState.matches,((n,a,s)=>{let i=a&&n.length===a.length;const l=[];for(let c=0,d=n.length;c<d;c++){const m=a&&a[c],h=n[c];s&&m&&h.route.key===m.route.key?l[c]=s[c]:(i=!1,t[c]&&t[c](),Qe((g=>{t[c]=g,l[c]=Ft(e.routerState,l[c-1]||e.routerState.base,ue((()=>o()[c+1])),(()=>e.routerState.matches()[c]))})))}return t.splice(n.length).forEach((c=>c())),s&&i?s:(r=l[0],l)})));return ue((()=>o()&&r))()}const ue=e=>()=>$(T,{get when(){return e()},keyed:!0,children:t=>$(Fe.Provider,{value:t,get children(){return t.outlet()}})}),X=e=>{const t=Re((()=>e.children));return Je(e,{get children(){return t()}})};function Nt(e,t,r){const o=new URL(e.request.url),n=q(r,new URL(e.router.previousUrl||e.request.url).pathname),a=q(r,o.pathname);for(let s=0;s<a.length;s++){(!n[s]||a[s].route!==n[s].route)&&(e.router.dataOnly=!0);const{route:i,params:l}=a[s];i.preload&&i.preload({params:l,location:t.location,intent:"preload"})}}function qt([e,t],r,o){return[e,n=>t(o(n))]}function Bt(e){let t=!1;const r=n=>typeof n=="string"?{value:n}:n,o=qt(A(r(e.get()),{equals:(n,a)=>n.value===a.value&&n.state===a.state}),void 0,(n=>(!t&&e.set(n),J.registry&&!J.done&&(J.done=!0),n)));return e.init&&Se(e.init(((n=e.get())=>{t=!0,o[1](r(n)),t=!1}))),Mt({signal:o,create:e.create,utils:e.utils})}function jt(e,t,r){return e.addEventListener(t,r),()=>e.removeEventListener(t,r)}function Dt(e,t){const r=e&&document.getElementById(e);r?r.scrollIntoView():t&&window.scrollTo(0,0)}const Wt=new Map;function Ht(e=!0,t=!1,r="/_server",o){return n=>{const a=n.base.path(),s=n.navigatorFactory(n.base);let i,l;function c(u){return u.namespaceURI==="http://www.w3.org/2000/svg"}function d(u){if(u.defaultPrevented||u.button!==0||u.metaKey||u.altKey||u.ctrlKey||u.shiftKey)return;const f=u.composedPath().find((M=>M instanceof Node&&M.nodeName.toUpperCase()==="A"));if(!f||t&&!f.hasAttribute("link"))return;const b=c(f),p=b?f.href.baseVal:f.href;if((b?f.target.baseVal:f.target)||!p&&!f.hasAttribute("state"))return;const R=(f.getAttribute("rel")||"").split(/\s+/);if(f.hasAttribute("download")||R&&R.includes("external"))return;const _=b?new URL(p,document.baseURI):new URL(p);if(!(_.origin!==window.location.origin||a&&_.pathname&&!_.pathname.toLowerCase().startsWith(a.toLowerCase())))return[f,_]}function m(u){const f=d(u);if(!f)return;const[b,p]=f,P=n.parsePath(p.pathname+p.search+p.hash),R=b.getAttribute("state");u.preventDefault(),s(P,{resolve:!1,replace:b.hasAttribute("replace"),scroll:!b.hasAttribute("noscroll"),state:R?JSON.parse(R):void 0})}function h(u){const f=d(u);if(!f)return;const[b,p]=f;n.preloadRoute(p,b.getAttribute("preload")!=="false")}function g(u){clearTimeout(i);const f=d(u);if(!f)return l=null;const[b,p]=f;l!==b&&(i=setTimeout((()=>{n.preloadRoute(p,b.getAttribute("preload")!=="false"),l=b}),20))}function y(u){if(u.defaultPrevented)return;let f=u.submitter&&u.submitter.hasAttribute("formaction")?u.submitter.getAttribute("formaction"):u.target.getAttribute("action");if(!f)return;if(!f.startsWith("https://action/")){const p=new URL(f,_e);if(f=n.parsePath(p.pathname+p.search),!f.startsWith(r))return}if(u.target.method.toUpperCase()!=="POST")throw new Error("Only POST forms are supported for Actions");const b=Wt.get(f);if(b){u.preventDefault();const p=new FormData(u.target,u.submitter);b.call({r:n,f:u.target},u.target.enctype==="multipart/form-data"?p:new URLSearchParams(p))}}te(["click","submit"]),document.addEventListener("click",m),e&&(document.addEventListener("mousemove",g,{passive:!0}),document.addEventListener("focusin",h,{passive:!0}),document.addEventListener("touchstart",h,{passive:!0})),document.addEventListener("submit",y),Se((()=>{document.removeEventListener("click",m),e&&(document.removeEventListener("mousemove",g),document.removeEventListener("focusin",h),document.removeEventListener("touchstart",h)),document.removeEventListener("submit",y)}))}}function Vt(e){const t=e.replace(/^.*?#/,"");if(!t.startsWith("/")){const[,r="/"]=window.location.hash.split("#",2);return`${r}#${t}`}return t}function Gt(e){const t=()=>window.location.hash.slice(1),r=Pe();return Bt({get:t,set({value:o,replace:n,scroll:a,state:s}){n?window.history.replaceState(yt(s),"","#"+o):window.history.pushState(s,"","#"+o);const i=o.indexOf("#"),l=i>=0?o.slice(i+1):"";Dt(l,a),re()},init:o=>jt(window,"hashchange",vt(o,(n=>!r.confirm(n&&n<0?n:t())))),create:Ht(e.preload,e.explicitLinks,e.actionBase),utils:{go:o=>window.history.go(o),renderPath:o=>`#${o}`,parsePath:Vt,beforeLeave:r}})(e)}function Kt(e){const t=Me(),r=At(),{href:o,state:n}=e,a=typeof o=="function"?o({navigate:t,location:r}):o;return t(a,{replace:!0,state:n}),null}const zt={};async function de({language:e,text:t,limit:r,start:o,templateName:n}){const a=`${Le}/search?language=${encodeURIComponent(e)}&q=${encodeURIComponent(t)}&limit=${encodeURIComponent(r)}&start=${encodeURIComponent(o)}&tpl=${encodeURIComponent(n)}`,s=await fetch(a,{method:"GET"});if(s.status!==200){const l=await s.text();throw new Error(`API error (${s.status}): ${l}`)}return await s.json()}const Jt="_SearchForm_1a5n6_1",Qt={SearchForm:Jt};var Xt=S("<form><input type=search><button type=submit>");const Yt=e=>{const t=Me(),[r,o]=A(e.value??""),{t:n}=z(e.language);ne(B((()=>e.value),(()=>o(e.value??""))));const a=async s=>{s.preventDefault(),t(`/q/${encodeURIComponent(r())}`)};return(()=>{var s=Xt(),i=s.firstChild,l=i.nextSibling;return s.addEventListener("submit",a),i.addEventListener("change",(c=>o(c.currentTarget.value))),E(l,(()=>n("searchApp.search"))),F((c=>{var d=Qt.SearchForm,m=n("searchApp.search");return d!==c.e&&pe(s,c.e=d),m!==c.t&&K(i,"placeholder",c.t=m),c}),{e:void 0,t:void 0}),F((()=>i.value=r())),s})()};var Zt=S("<div class=SearchPageResponse>"),fe=S("<div>"),en=S("<img class=SearchPageResponse-spinner width=80 height=80 alt=…>"),tn=S("<button type=button>"),nn=S("<div class=SearchPageResponse-noResultMessage> <span>");function he({language:e,limit:t,templateName:r}){const{t:o}=z(e),{searchString:n}=Pt(),[a,s]=A(""),[i,l]=A(0),[c,d]=A(0),[m,h]=A(!1);ne(B((()=>n),g));async function g(){if(n){h(!0);try{s(""),d(0);const u=await de({language:e,text:decodeURIComponent(n),limit:t,start:c(),templateName:r});if(l(u.total),d(c()+t),!u.html)return;s(u.html)}finally{h(!1)}}}async function y(){if(!n)return;const u=i();if(u===void 0||c()>=u)return;const f=await de({language:e,text:decodeURIComponent(n),limit:t,start:c(),templateName:r});f.html&&(s(`${a()}${f.html}`),d(c()+t))}return(()=>{var u=fe();return E(u,$(Yt,{language:e,get value(){return n?decodeURIComponent(n):void 0}}),null),E(u,$(T,{when:n,get children(){var f=Zt();return E(f,(()=>{var b=me((()=>!!m()));return()=>b()?(()=>{var p=en();return K(p,"src",`${Ee}/spinner.svg`),p})():$(T,{get when(){return a()},get fallback(){return(()=>{var p=nn(),P=p.firstChild,R=P.nextSibling;return E(p,(()=>o("searchApp.nothingGet")),P),E(R,n),p})()},get children(){return[(()=>{var p=fe();return F((()=>p.innerHTML=a())),p})(),$(T,{get when(){return c()<i()},get children(){var p=tn();return p.$$click=y,E(p,(()=>o("infiniteLoading.loadMore"))),p}})]}})})()),f}}),null),F((()=>pe(u,zt.SiteApp))),u})()}te(["click"]);function rn(e,{language:t}){if(!t)throw new Error("Missing language");const r=V(e.dataset.limit),o=H(e.dataset.template);r===void 0||o===void 0||ge((()=>$(Gt,{explicitLinks:!0,get children(){return[$(X,{path:"/",component:()=>$(Kt,{href:"/q"})}),$(X,{path:"/q",component:()=>$(he,{language:t,templateName:o,limit:r})}),$(X,{path:"/q/:searchString",component:()=>$(he,{language:t,templateName:o,limit:r})})]}})),e)}function on({openButton:e,dialogContent:t}){const r=e?typeof e=="string"?document.querySelector(e):e:void 0,o=typeof t=="string"?document.querySelector(t):t;if(!o)return;o instanceof HTMLTemplateElement||o.classList.remove("HiddenForTinyModal");const n=document.createElement("dialog");n.classList.add("TinyModal");const a=document.createElement("button");a.classList.add("TinyModal-closeBtn"),n.appendChild(a);const s=document.createElement("div");s.classList.add("TinyModal-wrapper"),s.appendChild(o instanceof HTMLTemplateElement?o.content.cloneNode(!0):o),n.appendChild(s),document.body.appendChild(n);const i=new Map;function l(h,g){i.has(h)||i.set(h,[]),i.get(h)?.push(g)}function c(h){i.has(h)&&i.get(h)?.forEach((g=>g()))}function d(){n.showModal(),document.body.style.overflow="hidden",c("open")}function m(){n.close()}return r?.addEventListener("click",d),a.addEventListener("click",m),n.addEventListener("close",(()=>{document.body.style.overflow="",c("close")})),{open:d,close:m,on:l}}var an=S("<input class=SearchForm-input type=search required>"),sn=S("<div class=SearchOpener><form class=SearchForm><button class=SearchForm-btn type=submit>");function cn({searchURL:e,language:t}){const[r,o]=A(""),{t:n}=z(t),a=(()=>{var i=an();return i.addEventListener("change",(l=>o(l.currentTarget.value))),F((()=>K(i,"placeholder",n("searchApp.search")))),F((()=>i.value=r())),i})(),s=i=>{i.preventDefault(),window.location.href=`${e}#/q/${encodeURIComponent(r())}`};return ne((()=>{a.focus()})),(()=>{var i=sn(),l=i.firstChild,c=l.firstChild;return l.addEventListener("submit",s),E(l,a,c),E(c,(()=>n("searchApp.search"))),i})()}var ln=S('<button type=button class=SearchOpenerBtn><svg class=SearchOpenerBtn-svg width=20 height=20 version=1.1 id=Capa_1 xmlns=http://www.w3.org/2000/svg viewBox="0 0 490.4 490.4"><title>Search Icon</title><g id=SVGRepo_bgCarrier stroke-width=0></g><g id=SVGRepo_tracerCarrier stroke-linecap=round stroke-linejoin=round></g><g id=SVGRepo_iconCarrier><g><path d="M484.1,454.796l-110.5-110.6c29.8-36.3,47.6-82.8,47.6-133.4c0-116.3-94.3-210.6-210.6-210.6S0,94.496,0,210.796 s94.3,210.6,210.6,210.6c50.8,0,97.4-18,133.8-48l110.5,110.5c12.9,11.8,25,4.2,29.2,0C492.5,475.596,492.5,463.096,484.1,454.796z M41.1,210.796c0-93.6,75.9-169.5,169.5-169.5s169.6,75.9,169.6,169.5s-75.9,169.5-169.5,169.5S41.1,304.396,41.1,210.796z"></path> ');function un({searchIconColor:e,language:t,searchURL:r}){const o=(()=>{var a=ln(),s=a.firstChild;return e!=null?s.style.setProperty("fill",e):s.style.removeProperty("fill"),a})(),n=$(cn,{searchURL:r,language:t});return on({openButton:o,dialogContent:n}),o}function dn(e,{language:t}){const r=e.dataset.searchUrl,o=e.dataset.iconColor;if(!t)throw new Error("Missing language");if(!r)throw new Error("Missing search url");ge((()=>$(un,{language:t,searchURL:r,searchIconColor:o})),e)}document.addEventListener("DOMContentLoaded",(()=>{const e=document.documentElement.lang,t={searchOpener:dn,searchForm:rn,infiniteLoading:pt},r=document.querySelectorAll("[data-effect]");for(const o of r){const n=o.dataset.effect;if(!n)continue;const a=t[n];a&&a(o,{language:e})}}));
|
|
1
|
+
import{delegateEvents as te,template as S,insert as E,setAttribute as K,isServer as k,getRequestEvent as Y,createComponent as $,memo as me,effect as F,className as pe,render as ge}from"https://esm.sh/solid-js@1.9.4/web";import{createMemo as C,getOwner as we,runWithOwner as ve,useContext as ye,createContext as be,createSignal as A,createRenderEffect as He,on as B,startTransition as Ve,resetErrorBoundaries as Ge,batch as Ke,untrack as $e,createComponent as ze,children as Re,mergeProps as Je,Show as T,createRoot as Qe,onCleanup as Se,sharedConfig as J,createEffect as ne}from"https://esm.sh/solid-js@1.9.4";function Z(e){return e.varName?` for '${e.varName}'`:""}function Xe(e){return!isNaN(e)&&!isNaN(parseFloat(e))}function Ye(e,t={}){if(e==null||e===""&&!t.allowEmpty)throw new Error(`Missing string value${Z(t)}`);return typeof e=="string"?e:e.toString()}function H(e,t={}){return e==null||e===""&&!t.allowEmpty?void 0:Ye(e,t)}function Ze(e,t={}){if(typeof e=="number")return e;if(e==null)throw new Error(`Missing number value${Z(t)}`);if(typeof e=="string"&&Xe(e))return Number(e);throw new Error(`Cannot convert to number the value of type '${typeof e}'${Z(t)}`)}function V(e,t={}){return e==null?void 0:Ze(e,t)}function et(e){let t=e;const r=t.indexOf("?");r!==-1&&(t=t.substring(0,r));const o=t.indexOf("#");o!==-1&&(t=t.substring(0,o));const n=t.lastIndexOf("/");return n===-1?void 0:t.slice(0,n)}const Le="/api/plugin/content-loading",Ee=et(import.meta.url);async function tt(e){const t=`${Le}${e}`,r=await fetch(t);if(r.status!==200)throw new Error(`api error ${r.status}`);return await r.text()}var Ce=e=>e!=null&&(e=Object.getPrototypeOf(e),e===Array.prototype||e===Object.prototype);function Ae(e,t,r){for(const[o,n]of Object.entries(t)){const a=`${r}.${o}`;e[a]=n,Ce(n)&&Ae(e,n,a)}}function nt(e){const t={...e};for(const[r,o]of Object.entries(e))Ce(o)&&Ae(t,o,r);return t}var rt=(e,t)=>{if(t)for(const[r,o]of Object.entries(t))e=e.replace(new RegExp(`{{\\s*${r}\\s*}}`,"g"),o);return e},ot=e=>e;function at(e,t=ot){return(r,...o)=>{r[0]==="."&&(r=r.slice(1));const n=e()?.[r];switch(typeof n){case"function":return n(...o);case"string":return t(n,o[0]);default:return n}}}const st={nothingGet:"No results found for",search:"Search"},it={loadMore:"Load more"},ct={searchApp:st,infiniteLoading:it},lt={nothingGet:"Aucun résultat trouvé pour",search:"Rechercher"},ut={loadMore:"Charger la suite"},dt={searchApp:lt,infiniteLoading:ut},le={en:ct,fr:dt};function z(e){const t=C((()=>{const o=e in le?e:"en";return nt(le[o])}));return{t:at(t,rt)}}var ft=S("<button class=InfiniteLoading-btn type=button>"),ht=S("<div class=InfiniteLoading-actionArea>"),mt=S("<img class=InfiniteLoading-spinner width=50 height=50 alt=…>");function pt(e,{language:t}){const r=V(e.dataset.start),o=V(e.dataset.total),n=V(e.dataset.limit),a=H(e.dataset.parentId),s=H(e.dataset.template),i=H(e.dataset.labeledById);if(!(r===void 0||o===void 0||a===void 0||n===void 0||s===void 0)){if(!t)throw new Error("Missing language");gt({language:t,limit:n,parentId:a,root:e,start:r,total:o,templateName:s,labeledById:i})}}function gt({language:e,limit:t,root:r,start:o,total:n,parentId:a,templateName:s,labeledById:i}){const{t:l}=z(e);let c=o;if(c>=n)return;const d=(()=>{var v=ft();return v.$$click=g,E(v,(()=>l("infiniteLoading.loadMore"))),v})(),m=(()=>{var v=ht();return E(v,d),v})(),h=(()=>{var v=mt();return K(v,"src",`${Ee}/spinner.svg`),v})();r.appendChild(m);async function g(){r.appendChild(h);const v=await wt({limit:t,newStart:c,parentId:a,templateName:s,labeledById:i});for(const u of v)r.insertBefore(u,m);c+=t,c>=n&&m.remove(),h.remove()}}async function wt({limit:e,newStart:t,parentId:r,templateName:o,labeledById:n}){const a=n?`?labeled=${encodeURIComponent(n)}`:"",s=`/partials?templateName=${encodeURIComponent(o)}&children-of=${encodeURIComponent(r)}&start=${encodeURIComponent(t)}&limit=${encodeURIComponent(e)}${a}`,i=await tt(s),l=document.createElement("div");return l.innerHTML=i,[...l.children]}te(["click"]);function Pe(){let e=new Set;function t(n){return e.add(n),()=>e.delete(n)}let r=!1;function o(n,a){if(r)return!(r=!1);const s={to:n,options:a,defaultPrevented:!1,preventDefault:()=>s.defaultPrevented=!0};for(const i of e)i.listener({...s,from:i.location,retry:l=>{l&&(r=!0),i.navigate(n,{...a,resolve:!1})}});return!s.defaultPrevented}return{subscribe:t,confirm:o}}let ee;function re(){(!window.history.state||window.history.state._depth==null)&&window.history.replaceState({...window.history.state,_depth:window.history.length-1},""),ee=window.history.state._depth}k||re();function vt(e){return{...e,_depth:window.history.state&&window.history.state._depth}}function yt(e,t){let r=!1;return()=>{const o=ee;re();const n=o==null?null:ee-o;if(r){r=!1;return}n&&t(n)?(r=!0,window.history.go(-n)):e()}}const bt=/^(?:[a-z0-9]+:)?\/\//i,$t=/^\/+|(\/)\/+$/g,_e="http://sr";function N(e,t=!1){const r=e.replace($t,"$1");return r?t||/^[?#]/.test(r)?r:"/"+r:""}function G(e,t,r){if(bt.test(t))return;const o=N(e),n=r&&N(r);let a="";return!n||t.startsWith("/")?a=o:n.toLowerCase().indexOf(o.toLowerCase())!==0?a=o+n:a=n,(a||"/")+N(t,!a)}function Rt(e,t){if(e==null)throw new Error(t);return e}function St(e,t){return N(e).replace(/\/*(\*.*)?$/g,"")+N(t)}function xe(e){const t={};return e.searchParams.forEach(((r,o)=>{o in t?Array.isArray(t[o])?t[o].push(r):t[o]=[t[o],r]:t[o]=r})),t}function Lt(e,t,r){const[o,n]=e.split("/*",2),a=o.split("/").filter(Boolean),s=a.length;return i=>{const l=i.split("/").filter(Boolean),c=l.length-s;if(c<0||c>0&&n===void 0&&!t)return null;const d={path:s?"":"/",params:{}},m=h=>r===void 0?void 0:r[h];for(let h=0;h<s;h++){const g=a[h],v=g[0]===":",u=v?l[h]:l[h].toLowerCase(),f=v?g.slice(1):g.toLowerCase();if(v&&Q(u,m(f)))d.params[f]=u;else if(v||!Q(u,f))return null;d.path+=`/${u}`}if(n){const h=c?l.slice(-c).join("/"):"";if(Q(h,m(n)))d.params[n]=h;else return null}return d}}function Q(e,t){const r=o=>o===e;return t===void 0?!0:typeof t=="string"?r(t):typeof t=="function"?t(e):Array.isArray(t)?t.some(r):t instanceof RegExp?t.test(e):!1}function Et(e){const[t,r]=e.pattern.split("/*",2),o=t.split("/").filter(Boolean);return o.reduce(((n,a)=>n+(a.startsWith(":")?2:3)),o.length-(r===void 0?0:1))}function Ue(e){const t=new Map,r=we();return new Proxy({},{get(o,n){return t.has(n)||ve(r,(()=>t.set(n,C((()=>e()[n]))))),t.get(n)()},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}},ownKeys(){return Reflect.ownKeys(e())}})}function Ie(e){let t=/(\/?\:[^\/]+)\?/.exec(e);if(!t)return[e];let r=e.slice(0,t.index),o=e.slice(t.index+t[0].length);const n=[r,r+=t[1]];for(;t=/^(\/\:[^\/]+)\?/.exec(o);)n.push(r+=t[1]),o=o.slice(t[0].length);return Ie(o).reduce(((a,s)=>[...a,...n.map((i=>i+s))]),[])}const Ct=100,Oe=be(),Fe=be(),oe=()=>Rt(ye(Oe),"<A> and 'use' router primitives can be only used inside a Route."),Me=()=>oe().navigatorFactory(),At=()=>oe().location,Pt=()=>oe().params;function _t(e,t=""){const{component:r,preload:o,load:n,children:a,info:s}=e,i=!a||Array.isArray(a)&&!a.length,l={key:e,component:r,preload:o||n,info:s};return ke(e.path).reduce(((c,d)=>{for(const m of Ie(d)){const h=St(t,m);let g=i?h:h.split("/*",1)[0];g=g.split("/").map((v=>v.startsWith(":")||v.startsWith("*")?v:encodeURIComponent(v))).join("/"),c.push({...l,originalPath:d,pattern:g,matcher:Lt(g,!i,e.matchFilters)})}return c}),[])}function xt(e,t=0){return{routes:e,score:Et(e[e.length-1])*1e4-t,matcher(r){const o=[];for(let n=e.length-1;n>=0;n--){const a=e[n],s=a.matcher(r);if(!s)return null;o.unshift({...s,route:a})}return o}}}function ke(e){return Array.isArray(e)?e:[e]}function Te(e,t="",r=[],o=[]){const n=ke(e);for(let a=0,s=n.length;a<s;a++){const i=n[a];if(i&&typeof i=="object"){i.hasOwnProperty("path")||(i.path="");const l=_t(i,t);for(const c of l){r.push(c);const d=Array.isArray(i.children)&&i.children.length===0;if(i.children&&!d)Te(i.children,c.pattern,r,o);else{const m=xt([...r],o.length);o.push(m)}r.pop()}}}return r.length?o:o.sort(((a,s)=>s.score-a.score))}function q(e,t){for(let r=0,o=e.length;r<o;r++){const n=e[r].matcher(t);if(n)return n}return[]}function Ut(e,t,r){const o=new URL(_e),n=C((d=>{const m=e();try{return new URL(m,o)}catch{return console.error(`Invalid path ${m}`),d}}),o,{equals:(d,m)=>d.href===m.href}),a=C((()=>n().pathname)),s=C((()=>n().search),!0),i=C((()=>n().hash)),l=()=>"",c=B(s,(()=>xe(n())));return{get pathname(){return a()},get search(){return s()},get hash(){return i()},get state(){return t()},get key(){return l()},query:r?r(c):Ue(c)}}let x;function It(){return x}function Ot(e,t,r,o={}){const{signal:[n,a],utils:s={}}=e,i=s.parsePath||(w=>w),l=s.renderPath||(w=>w),c=s.beforeLeave||Pe(),d=G("",o.base||"");if(d===void 0)throw new Error(`${d} is not a valid base path`);d&&!n().value&&a({value:d,replace:!0,scroll:!1});const[m,h]=A(!1);let g;const v=(w,y)=>{y.value===u()&&y.state===b()||(g===void 0&&h(!0),x=w,g=y,Ve((()=>{g===y&&(f(g.value),p(g.state),Ge(),k||_[1]([]))})).finally((()=>{g===y&&Ke((()=>{x=void 0,w==="navigate"&&je(g),h(!1),g=void 0}))})))},[u,f]=A(n().value),[b,p]=A(n().state),P=Ut(u,b,s.queryWrapper),R=[],_=A(k?We():[]),M=C((()=>typeof o.transformUrl=="function"?q(t(),o.transformUrl(P.pathname)):q(t(),P.pathname))),ae=()=>{const w=M(),y={};for(let L=0;L<w.length;L++)Object.assign(y,w[L].params);return y},Ne=s.paramsWrapper?s.paramsWrapper(ae,t):Ue(ae),se={pattern:d,path:()=>d,outlet:()=>null,resolvePath(w){return G(d,w)}};return He(B(n,(w=>v("native",w)),{defer:!0})),{base:se,location:P,params:Ne,isRouting:m,renderPath:l,parsePath:i,navigatorFactory:Be,matches:M,beforeLeave:c,preloadRoute:De,singleFlight:o.singleFlight===void 0?!0:o.singleFlight,submissions:_};function qe(w,y,L){$e((()=>{if(typeof y=="number"){y&&(s.go?s.go(y):console.warn("Router integration does not support relative routing"));return}const j=!y||y[0]==="?",{replace:D,resolve:U,scroll:W,state:I}={replace:!1,resolve:!j,scroll:!0,...L},O=U?w.resolvePath(y):G(j&&P.pathname||"",y);if(O===void 0)throw new Error(`Path '${y}' is not a routable path`);if(R.length>=Ct)throw new Error("Too many redirects");const ie=u();if(O!==ie||I!==b())if(k){const ce=Y();ce&&(ce.response={status:302,headers:new Headers({Location:O})}),a({value:O,replace:D,scroll:W,state:I})}else c.confirm(O,L)&&(R.push({value:ie,replace:D,scroll:W,state:b()}),v("navigate",{value:O,state:I}))}))}function Be(w){return w=w||ye(Fe)||se,(y,L)=>qe(w,y,L)}function je(w){const y=R[0];y&&(a({...w,replace:y.replace,scroll:y.scroll}),R.length=0)}function De(w,y){const L=q(t(),w.pathname),j=x;x="preload";for(let D in L){const{route:U,params:W}=L[D];U.component&&U.component.preload&&U.component.preload();const{preload:I}=U;y&&I&&ve(r(),(()=>I({params:W,location:{pathname:w.pathname,search:w.search,hash:w.hash,query:xe(w),state:null,key:""},intent:"preload"})))}x=j}function We(){const w=Y();return w&&w.router&&w.router.submission?[w.router.submission]:[]}}function Ft(e,t,r,o){const{base:n,location:a,params:s}=e,{pattern:i,component:l,preload:c}=o().route,d=C((()=>o().path));l&&l.preload&&l.preload();const m=c?c({params:s,location:a,intent:x||"initial"}):void 0;return{parent:t,pattern:i,path:d,outlet:()=>l?ze(l,{params:s,location:a,data:m,get children(){return r()}}):r(),resolvePath(g){return G(n.path(),g,d())}}}const Mt=e=>t=>{const{base:r}=t,o=Re((()=>t.children)),n=C((()=>Te(o(),t.base||"")));let a;const s=Ot(e,n,(()=>a),{base:r,singleFlight:t.singleFlight,transformUrl:t.transformUrl});return e.create&&e.create(s),$(Oe.Provider,{value:s,get children(){return $(kt,{routerState:s,get root(){return t.root},get preload(){return t.rootPreload||t.rootLoad},get children(){return[me((()=>(a=we())&&null)),$(Tt,{routerState:s,get branches(){return n()}})]}})}})};function kt(e){const t=e.routerState.location,r=e.routerState.params,o=C((()=>e.preload&&$e((()=>{e.preload({params:r,location:t,intent:It()||"initial"})}))));return $(T,{get when(){return e.root},keyed:!0,get fallback(){return e.children},children:n=>$(n,{params:r,location:t,get data(){return o()},get children(){return e.children}})})}function Tt(e){if(k){const n=Y();if(n&&n.router&&n.router.dataOnly){Nt(n,e.routerState,e.branches);return}n&&((n.router||(n.router={})).matches||(n.router.matches=e.routerState.matches().map((({route:a,path:s,params:i})=>({path:a.originalPath,pattern:a.pattern,match:s,params:i,info:a.info})))))}const t=[];let r;const o=C(B(e.routerState.matches,((n,a,s)=>{let i=a&&n.length===a.length;const l=[];for(let c=0,d=n.length;c<d;c++){const m=a&&a[c],h=n[c];s&&m&&h.route.key===m.route.key?l[c]=s[c]:(i=!1,t[c]&&t[c](),Qe((g=>{t[c]=g,l[c]=Ft(e.routerState,l[c-1]||e.routerState.base,ue((()=>o()[c+1])),(()=>e.routerState.matches()[c]))})))}return t.splice(n.length).forEach((c=>c())),s&&i?s:(r=l[0],l)})));return ue((()=>o()&&r))()}const ue=e=>()=>$(T,{get when(){return e()},keyed:!0,children:t=>$(Fe.Provider,{value:t,get children(){return t.outlet()}})}),X=e=>{const t=Re((()=>e.children));return Je(e,{get children(){return t()}})};function Nt(e,t,r){const o=new URL(e.request.url),n=q(r,new URL(e.router.previousUrl||e.request.url).pathname),a=q(r,o.pathname);for(let s=0;s<a.length;s++){(!n[s]||a[s].route!==n[s].route)&&(e.router.dataOnly=!0);const{route:i,params:l}=a[s];i.preload&&i.preload({params:l,location:t.location,intent:"preload"})}}function qt([e,t],r,o){return[e,o?n=>t(o(n)):t]}function Bt(e){let t=!1;const r=n=>typeof n=="string"?{value:n}:n,o=qt(A(r(e.get()),{equals:(n,a)=>n.value===a.value&&n.state===a.state}),void 0,(n=>(!t&&e.set(n),J.registry&&!J.done&&(J.done=!0),n)));return e.init&&Se(e.init(((n=e.get())=>{t=!0,o[1](r(n)),t=!1}))),Mt({signal:o,create:e.create,utils:e.utils})}function jt(e,t,r){return e.addEventListener(t,r),()=>e.removeEventListener(t,r)}function Dt(e,t){const r=e&&document.getElementById(e);r?r.scrollIntoView():t&&window.scrollTo(0,0)}const Wt=new Map;function Ht(e=!0,t=!1,r="/_server",o){return n=>{const a=n.base.path(),s=n.navigatorFactory(n.base);let i,l;function c(u){return u.namespaceURI==="http://www.w3.org/2000/svg"}function d(u){if(u.defaultPrevented||u.button!==0||u.metaKey||u.altKey||u.ctrlKey||u.shiftKey)return;const f=u.composedPath().find((M=>M instanceof Node&&M.nodeName.toUpperCase()==="A"));if(!f||t&&!f.hasAttribute("link"))return;const b=c(f),p=b?f.href.baseVal:f.href;if((b?f.target.baseVal:f.target)||!p&&!f.hasAttribute("state"))return;const R=(f.getAttribute("rel")||"").split(/\s+/);if(f.hasAttribute("download")||R&&R.includes("external"))return;const _=b?new URL(p,document.baseURI):new URL(p);if(!(_.origin!==window.location.origin||a&&_.pathname&&!_.pathname.toLowerCase().startsWith(a.toLowerCase())))return[f,_]}function m(u){const f=d(u);if(!f)return;const[b,p]=f,P=n.parsePath(p.pathname+p.search+p.hash),R=b.getAttribute("state");u.preventDefault(),s(P,{resolve:!1,replace:b.hasAttribute("replace"),scroll:!b.hasAttribute("noscroll"),state:R?JSON.parse(R):void 0})}function h(u){const f=d(u);if(!f)return;const[b,p]=f;n.preloadRoute(p,b.getAttribute("preload")!=="false")}function g(u){clearTimeout(i);const f=d(u);if(!f)return l=null;const[b,p]=f;l!==b&&(i=setTimeout((()=>{n.preloadRoute(p,b.getAttribute("preload")!=="false"),l=b}),20))}function v(u){if(u.defaultPrevented)return;let f=u.submitter&&u.submitter.hasAttribute("formaction")?u.submitter.getAttribute("formaction"):u.target.getAttribute("action");if(!f)return;if(!f.startsWith("https://action/")){const p=new URL(f,_e);if(f=n.parsePath(p.pathname+p.search),!f.startsWith(r))return}if(u.target.method.toUpperCase()!=="POST")throw new Error("Only POST forms are supported for Actions");const b=Wt.get(f);if(b){u.preventDefault();const p=new FormData(u.target,u.submitter);b.call({r:n,f:u.target},u.target.enctype==="multipart/form-data"?p:new URLSearchParams(p))}}te(["click","submit"]),document.addEventListener("click",m),e&&(document.addEventListener("mousemove",g,{passive:!0}),document.addEventListener("focusin",h,{passive:!0}),document.addEventListener("touchstart",h,{passive:!0})),document.addEventListener("submit",v),Se((()=>{document.removeEventListener("click",m),e&&(document.removeEventListener("mousemove",g),document.removeEventListener("focusin",h),document.removeEventListener("touchstart",h)),document.removeEventListener("submit",v)}))}}function Vt(e){const t=e.replace(/^.*?#/,"");if(!t.startsWith("/")){const[,r="/"]=window.location.hash.split("#",2);return`${r}#${t}`}return t}function Gt(e){const t=()=>window.location.hash.slice(1),r=Pe();return Bt({get:t,set({value:o,replace:n,scroll:a,state:s}){n?window.history.replaceState(vt(s),"","#"+o):window.history.pushState(s,"","#"+o);const i=o.indexOf("#"),l=i>=0?o.slice(i+1):"";Dt(l,a),re()},init:o=>jt(window,"hashchange",yt(o,(n=>!r.confirm(n&&n<0?n:t())))),create:Ht(e.preload,e.explicitLinks,e.actionBase),utils:{go:o=>window.history.go(o),renderPath:o=>`#${o}`,parsePath:Vt,beforeLeave:r}})(e)}function Kt(e){const t=Me(),r=At(),{href:o,state:n}=e,a=typeof o=="function"?o({navigate:t,location:r}):o;return t(a,{replace:!0,state:n}),null}const zt={};async function de({language:e,text:t,limit:r,start:o,templateName:n}){const a=`${Le}/search?language=${encodeURIComponent(e)}&q=${encodeURIComponent(t)}&limit=${encodeURIComponent(r)}&start=${encodeURIComponent(o)}&tpl=${encodeURIComponent(n)}`,s=await fetch(a,{method:"GET"});if(s.status!==200){const l=await s.text();throw new Error(`API error (${s.status}): ${l}`)}return await s.json()}const Jt="_SearchForm_1a5n6_1",Qt={SearchForm:Jt};var Xt=S("<form><input type=search><button type=submit>");const Yt=e=>{const t=Me(),[r,o]=A(e.value??""),{t:n}=z(e.language);ne(B((()=>e.value),(()=>o(e.value??""))));const a=async s=>{s.preventDefault(),t(`/q/${encodeURIComponent(r())}`)};return(()=>{var s=Xt(),i=s.firstChild,l=i.nextSibling;return s.addEventListener("submit",a),i.addEventListener("change",(c=>o(c.currentTarget.value))),E(l,(()=>n("searchApp.search"))),F((c=>{var d=Qt.SearchForm,m=n("searchApp.search");return d!==c.e&&pe(s,c.e=d),m!==c.t&&K(i,"placeholder",c.t=m),c}),{e:void 0,t:void 0}),F((()=>i.value=r())),s})()};var Zt=S("<div class=SearchPageResponse>"),fe=S("<div>"),en=S("<img class=SearchPageResponse-spinner width=80 height=80 alt=…>"),tn=S("<button type=button>"),nn=S("<div class=SearchPageResponse-noResultMessage> <span>");function he({language:e,limit:t,templateName:r}){const{t:o}=z(e),{searchString:n}=Pt(),[a,s]=A(""),[i,l]=A(0),[c,d]=A(0),[m,h]=A(!1);ne(B((()=>n),g));async function g(){if(n){h(!0);try{s(""),d(0);const u=await de({language:e,text:decodeURIComponent(n),limit:t,start:c(),templateName:r});if(l(u.total),d(c()+t),!u.html)return;s(u.html)}finally{h(!1)}}}async function v(){if(!n)return;const u=i();if(u===void 0||c()>=u)return;const f=await de({language:e,text:decodeURIComponent(n),limit:t,start:c(),templateName:r});f.html&&(s(`${a()}${f.html}`),d(c()+t))}return(()=>{var u=fe();return E(u,$(Yt,{language:e,get value(){return n?decodeURIComponent(n):void 0}}),null),E(u,$(T,{when:n,get children(){var f=Zt();return E(f,(()=>{var b=me((()=>!!m()));return()=>b()?(()=>{var p=en();return K(p,"src",`${Ee}/spinner.svg`),p})():$(T,{get when(){return a()},get fallback(){return(()=>{var p=nn(),P=p.firstChild,R=P.nextSibling;return E(p,(()=>o("searchApp.nothingGet")),P),E(R,n),p})()},get children(){return[(()=>{var p=fe();return F((()=>p.innerHTML=a())),p})(),$(T,{get when(){return c()<i()},get children(){var p=tn();return p.$$click=v,E(p,(()=>o("infiniteLoading.loadMore"))),p}})]}})})()),f}}),null),F((()=>pe(u,zt.SiteApp))),u})()}te(["click"]);function rn(e,{language:t}){if(!t)throw new Error("Missing language");const r=V(e.dataset.limit),o=H(e.dataset.template);r===void 0||o===void 0||ge((()=>$(Gt,{explicitLinks:!0,get children(){return[$(X,{path:"/",component:()=>$(Kt,{href:"/q"})}),$(X,{path:"/q",component:()=>$(he,{language:t,templateName:o,limit:r})}),$(X,{path:"/q/:searchString",component:()=>$(he,{language:t,templateName:o,limit:r})})]}})),e)}function on({openButton:e,dialogContent:t}){const r=e?typeof e=="string"?document.querySelector(e):e:void 0,o=typeof t=="string"?document.querySelector(t):t;if(!o)return;o instanceof HTMLTemplateElement||o.classList.remove("HiddenForTinyModal");const n=document.createElement("dialog");n.classList.add("TinyModal");const a=document.createElement("button");a.classList.add("TinyModal-closeBtn"),n.appendChild(a);const s=document.createElement("div");s.classList.add("TinyModal-wrapper"),s.appendChild(o instanceof HTMLTemplateElement?o.content.cloneNode(!0):o),n.appendChild(s),document.body.appendChild(n);const i=new Map;function l(h,g){i.has(h)||i.set(h,[]),i.get(h)?.push(g)}function c(h){i.has(h)&&i.get(h)?.forEach((g=>g()))}function d(){n.showModal(),document.body.style.overflow="hidden",c("open")}function m(){n.close()}return r?.addEventListener("click",d),a.addEventListener("click",m),n.addEventListener("close",(()=>{document.body.style.overflow="",c("close")})),{open:d,close:m,on:l}}var an=S("<input class=SearchForm-input type=search required>"),sn=S("<div class=SearchOpener><form class=SearchForm><button class=SearchForm-btn type=submit>");function cn({searchURL:e,language:t}){const[r,o]=A(""),{t:n}=z(t),a=(()=>{var i=an();return i.addEventListener("change",(l=>o(l.currentTarget.value))),F((()=>K(i,"placeholder",n("searchApp.search")))),F((()=>i.value=r())),i})(),s=i=>{i.preventDefault(),window.location.href=`${e}#/q/${encodeURIComponent(r())}`};return ne((()=>{a.focus()})),(()=>{var i=sn(),l=i.firstChild,c=l.firstChild;return l.addEventListener("submit",s),E(l,a,c),E(c,(()=>n("searchApp.search"))),i})()}var ln=S('<button type=button class=SearchOpenerBtn><svg class=SearchOpenerBtn-svg width=20 height=20 version=1.1 id=Capa_1 xmlns=http://www.w3.org/2000/svg viewBox="0 0 490.4 490.4"><title>Search Icon</title><g id=SVGRepo_bgCarrier stroke-width=0></g><g id=SVGRepo_tracerCarrier stroke-linecap=round stroke-linejoin=round></g><g id=SVGRepo_iconCarrier><g><path d="M484.1,454.796l-110.5-110.6c29.8-36.3,47.6-82.8,47.6-133.4c0-116.3-94.3-210.6-210.6-210.6S0,94.496,0,210.796 s94.3,210.6,210.6,210.6c50.8,0,97.4-18,133.8-48l110.5,110.5c12.9,11.8,25,4.2,29.2,0C492.5,475.596,492.5,463.096,484.1,454.796z M41.1,210.796c0-93.6,75.9-169.5,169.5-169.5s169.6,75.9,169.6,169.5s-75.9,169.5-169.5,169.5S41.1,304.396,41.1,210.796z"></path> ');function un({searchIconColor:e,language:t,searchURL:r}){const o=(()=>{var a=ln(),s=a.firstChild;return e!=null?s.style.setProperty("fill",e):s.style.removeProperty("fill"),a})(),n=$(cn,{searchURL:r,language:t});return on({openButton:o,dialogContent:n}),o}function dn(e,{language:t}){const r=e.dataset.searchUrl,o=e.dataset.iconColor;if(!t)throw new Error("Missing language");if(!r)throw new Error("Missing search url");ge((()=>$(un,{language:t,searchURL:r,searchIconColor:o})),e)}document.addEventListener("DOMContentLoaded",(()=>{const e=document.documentElement.lang,t={searchOpener:dn,searchForm:rn,infiniteLoading:pt},r=document.querySelectorAll("[data-effect]");for(const o of r){const n=o.dataset.effect;if(!n)continue;const a=t[n];a&&a(o,{language:e})}}));
|