@miroart/sdk 0.2.0 → 0.4.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.
@@ -0,0 +1,45 @@
1
+ import { type PropType, type VNode } from "vue";
2
+ import { type OrderPathPart } from "./order";
3
+ /**
4
+ * Kolejność elementów strony, którą można zmienić w edytorze wizualnym.
5
+ *
6
+ * Stałe bloki szablonu: `<MiroOrder name="home"><template #hero>…</template></MiroOrder>`.
7
+ * Kolejność jest w opcji `miro_order`, a slot nazywa się po kluczu, nie po numerze.
8
+ *
9
+ * Lista z opcji: `<MiroOrder source="faq.items" :items="rows" v-slot="{ item, index }">`.
10
+ * Kolejność to sama tablica. Gdy `items` powstało przez filtr, `:at` podaje indeks w surowej tablicy.
11
+ *
12
+ * Sam komponent nie dokłada elementu do DOM, a poza ramką edytora także atrybutów.
13
+ */
14
+ export declare const MiroOrder: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
15
+ name: StringConstructor;
16
+ source: PropType<string | OrderPathPart[]>;
17
+ items: PropType<unknown[]>;
18
+ at: PropType<(item: never, position: number) => string | number>;
19
+ scope: {
20
+ type: PropType<"page" | "site">;
21
+ default: string;
22
+ };
23
+ locked: {
24
+ type: PropType<string[]>;
25
+ default: () => never[];
26
+ };
27
+ }>, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
28
+ [key: string]: any;
29
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
30
+ name: StringConstructor;
31
+ source: PropType<string | OrderPathPart[]>;
32
+ items: PropType<unknown[]>;
33
+ at: PropType<(item: never, position: number) => string | number>;
34
+ scope: {
35
+ type: PropType<"page" | "site">;
36
+ default: string;
37
+ };
38
+ locked: {
39
+ type: PropType<string[]>;
40
+ default: () => never[];
41
+ };
42
+ }>> & Readonly<{}>, {
43
+ scope: "page" | "site";
44
+ locked: string[];
45
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -0,0 +1,14 @@
1
+ import { type FunctionalComponent } from "vue";
2
+ /**
3
+ * Tekst z CMS z formatowaniem: `<h1><MiroText :value="heading" /></h1>`.
4
+ *
5
+ * Bez `v-html`: tagi i style pochodzą ze stałych list, a tekst użytkownika trafia tylko do
6
+ * węzłów tekstowych. `<script>` w wartości pokaże się jako tekst. Wartość bez znaczników i
7
+ * złamań linii daje zwykły węzeł tekstowy, więc można tu podać wszystko to co do `{{ }}`.
8
+ *
9
+ * W ramce edytora wynik dostaje `data-miro-rich`: po tym nakładka poznaje, że znaczniki się
10
+ * tu wyrenderują, i pokazuje pasek formatowania. `display: contents` nie zmienia układu.
11
+ */
12
+ export declare const MiroText: FunctionalComponent<{
13
+ value?: unknown;
14
+ }>;
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.create,Object.defineProperty,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.prototype.hasOwnProperty,Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue");function e(t,e){return{page:void 0!==e.page?e.page:t.page,site:void 0!==e.site?e.site:t.site,menus:e.menus?{...t.menus,...e.menus}:{...t.menus},locales:e.locales??t.locales,seo:void 0!==e.seo?e.seo:t.seo,options:e.options?{...t.options,...e.options}:{...t.options}}}function r(t){return Boolean(t)&&"object"==typeof t&&!Array.isArray(t)}function n(t){return r(t)?t:null}function s(t){return t?String(t.uuid||t.ulid||t.id||t.slug||t.full_url||""):""}function i(t){return t?String(t.uuid||t.domain||t.id||""):""}function o(t){return String.fromCharCode(...t.map(t=>23^t))}function a(t,e){const r=String(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return r?`${r}${n}`:n}function c(){const t=o([56,118,103,126]),e=o([97,38]),r=o([100,126,99,114,100]),n=o([103,118,112,114,100]),s=o([100,114,118,101,116,127]),i=o([122,114,121,98,100]),c=o([122,114,115,126,118]),u=o([103,123,98,112,126,121,100]),l=o([118,116,99,126,120,121,100]);return{sites:()=>a("",`${t}/${e}/${r}`),site:n=>a("",`${t}/${e}/${r}/${encodeURIComponent(n)}`),pages:s=>a("",`${t}/${e}/${r}/${encodeURIComponent(s)}/${n}`),page:(s,i)=>a("",`${t}/${e}/${r}/${encodeURIComponent(s)}/${n}/${i.split("/").map(t=>encodeURIComponent(t)).join("/")}`),search:i=>a("",`${t}/${e}/${r}/${encodeURIComponent(i)}/${n}/${s}`),menus:n=>a("",`${t}/${e}/${r}/${encodeURIComponent(n)}/${i}`),menu:(n,s)=>a("",`${t}/${e}/${r}/${encodeURIComponent(n)}/${i}/${encodeURIComponent(s)}`),media:e=>a("",`${t}/${c}/${encodeURIComponent(e)}`),action:e=>a("",`${t}/${l}/${encodeURIComponent(e)}`),plugins:(e,r,n="")=>{const s=`${t}/${u}/${encodeURIComponent(e)}/${encodeURIComponent(r)}`;return n&&"/"!==n?`${s}${n.startsWith("/")?n:`/${n}`}`:s}}}function u(){if("undefined"==typeof globalThis)return{};const t=globalThis.MiroConfig;return t&&"object"==typeof t?t:{}}function l(t){return t&&"object"==typeof t&&"data"in t?t.data:t}function p(t){return null==t?"":"string"==typeof t?t:"number"==typeof t||"boolean"==typeof t?String(t):""}function h(t){const e=p(t);if(!e)return"";if("undefined"!=typeof document){const t=document.createElement("textarea");return t.innerHTML=e,t.value}return e.replace(/&#(\d+);/g,(t,e)=>String.fromCharCode(Number(e))).replace(/&#x([0-9a-f]+);/gi,(t,e)=>String.fromCharCode(parseInt(e,16))).replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">")}function g(t){return h(t).replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi," ").replace(/<style[\s\S]*?>[\s\S]*?<\/style>/gi," ").replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim()}class d extends String{kind;extra;constructor(t,e,r={}){super(h(e)),this.kind=t,this.extra=r,Object.setPrototypeOf(this,new.target.prototype)}toString(){return String.prototype.toString.call(this)}valueOf(){return String.prototype.valueOf.call(this)}raw(){return this.toString()}decode(){return h(this.toString())}cleanContent(){return g(this.toString())}stripHtml(){return this.cleanContent()}excerpt(t=160){const e=this.cleanContent();return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}firstParagraph(){return function(t){const e=h(t),r=e.match(/<p\b[^>]*>([\s\S]*?)<\/p>/i);return g(r?r[1]:e)}(this.toString())}isEmpty(){return""===this.cleanContent()}json(){const t=this.toString().trim();if(!t)return null;try{return JSON.parse(t)}catch{return null}}bool(){const t=this.toString().trim().toLowerCase();return"1"===t||"true"===t||"yes"===t||"on"===t}number(){const t=Number(this.toString().trim());return Number.isFinite(t)?t:null}}class f extends d{constructor(t){super("PageTitle",t)}}class m extends d{constructor(t){super("PageSubtitle",t)}}class y extends d{constructor(t){super("PageSmallTitle",t)}}class w extends d{constructor(t){super("PageSummary",t)}}class S extends d{constructor(t){super("PageContent",t)}html(){return this.toString()}}class b extends d{constructor(t){super("SiteTitle",t)}}class $ extends d{constructor(t){super("SiteName",t)}}class _ extends d{key;structured;constructor(t,e){const r=C(e);super("OptionValue",r.text,{key:t}),this.key=t,this.structured=r.structured}json(){return void 0!==this.structured?this.structured:super.json()}present(){return!this.isEmpty()}}class j extends d{constructor(t){super("UrlValue",t)}path(){const t=this.toString().trim();if(!t)return"/";try{if(/^https?:\/\//i.test(t))return new URL(t).pathname.replace(/\/+$/,"")||"/"}catch{}return(t.startsWith("/")?t:`/${t}`).replace(/\/+$/,"")||"/"}href(t=""){const e=this.path();return!t||/^https?:\/\//i.test(e)?e:`${String(t).replace(/\/+$/,"")}${e}`}}class x extends d{constructor(t){super("MenuTitle",t)}}class k extends d{constructor(t){super("AssetName",t)}}class A extends d{constructor(t){super("SeoTitle",t)}}class P extends d{constructor(t){super("SeoDescription",t)}}function C(t){if(null==t)return{text:""};if("boolean"==typeof t||"number"==typeof t)return{text:String(t)};if("string"==typeof t){const e=t.trim();if(""===e||"[]"===e||"{}"===e)return{text:""};if(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]")||e.startsWith('"')&&e.endsWith('"'))try{return C(JSON.parse(e))}catch{return{text:h(t)}}return{text:h(t)}}return Array.isArray(t)?{text:JSON.stringify(t),structured:t}:"object"==typeof t?function(t){return"value"in t&&Object.keys(t).every(t=>"value"===t||"key"===t||"id"===t||"active"===t)}(t)?C(t.value):{text:JSON.stringify(t),structured:t}:{text:p(t)}}function M(t,e){if(!t)return"";if(Array.isArray(t)){const r=t.find(t=>t&&"object"==typeof t&&t.key===e);return r&&"object"==typeof r?r.value:""}return"object"==typeof t?t[e]:""}function v(t){if("string"==typeof t){const e=t.trim();return e?I(e)?{uuid:e}:{url:e,path:e}:null}if(!t||"object"!=typeof t||Array.isArray(t))return null;const e=t,r=R(e.source),n=O(e.url,e.preview_url,e.path,e.src,r?.url,r?.preview_url,r?.path),s=O(e.uuid,r?.uuid);if(n||s&&I(s))return e;const i=O(e.value);return i?v(i):null}function O(...t){for(const e of t)if("string"==typeof e&&""!==e.trim())return e.trim();return""}function T(t){return"string"==typeof t?t.trim():""}function R(t){return!t||"object"!=typeof t||Array.isArray(t)?null:t}function U(t){return t.startsWith("/media/")||t.startsWith("/_images/")||t.startsWith("/api/media/")||t.startsWith("/branding-assets/")||t.startsWith("/storage/")}function I(t){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)}const N=[{mark:"1_8",width:256},{mark:"1_4",width:512},{mark:"1_2",width:1024},{mark:"2_3",width:1400}];class W{constructor(t,e){this.record=t,this.runtime=e}record;runtime;getUuid(){return String(this.record.uuid||this.record.id||"")}getName(){return new k(this.record.name)}getAlt(){return T(this.record.alt)}getCaption(){return T(this.record.caption)}getGallery(){return this.memberships()[0]??null}galleryUuid(){return this.memberships()[0]?.uuid??""}galleryName(){return this.memberships()[0]?.name??""}memberships(){const t=this.record.galleries;if(Array.isArray(t)&&t.length>0)return t.map(t=>B(t)).filter(t=>null!==t);const e=String(this.record.gallery_uuid??"").trim(),r=String(this.record.gallery_name??"").trim();if(!e&&!r)return[];const n=this.record.gallery_id;return[{id:"number"==typeof n||"string"==typeof n?n:null,uuid:e,name:r,sort_order:q(this.record.gallery_sort_order)}]}getMime(){const t=R(this.record.source);return String(this.record.mime_type||t?.mime_type||"")}getSize(){const t=R(this.record.source),e=Number(this.record.size??t?.size??0);return Number.isFinite(e)?e:0}getType(){const t=T(this.record.type);if(t)return t;const e=this.getMime();return e.startsWith("image/")?"image":e.startsWith("video/")?"video":"application/pdf"===e?"pdf":""}getSortOrder(){const t=Number(this.record.sort_order??0);return Number.isFinite(t)?t:0}isImage(){return!!this.getMime().startsWith("image/")||/\.(jpe?g|png|gif|webp|svg)(\?|$)/i.test(this.urlString())}url(){return new j(this.urlString())}srcset(){const t=this.urlString();if(!t||/\.svg([?#]|$)/i.test(t)||/^https?:\/\//i.test(t)||t.startsWith("//"))return"";if(!/\.webp([?#]|$)/i.test(t)||/\.(?:1_16|1_8|1_4|1_2|2_3)\.webp([?#]|$)/i.test(t))return"";const e=N.map(({mark:e,width:r})=>`${t.replace(/\.webp([?#].*)?$/i,`.${e}.webp$1`)} ${r}w`);return e.push(`${t} 2048w`),e.join(", ")}raw(){return{...this.record}}urlString(){const t=R(this.record.source),e=O(this.record.uuid,t?.uuid),r=O(this.record.disk,t?.disk);let n=O(this.record.url,this.record.preview_url,this.record.path,this.record.src,t?.url,t?.preview_url,t?.path);if(e&&I(e)&&n&&function(t,e){return!!(/\/project-storage\//i.test(r=t)||/\/editor\/project-file/i.test(r)||/cms\.miroart\.pl/i.test(r)&&/\/(?:project-storage|storage)\//i.test(r))||"project_public"===e&&!U(t)&&!/^https?:\/\//i.test(t)&&!t.startsWith("//");var r}(n,r))return this.mediaUrl(e);if(!n)return e&&I(e)?this.mediaUrl(e):"";if(!0===globalThis.isSsg){if(n.startsWith("/_images/")||n.startsWith("_images/"))return n.startsWith("/")?n:`/${n}`;const e=function(t){const e=t.match(/[?&]path=([^&]+)/i);if(e)try{const t=decodeURIComponent(e[1].replace(/\+/g," ")).split(/[/\\]/).pop()||"";if(t&&"project-file"!==t.toLowerCase())return t.trim()}catch{}return(t.split("#")[0].split("?")[0].split(/[/\\]/).pop()||"").trim()}(O(t?.path,this.record.path,n)),r=/\.(jpe?g|png|gif|webp|svg)$/i.test(s=e)?/\.svg$/i.test(s)?`/_images/${s}`:`/_images/${s.replace(/\.(jpe?g|png|gif|webp)$/i,".webp")}`:null;if(r)return r}var s;if(/^https?:\/\//i.test(n)||n.startsWith("//"))return n;if(n.startsWith("_images/"))return`/${n}`;if(U(n))return n;n.includes("/")||n.includes("\\")||I(n)||(n=`images/${n}`);const i=n.startsWith("/")?n:`/${n}`;return U(i)||i.startsWith("/project-storage/")?i:`/storage${i}`}mediaUrl(t){const e=c().media(t),r=this.runtime.apiBase();return r?a(r,e):e}}class L{constructor(t){this.items=t}items;all(){return this.items.slice()}first(){return this.items[0]??null}extra(){return this.items.slice(1)}hero(){return this.first()}urls(){return this.items.map(t=>t.url())}isEmpty(){return 0===this.items.length}count(){return this.items.length}[Symbol.iterator](){return this.items[Symbol.iterator]()}}function B(t){if(!t||"object"!=typeof t)return null;const e=t,r=String(e.uuid??"").trim(),n=String(e.name??"").trim();if(!r&&!n)return null;const s=e.id;return{id:"number"==typeof s||"string"==typeof s?s:null,uuid:r,name:n,sort_order:q(e.sort_order)}}function q(t){const e=Number(t??0);return Number.isFinite(e)?e:0}function E(t,e){return Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new W(t,e)):[]}const G=new Set(["id","uuid","created_at","updated_at"]);class D{constructor(t,e){this.row=t,this.kernel=e}row;kernel;getHref(){return new j(this.row.href)}getTitle(){return String(this.row.title??"")}item(){const t=this.row.item;return t&&"object"==typeof t?t:{}}image(){return J(this.item(),this.kernel)}}function J(t,e){if(!t||"object"!=typeof t)return null;for(const[r,n]of Object.entries(t)){if(G.has(r)||"string"!=typeof n||!z(n))continue;const t=v(n);if(t)return new W(t,e)}return null}function z(t){const e=t.trim();return!!e&&(!!(e.startsWith("/media/")||e.startsWith("/_images/")||e.startsWith("_images/")||e.startsWith("/api/media/")||e.startsWith("/branding-assets/"))||/\.(jpe?g|png|gif|webp|svg)(\?|#|$)/i.test(e))}function F(t,e){const r=t&&"object"==typeof t?t.meta:null,n=r&&"object"==typeof r?r:{};return{currentPage:V(n.current_page,1),lastPage:V(n.last_page,1),perPage:V(n.per_page,Math.max(e,1)),total:K(n.total,e)}}function H(t,e){return Object.assign(t,{meta:e})}function V(t,e){const r=Number(t);return!Number.isFinite(r)||r<1?e:Math.floor(r)}function K(t,e){if(null==t||""===t)return e;const r=Number(t);return!Number.isFinite(r)||r<0?e:Math.floor(r)}class Z{constructor(t,e){this.source=t,this.kernel=e}source;kernel;get record(){return"function"==typeof this.source?this.source():this.source}static async all(){const t=Q(),e=await t.request(c().sites());return(Array.isArray(e?.data)?e.data:[]).filter(t=>Boolean(t)&&"object"==typeof t).map(e=>new Z(e,t))}static async find(t){const e=Q(),r=null!=t&&""!==String(t)?String(t):e.siteRef(),n=e.snapshot().site;if(n&&(!t||String(n.uuid)===String(t)||String(n.id)===String(t)||String(n.domain)===String(t)||i(n)===String(t)))return new Z(n,e);const s=l(await e.request(c().site(r)));return e.rememberSite(s),new Z(s,e)}static async findPage(t,e){return X.find(t,e)}static async findMenu(t,e){return ut.find(t,e)}getName(){return new $(this.record.name)}getTitle(){const t=M(this.record.options,"seo_title")||M(this.record.options,"title");return new b(t||this.record.name)}getDomain(){return String(this.record.domain||"")}getLang(){return String(this.record.lang||"")}getUuid(){return String(this.record.uuid||"")}getOption(t){return new _(t,M(this.record.options,t))}getImage(t){const e=this.getOption(t),r=e.json(),n=null==r?e.toString().trim():r;if(null==n||""===n)return null;const s=v(n);return s?new W(s,this.kernel):null}async findPage(t){return X.find(t,this.ref())}async findMenu(t){return ut.find(t,this.ref())}async menus(){const t=this.kernel.snapshot().menus,e=Object.values(t).filter(Boolean);return e.length?e.map(t=>new ut(t,this.kernel)):((await this.kernel.request(c().menus(this.ref()))).data??[]).map(t=>(this.kernel.rememberMenu(t),new ut(t,this.kernel)))}async pages(t={}){const e=new URLSearchParams,r={...t};null!=r.perPage&&null==r.per_page&&(r.per_page=r.perPage,delete r.perPage);for(const[o,a]of Object.entries(r))e.set(o,String(a));const n=e.toString()?`?${e.toString()}`:"",s=await this.kernel.request(`${c().pages(this.ref())}${n}`),i=(s.data??[]).map(t=>(this.kernel.rememberPage(t),new X(t,this.kernel)));return H(i,F(s,i.length))}async runAction(t){const e=String(t.uuid||"").trim();if(!e)throw new Error("Action uuid is required.");const r=String(this.record.domain||this.ref());return this.kernel.request(c().action(r),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({uuid:e,method:t.method||"GET",path:t.path||"",query:t.query||{},body:t.body||"",headers:t.headers||{},params:t.params||{},post:t.post||{}})})}raw(){return{...this.record}}ref(){return String(this.record.uuid||this.record.domain||this.record.id||this.kernel.siteRef())}}let Y=null;function Q(){if(!Y)throw new Error("Client is not installed.");return Y}class X{constructor(t,e){this.source=t,this.kernel=e}source;kernel;get record(){return"function"==typeof this.source?this.source():this.source}setRecord(t){"function"!=typeof this.source?this.source=t:this.kernel.rememberPage(t)}static async findByUlid(t,e){return at(t,e)}static async find(t,e){return at(t,e)}static async search(t,e,r){const n=et(),s=rt(n,e),i=new URLSearchParams;i.set("q",t),nt(i,r);const o=await n.request(`${c().search(s)}?${i.toString()}`),a=(Array.isArray(o?.data)?o.data:Array.isArray(o)?o:[]).map(t=>(n.rememberPage(t),new X(t,n)));return H(a,F(o,a.length))}getTitle(){return new f(this.record.title)}getSubtitle(){return new m(this.record.subtitle)}getSmallTitle(){return new y(this.record.smalltitle)}getSummary(){return new w(this.record.summary)}getContent(){return new S(this.record.content)}getSlug(){return String(this.record.slug||"")}getUrl(){return new j(this.record.full_url||(this.record.slug?`/${this.record.slug}`:"/"))}getUuid(){return String(this.record.uuid||this.record.ulid||"")}getId(){return String(this.record.id||this.getUuid())}getLayout(){return String(this.record.layout||"")}getDisplay(){return String(this.record.display||"")}getDisplayInMenu(){const t=this.record.display_in_menu;return null==t||""===t||!1!==t&&0!==t&&"0"!==t}getSortOrder(){const t=Number(this.record.sort_order??0);return Number.isFinite(t)?t:0}getLang(){const t=String(this.record.lang||"").trim();if(t)return t;const e=this.kernel.snapshot().site;return String(e?.lang||function(t){return t&&"object"==typeof t?String(t.lang||""):""}(this.record.site)||"")}getOption(t){const e=[M(this.record.options,t),this.kernel.snapshot().options[t],M(this.kernel.snapshot().site?.options,t),M(it(this.record.site),t)];for(const r of e)if(st(r))return new _(t,r);return new _(t,"")}getSeo(){const t=this.seoBag(),e=t=>null==t?"":String(t),r=t=>{const e=v(t);return e?new W(e,this.kernel):null};return{title:new A(t.title??this.record.title),description:new P(t.description??this.record.summary),keywords:e(t.keywords),robots:e(t.robots),canonical:new j(t.canonical),ogTitle:e(t.og_title??t.title??this.record.title),ogDescription:e(t.og_description??t.description??this.record.summary),ogImage:r(t.og_image),ogType:e(t.og_type),ogUrl:new j(t.og_url||t.canonical),twitterCard:e(t.twitter_card),twitterTitle:e(t.twitter_title??t.og_title??t.title),twitterDescription:e(t.twitter_description??t.og_description??t.description),twitterImage:r(t.twitter_image||t.og_image),ldJson:ot(t.ld_json),raw:{...t}}}get collectionItem(){const t=this.record.collectionItem;return t&&"object"==typeof t?t:{}}get collectionItems(){const t=this.record.collectionItems;return t&&"object"==typeof t?t:{}}get collectionGallery(){return t=this.record.collectionGallery,e=this.kernel,Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new D(t,e)):[];var t,e}collectionImage(){return J(this.collectionItem,this.kernel)}getAssets(){return new L(E(this.record.assets,this.kernel))}getGallery(t){const e=t.trim();if(!e)return new L([]);const r=[];return E(this.record.assets,this.kernel).forEach((t,n)=>{const s=t.memberships().find(t=>function(t,e){const r=e.trim().toLocaleLowerCase();return!!r&&(t.uuid.toLocaleLowerCase()===r||t.name.toLocaleLowerCase()===r)}(t,e));s&&r.push({asset:t,sort:s.sort_order,index:n})}),r.sort((t,e)=>t.sort-e.sort||t.index-e.index),new L(r.map(t=>t.asset))}getGalleries(){const t=E(this.record.assets,this.kernel);return this.galleryList(t).map(t=>({id:t.id,uuid:t.uuid,name:t.name,description:t.description,sort_order:t.sort_order,assets:this.getGallery(t.uuid||t.name)}))}async getChildren(t){const e=function(t){if(!Array.isArray(t))return[];const e=new Set(["options","assets"]),r=[];for(const n of t){const t=String(n).trim().toLowerCase();e.has(t)&&!r.includes(t)&&r.push(t)}return r}(t?.with),r=Array.isArray(this.record.children)?this.record.children:null;if(r&&function(t,e){return!e.length||t.every(t=>{if(!t||"object"!=typeof t)return!1;const r=t;if(e.includes("options")){const t=r.options;if(null==t||"object"!=typeof t)return!1}return!(e.includes("assets")&&!Array.isArray(r.assets))})}(r,e)){const e=function(t,e,r){const n=t.length;if(!e&&!r)return{items:t,meta:{currentPage:1,lastPage:1,perPage:Math.max(n,1),total:n}};const s=r&&r>0?Math.floor(r):Math.max(n,1),i=e&&e>0?Math.floor(e):1,o=Math.max(1,Math.ceil(n/s)),a=(i-1)*s;return{items:t.slice(a,a+s),meta:{currentPage:i,lastPage:o,perPage:s,total:n}}}(this.rowsToPages(r),t?.page,t?.perPage);return H(e.items,e.meta)}const n=this.getUuid()||String(this.record.id??"");if(!n){const t=r?this.rowsToPages(r):[];return H(t,F(null,t.length))}const s=new URLSearchParams;s.set("parent",n),e.length&&s.set("with",e.join(",")),nt(s,t);const i=await this.kernel.request(`${c().pages(this.siteRef())}?${s.toString()}`);return H(this.rowsToPages(i.data??[]),F(i,(i.data??[]).length))}async getSiblings(){if(Array.isArray(this.record.siblings))return this.record.siblings.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new X(t,this.kernel));const t=this.record.parent_id,e=this.siteRef();if(null==t||""===t){const t=await this.kernel.request(`${c().pages(e)}?parent=root`);return this.excludeSelf(t.data??[])}const r=await this.kernel.request(`${c().pages(e)}?parent=${encodeURIComponent(String(t))}`);return this.excludeSelf(r.data??[])}async getParent(){if(this.record.parent&&"object"==typeof this.record.parent)return new X(this.record.parent,this.kernel);const t=this.record.parent_id;return null==t||""===t?null:at(String(t),this.siteRef())}async getAncestors(){if(Array.isArray(this.record.ancestors))return this.rowsToPages(this.record.ancestors);const t=this.embeddedAncestors();if(t.length){const e=t[0],r=e.raw().parent_id;return null==r||""===r||0===r?t:[...await e.fetchAncestors(),...t]}return this.fetchAncestors()}async getSite(){if(this.record.site&&"object"==typeof this.record.site)return new Z(this.record.site,this.kernel);const t=this.kernel.snapshot().site;if(t&&(String(t.id)===String(this.record.site_id)||!this.record.site_id))return new Z(t,this.kernel);const e=this.record.site_id?String(this.record.site_id):this.kernel.siteRef(),r=l(await this.kernel.request(c().site(e)));return this.kernel.rememberSite(r),new Z(r,this.kernel)}async load(){return await this.ensure(["content","options","assets","children"]),this}raw(){return{...this.record}}seoBag(){const t=this.record.seo&&"object"==typeof this.record.seo?this.record.seo:this.kernel.snapshot().seo;return t&&"object"==typeof t?{...t}:{}}galleryList(t){if(Array.isArray(this.record.galleries))return this.record.galleries.flatMap(t=>{const e=B(t);if(!e)return[];const r=t&&"object"==typeof t?String(t.description??""):"";return[{...e,description:r}]});const e=new Map;for(const r of t)for(const t of r.memberships()){const r=(t.uuid||t.name).toLocaleLowerCase();r&&!e.has(r)&&e.set(r,{...t,description:""})}return[...e.values()]}siteRef(){return this.record.site&&"object"==typeof this.record.site?i(this.record.site)||this.kernel.siteRef():this.record.site_id?String(this.record.site_id):this.kernel.siteRef()}rowsToPages(t){return Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new X(t,this.kernel)):[]}embeddedAncestors(){const t=[],e=new Set;let r=this.record.parent;for(;r&&"object"==typeof r&&t.length<12;){const n=r,s=String(n.uuid||n.id||"");if(!s||e.has(s))break;e.add(s),t.unshift(new X(n,this.kernel)),r=n.parent}return t}async fetchAncestors(){const t=[],e=new Set;let r=await this.getParent();for(;r&&t.length<12;){const n=r.getUuid()||String(r.raw().id??"");if(!n||e.has(n))break;e.add(n),t.unshift(r),r=await r.getParent()}return t}excludeSelf(t){const e=s(this.record);return t.filter(t=>s(t)!==e).map(t=>new X(t,this.kernel))}async ensure(t){if(!t.some(t=>void 0===this.record[t]))return;const e=this.getUuid()||this.getSlug()||String(this.record.id||"");if(!e)return;const r=l(await this.kernel.request(c().page(this.siteRef(),e)));this.setRecord({...this.record,...r})}}let tt=null;function et(){if(!tt)throw new Error("Client is not installed.");return tt}function rt(t,e){return null!=e&&""!==String(e)?String(e):t.siteRef()}function nt(t,e){e?.page&&e.page>0&&t.set("page",String(Math.floor(e.page))),e?.perPage&&e.perPage>0&&t.set("per_page",String(Math.floor(e.perPage)))}function st(t){if(null==t)return!1;if("string"==typeof t){const e=t.trim();return""!==e&&"{}"!==e&&"[]"!==e}return Array.isArray(t)?t.length>0:"object"!=typeof t||Object.keys(t).length>0}function it(t){if(t&&"object"==typeof t)return t.options}function ot(t){if("string"==typeof t)return t;if(t&&"object"==typeof t)try{return JSON.stringify(t)}catch{return""}return""}async function at(t,e){const r=et(),n=rt(r,e),s=l(await r.request(c().page(n,t)));return r.rememberPage(s),new X(s,r)}class ct{constructor(t,e=null){this.record=t,this.kernel=e}record;kernel;getTitle(){return new x(this.record.title)}getUrl(){return new j(this.record.url)}getChildren(){return lt(this.record.children,this.kernel)}isCurrent(t){const e=this.getUrl().path();if(!e)return!1;if(t)return e===t.getUrl().path();const r=this.kernel??pt,n=r?.snapshot().page;return!(!r||!n)&&e===new X(n,r).getUrl().path()}getPage(){const t=this.record.page;if(!t||"object"!=typeof t)return null;const e=this.kernel??pt;return e?new X(t,e):null}raw(){return{...this.record}}}class ut{constructor(t,e){this.source=t,this.runtime=e}source;runtime;get record(){return"function"==typeof this.source?this.source():this.source}static async find(t,e){const r=function(){if(!pt)throw new Error("Client is not installed.");return pt}(),n=null!=e&&""!==String(e)?String(e):r.siteRef(),s=r.snapshot().menus,i=s[t]||Object.values(s).find(e=>!!e&&(String(e.uuid)===t||String(e.id)===t||String(e.name)===t||String(e.position)===t));if(i)return new ut(i,r);const o=l(await r.request(c().menu(n,t)));return r.rememberMenu(o),new ut(o,r)}getName(){return new x(this.record.name)}getPosition(){return String(this.record.position||"")}getItems(){return lt(this.record.items,this.runtime)}raw(){return{...this.record}}}function lt(t,e=null){return Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new ct(t,e)):[]}let pt=null;class ht{snap={page:null,site:null,menus:{},locales:[],seo:null,options:{}};options;inflight=new Map;cache=new Map;constructor(t={}){this.options=t,t.page&&this.hydrate(t.page),tt=this,Y=this,pt=this}hydrate(t){return this.snap=e(this.snap,function(t){const e={page:null,site:null,menus:{},locales:[],seo:null,options:{}};if(!t||"object"!=typeof t)return e;const s=t,i=r(s.props)?s.props:s;e.page=n(i.page),e.site=n(i.site),e.seo=r(i.seo)?i.seo:null,e.options=r(i.options)?i.options:{},e.locales=Array.isArray(i.locales)?i.locales:[];const o=i.menus;if(r(o))for(const[r,a]of Object.entries(o))e.menus[r]=n(a);return e}(t)),this.snap}snapshot(){return this.snap}apiBase(){return function(t){if(t)return String(t).replace(/\/+$/,"");const e=u();return e.apiBase?String(e.apiBase).replace(/\/+$/,""):function(){if("undefined"==typeof location)return"";const t=String(location.origin||"").replace(/\/+$/,"");if(t&&"null"!==t)return t;const e=location.hostname||"";return e?`${location.protocol}//${e}`:""}()}(this.options.apiBase)}siteBase(){return function(t){if(t)return String(t).replace(/\/+$/,"");const e=u();return e.siteBase?String(e.siteBase).replace(/\/+$/,""):"undefined"!=typeof location?location.origin:""}(this.options.siteBase)}siteRef(){return null!=this.options.site&&""!==String(this.options.site)?String(this.options.site):i(this.snap.site)}async request(t,e={}){const r=String(e.method||"GET").toUpperCase(),n=`${r} ${t}`;if("GET"===r&&this.cache.has(n))return this.cache.get(n);if("GET"===r){const t=this.inflight.get(n);if(t)return t}const s=this.apiBase();if(!s)throw new Error("Remote origin is not configured.");const i=async function(t,e,r={}){const{fetchImpl:n,...s}=r,i=e.startsWith("http")?e:a(t,e),o=n??fetch,c=new Headers(s.headers);c.has("Accept")||c.set("Accept","application/json");const u=await o(i,{...s,headers:c}),l=await u.text();let p=null;if(l)try{p=JSON.parse(l)}catch{p={message:l}}if(!u.ok){const t=new Error(`Request failed (${u.status})`);throw t.status=u.status,t.body=p,t}return p}(s,t,{...e,fetchImpl:this.options.fetch}).then(t=>("GET"===r&&this.cache.set(n,t),t));return"GET"===r&&(this.inflight.set(n,i),i.finally(()=>{this.inflight.delete(n)}).catch(()=>{})),i}rememberPage(t){const r=this.snap.page;r&&String(r.id)===String(t.id)&&(this.snap=e(this.snap,{page:{...r,...t}}))}rememberSite(t){this.snap=e(this.snap,{site:{...this.snap.site??{},...t}})}rememberMenu(t){const r=String(t.position||t.uuid||t.id||t.name||"menu");this.snap=e(this.snap,{menus:{[r]:t}})}}let gt=null;function dt(t={}){return gt=new ht(t),gt}function ft(){return gt||(gt=new ht),gt}const mt=Symbol.for("miro.client");function yt(){return t.inject(mt,null)??ft()}function wt(t={}){return{install(e,r={}){const n=dt({...t,...r});e.provide(mt,n),function(t){import("@inertiajs/vue3").then(e=>{const r=e.router;r?.page&&t.hydrate(r.page),r?.on?.("success",e=>{const r=e?.detail?.page;r&&t.hydrate(r)}),r?.on?.("navigate",e=>{const r=e?.detail?.page;r&&t.hydrate(r)})}).catch(()=>{})}(n)}}}const St=wt();class bt{constructor(t){this.kernel=t}kernel;all(){return function(t,e=function(){return globalThis}()){const r=Array.isArray(t)?t.flatMap(t=>function(t){if(!t||"object"!=typeof t)return[];const e=t,r=$t(String(e.lang??""));return r?[{lang:r,domain:jt(String(e.domain??"")),url:String(e.url??"").trim()}]:[]}(t)):[];return r.length?r.flatMap(t=>{const r=_t(t.url||function(t,e){const r=e[`locale_${t}_baseurl`];return"string"==typeof r?r.trim():""}(t.lang,e)||t.domain);return t.lang&&r?[{lang:t.lang,domain:t.domain||jt(r),url:r}]:[]}):function(t){const e=[];for(const r of Object.keys(t)){const n=/^locale_([a-z]+)_baseurl$/.exec(r);if(!n)continue;const s=_t(String(t[r]??""));s&&e.push({lang:n[1],domain:jt(s),url:s})}return e}(e)}(this.kernel.snapshot().locales)}current(){return $t(String(this.kernel.snapshot().site?.lang||""))}url(t){const e=$t(t),r=this.all().find(t=>t.lang===e);return r?.url??""}}function $t(t){return(t.trim().toLowerCase().replaceAll("_","-").split("-")[0]??"").replace(/[^a-z]/g,"")}function _t(t){const e=t.trim();return e?(/^https?:\/\//i.test(e)?e:`https://${e.replace(/^\/+/,"")}`).replace(/\/+$/,""):""}function jt(t){return t.trim().replace(/^https?:\/\//i,"").replace(/\/.*$/,"")}function xt(t){return`mc_${(String(t??"").trim().split("/").pop()??"").replace(/^@/,"").replace(/[^A-Za-z0-9]+/g,"_").replace(/^_+|_+$/g,"").toUpperCase()}`}function kt(t){if("undefined"==typeof window||""===t)return"";const e=window.__MIRO_WEB_PLUGINS__;if(!Array.isArray(e))return"";for(const r of e){const e=String(r??"").trim().toLowerCase(),n=e.lastIndexOf("/");if(n<=0)continue;const s=e.slice(0,n),i=e.slice(n+1);if(""!==s&&(i===t||At(i)===t))return s}return""}function At(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[^A-Za-z0-9]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Pt(t){if("undefined"==typeof window)return{};const e=window[t];return e&&"object"==typeof e?e:{}}function Ct(){const t=yt(),e=function(){try{const t=globalThis.__INERTIA_PAGE__;if(t?.props)return t.props}catch{}return function(){if("undefined"==typeof document)return null;const t=document.querySelector("[data-page]")?.getAttribute("data-page");if(!t)return null;try{return JSON.parse(t).props??null}catch{return null}}()}();return e&&t.hydrate(e),t}function Mt(){const t=Ct();return vt(t),new X(()=>t.snapshot().page??{},t)}function vt(e){try{const r=function(){try{return Ot??null}catch{return null}}();if(!r)return;const n=r.usePage();e.hydrate(t.unref(n))}catch{}}let Ot=null;import("@inertiajs/vue3").then(t=>{Ot=t}).catch(()=>{Ot=null});const Tt=St;exports.Asset=W,exports.AssetName=k,exports.CollectionCard=D,exports.Gallery=L,exports.Locales=bt,exports.Menu=ut,exports.MenuItem=ct,exports.MenuTitle=x,exports.Miro=St,exports.OptionValue=_,exports.Page=X,exports.PageContent=S,exports.PageSmallTitle=y,exports.PageSubtitle=m,exports.PageSummary=w,exports.PageTitle=f,exports.SDK_KEY=mt,exports.SeoDescription=P,exports.SeoTitle=A,exports.Site=Z,exports.SiteName=$,exports.SiteTitle=b,exports.TextValue=d,exports.UrlValue=j,exports.createMiro=wt,exports.createRuntime=dt,exports.default=Tt,exports.getRuntime=ft,exports.pluginWindowKey=xt,exports.useKernel=yt,exports.useMiroAssets=function(){return Mt().getAssets()},exports.useMiroConfig=function(){const e=yt();return{apiBase:t.computed(()=>e.apiBase()),siteBase:t.computed(()=>e.siteBase()),siteRef:t.computed(()=>e.siteRef())}},exports.useMiroLocales=function(){const t=Ct();return vt(t),new bt(t)},exports.useMiroMenu=function(t="topbar"){const e=Ct();return vt(e),new ut(()=>e.snapshot().menus[t]??{position:t,items:[]},e)},exports.useMiroPage=Mt,exports.useMiroSite=function(){const t=Ct();return vt(t),new Z(()=>t.snapshot().site??{},t)},exports.usePlugin=function(t){return function(t,e){const r=xt(t),n=function(t){const e=String(t??"").trim();if(e.includes("/")){const[t,...r]=e.split("/");return{vendor:t||"miroart",slug:At(r.join("/")||e)}}const r=At(e);return{vendor:kt(r)||"miroart",slug:r}}(t);return new Proxy({name:t,key:r,ready:async()=>async function(t){const e=Date.now();for(;Date.now()-e<4e3;){const e=Pt(t);if(Object.keys(e).length)return e;await new Promise(t=>setTimeout(t,50))}return Pt(t)}(r),api:()=>Pt(r),call:(t,...e)=>{const n=Pt(r),s=n[t];if("function"!=typeof s)throw new Error(`Missing plugin method: ${t}`);return s.apply(n,e)},request:async(t="/",r={})=>{const s=c().plugins(n.vendor,n.slug,t||"/"),i=new Headers(r.headers);let o=r.body;return void 0!==r.json&&(o=JSON.stringify(r.json)),l(await e.request(s,{...r,headers:i,body:o}))}},{get(t,e,n){if(e in t)return Reflect.get(t,e,n);if("then"===e||e===Symbol.toStringTag)return;const s=Pt(r),i=s[String(e)];return"function"==typeof i?i.bind(s):i},has:(t,e)=>e in t||e in Pt(r)})}(t,yt())};
1
+ "use strict";Object.create,Object.defineProperty,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.prototype.hasOwnProperty,Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),e=["primary","secondary","accent","neutral","base-100","base-content","info","success","warning","error"],r=["sans","serif"],n=/\\(\[\/?(?:b|i|u|s|c|f)(?:=[a-z0-9-]+)?\])|\[(\/?)(b|i|u|s|c|f)(?:=([a-z0-9-]+))?\]/g;function i(t,n){return"c"===t?e.includes(n??""):"f"===t?r.includes(n??""):void 0===n}function s(t,e){""!==e&&e.split(/\r?\n/).forEach((e,r)=>{if(r>0&&t.push({type:"br"}),""===e)return;const n=t[t.length-1];"text"===n?.type?n.value+=e:t.push({type:"text",value:e})})}function o(t){const e=String(t??""),r=[],o=[],a=()=>o[o.length-1]?.children??r,c=()=>{var t,e;t=o.pop(),e=a(),0!==t.children.length&&("c"===t.tag?e.push({type:"c",value:t.value,children:t.children}):"f"===t.tag?e.push({type:"f",value:t.value,children:t.children}):e.push({type:t.tag,children:t.children}))};let u,l=0;for(n.lastIndex=0;null!==(u=n.exec(e));){s(a(),e.slice(l,u.index)),l=n.lastIndex;const[t,r,p,h,d]=u;if(void 0===r){if("/"===p){const e=void 0===d?o.map(t=>t.tag).lastIndexOf(h):-1;if(-1===e){s(a(),t);continue}for(;o.length>e;)c();continue}!i(h,d)||o.length>=8?s(a(),t):o.push({tag:h,value:d??null,children:[]})}else s(a(),r)}for(s(a(),e.slice(l));o.length>0;)c();return r}function a(t,e){for(const r of t)"text"===r.type?e.push(r.value):"br"===r.type?e.push("\n"):a(r.children,e)}function c(t){const e=String(t??"");if(!e.includes("["))return e;const r=[];return a(o(e),r),r.join("")}function u(t){return null==t?"":"string"==typeof t?t:"number"==typeof t||"boolean"==typeof t?String(t):""}function l(t){const e=u(t);if(!e)return"";if("undefined"!=typeof document){const t=document.createElement("textarea");return t.innerHTML=e,t.value}return e.replace(/&#(\d+);/g,(t,e)=>String.fromCharCode(Number(e))).replace(/&#x([0-9a-f]+);/gi,(t,e)=>String.fromCharCode(parseInt(e,16))).replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">")}function p(t){return c(l(t)).replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi," ").replace(/<style[\s\S]*?>[\s\S]*?<\/style>/gi," ").replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim()}class h extends String{kind;extra;constructor(t,e,r={}){super(l(e)),this.kind=t,this.extra=r,Object.setPrototypeOf(this,new.target.prototype)}toString(){return String.prototype.toString.call(this)}valueOf(){return String.prototype.valueOf.call(this)}raw(){return this.toString()}decode(){return l(this.toString())}cleanContent(){return p(this.toString())}stripHtml(){return this.cleanContent()}plain(){return c(this.toString())}excerpt(t=160){const e=this.cleanContent();return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}firstParagraph(){return function(t){const e=l(t),r=e.match(/<p\b[^>]*>([\s\S]*?)<\/p>/i);return p(r?r[1]:e)}(this.toString())}isEmpty(){return""===this.cleanContent()}json(){const t=this.toString().trim();if(!t)return null;try{return JSON.parse(t)}catch{return null}}bool(){const t=this.toString().trim().toLowerCase();return"1"===t||"true"===t||"yes"===t||"on"===t}number(){const t=Number(this.toString().trim());return Number.isFinite(t)?t:null}}class d extends h{constructor(t){super("PageTitle",t)}}class g extends h{constructor(t){super("PageSubtitle",t)}}class f extends h{constructor(t){super("PageSmallTitle",t)}}class m extends h{constructor(t){super("PageSummary",t)}}class y extends h{constructor(t){super("PageContent",t)}html(){return this.toString()}}class w extends h{constructor(t){super("SiteTitle",t)}}class S extends h{constructor(t){super("SiteName",t)}}class b extends h{key;structured;constructor(t,e){const r=A(e);super("OptionValue",r.text,{key:t}),this.key=t,this.structured=r.structured}json(){return void 0!==this.structured?this.structured:super.json()}present(){return!this.isEmpty()}}class $ extends h{constructor(t){super("UrlValue",t)}path(){const t=this.toString().trim();if(!t)return"/";try{if(/^https?:\/\//i.test(t))return new URL(t).pathname.replace(/\/+$/,"")||"/"}catch{}return(t.startsWith("/")?t:`/${t}`).replace(/\/+$/,"")||"/"}href(t=""){const e=this.path();return!t||/^https?:\/\//i.test(e)?e:`${String(t).replace(/\/+$/,"")}${e}`}}class k extends h{constructor(t){super("MenuTitle",t)}}class _ extends h{constructor(t){super("AssetName",t)}}class x extends h{constructor(t){super("SeoTitle",t)}}class j extends h{constructor(t){super("SeoDescription",t)}}function A(t){if(null==t)return{text:""};if("boolean"==typeof t||"number"==typeof t)return{text:String(t)};if("string"==typeof t){const e=t.trim();if(""===e||"[]"===e||"{}"===e)return{text:""};if(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]")||e.startsWith('"')&&e.endsWith('"'))try{return A(JSON.parse(e))}catch{return{text:l(t)}}return{text:l(t)}}return Array.isArray(t)?{text:JSON.stringify(t),structured:t}:"object"==typeof t?function(t){return"value"in t&&Object.keys(t).every(t=>"value"===t||"key"===t||"id"===t||"active"===t)}(t)?A(t.value):{text:JSON.stringify(t),structured:t}:{text:u(t)}}function v(t,e){if(!t)return"";if(Array.isArray(t)){const r=t.find(t=>t&&"object"==typeof t&&t.key===e);return r&&"object"==typeof r?r.value:""}return"object"==typeof t?t[e]:""}function P(t){return String.fromCharCode(...t.map(t=>23^t))}function C(t,e){const r=String(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return r?`${r}${n}`:n}function O(){const t=P([56,118,103,126]),e=P([97,38]),r=P([100,126,99,114,100]),n=P([103,118,112,114,100]),i=P([100,114,118,101,116,127]),s=P([122,114,121,98,100]),o=P([122,114,115,126,118]),a=P([103,123,98,112,126,121,100]),c=P([118,116,99,126,120,121,100]);return{sites:()=>C("",`${t}/${e}/${r}`),site:n=>C("",`${t}/${e}/${r}/${encodeURIComponent(n)}`),pages:i=>C("",`${t}/${e}/${r}/${encodeURIComponent(i)}/${n}`),page:(i,s)=>C("",`${t}/${e}/${r}/${encodeURIComponent(i)}/${n}/${s.split("/").map(t=>encodeURIComponent(t)).join("/")}`),search:s=>C("",`${t}/${e}/${r}/${encodeURIComponent(s)}/${n}/${i}`),menus:n=>C("",`${t}/${e}/${r}/${encodeURIComponent(n)}/${s}`),menu:(n,i)=>C("",`${t}/${e}/${r}/${encodeURIComponent(n)}/${s}/${encodeURIComponent(i)}`),media:e=>C("",`${t}/${o}/${encodeURIComponent(e)}`),action:e=>C("",`${t}/${c}/${encodeURIComponent(e)}`),plugins:(e,r,n="")=>{const i=`${t}/${a}/${encodeURIComponent(e)}/${encodeURIComponent(r)}`;return n&&"/"!==n?`${i}${n.startsWith("/")?n:`/${n}`}`:i}}}function M(t){if("string"==typeof t){const e=t.trim();return e?N(e)?{uuid:e}:{url:e,path:e}:null}if(!t||"object"!=typeof t||Array.isArray(t))return null;const e=t,r=U(e.source),n=T(e.url,e.preview_url,e.path,e.src,r?.url,r?.preview_url,r?.path),i=T(e.uuid,r?.uuid);if(n||i&&N(i))return e;const s=T(e.value);return s?M(s):null}function T(...t){for(const e of t)if("string"==typeof e&&""!==e.trim())return e.trim();return""}function R(t){return"string"==typeof t?t.trim():""}function U(t){return!t||"object"!=typeof t||Array.isArray(t)?null:t}function I(t){return t.startsWith("/media/")||t.startsWith("/_images/")||t.startsWith("/api/media/")||t.startsWith("/branding-assets/")||t.startsWith("/storage/")}function N(t){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)}const W=[{mark:"1_8",width:256},{mark:"1_4",width:512},{mark:"1_2",width:1024},{mark:"2_3",width:1400}];class E{constructor(t,e){this.record=t,this.runtime=e}record;runtime;getUuid(){return String(this.record.uuid||this.record.id||"")}getName(){return new _(this.record.name)}getAlt(){return R(this.record.alt)}getCaption(){return R(this.record.caption)}getGallery(){return this.memberships()[0]??null}galleryUuid(){return this.memberships()[0]?.uuid??""}galleryName(){return this.memberships()[0]?.name??""}memberships(){const t=this.record.galleries;if(Array.isArray(t)&&t.length>0)return t.map(t=>B(t)).filter(t=>null!==t);const e=String(this.record.gallery_uuid??"").trim(),r=String(this.record.gallery_name??"").trim();if(!e&&!r)return[];const n=this.record.gallery_id;return[{id:"number"==typeof n||"string"==typeof n?n:null,uuid:e,name:r,sort_order:q(this.record.gallery_sort_order)}]}getMime(){const t=U(this.record.source);return String(this.record.mime_type||t?.mime_type||"")}getSize(){const t=U(this.record.source),e=Number(this.record.size??t?.size??0);return Number.isFinite(e)?e:0}getType(){const t=R(this.record.type);if(t)return t;const e=this.getMime();return e.startsWith("image/")?"image":e.startsWith("video/")?"video":"application/pdf"===e?"pdf":""}getSortOrder(){const t=Number(this.record.sort_order??0);return Number.isFinite(t)?t:0}isImage(){return!!this.getMime().startsWith("image/")||/\.(jpe?g|png|gif|webp|svg)(\?|$)/i.test(this.urlString())}url(){return new $(this.urlString())}srcset(){const t=this.urlString();if(!t||/\.svg([?#]|$)/i.test(t)||/^https?:\/\//i.test(t)||t.startsWith("//"))return"";if(!/\.webp([?#]|$)/i.test(t)||/\.(?:1_16|1_8|1_4|1_2|2_3)\.webp([?#]|$)/i.test(t))return"";const e=W.map(({mark:e,width:r})=>`${t.replace(/\.webp([?#].*)?$/i,`.${e}.webp$1`)} ${r}w`);return e.push(`${t} 2048w`),e.join(", ")}raw(){return{...this.record}}urlString(){const t=U(this.record.source),e=T(this.record.uuid,t?.uuid),r=T(this.record.disk,t?.disk);let n=T(this.record.url,this.record.preview_url,this.record.path,this.record.src,t?.url,t?.preview_url,t?.path);if(e&&N(e)&&n&&function(t,e){return!!(/\/project-storage\//i.test(r=t)||/\/editor\/project-file/i.test(r)||/cms\.miroart\.pl/i.test(r)&&/\/(?:project-storage|storage)\//i.test(r))||"project_public"===e&&!I(t)&&!/^https?:\/\//i.test(t)&&!t.startsWith("//");var r}(n,r))return this.mediaUrl(e);if(!n)return e&&N(e)?this.mediaUrl(e):"";if(!0===globalThis.isSsg){if(n.startsWith("/_images/")||n.startsWith("_images/"))return n.startsWith("/")?n:`/${n}`;const e=function(t){const e=t.match(/[?&]path=([^&]+)/i);if(e)try{const t=decodeURIComponent(e[1].replace(/\+/g," ")).split(/[/\\]/).pop()||"";if(t&&"project-file"!==t.toLowerCase())return t.trim()}catch{}return(t.split("#")[0].split("?")[0].split(/[/\\]/).pop()||"").trim()}(T(t?.path,this.record.path,n)),r=/\.(jpe?g|png|gif|webp|svg)$/i.test(i=e)?/\.svg$/i.test(i)?`/_images/${i}`:`/_images/${i.replace(/\.(jpe?g|png|gif|webp)$/i,".webp")}`:null;if(r)return r}var i;if(/^https?:\/\//i.test(n)||n.startsWith("//"))return n;if(n.startsWith("_images/"))return`/${n}`;if(I(n))return n;n.includes("/")||n.includes("\\")||N(n)||(n=`images/${n}`);const s=n.startsWith("/")?n:`/${n}`;return I(s)||s.startsWith("/project-storage/")?s:`/storage${s}`}mediaUrl(t){const e=O().media(t),r=this.runtime.apiBase();return r?C(r,e):e}}class L{constructor(t){this.items=t}items;all(){return this.items.slice()}first(){return this.items[0]??null}extra(){return this.items.slice(1)}hero(){return this.first()}urls(){return this.items.map(t=>t.url())}isEmpty(){return 0===this.items.length}count(){return this.items.length}[Symbol.iterator](){return this.items[Symbol.iterator]()}}function B(t){if(!t||"object"!=typeof t)return null;const e=t,r=String(e.uuid??"").trim(),n=String(e.name??"").trim();if(!r&&!n)return null;const i=e.id;return{id:"number"==typeof i||"string"==typeof i?i:null,uuid:r,name:n,sort_order:q(e.sort_order)}}function q(t){const e=Number(t??0);return Number.isFinite(e)?e:0}function G(t,e){return Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new E(t,e)):[]}function z(){if("undefined"==typeof globalThis)return{};const t=globalThis.MiroConfig;return t&&"object"==typeof t?t:{}}function F(t){return t&&"object"==typeof t&&"data"in t?t.data:t}function D(t,e){return{page:void 0!==e.page?e.page:t.page,site:void 0!==e.site?e.site:t.site,menus:e.menus?{...t.menus,...e.menus}:{...t.menus},locales:e.locales??t.locales,seo:void 0!==e.seo?e.seo:t.seo,options:e.options?{...t.options,...e.options}:{...t.options},editing:e.editing??t.editing}}function J(t){return Boolean(t)&&"object"==typeof t&&!Array.isArray(t)}function H(t){return J(t)?t:null}function V(t){return t?String(t.uuid||t.ulid||t.id||t.slug||t.full_url||""):""}function K(t){return t?String(t.uuid||t.domain||t.id||""):""}const Z=new Set(["id","uuid","created_at","updated_at"]);class Y{constructor(t,e){this.row=t,this.kernel=e}row;kernel;getHref(){return new $(this.row.href)}getTitle(){return String(this.row.title??"")}item(){const t=this.row.item;return t&&"object"==typeof t?t:{}}image(){return Q(this.item(),this.kernel)}}function Q(t,e){if(!t||"object"!=typeof t)return null;for(const[r,n]of Object.entries(t)){if(Z.has(r)||"string"!=typeof n||!X(n))continue;const t=M(n);if(t)return new E(t,e)}return null}function X(t){const e=t.trim();return!!e&&(!!(e.startsWith("/media/")||e.startsWith("/_images/")||e.startsWith("_images/")||e.startsWith("/api/media/")||e.startsWith("/branding-assets/"))||/\.(jpe?g|png|gif|webp|svg)(\?|#|$)/i.test(e))}function tt(t,e){const r=t&&"object"==typeof t?t.meta:null,n=r&&"object"==typeof r?r:{};return{currentPage:rt(n.current_page,1),lastPage:rt(n.last_page,1),perPage:rt(n.per_page,Math.max(e,1)),total:nt(n.total,e)}}function et(t,e){return Object.assign(t,{meta:e})}function rt(t,e){const r=Number(t);return!Number.isFinite(r)||r<1?e:Math.floor(r)}function nt(t,e){if(null==t||""===t)return e;const r=Number(t);return!Number.isFinite(r)||r<0?e:Math.floor(r)}class it{constructor(t,e){this.source=t,this.kernel=e}source;kernel;get record(){return"function"==typeof this.source?this.source():this.source}static async all(){const t=ot(),e=await t.request(O().sites());return(Array.isArray(e?.data)?e.data:[]).filter(t=>Boolean(t)&&"object"==typeof t).map(e=>new it(e,t))}static async find(t){const e=ot(),r=null!=t&&""!==String(t)?String(t):e.siteRef(),n=e.snapshot().site;if(n&&(!t||String(n.uuid)===String(t)||String(n.id)===String(t)||String(n.domain)===String(t)||K(n)===String(t)))return new it(n,e);const i=F(await e.request(O().site(r)));return e.rememberSite(i),new it(i,e)}static async findPage(t,e){return at.find(t,e)}static async findMenu(t,e){return yt.find(t,e)}getName(){return new S(this.record.name)}getTitle(){const t=v(this.record.options,"seo_title")||v(this.record.options,"title");return new w(t||this.record.name)}getDomain(){return String(this.record.domain||"")}getLang(){return String(this.record.lang||"")}getUuid(){return String(this.record.uuid||"")}getOption(t){return new b(t,v(this.record.options,t))}getImage(t){const e=this.getOption(t),r=e.json(),n=null==r?e.toString().trim():r;if(null==n||""===n)return null;const i=M(n);return i?new E(i,this.kernel):null}async findPage(t){return at.find(t,this.ref())}async findMenu(t){return yt.find(t,this.ref())}async menus(){const t=this.kernel.snapshot().menus,e=Object.values(t).filter(Boolean);return e.length?e.map(t=>new yt(t,this.kernel)):((await this.kernel.request(O().menus(this.ref()))).data??[]).map(t=>(this.kernel.rememberMenu(t),new yt(t,this.kernel)))}async pages(t={}){const e=new URLSearchParams,r={...t};null!=r.perPage&&null==r.per_page&&(r.per_page=r.perPage,delete r.perPage);for(const[o,a]of Object.entries(r))e.set(o,String(a));const n=e.toString()?`?${e.toString()}`:"",i=await this.kernel.request(`${O().pages(this.ref())}${n}`),s=(i.data??[]).map(t=>(this.kernel.rememberPage(t),new at(t,this.kernel)));return et(s,tt(i,s.length))}async runAction(t){const e=String(t.uuid||"").trim();if(!e)throw new Error("Action uuid is required.");const r=String(this.record.domain||this.ref());return this.kernel.request(O().action(r),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({uuid:e,method:t.method||"GET",path:t.path||"",query:t.query||{},body:t.body||"",headers:t.headers||{},params:t.params||{},post:t.post||{}})})}raw(){return{...this.record}}ref(){return String(this.record.uuid||this.record.domain||this.record.id||this.kernel.siteRef())}}let st=null;function ot(){if(!st)throw new Error("Client is not installed.");return st}class at{constructor(t,e){this.source=t,this.kernel=e}source;kernel;get record(){return"function"==typeof this.source?this.source():this.source}setRecord(t){"function"!=typeof this.source?this.source=t:this.kernel.rememberPage(t)}static async findByUlid(t,e){return ft(t,e)}static async find(t,e){return ft(t,e)}static async search(t,e,r){const n=ut(),i=lt(n,e),s=new URLSearchParams;s.set("q",t),pt(s,r);const o=await n.request(`${O().search(i)}?${s.toString()}`),a=(Array.isArray(o?.data)?o.data:Array.isArray(o)?o:[]).map(t=>(n.rememberPage(t),new at(t,n)));return et(a,tt(o,a.length))}getTitle(){return new d(this.record.title)}getSubtitle(){return new g(this.record.subtitle)}getSmallTitle(){return new f(this.record.smalltitle)}getSummary(){return new m(this.record.summary)}getContent(){return new y(this.record.content)}getSlug(){return String(this.record.slug||"")}getUrl(){return new $(this.record.full_url||(this.record.slug?`/${this.record.slug}`:"/"))}getUuid(){return String(this.record.uuid||this.record.ulid||"")}getId(){return String(this.record.id||this.getUuid())}getLayout(){return String(this.record.layout||"")}getDisplay(){return String(this.record.display||"")}getDisplayInMenu(){const t=this.record.display_in_menu;return null==t||""===t||!1!==t&&0!==t&&"0"!==t}getSortOrder(){const t=Number(this.record.sort_order??0);return Number.isFinite(t)?t:0}getLang(){const t=String(this.record.lang||"").trim();if(t)return t;const e=this.kernel.snapshot().site;return String(e?.lang||function(t){return t&&"object"==typeof t?String(t.lang||""):""}(this.record.site)||"")}getOption(t){const e=[v(this.record.options,t),this.kernel.snapshot().options[t],v(this.kernel.snapshot().site?.options,t),v(dt(this.record.site),t)];for(const r of e)if(ht(r))return new b(t,r);return new b(t,"")}getSeo(){const t=this.seoBag(),e=t=>null==t?"":String(t),r=t=>{const e=M(t);return e?new E(e,this.kernel):null};return{title:new x(t.title??this.record.title),description:new j(t.description??this.record.summary),keywords:e(t.keywords),robots:e(t.robots),canonical:new $(t.canonical),ogTitle:e(t.og_title??t.title??this.record.title),ogDescription:e(t.og_description??t.description??this.record.summary),ogImage:r(t.og_image),ogType:e(t.og_type),ogUrl:new $(t.og_url||t.canonical),twitterCard:e(t.twitter_card),twitterTitle:e(t.twitter_title??t.og_title??t.title),twitterDescription:e(t.twitter_description??t.og_description??t.description),twitterImage:r(t.twitter_image||t.og_image),ldJson:gt(t.ld_json),raw:{...t}}}get collectionItem(){const t=this.record.collectionItem;return t&&"object"==typeof t?t:{}}get collectionItems(){const t=this.record.collectionItems;return t&&"object"==typeof t?t:{}}get collectionGallery(){return t=this.record.collectionGallery,e=this.kernel,Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new Y(t,e)):[];var t,e}collectionImage(){return Q(this.collectionItem,this.kernel)}getAssets(){return new L(G(this.record.assets,this.kernel))}getGallery(t){const e=t.trim();if(!e)return new L([]);const r=[];return G(this.record.assets,this.kernel).forEach((t,n)=>{const i=t.memberships().find(t=>function(t,e){const r=e.trim().toLocaleLowerCase();return!!r&&(t.uuid.toLocaleLowerCase()===r||t.name.toLocaleLowerCase()===r)}(t,e));i&&r.push({asset:t,sort:i.sort_order,index:n})}),r.sort((t,e)=>t.sort-e.sort||t.index-e.index),new L(r.map(t=>t.asset))}getGalleries(){const t=G(this.record.assets,this.kernel);return this.galleryList(t).map(t=>({id:t.id,uuid:t.uuid,name:t.name,description:t.description,sort_order:t.sort_order,assets:this.getGallery(t.uuid||t.name)}))}async getChildren(t){const e=function(t){if(!Array.isArray(t))return[];const e=new Set(["options","assets"]),r=[];for(const n of t){const t=String(n).trim().toLowerCase();e.has(t)&&!r.includes(t)&&r.push(t)}return r}(t?.with),r=Array.isArray(this.record.children)?this.record.children:null;if(r&&function(t,e){return!e.length||t.every(t=>{if(!t||"object"!=typeof t)return!1;const r=t;if(e.includes("options")){const t=r.options;if(null==t||"object"!=typeof t)return!1}return!(e.includes("assets")&&!Array.isArray(r.assets))})}(r,e)){const e=function(t,e,r){const n=t.length;if(!e&&!r)return{items:t,meta:{currentPage:1,lastPage:1,perPage:Math.max(n,1),total:n}};const i=r&&r>0?Math.floor(r):Math.max(n,1),s=e&&e>0?Math.floor(e):1,o=Math.max(1,Math.ceil(n/i)),a=(s-1)*i;return{items:t.slice(a,a+i),meta:{currentPage:s,lastPage:o,perPage:i,total:n}}}(this.rowsToPages(r),t?.page,t?.perPage);return et(e.items,e.meta)}const n=this.getUuid()||String(this.record.id??"");if(!n){const t=r?this.rowsToPages(r):[];return et(t,tt(null,t.length))}const i=new URLSearchParams;i.set("parent",n),e.length&&i.set("with",e.join(",")),pt(i,t);const s=await this.kernel.request(`${O().pages(this.siteRef())}?${i.toString()}`);return et(this.rowsToPages(s.data??[]),tt(s,(s.data??[]).length))}async getSiblings(){if(Array.isArray(this.record.siblings))return this.record.siblings.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new at(t,this.kernel));const t=this.record.parent_id,e=this.siteRef();if(null==t||""===t){const t=await this.kernel.request(`${O().pages(e)}?parent=root`);return this.excludeSelf(t.data??[])}const r=await this.kernel.request(`${O().pages(e)}?parent=${encodeURIComponent(String(t))}`);return this.excludeSelf(r.data??[])}async getParent(){if(this.record.parent&&"object"==typeof this.record.parent)return new at(this.record.parent,this.kernel);const t=this.record.parent_id;return null==t||""===t?null:ft(String(t),this.siteRef())}async getAncestors(){if(Array.isArray(this.record.ancestors))return this.rowsToPages(this.record.ancestors);const t=this.embeddedAncestors();if(t.length){const e=t[0],r=e.raw().parent_id;return null==r||""===r||0===r?t:[...await e.fetchAncestors(),...t]}return this.fetchAncestors()}async getSite(){if(this.record.site&&"object"==typeof this.record.site)return new it(this.record.site,this.kernel);const t=this.kernel.snapshot().site;if(t&&(String(t.id)===String(this.record.site_id)||!this.record.site_id))return new it(t,this.kernel);const e=this.record.site_id?String(this.record.site_id):this.kernel.siteRef(),r=F(await this.kernel.request(O().site(e)));return this.kernel.rememberSite(r),new it(r,this.kernel)}async load(){return await this.ensure(["content","options","assets","children"]),this}raw(){return{...this.record}}seoBag(){const t=this.record.seo&&"object"==typeof this.record.seo?this.record.seo:this.kernel.snapshot().seo;return t&&"object"==typeof t?{...t}:{}}galleryList(t){if(Array.isArray(this.record.galleries))return this.record.galleries.flatMap(t=>{const e=B(t);if(!e)return[];const r=t&&"object"==typeof t?String(t.description??""):"";return[{...e,description:r}]});const e=new Map;for(const r of t)for(const t of r.memberships()){const r=(t.uuid||t.name).toLocaleLowerCase();r&&!e.has(r)&&e.set(r,{...t,description:""})}return[...e.values()]}siteRef(){return this.record.site&&"object"==typeof this.record.site?K(this.record.site)||this.kernel.siteRef():this.record.site_id?String(this.record.site_id):this.kernel.siteRef()}rowsToPages(t){return Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new at(t,this.kernel)):[]}embeddedAncestors(){const t=[],e=new Set;let r=this.record.parent;for(;r&&"object"==typeof r&&t.length<12;){const n=r,i=String(n.uuid||n.id||"");if(!i||e.has(i))break;e.add(i),t.unshift(new at(n,this.kernel)),r=n.parent}return t}async fetchAncestors(){const t=[],e=new Set;let r=await this.getParent();for(;r&&t.length<12;){const n=r.getUuid()||String(r.raw().id??"");if(!n||e.has(n))break;e.add(n),t.unshift(r),r=await r.getParent()}return t}excludeSelf(t){const e=V(this.record);return t.filter(t=>V(t)!==e).map(t=>new at(t,this.kernel))}async ensure(t){if(!t.some(t=>void 0===this.record[t]))return;const e=this.getUuid()||this.getSlug()||String(this.record.id||"");if(!e)return;const r=F(await this.kernel.request(O().page(this.siteRef(),e)));this.setRecord({...this.record,...r})}}let ct=null;function ut(){if(!ct)throw new Error("Client is not installed.");return ct}function lt(t,e){return null!=e&&""!==String(e)?String(e):t.siteRef()}function pt(t,e){e?.page&&e.page>0&&t.set("page",String(Math.floor(e.page))),e?.perPage&&e.perPage>0&&t.set("per_page",String(Math.floor(e.perPage)))}function ht(t){if(null==t)return!1;if("string"==typeof t){const e=t.trim();return""!==e&&"{}"!==e&&"[]"!==e}return Array.isArray(t)?t.length>0:"object"!=typeof t||Object.keys(t).length>0}function dt(t){if(t&&"object"==typeof t)return t.options}function gt(t){if("string"==typeof t)return t;if(t&&"object"==typeof t)try{return JSON.stringify(t)}catch{return""}return""}async function ft(t,e){const r=ut(),n=lt(r,e),i=F(await r.request(O().page(n,t)));return r.rememberPage(i),new at(i,r)}class mt{constructor(t,e=null){this.record=t,this.kernel=e}record;kernel;getTitle(){return new k(this.record.title)}getUrl(){return new $(this.record.url)}getChildren(){return wt(this.record.children,this.kernel)}isCurrent(t){const e=this.getUrl().path();if(!e)return!1;if(t)return e===t.getUrl().path();const r=this.kernel??St,n=r?.snapshot().page;return!(!r||!n)&&e===new at(n,r).getUrl().path()}getPage(){const t=this.record.page;if(!t||"object"!=typeof t)return null;const e=this.kernel??St;return e?new at(t,e):null}raw(){return{...this.record}}}class yt{constructor(t,e){this.source=t,this.runtime=e}source;runtime;get record(){return"function"==typeof this.source?this.source():this.source}static async find(t,e){const r=function(){if(!St)throw new Error("Client is not installed.");return St}(),n=null!=e&&""!==String(e)?String(e):r.siteRef(),i=r.snapshot().menus,s=i[t]||Object.values(i).find(e=>!!e&&(String(e.uuid)===t||String(e.id)===t||String(e.name)===t||String(e.position)===t));if(s)return new yt(s,r);const o=F(await r.request(O().menu(n,t)));return r.rememberMenu(o),new yt(o,r)}getName(){return new k(this.record.name)}getPosition(){return String(this.record.position||"")}getItems(){return wt(this.record.items,this.runtime)}raw(){return{...this.record}}}function wt(t,e=null){return Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new mt(t,e)):[]}let St=null;class bt{constructor(t){this.kernel=t}kernel;all(){return function(t,e=function(){return globalThis}()){const r=Array.isArray(t)?t.flatMap(t=>function(t){if(!t||"object"!=typeof t)return[];const e=t,r=$t(String(e.lang??""));return r?[{lang:r,domain:_t(String(e.domain??"")),url:String(e.url??"").trim()}]:[]}(t)):[];return r.length?r.flatMap(t=>{const r=kt(t.url||function(t,e){const r=e[`locale_${t}_baseurl`];return"string"==typeof r?r.trim():""}(t.lang,e)||t.domain);return t.lang&&r?[{lang:t.lang,domain:t.domain||_t(r),url:r}]:[]}):function(t){const e=[];for(const r of Object.keys(t)){const n=/^locale_([a-z]+)_baseurl$/.exec(r);if(!n)continue;const i=kt(String(t[r]??""));i&&e.push({lang:n[1],domain:_t(i),url:i})}return e}(e)}(this.kernel.snapshot().locales)}current(){return $t(String(this.kernel.snapshot().site?.lang||""))}url(t){const e=$t(t),r=this.all().find(t=>t.lang===e);return r?.url??""}}function $t(t){return(t.trim().toLowerCase().replaceAll("_","-").split("-")[0]??"").replace(/[^a-z]/g,"")}function kt(t){const e=t.trim();return e?(/^https?:\/\//i.test(e)?e:`https://${e.replace(/^\/+/,"")}`).replace(/\/+$/,""):""}function _t(t){return t.trim().replace(/^https?:\/\//i,"").replace(/\/.*$/,"")}function xt(t){return`mc_${(String(t??"").trim().split("/").pop()??"").replace(/^@/,"").replace(/[^A-Za-z0-9]+/g,"_").replace(/^_+|_+$/g,"").toUpperCase()}`}function jt(t){if("undefined"==typeof window||""===t)return"";const e=window.__MIRO_WEB_PLUGINS__;if(!Array.isArray(e))return"";for(const r of e){const e=String(r??"").trim().toLowerCase(),n=e.lastIndexOf("/");if(n<=0)continue;const i=e.slice(0,n),s=e.slice(n+1);if(""!==i&&(s===t||At(s)===t))return i}return""}function At(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[^A-Za-z0-9]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function vt(t){if("undefined"==typeof window)return{};const e=window[t];return e&&"object"==typeof e?e:{}}function Pt(){const t=Qt(),e=function(){try{const t=globalThis.__INERTIA_PAGE__;if(t?.props)return t.props}catch{}return function(){if("undefined"==typeof document)return null;const t=document.querySelector("[data-page]")?.getAttribute("data-page");if(!t)return null;try{return JSON.parse(t).props??null}catch{return null}}()}();return e&&t.hydrate(e),t}function Ct(){const t=Pt();return Mt(t),new at(()=>t.snapshot().page??{},t)}function Ot(){const t=Pt();return Mt(t),new it(()=>t.snapshot().site??{},t)}function Mt(e){try{const r=function(){try{return Tt??null}catch{return null}}();if(!r)return;const n=r.usePage();e.hydrate(t.unref(n))}catch{}}let Tt=null;function Rt(t){return[...new Set(t)]}function Ut(t,e){const r=new Set(t),n=Rt(e).filter(t=>r.has(t));return Rt(t).forEach((t,e,r)=>{n.includes(t)||n.splice(0===e?0:n.indexOf(r[e-1])+1,0,t)}),n}function It(t,e,r){const n=e.filter(e=>r.includes(e)&&t.includes(e)),i=t.filter(t=>!n.includes(t));return n.forEach(t=>{i.splice(Math.min(e.indexOf(t),i.length),0,t)}),i}function Nt(t,e){const r=t?.options,n=Array.isArray(r)?r.find(t=>t?.key===e)?.value:r?.[e];if("string"!=typeof n)return n;try{return JSON.parse(n)}catch{return}}function Wt(){if("undefined"==typeof window)return null;const t=window;return t.__miroOrder??=new Map,t.__miroOrder}import("@inertiajs/vue3").then(t=>{Tt=t}).catch(()=>{Tt=null});const Et=new Set;function Lt(t){Et.has(t)||Et.add(t)}function Bt(e,r,n){const i=e.filter(e=>e.type!==t.Comment);if(0===i.length)return e;const[s]=i;return i.length>1?(Lt(`Slot „${n}” ma kilka korzeni, więc nie da się go przeciągnąć.`),e):s.type===t.Fragment?Array.isArray(s.children)?e.map(e=>e===s?t.h(t.Fragment,{key:s.key??void 0},Bt(s.children,r,n)):e):e:e.map(e=>e===s?t.cloneVNode(s,r):e)}const qt=t.defineComponent({name:"MiroOrder",inheritAttrs:!1,props:{name:String,source:[String,Array],items:Array,at:Function,scope:{type:String,default:"page"},locked:{type:Array,default:()=>[]}},setup(e,{slots:r}){const n=Ct(),i=Ot(),s=!0===Qt().snapshot().editing,o=()=>"site"===e.scope?i.raw():n.raw(),a=t.shallowRef(null),c=()=>Object.keys(r).filter(t=>"default"!==t&&"$stable"!==t&&!t.startsWith("_")),u=(t,r)=>String(e.at?e.at(t,r):r),l=()=>void 0!==e.items?(()=>{const t=(e.items??[]).map(u);return a.value?Ut(t,a.value):Ut(t,t)})():(()=>{const t=c();return It(Ut(t,a.value??(e.name?function(t,e){const r=Nt(t,"miro_order"),n=r&&"object"==typeof r?r[e]:null;return Array.isArray(n)?n.filter(t=>"string"==typeof t):[]}(o(),e.name):[])),t,e.locked)})(),p=(()=>{const t=o()?.id;if(!s||null==t)return null;const r="site"===e.scope?{site:t}:{page:t};if(void 0===e.items)return e.name?{kind:"site"===e.scope?"site_blocks":"page_blocks",...r,name:e.name}:null;const n=e.source?function(t){const e=Array.isArray(t)?t:t.split(".").map(t=>/^\d+$/.test(t)?Number(t):t),[r,...n]=e;return"string"==typeof r&&""!==r?{key:r,path:n}:null}(e.source):null;if(!n)return null;const i=function(t,e,r){let n=Nt(t,e);for(const i of r){if(!n||"object"!=typeof n)return null;n=n[i]}return Array.isArray(n)?n:null}(o(),n.key,n.path);return!i||!e.at&&i.length!==e.items.length?(Lt(`Lista „${n.key}” różni się od zapisanej. Podaj :at z indeksem w surowej tablicy.`),null):{kind:"site"===e.scope?"site_option":"page_option",...r,key:n.key,path:n.path}})(),h=p?function(t){return"page_blocks"===t.kind||"site_blocks"===t.kind?`${t.kind}:${"page"in t?t.page:t.site}:${t.name}`:`${t.kind}:${"page"in t?t.page:t.site}:${t.key}:${t.path.join(".")}`}(p):"";if(p){const r={id:h,target:p,keys:l,locked:()=>void 0===e.items?e.locked:[],plan:t=>void 0!==e.items?t:It(function(t,e){const r=new Set(e);let n=0;return t.map(t=>r.has(t)?e[n++]:t)}(l(),t),c(),e.locked),apply:t=>{a.value=t}};t.onMounted(()=>Wt()?.set(h,r)),t.onBeforeUnmount(()=>{const t=Wt();t?.get(h)===r&&t.delete(h)})}return()=>{const n=l(),i=void 0!==e.items,s=new Map;i&&e.items.forEach((t,e)=>s.set(u(t,e),t));const o=n.map((o,a)=>{const c={key:o,index:a,first:0===a,last:a===n.length-1},u=i?r.default:r[o],l=u?.(i?{...c,item:s.get(o)}:c)??[],d=p?Bt(l,{"data-miro-order-group":h,"data-miro-order-key":o},i?`${e.source}[${o}]`:o):l;return t.h(t.Fragment,{key:o},d)});return t.h(t.Fragment,null,o)}}}),Gt=/[⁢⁤][​‌‍⁠]+⁣/,zt={b:"strong",i:"em",u:"u",s:"s"};function Ft(e){switch(e.type){case"text":return e.value;case"br":return t.h("br");case"c":return t.h("span",{style:{color:`var(--color-${e.value})`}},Dt(e.children));case"f":return t.h("span",{style:{fontFamily:`var(--font-${e.value})`}},Dt(e.children));default:return t.h(zt[e.type],Dt(e.children))}}function Dt(t){return t.map(Ft)}const Jt=e=>{const r=t.toDisplayString(e.value),n=Gt.test(r);if(!n&&!function(t){return t.includes("[")||t.includes("\n")}(r))return r;const i=Dt(o(r));return n?t.h("span",{"data-miro-rich":"",style:{display:"contents"}},i):1===i.length?i[0]:i};Jt.props=["value"],Jt.displayName="MiroText";class Ht{snap={page:null,site:null,menus:{},locales:[],seo:null,options:{},editing:!1};options;inflight=new Map;cache=new Map;constructor(t={}){this.options=t,t.page&&this.hydrate(t.page),ct=this,st=this,St=this}hydrate(t){return this.snap=D(this.snap,function(t){const e={page:null,site:null,menus:{},locales:[],seo:null,options:{},editing:!1};if(!t||"object"!=typeof t)return e;const r=t,n=J(r.props)?r.props:r;e.page=H(n.page),e.site=H(n.site),e.seo=J(n.seo)?n.seo:null,e.options=J(n.options)?n.options:{},e.locales=Array.isArray(n.locales)?n.locales:[],e.editing=void 0!==n.miroEdit&&null!==n.miroEdit;const i=n.menus;if(J(i))for(const[s,o]of Object.entries(i))e.menus[s]=H(o);return e}(t)),this.snap}snapshot(){return this.snap}apiBase(){return function(t){if(t)return String(t).replace(/\/+$/,"");const e=z();return e.apiBase?String(e.apiBase).replace(/\/+$/,""):function(){if("undefined"==typeof location)return"";const t=String(location.origin||"").replace(/\/+$/,"");if(t&&"null"!==t)return t;const e=location.hostname||"";return e?`${location.protocol}//${e}`:""}()}(this.options.apiBase)}siteBase(){return function(t){if(t)return String(t).replace(/\/+$/,"");const e=z();return e.siteBase?String(e.siteBase).replace(/\/+$/,""):"undefined"!=typeof location?location.origin:""}(this.options.siteBase)}siteRef(){return null!=this.options.site&&""!==String(this.options.site)?String(this.options.site):K(this.snap.site)}async request(t,e={}){const r=String(e.method||"GET").toUpperCase(),n=`${r} ${t}`;if("GET"===r&&this.cache.has(n))return this.cache.get(n);if("GET"===r){const t=this.inflight.get(n);if(t)return t}const i=this.apiBase();if(!i)throw new Error("Remote origin is not configured.");const s=async function(t,e,r={}){const{fetchImpl:n,...i}=r,s=e.startsWith("http")?e:C(t,e),o=n??fetch,a=new Headers(i.headers);a.has("Accept")||a.set("Accept","application/json");const c=await o(s,{...i,headers:a}),u=await c.text();let l=null;if(u)try{l=JSON.parse(u)}catch{l={message:u}}if(!c.ok){const t=new Error(`Request failed (${c.status})`);throw t.status=c.status,t.body=l,t}return l}(i,t,{...e,fetchImpl:this.options.fetch}).then(t=>("GET"===r&&this.cache.set(n,t),t));return"GET"===r&&(this.inflight.set(n,s),s.finally(()=>{this.inflight.delete(n)}).catch(()=>{})),s}rememberPage(t){const e=this.snap.page;e&&String(e.id)===String(t.id)&&(this.snap=D(this.snap,{page:{...e,...t}}))}rememberSite(t){this.snap=D(this.snap,{site:{...this.snap.site??{},...t}})}rememberMenu(t){const e=String(t.position||t.uuid||t.id||t.name||"menu");this.snap=D(this.snap,{menus:{[e]:t}})}}let Vt=null;function Kt(t={}){return Vt=new Ht(t),Vt}function Zt(){return Vt||(Vt=new Ht),Vt}const Yt=Symbol.for("miro.client");function Qt(){return t.inject(Yt,null)??Zt()}function Xt(t={}){return{install(e,r={}){const n=Kt({...t,...r});e.provide(Yt,n),e.component("MiroText",Jt),e.component("MiroOrder",qt),function(t){import("@inertiajs/vue3").then(e=>{const r=e.router;r?.page&&t.hydrate(r.page),r?.on?.("success",e=>{const r=e?.detail?.page;r&&t.hydrate(r)}),r?.on?.("navigate",e=>{const r=e?.detail?.page;r&&t.hydrate(r)})}).catch(()=>{})}(n)}}}const te=Xt(),ee=te;exports.Asset=E,exports.AssetName=_,exports.CollectionCard=Y,exports.Gallery=L,exports.Locales=bt,exports.Menu=yt,exports.MenuItem=mt,exports.MenuTitle=k,exports.Miro=te,exports.MiroOrder=qt,exports.MiroText=Jt,exports.OptionValue=b,exports.Page=at,exports.PageContent=y,exports.PageSmallTitle=f,exports.PageSubtitle=g,exports.PageSummary=m,exports.PageTitle=d,exports.RICH_COLORS=e,exports.RICH_FONTS=r,exports.SDK_KEY=Yt,exports.SeoDescription=j,exports.SeoTitle=x,exports.Site=it,exports.SiteName=S,exports.SiteTitle=w,exports.TextValue=h,exports.UrlValue=$,exports.createMiro=Xt,exports.createRuntime=Kt,exports.default=ee,exports.getRuntime=Zt,exports.parseRichText=o,exports.plainText=c,exports.pluginWindowKey=xt,exports.useKernel=Qt,exports.useMiroAssets=function(){return Ct().getAssets()},exports.useMiroConfig=function(){const e=Qt();return{apiBase:t.computed(()=>e.apiBase()),siteBase:t.computed(()=>e.siteBase()),siteRef:t.computed(()=>e.siteRef())}},exports.useMiroLocales=function(){const t=Pt();return Mt(t),new bt(t)},exports.useMiroMenu=function(t="topbar"){const e=Pt();return Mt(e),new yt(()=>e.snapshot().menus[t]??{position:t,items:[]},e)},exports.useMiroPage=Ct,exports.useMiroSite=Ot,exports.usePlugin=function(t){return function(t,e){const r=xt(t),n=function(t){const e=String(t??"").trim();if(e.includes("/")){const[t,...r]=e.split("/");return{vendor:t||"miroart",slug:At(r.join("/")||e)}}const r=At(e);return{vendor:jt(r)||"miroart",slug:r}}(t);return new Proxy({name:t,key:r,ready:async()=>async function(t){const e=Date.now();for(;Date.now()-e<4e3;){const e=vt(t);if(Object.keys(e).length)return e;await new Promise(t=>setTimeout(t,50))}return vt(t)}(r),api:()=>vt(r),call:(t,...e)=>{const n=vt(r),i=n[t];if("function"!=typeof i)throw new Error(`Missing plugin method: ${t}`);return i.apply(n,e)},request:async(t="/",r={})=>{const i=O().plugins(n.vendor,n.slug,t||"/"),s=new Headers(r.headers);let o=r.body;return void 0!==r.json&&(o=JSON.stringify(r.json)),F(await e.request(i,{...r,headers:s,body:o}))}},{get(t,e,n){if(e in t)return Reflect.get(t,e,n);if("then"===e||e===Symbol.toStringTag)return;const i=vt(r),s=i[String(e)];return"function"==typeof s?s.bind(i):s},has:(t,e)=>e in t||e in vt(r)})}(t,Qt())};
package/dist/index.d.ts CHANGED
@@ -11,8 +11,11 @@ import { createRuntime, getRuntime } from "./runtime";
11
11
  import { useMiroAssets, useMiroConfig, useMiroLocales, useMiroMenu, useMiroPage, useMiroSite, usePlugin } from "./composables";
12
12
  import { AssetName, MenuTitle, OptionValue, PageContent, PageSmallTitle, PageSubtitle, PageSummary, PageTitle, SeoDescription, SeoTitle, SiteName, SiteTitle, TextValue, UrlValue } from "./values";
13
13
  import { pluginWindowKey } from "./plugin";
14
+ import { MiroOrder } from "./MiroOrder";
15
+ import { MiroText } from "./MiroText";
16
+ import { parseRichText, plainText, RICH_COLORS, RICH_FONTS, type RichColor, type RichFont, type RichNode } from "./richText";
14
17
  import type { ActionCall, ClientOptions } from "./types";
15
- export { Asset, AssetName, CollectionCard, createMiro, createRuntime, Gallery, getRuntime, Locales, Menu, MenuItem, MenuTitle, Miro, OptionValue, Page, PageContent, PageSmallTitle, PageSubtitle, PageSummary, PageTitle, pluginWindowKey, SDK_KEY, SeoDescription, SeoTitle, Site, SiteName, SiteTitle, TextValue, UrlValue, useKernel, useMiroAssets, useMiroConfig, useMiroLocales, useMiroMenu, useMiroPage, useMiroSite, usePlugin, };
16
- export type { ActionCall, ClientOptions, GalleryMembership, LocaleLink, PageGallery, PageListMeta, PageListQuery, PagedPages, SeoView, };
18
+ export { Asset, AssetName, MiroOrder, MiroText, parseRichText, plainText, RICH_COLORS, RICH_FONTS, CollectionCard, createMiro, createRuntime, Gallery, getRuntime, Locales, Menu, MenuItem, MenuTitle, Miro, OptionValue, Page, PageContent, PageSmallTitle, PageSubtitle, PageSummary, PageTitle, pluginWindowKey, SDK_KEY, SeoDescription, SeoTitle, Site, SiteName, SiteTitle, TextValue, UrlValue, useKernel, useMiroAssets, useMiroConfig, useMiroLocales, useMiroMenu, useMiroPage, useMiroSite, usePlugin, };
19
+ export type { ActionCall, ClientOptions, GalleryMembership, LocaleLink, PageGallery, PageListMeta, PageListQuery, PagedPages, RichColor, RichFont, RichNode, SeoView, };
17
20
  declare const plugin: Plugin;
18
21
  export default plugin;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{inject as t,computed as e,unref as r}from"vue";function n(t,e){return{page:void 0!==e.page?e.page:t.page,site:void 0!==e.site?e.site:t.site,menus:e.menus?{...t.menus,...e.menus}:{...t.menus},locales:e.locales??t.locales,seo:void 0!==e.seo?e.seo:t.seo,options:e.options?{...t.options,...e.options}:{...t.options}}}function i(t){return Boolean(t)&&"object"==typeof t&&!Array.isArray(t)}function s(t){return i(t)?t:null}function o(t){return t?String(t.uuid||t.ulid||t.id||t.slug||t.full_url||""):""}function a(t){return t?String(t.uuid||t.domain||t.id||""):""}function c(t){return String.fromCharCode(...t.map(t=>23^t))}function u(t,e){const r=String(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return r?`${r}${n}`:n}function l(){const t=c([56,118,103,126]),e=c([97,38]),r=c([100,126,99,114,100]),n=c([103,118,112,114,100]),i=c([100,114,118,101,116,127]),s=c([122,114,121,98,100]),o=c([122,114,115,126,118]),a=c([103,123,98,112,126,121,100]),l=c([118,116,99,126,120,121,100]);return{sites:()=>u("",`${t}/${e}/${r}`),site:n=>u("",`${t}/${e}/${r}/${encodeURIComponent(n)}`),pages:i=>u("",`${t}/${e}/${r}/${encodeURIComponent(i)}/${n}`),page:(i,s)=>u("",`${t}/${e}/${r}/${encodeURIComponent(i)}/${n}/${s.split("/").map(t=>encodeURIComponent(t)).join("/")}`),search:s=>u("",`${t}/${e}/${r}/${encodeURIComponent(s)}/${n}/${i}`),menus:n=>u("",`${t}/${e}/${r}/${encodeURIComponent(n)}/${s}`),menu:(n,i)=>u("",`${t}/${e}/${r}/${encodeURIComponent(n)}/${s}/${encodeURIComponent(i)}`),media:e=>u("",`${t}/${o}/${encodeURIComponent(e)}`),action:e=>u("",`${t}/${l}/${encodeURIComponent(e)}`),plugins:(e,r,n="")=>{const i=`${t}/${a}/${encodeURIComponent(e)}/${encodeURIComponent(r)}`;return n&&"/"!==n?`${i}${n.startsWith("/")?n:`/${n}`}`:i}}}function h(){if("undefined"==typeof globalThis)return{};const t=globalThis.MiroConfig;return t&&"object"==typeof t?t:{}}function p(t){return t&&"object"==typeof t&&"data"in t?t.data:t}function d(t){return null==t?"":"string"==typeof t?t:"number"==typeof t||"boolean"==typeof t?String(t):""}function g(t){const e=d(t);if(!e)return"";if("undefined"!=typeof document){const t=document.createElement("textarea");return t.innerHTML=e,t.value}return e.replace(/&#(\d+);/g,(t,e)=>String.fromCharCode(Number(e))).replace(/&#x([0-9a-f]+);/gi,(t,e)=>String.fromCharCode(parseInt(e,16))).replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">")}function f(t){return g(t).replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi," ").replace(/<style[\s\S]*?>[\s\S]*?<\/style>/gi," ").replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim()}class m extends String{kind;extra;constructor(t,e,r={}){super(g(e)),this.kind=t,this.extra=r,Object.setPrototypeOf(this,new.target.prototype)}toString(){return String.prototype.toString.call(this)}valueOf(){return String.prototype.valueOf.call(this)}raw(){return this.toString()}decode(){return g(this.toString())}cleanContent(){return f(this.toString())}stripHtml(){return this.cleanContent()}excerpt(t=160){const e=this.cleanContent();return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}firstParagraph(){return function(t){const e=g(t),r=e.match(/<p\b[^>]*>([\s\S]*?)<\/p>/i);return f(r?r[1]:e)}(this.toString())}isEmpty(){return""===this.cleanContent()}json(){const t=this.toString().trim();if(!t)return null;try{return JSON.parse(t)}catch{return null}}bool(){const t=this.toString().trim().toLowerCase();return"1"===t||"true"===t||"yes"===t||"on"===t}number(){const t=Number(this.toString().trim());return Number.isFinite(t)?t:null}}class y extends m{constructor(t){super("PageTitle",t)}}class w extends m{constructor(t){super("PageSubtitle",t)}}class S extends m{constructor(t){super("PageSmallTitle",t)}}class b extends m{constructor(t){super("PageSummary",t)}}class $ extends m{constructor(t){super("PageContent",t)}html(){return this.toString()}}class _ extends m{constructor(t){super("SiteTitle",t)}}class k extends m{constructor(t){super("SiteName",t)}}class j extends m{key;structured;constructor(t,e){const r=R(e);super("OptionValue",r.text,{key:t}),this.key=t,this.structured=r.structured}json(){return void 0!==this.structured?this.structured:super.json()}present(){return!this.isEmpty()}}class A extends m{constructor(t){super("UrlValue",t)}path(){const t=this.toString().trim();if(!t)return"/";try{if(/^https?:\/\//i.test(t))return new URL(t).pathname.replace(/\/+$/,"")||"/"}catch{}return(t.startsWith("/")?t:`/${t}`).replace(/\/+$/,"")||"/"}href(t=""){const e=this.path();return!t||/^https?:\/\//i.test(e)?e:`${String(t).replace(/\/+$/,"")}${e}`}}class P extends m{constructor(t){super("MenuTitle",t)}}class C extends m{constructor(t){super("AssetName",t)}}class x extends m{constructor(t){super("SeoTitle",t)}}class v extends m{constructor(t){super("SeoDescription",t)}}function R(t){if(null==t)return{text:""};if("boolean"==typeof t||"number"==typeof t)return{text:String(t)};if("string"==typeof t){const e=t.trim();if(""===e||"[]"===e||"{}"===e)return{text:""};if(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]")||e.startsWith('"')&&e.endsWith('"'))try{return R(JSON.parse(e))}catch{return{text:g(t)}}return{text:g(t)}}return Array.isArray(t)?{text:JSON.stringify(t),structured:t}:"object"==typeof t?function(t){return"value"in t&&Object.keys(t).every(t=>"value"===t||"key"===t||"id"===t||"active"===t)}(t)?R(t.value):{text:JSON.stringify(t),structured:t}:{text:d(t)}}function U(t,e){if(!t)return"";if(Array.isArray(t)){const r=t.find(t=>t&&"object"==typeof t&&t.key===e);return r&&"object"==typeof r?r.value:""}return"object"==typeof t?t[e]:""}function T(t){if("string"==typeof t){const e=t.trim();return e?O(e)?{uuid:e}:{url:e,path:e}:null}if(!t||"object"!=typeof t||Array.isArray(t))return null;const e=t,r=M(e.source),n=I(e.url,e.preview_url,e.path,e.src,r?.url,r?.preview_url,r?.path),i=I(e.uuid,r?.uuid);if(n||i&&O(i))return e;const s=I(e.value);return s?T(s):null}function I(...t){for(const e of t)if("string"==typeof e&&""!==e.trim())return e.trim();return""}function W(t){return"string"==typeof t?t.trim():""}function M(t){return!t||"object"!=typeof t||Array.isArray(t)?null:t}function N(t){return t.startsWith("/media/")||t.startsWith("/_images/")||t.startsWith("/api/media/")||t.startsWith("/branding-assets/")||t.startsWith("/storage/")}function O(t){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)}const B=[{mark:"1_8",width:256},{mark:"1_4",width:512},{mark:"1_2",width:1024},{mark:"2_3",width:1400}];class L{constructor(t,e){this.record=t,this.runtime=e}record;runtime;getUuid(){return String(this.record.uuid||this.record.id||"")}getName(){return new C(this.record.name)}getAlt(){return W(this.record.alt)}getCaption(){return W(this.record.caption)}getGallery(){return this.memberships()[0]??null}galleryUuid(){return this.memberships()[0]?.uuid??""}galleryName(){return this.memberships()[0]?.name??""}memberships(){const t=this.record.galleries;if(Array.isArray(t)&&t.length>0)return t.map(t=>E(t)).filter(t=>null!==t);const e=String(this.record.gallery_uuid??"").trim(),r=String(this.record.gallery_name??"").trim();if(!e&&!r)return[];const n=this.record.gallery_id;return[{id:"number"==typeof n||"string"==typeof n?n:null,uuid:e,name:r,sort_order:G(this.record.gallery_sort_order)}]}getMime(){const t=M(this.record.source);return String(this.record.mime_type||t?.mime_type||"")}getSize(){const t=M(this.record.source),e=Number(this.record.size??t?.size??0);return Number.isFinite(e)?e:0}getType(){const t=W(this.record.type);if(t)return t;const e=this.getMime();return e.startsWith("image/")?"image":e.startsWith("video/")?"video":"application/pdf"===e?"pdf":""}getSortOrder(){const t=Number(this.record.sort_order??0);return Number.isFinite(t)?t:0}isImage(){return!!this.getMime().startsWith("image/")||/\.(jpe?g|png|gif|webp|svg)(\?|$)/i.test(this.urlString())}url(){return new A(this.urlString())}srcset(){const t=this.urlString();if(!t||/\.svg([?#]|$)/i.test(t)||/^https?:\/\//i.test(t)||t.startsWith("//"))return"";if(!/\.webp([?#]|$)/i.test(t)||/\.(?:1_16|1_8|1_4|1_2|2_3)\.webp([?#]|$)/i.test(t))return"";const e=B.map(({mark:e,width:r})=>`${t.replace(/\.webp([?#].*)?$/i,`.${e}.webp$1`)} ${r}w`);return e.push(`${t} 2048w`),e.join(", ")}raw(){return{...this.record}}urlString(){const t=M(this.record.source),e=I(this.record.uuid,t?.uuid),r=I(this.record.disk,t?.disk);let n=I(this.record.url,this.record.preview_url,this.record.path,this.record.src,t?.url,t?.preview_url,t?.path);if(e&&O(e)&&n&&function(t,e){return!!(/\/project-storage\//i.test(r=t)||/\/editor\/project-file/i.test(r)||/cms\.miroart\.pl/i.test(r)&&/\/(?:project-storage|storage)\//i.test(r))||"project_public"===e&&!N(t)&&!/^https?:\/\//i.test(t)&&!t.startsWith("//");var r}(n,r))return this.mediaUrl(e);if(!n)return e&&O(e)?this.mediaUrl(e):"";if(!0===globalThis.isSsg){if(n.startsWith("/_images/")||n.startsWith("_images/"))return n.startsWith("/")?n:`/${n}`;const e=function(t){const e=t.match(/[?&]path=([^&]+)/i);if(e)try{const t=decodeURIComponent(e[1].replace(/\+/g," ")).split(/[/\\]/).pop()||"";if(t&&"project-file"!==t.toLowerCase())return t.trim()}catch{}return(t.split("#")[0].split("?")[0].split(/[/\\]/).pop()||"").trim()}(I(t?.path,this.record.path,n)),r=/\.(jpe?g|png|gif|webp|svg)$/i.test(i=e)?/\.svg$/i.test(i)?`/_images/${i}`:`/_images/${i.replace(/\.(jpe?g|png|gif|webp)$/i,".webp")}`:null;if(r)return r}var i;if(/^https?:\/\//i.test(n)||n.startsWith("//"))return n;if(n.startsWith("_images/"))return`/${n}`;if(N(n))return n;n.includes("/")||n.includes("\\")||O(n)||(n=`images/${n}`);const s=n.startsWith("/")?n:`/${n}`;return N(s)||s.startsWith("/project-storage/")?s:`/storage${s}`}mediaUrl(t){const e=l().media(t),r=this.runtime.apiBase();return r?u(r,e):e}}class q{constructor(t){this.items=t}items;all(){return this.items.slice()}first(){return this.items[0]??null}extra(){return this.items.slice(1)}hero(){return this.first()}urls(){return this.items.map(t=>t.url())}isEmpty(){return 0===this.items.length}count(){return this.items.length}[Symbol.iterator](){return this.items[Symbol.iterator]()}}function E(t){if(!t||"object"!=typeof t)return null;const e=t,r=String(e.uuid??"").trim(),n=String(e.name??"").trim();if(!r&&!n)return null;const i=e.id;return{id:"number"==typeof i||"string"==typeof i?i:null,uuid:r,name:n,sort_order:G(e.sort_order)}}function G(t){const e=Number(t??0);return Number.isFinite(e)?e:0}function J(t,e){return Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new L(t,e)):[]}const z=/* @__PURE__ */new Set(["id","uuid","created_at","updated_at"]);class D{constructor(t,e){this.row=t,this.kernel=e}row;kernel;getHref(){return new A(this.row.href)}getTitle(){return String(this.row.title??"")}item(){const t=this.row.item;return t&&"object"==typeof t?t:{}}image(){return F(this.item(),this.kernel)}}function F(t,e){if(!t||"object"!=typeof t)return null;for(const[r,n]of Object.entries(t)){if(z.has(r)||"string"!=typeof n||!H(n))continue;const t=T(n);if(t)return new L(t,e)}return null}function H(t){const e=t.trim();return!!e&&(!!(e.startsWith("/media/")||e.startsWith("/_images/")||e.startsWith("_images/")||e.startsWith("/api/media/")||e.startsWith("/branding-assets/"))||/\.(jpe?g|png|gif|webp|svg)(\?|#|$)/i.test(e))}function Z(t,e){const r=t&&"object"==typeof t?t.meta:null,n=r&&"object"==typeof r?r:{};return{currentPage:K(n.current_page,1),lastPage:K(n.last_page,1),perPage:K(n.per_page,Math.max(e,1)),total:Q(n.total,e)}}function V(t,e){return Object.assign(t,{meta:e})}function K(t,e){const r=Number(t);return!Number.isFinite(r)||r<1?e:Math.floor(r)}function Q(t,e){if(null==t||""===t)return e;const r=Number(t);return!Number.isFinite(r)||r<0?e:Math.floor(r)}class X{constructor(t,e){this.source=t,this.kernel=e}source;kernel;get record(){return"function"==typeof this.source?this.source():this.source}static async all(){const t=tt(),e=await t.request(l().sites());return(Array.isArray(e?.data)?e.data:[]).filter(t=>Boolean(t)&&"object"==typeof t).map(e=>new X(e,t))}static async find(t){const e=tt(),r=null!=t&&""!==String(t)?String(t):e.siteRef(),n=e.snapshot().site;if(n&&(!t||String(n.uuid)===String(t)||String(n.id)===String(t)||String(n.domain)===String(t)||a(n)===String(t)))return new X(n,e);const i=p(await e.request(l().site(r)));return e.rememberSite(i),new X(i,e)}static async findPage(t,e){return et.find(t,e)}static async findMenu(t,e){return ht.find(t,e)}getName(){return new k(this.record.name)}getTitle(){const t=U(this.record.options,"seo_title")||U(this.record.options,"title");return new _(t||this.record.name)}getDomain(){return String(this.record.domain||"")}getLang(){return String(this.record.lang||"")}getUuid(){return String(this.record.uuid||"")}getOption(t){return new j(t,U(this.record.options,t))}getImage(t){const e=this.getOption(t),r=e.json(),n=null==r?e.toString().trim():r;if(null==n||""===n)return null;const i=T(n);return i?new L(i,this.kernel):null}async findPage(t){return et.find(t,this.ref())}async findMenu(t){return ht.find(t,this.ref())}async menus(){const t=this.kernel.snapshot().menus,e=Object.values(t).filter(Boolean);return e.length?e.map(t=>new ht(t,this.kernel)):((await this.kernel.request(l().menus(this.ref()))).data??[]).map(t=>(this.kernel.rememberMenu(t),new ht(t,this.kernel)))}async pages(t={}){const e=new URLSearchParams,r={...t};null!=r.perPage&&null==r.per_page&&(r.per_page=r.perPage,delete r.perPage);for(const[o,a]of Object.entries(r))e.set(o,String(a));const n=e.toString()?`?${e.toString()}`:"",i=await this.kernel.request(`${l().pages(this.ref())}${n}`),s=(i.data??[]).map(t=>(this.kernel.rememberPage(t),new et(t,this.kernel)));return V(s,Z(i,s.length))}async runAction(t){const e=String(t.uuid||"").trim();if(!e)throw new Error("Action uuid is required.");const r=String(this.record.domain||this.ref());return this.kernel.request(l().action(r),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({uuid:e,method:t.method||"GET",path:t.path||"",query:t.query||{},body:t.body||"",headers:t.headers||{},params:t.params||{},post:t.post||{}})})}raw(){return{...this.record}}ref(){return String(this.record.uuid||this.record.domain||this.record.id||this.kernel.siteRef())}}let Y=null;function tt(){if(!Y)throw new Error("Client is not installed.");return Y}class et{constructor(t,e){this.source=t,this.kernel=e}source;kernel;get record(){return"function"==typeof this.source?this.source():this.source}setRecord(t){"function"!=typeof this.source?this.source=t:this.kernel.rememberPage(t)}static async findByUlid(t,e){return ut(t,e)}static async find(t,e){return ut(t,e)}static async search(t,e,r){const n=nt(),i=it(n,e),s=new URLSearchParams;s.set("q",t),st(s,r);const o=await n.request(`${l().search(i)}?${s.toString()}`),a=(Array.isArray(o?.data)?o.data:Array.isArray(o)?o:[]).map(t=>(n.rememberPage(t),new et(t,n)));return V(a,Z(o,a.length))}getTitle(){return new y(this.record.title)}getSubtitle(){return new w(this.record.subtitle)}getSmallTitle(){return new S(this.record.smalltitle)}getSummary(){return new b(this.record.summary)}getContent(){return new $(this.record.content)}getSlug(){return String(this.record.slug||"")}getUrl(){return new A(this.record.full_url||(this.record.slug?`/${this.record.slug}`:"/"))}getUuid(){return String(this.record.uuid||this.record.ulid||"")}getId(){return String(this.record.id||this.getUuid())}getLayout(){return String(this.record.layout||"")}getDisplay(){return String(this.record.display||"")}getDisplayInMenu(){const t=this.record.display_in_menu;return null==t||""===t||!1!==t&&0!==t&&"0"!==t}getSortOrder(){const t=Number(this.record.sort_order??0);return Number.isFinite(t)?t:0}getLang(){const t=String(this.record.lang||"").trim();if(t)return t;const e=this.kernel.snapshot().site;return String(e?.lang||function(t){return t&&"object"==typeof t?String(t.lang||""):""}(this.record.site)||"")}getOption(t){const e=[U(this.record.options,t),this.kernel.snapshot().options[t],U(this.kernel.snapshot().site?.options,t),U(at(this.record.site),t)];for(const r of e)if(ot(r))return new j(t,r);return new j(t,"")}getSeo(){const t=this.seoBag(),e=t=>null==t?"":String(t),r=t=>{const e=T(t);return e?new L(e,this.kernel):null};return{title:new x(t.title??this.record.title),description:new v(t.description??this.record.summary),keywords:e(t.keywords),robots:e(t.robots),canonical:new A(t.canonical),ogTitle:e(t.og_title??t.title??this.record.title),ogDescription:e(t.og_description??t.description??this.record.summary),ogImage:r(t.og_image),ogType:e(t.og_type),ogUrl:new A(t.og_url||t.canonical),twitterCard:e(t.twitter_card),twitterTitle:e(t.twitter_title??t.og_title??t.title),twitterDescription:e(t.twitter_description??t.og_description??t.description),twitterImage:r(t.twitter_image||t.og_image),ldJson:ct(t.ld_json),raw:{...t}}}get collectionItem(){const t=this.record.collectionItem;return t&&"object"==typeof t?t:{}}get collectionItems(){const t=this.record.collectionItems;return t&&"object"==typeof t?t:{}}get collectionGallery(){return t=this.record.collectionGallery,e=this.kernel,Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new D(t,e)):[];var t,e}collectionImage(){return F(this.collectionItem,this.kernel)}getAssets(){return new q(J(this.record.assets,this.kernel))}getGallery(t){const e=t.trim();if(!e)return new q([]);const r=[];return J(this.record.assets,this.kernel).forEach((t,n)=>{const i=t.memberships().find(t=>function(t,e){const r=e.trim().toLocaleLowerCase();return!!r&&(t.uuid.toLocaleLowerCase()===r||t.name.toLocaleLowerCase()===r)}(t,e));i&&r.push({asset:t,sort:i.sort_order,index:n})}),r.sort((t,e)=>t.sort-e.sort||t.index-e.index),new q(r.map(t=>t.asset))}getGalleries(){const t=J(this.record.assets,this.kernel);return this.galleryList(t).map(t=>({id:t.id,uuid:t.uuid,name:t.name,description:t.description,sort_order:t.sort_order,assets:this.getGallery(t.uuid||t.name)}))}async getChildren(t){const e=function(t){if(!Array.isArray(t))return[];const e=/* @__PURE__ */new Set(["options","assets"]),r=[];for(const n of t){const t=String(n).trim().toLowerCase();e.has(t)&&!r.includes(t)&&r.push(t)}return r}(t?.with),r=Array.isArray(this.record.children)?this.record.children:null;if(r&&function(t,e){return!e.length||t.every(t=>{if(!t||"object"!=typeof t)return!1;const r=t;if(e.includes("options")){const t=r.options;if(null==t||"object"!=typeof t)return!1}return!(e.includes("assets")&&!Array.isArray(r.assets))})}(r,e)){const e=function(t,e,r){const n=t.length;if(!e&&!r)return{items:t,meta:{currentPage:1,lastPage:1,perPage:Math.max(n,1),total:n}};const i=r&&r>0?Math.floor(r):Math.max(n,1),s=e&&e>0?Math.floor(e):1,o=Math.max(1,Math.ceil(n/i)),a=(s-1)*i;return{items:t.slice(a,a+i),meta:{currentPage:s,lastPage:o,perPage:i,total:n}}}(this.rowsToPages(r),t?.page,t?.perPage);return V(e.items,e.meta)}const n=this.getUuid()||String(this.record.id??"");if(!n){const t=r?this.rowsToPages(r):[];return V(t,Z(null,t.length))}const i=new URLSearchParams;i.set("parent",n),e.length&&i.set("with",e.join(",")),st(i,t);const s=await this.kernel.request(`${l().pages(this.siteRef())}?${i.toString()}`);return V(this.rowsToPages(s.data??[]),Z(s,(s.data??[]).length))}async getSiblings(){if(Array.isArray(this.record.siblings))return this.record.siblings.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new et(t,this.kernel));const t=this.record.parent_id,e=this.siteRef();if(null==t||""===t){const t=await this.kernel.request(`${l().pages(e)}?parent=root`);return this.excludeSelf(t.data??[])}const r=await this.kernel.request(`${l().pages(e)}?parent=${encodeURIComponent(String(t))}`);return this.excludeSelf(r.data??[])}async getParent(){if(this.record.parent&&"object"==typeof this.record.parent)return new et(this.record.parent,this.kernel);const t=this.record.parent_id;return null==t||""===t?null:ut(String(t),this.siteRef())}async getAncestors(){if(Array.isArray(this.record.ancestors))return this.rowsToPages(this.record.ancestors);const t=this.embeddedAncestors();if(t.length){const e=t[0],r=e.raw().parent_id;return null==r||""===r||0===r?t:[...await e.fetchAncestors(),...t]}return this.fetchAncestors()}async getSite(){if(this.record.site&&"object"==typeof this.record.site)return new X(this.record.site,this.kernel);const t=this.kernel.snapshot().site;if(t&&(String(t.id)===String(this.record.site_id)||!this.record.site_id))return new X(t,this.kernel);const e=this.record.site_id?String(this.record.site_id):this.kernel.siteRef(),r=p(await this.kernel.request(l().site(e)));return this.kernel.rememberSite(r),new X(r,this.kernel)}async load(){return await this.ensure(["content","options","assets","children"]),this}raw(){return{...this.record}}seoBag(){const t=this.record.seo&&"object"==typeof this.record.seo?this.record.seo:this.kernel.snapshot().seo;return t&&"object"==typeof t?{...t}:{}}galleryList(t){if(Array.isArray(this.record.galleries))return this.record.galleries.flatMap(t=>{const e=E(t);if(!e)return[];const r=t&&"object"==typeof t?String(t.description??""):"";return[{...e,description:r}]});const e=/* @__PURE__ */new Map;for(const r of t)for(const t of r.memberships()){const r=(t.uuid||t.name).toLocaleLowerCase();r&&!e.has(r)&&e.set(r,{...t,description:""})}return[...e.values()]}siteRef(){return this.record.site&&"object"==typeof this.record.site?a(this.record.site)||this.kernel.siteRef():this.record.site_id?String(this.record.site_id):this.kernel.siteRef()}rowsToPages(t){return Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new et(t,this.kernel)):[]}embeddedAncestors(){const t=[],e=/* @__PURE__ */new Set;let r=this.record.parent;for(;r&&"object"==typeof r&&t.length<12;){const n=r,i=String(n.uuid||n.id||"");if(!i||e.has(i))break;e.add(i),t.unshift(new et(n,this.kernel)),r=n.parent}return t}async fetchAncestors(){const t=[],e=/* @__PURE__ */new Set;let r=await this.getParent();for(;r&&t.length<12;){const n=r.getUuid()||String(r.raw().id??"");if(!n||e.has(n))break;e.add(n),t.unshift(r),r=await r.getParent()}return t}excludeSelf(t){const e=o(this.record);return t.filter(t=>o(t)!==e).map(t=>new et(t,this.kernel))}async ensure(t){if(!t.some(t=>void 0===this.record[t]))return;const e=this.getUuid()||this.getSlug()||String(this.record.id||"");if(!e)return;const r=p(await this.kernel.request(l().page(this.siteRef(),e)));this.setRecord({...this.record,...r})}}let rt=null;function nt(){if(!rt)throw new Error("Client is not installed.");return rt}function it(t,e){return null!=e&&""!==String(e)?String(e):t.siteRef()}function st(t,e){e?.page&&e.page>0&&t.set("page",String(Math.floor(e.page))),e?.perPage&&e.perPage>0&&t.set("per_page",String(Math.floor(e.perPage)))}function ot(t){if(null==t)return!1;if("string"==typeof t){const e=t.trim();return""!==e&&"{}"!==e&&"[]"!==e}return Array.isArray(t)?t.length>0:"object"!=typeof t||Object.keys(t).length>0}function at(t){if(t&&"object"==typeof t)return t.options}function ct(t){if("string"==typeof t)return t;if(t&&"object"==typeof t)try{return JSON.stringify(t)}catch{return""}return""}async function ut(t,e){const r=nt(),n=it(r,e),i=p(await r.request(l().page(n,t)));return r.rememberPage(i),new et(i,r)}class lt{constructor(t,e=null){this.record=t,this.kernel=e}record;kernel;getTitle(){return new P(this.record.title)}getUrl(){return new A(this.record.url)}getChildren(){return pt(this.record.children,this.kernel)}isCurrent(t){const e=this.getUrl().path();if(!e)return!1;if(t)return e===t.getUrl().path();const r=this.kernel??dt,n=r?.snapshot().page;return!(!r||!n)&&e===new et(n,r).getUrl().path()}getPage(){const t=this.record.page;if(!t||"object"!=typeof t)return null;const e=this.kernel??dt;return e?new et(t,e):null}raw(){return{...this.record}}}class ht{constructor(t,e){this.source=t,this.runtime=e}source;runtime;get record(){return"function"==typeof this.source?this.source():this.source}static async find(t,e){const r=function(){if(!dt)throw new Error("Client is not installed.");return dt}(),n=null!=e&&""!==String(e)?String(e):r.siteRef(),i=r.snapshot().menus,s=i[t]||Object.values(i).find(e=>!!e&&(String(e.uuid)===t||String(e.id)===t||String(e.name)===t||String(e.position)===t));if(s)return new ht(s,r);const o=p(await r.request(l().menu(n,t)));return r.rememberMenu(o),new ht(o,r)}getName(){return new P(this.record.name)}getPosition(){return String(this.record.position||"")}getItems(){return pt(this.record.items,this.runtime)}raw(){return{...this.record}}}function pt(t,e=null){return Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new lt(t,e)):[]}let dt=null;class gt{snap={page:null,site:null,menus:{},locales:[],seo:null,options:{}};options;inflight=/* @__PURE__ */new Map;cache=/* @__PURE__ */new Map;constructor(t={}){this.options=t,t.page&&this.hydrate(t.page),rt=this,Y=this,dt=this}hydrate(t){return this.snap=n(this.snap,function(t){const e={page:null,site:null,menus:{},locales:[],seo:null,options:{}};if(!t||"object"!=typeof t)return e;const r=t,n=i(r.props)?r.props:r;e.page=s(n.page),e.site=s(n.site),e.seo=i(n.seo)?n.seo:null,e.options=i(n.options)?n.options:{},e.locales=Array.isArray(n.locales)?n.locales:[];const o=n.menus;if(i(o))for(const[i,a]of Object.entries(o))e.menus[i]=s(a);return e}(t)),this.snap}snapshot(){return this.snap}apiBase(){return function(t){if(t)return String(t).replace(/\/+$/,"");const e=h();return e.apiBase?String(e.apiBase).replace(/\/+$/,""):function(){if("undefined"==typeof location)return"";const t=String(location.origin||"").replace(/\/+$/,"");if(t&&"null"!==t)return t;const e=location.hostname||"";return e?`${location.protocol}//${e}`:""}()}(this.options.apiBase)}siteBase(){return function(t){if(t)return String(t).replace(/\/+$/,"");const e=h();return e.siteBase?String(e.siteBase).replace(/\/+$/,""):"undefined"!=typeof location?location.origin:""}(this.options.siteBase)}siteRef(){return null!=this.options.site&&""!==String(this.options.site)?String(this.options.site):a(this.snap.site)}async request(t,e={}){const r=String(e.method||"GET").toUpperCase(),n=`${r} ${t}`;if("GET"===r&&this.cache.has(n))return this.cache.get(n);if("GET"===r){const t=this.inflight.get(n);if(t)return t}const i=this.apiBase();if(!i)throw new Error("Remote origin is not configured.");const s=async function(t,e,r={}){const{fetchImpl:n,...i}=r,s=e.startsWith("http")?e:u(t,e),o=n??fetch,a=new Headers(i.headers);a.has("Accept")||a.set("Accept","application/json");const c=await o(s,{...i,headers:a}),l=await c.text();let h=null;if(l)try{h=JSON.parse(l)}catch{h={message:l}}if(!c.ok){const t=new Error(`Request failed (${c.status})`);throw t.status=c.status,t.body=h,t}return h}(i,t,{...e,fetchImpl:this.options.fetch}).then(t=>("GET"===r&&this.cache.set(n,t),t));return"GET"===r&&(this.inflight.set(n,s),s.finally(()=>{this.inflight.delete(n)}).catch(()=>{})),s}rememberPage(t){const e=this.snap.page;e&&String(e.id)===String(t.id)&&(this.snap=n(this.snap,{page:{...e,...t}}))}rememberSite(t){this.snap=n(this.snap,{site:{...this.snap.site??{},...t}})}rememberMenu(t){const e=String(t.position||t.uuid||t.id||t.name||"menu");this.snap=n(this.snap,{menus:{[e]:t}})}}let ft=null;function mt(t={}){return ft=new gt(t),ft}function yt(){return ft||(ft=new gt),ft}const wt=/* @__PURE__ */Symbol.for("miro.client");function St(){return t(wt,null)??yt()}function bt(t={}){return{install(e,r={}){const n=mt({...t,...r});e.provide(wt,n),function(t){import("@inertiajs/vue3").then(e=>{const r=e.router;r?.page&&t.hydrate(r.page),r?.on?.("success",e=>{const r=e?.detail?.page;r&&t.hydrate(r)}),r?.on?.("navigate",e=>{const r=e?.detail?.page;r&&t.hydrate(r)})}).catch(()=>{})}(n)}}}const $t=bt();class _t{constructor(t){this.kernel=t}kernel;all(){return function(t,e=function(){return globalThis}()){const r=Array.isArray(t)?t.flatMap(t=>function(t){if(!t||"object"!=typeof t)return[];const e=t,r=kt(String(e.lang??""));return r?[{lang:r,domain:At(String(e.domain??"")),url:String(e.url??"").trim()}]:[]}(t)):[];return r.length?r.flatMap(t=>{const r=jt(t.url||function(t,e){const r=e[`locale_${t}_baseurl`];return"string"==typeof r?r.trim():""}(t.lang,e)||t.domain);return t.lang&&r?[{lang:t.lang,domain:t.domain||At(r),url:r}]:[]}):function(t){const e=[];for(const r of Object.keys(t)){const n=/^locale_([a-z]+)_baseurl$/.exec(r);if(!n)continue;const i=jt(String(t[r]??""));i&&e.push({lang:n[1],domain:At(i),url:i})}return e}(e)}(this.kernel.snapshot().locales)}current(){return kt(String(this.kernel.snapshot().site?.lang||""))}url(t){const e=kt(t),r=this.all().find(t=>t.lang===e);return r?.url??""}}function kt(t){return(t.trim().toLowerCase().replaceAll("_","-").split("-")[0]??"").replace(/[^a-z]/g,"")}function jt(t){const e=t.trim();return e?(/^https?:\/\//i.test(e)?e:`https://${e.replace(/^\/+/,"")}`).replace(/\/+$/,""):""}function At(t){return t.trim().replace(/^https?:\/\//i,"").replace(/\/.*$/,"")}function Pt(t){return`mc_${(String(t??"").trim().split("/").pop()??"").replace(/^@/,"").replace(/[^A-Za-z0-9]+/g,"_").replace(/^_+|_+$/g,"").toUpperCase()}`}function Ct(t){if("undefined"==typeof window||""===t)return"";const e=window.__MIRO_WEB_PLUGINS__;if(!Array.isArray(e))return"";for(const r of e){const e=String(r??"").trim().toLowerCase(),n=e.lastIndexOf("/");if(n<=0)continue;const i=e.slice(0,n),s=e.slice(n+1);if(""!==i&&(s===t||xt(s)===t))return i}return""}function xt(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[^A-Za-z0-9]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function vt(t){if("undefined"==typeof window)return{};const e=window[t];return e&&"object"==typeof e?e:{}}function Rt(){const t=St(),e=function(){try{const t=globalThis.__INERTIA_PAGE__;if(t?.props)return t.props}catch{}return function(){if("undefined"==typeof document)return null;const t=document.querySelector("[data-page]")?.getAttribute("data-page");if(!t)return null;try{return JSON.parse(t).props??null}catch{return null}}()}();return e&&t.hydrate(e),t}function Ut(){const t=Rt();return Bt(t),new et(()=>t.snapshot().page??{},t)}function Tt(){const t=Rt();return Bt(t),new X(()=>t.snapshot().site??{},t)}function It(t="topbar"){const e=Rt();return Bt(e),new ht(()=>e.snapshot().menus[t]??{position:t,items:[]},e)}function Wt(){const t=Rt();return Bt(t),new _t(t)}function Mt(){return Ut().getAssets()}function Nt(t){return function(t,e){const r=Pt(t),n=function(t){const e=String(t??"").trim();if(e.includes("/")){const[t,...r]=e.split("/");return{vendor:t||"miroart",slug:xt(r.join("/")||e)}}const r=xt(e);return{vendor:Ct(r)||"miroart",slug:r}}(t);return new Proxy({name:t,key:r,ready:async()=>async function(t){const e=Date.now();for(;Date.now()-e<4e3;){const e=vt(t);if(Object.keys(e).length)return e;await new Promise(t=>setTimeout(t,50))}return vt(t)}(r),api:()=>vt(r),call:(t,...e)=>{const n=vt(r),i=n[t];if("function"!=typeof i)throw new Error(`Missing plugin method: ${t}`);return i.apply(n,e)},request:async(t="/",r={})=>{const i=l().plugins(n.vendor,n.slug,t||"/"),s=new Headers(r.headers);let o=r.body;return void 0!==r.json&&(o=JSON.stringify(r.json)),p(await e.request(i,{...r,headers:s,body:o}))}},{get(t,e,n){if(e in t)return Reflect.get(t,e,n);if("then"===e||e===Symbol.toStringTag)return;const i=vt(r),s=i[String(e)];return"function"==typeof s?s.bind(i):s},has:(t,e)=>e in t||e in vt(r)})}(t,St())}function Ot(){const t=St();return{apiBase:e(()=>t.apiBase()),siteBase:e(()=>t.siteBase()),siteRef:e(()=>t.siteRef())}}function Bt(t){try{const e=function(){try{return Lt??null}catch{return null}}();if(!e)return;const n=e.usePage();t.hydrate(r(n))}catch{}}let Lt=null;import("@inertiajs/vue3").then(t=>{Lt=t}).catch(()=>{Lt=null});const qt=$t;export{L as Asset,C as AssetName,D as CollectionCard,q as Gallery,_t as Locales,ht as Menu,lt as MenuItem,P as MenuTitle,$t as Miro,j as OptionValue,et as Page,$ as PageContent,S as PageSmallTitle,w as PageSubtitle,b as PageSummary,y as PageTitle,wt as SDK_KEY,v as SeoDescription,x as SeoTitle,X as Site,k as SiteName,_ as SiteTitle,m as TextValue,A as UrlValue,bt as createMiro,mt as createRuntime,qt as default,yt as getRuntime,Pt as pluginWindowKey,St as useKernel,Mt as useMiroAssets,Ot as useMiroConfig,Wt as useMiroLocales,It as useMiroMenu,Ut as useMiroPage,Tt as useMiroSite,Nt as usePlugin};
1
+ import{computed as t,unref as e,defineComponent as r,shallowRef as n,onMounted as i,onBeforeUnmount as s,h as o,Fragment as a,Comment as c,cloneVNode as u,toDisplayString as l,inject as h}from"vue";const p=["primary","secondary","accent","neutral","base-100","base-content","info","success","warning","error"],d=["sans","serif"],g=/\\(\[\/?(?:b|i|u|s|c|f)(?:=[a-z0-9-]+)?\])|\[(\/?)(b|i|u|s|c|f)(?:=([a-z0-9-]+))?\]/g;function f(t,e){return"c"===t?p.includes(e??""):"f"===t?d.includes(e??""):void 0===e}function m(t,e){""!==e&&e.split(/\r?\n/).forEach((e,r)=>{if(r>0&&t.push({type:"br"}),""===e)return;const n=t[t.length-1];"text"===n?.type?n.value+=e:t.push({type:"text",value:e})})}function y(t){const e=String(t??""),r=[],n=[],i=()=>n[n.length-1]?.children??r,s=()=>{var t,e;t=n.pop(),e=i(),0!==t.children.length&&("c"===t.tag?e.push({type:"c",value:t.value,children:t.children}):"f"===t.tag?e.push({type:"f",value:t.value,children:t.children}):e.push({type:t.tag,children:t.children}))};let o,a=0;for(g.lastIndex=0;null!==(o=g.exec(e));){m(i(),e.slice(a,o.index)),a=g.lastIndex;const[t,r,c,u,l]=o;if(void 0===r){if("/"===c){const e=void 0===l?n.map(t=>t.tag).lastIndexOf(u):-1;if(-1===e){m(i(),t);continue}for(;n.length>e;)s();continue}!f(u,l)||n.length>=8?m(i(),t):n.push({tag:u,value:l??null,children:[]})}else m(i(),r)}for(m(i(),e.slice(a));n.length>0;)s();return r}function w(t,e){for(const r of t)"text"===r.type?e.push(r.value):"br"===r.type?e.push("\n"):w(r.children,e)}function S(t){const e=String(t??"");if(!e.includes("["))return e;const r=[];return w(y(e),r),r.join("")}function b(t){return null==t?"":"string"==typeof t?t:"number"==typeof t||"boolean"==typeof t?String(t):""}function $(t){const e=b(t);if(!e)return"";if("undefined"!=typeof document){const t=document.createElement("textarea");return t.innerHTML=e,t.value}return e.replace(/&#(\d+);/g,(t,e)=>String.fromCharCode(Number(e))).replace(/&#x([0-9a-f]+);/gi,(t,e)=>String.fromCharCode(parseInt(e,16))).replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">")}function k(t){return S($(t)).replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi," ").replace(/<style[\s\S]*?>[\s\S]*?<\/style>/gi," ").replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim()}class _ extends String{kind;extra;constructor(t,e,r={}){super($(e)),this.kind=t,this.extra=r,Object.setPrototypeOf(this,new.target.prototype)}toString(){return String.prototype.toString.call(this)}valueOf(){return String.prototype.valueOf.call(this)}raw(){return this.toString()}decode(){return $(this.toString())}cleanContent(){return k(this.toString())}stripHtml(){return this.cleanContent()}plain(){return S(this.toString())}excerpt(t=160){const e=this.cleanContent();return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}firstParagraph(){return function(t){const e=$(t),r=e.match(/<p\b[^>]*>([\s\S]*?)<\/p>/i);return k(r?r[1]:e)}(this.toString())}isEmpty(){return""===this.cleanContent()}json(){const t=this.toString().trim();if(!t)return null;try{return JSON.parse(t)}catch{return null}}bool(){const t=this.toString().trim().toLowerCase();return"1"===t||"true"===t||"yes"===t||"on"===t}number(){const t=Number(this.toString().trim());return Number.isFinite(t)?t:null}}class j extends _{constructor(t){super("PageTitle",t)}}class A extends _{constructor(t){super("PageSubtitle",t)}}class v extends _{constructor(t){super("PageSmallTitle",t)}}class x extends _{constructor(t){super("PageSummary",t)}}class P extends _{constructor(t){super("PageContent",t)}html(){return this.toString()}}class C extends _{constructor(t){super("SiteTitle",t)}}class O extends _{constructor(t){super("SiteName",t)}}class R extends _{key;structured;constructor(t,e){const r=W(e);super("OptionValue",r.text,{key:t}),this.key=t,this.structured=r.structured}json(){return void 0!==this.structured?this.structured:super.json()}present(){return!this.isEmpty()}}class U extends _{constructor(t){super("UrlValue",t)}path(){const t=this.toString().trim();if(!t)return"/";try{if(/^https?:\/\//i.test(t))return new URL(t).pathname.replace(/\/+$/,"")||"/"}catch{}return(t.startsWith("/")?t:`/${t}`).replace(/\/+$/,"")||"/"}href(t=""){const e=this.path();return!t||/^https?:\/\//i.test(e)?e:`${String(t).replace(/\/+$/,"")}${e}`}}class M extends _{constructor(t){super("MenuTitle",t)}}class I extends _{constructor(t){super("AssetName",t)}}class T extends _{constructor(t){super("SeoTitle",t)}}class N extends _{constructor(t){super("SeoDescription",t)}}function W(t){if(null==t)return{text:""};if("boolean"==typeof t||"number"==typeof t)return{text:String(t)};if("string"==typeof t){const e=t.trim();if(""===e||"[]"===e||"{}"===e)return{text:""};if(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]")||e.startsWith('"')&&e.endsWith('"'))try{return W(JSON.parse(e))}catch{return{text:$(t)}}return{text:$(t)}}return Array.isArray(t)?{text:JSON.stringify(t),structured:t}:"object"==typeof t?function(t){return"value"in t&&Object.keys(t).every(t=>"value"===t||"key"===t||"id"===t||"active"===t)}(t)?W(t.value):{text:JSON.stringify(t),structured:t}:{text:b(t)}}function E(t,e){if(!t)return"";if(Array.isArray(t)){const r=t.find(t=>t&&"object"==typeof t&&t.key===e);return r&&"object"==typeof r?r.value:""}return"object"==typeof t?t[e]:""}function B(t){return String.fromCharCode(...t.map(t=>23^t))}function L(t,e){const r=String(t||"").replace(/\/+$/,""),n=e.startsWith("/")?e:`/${e}`;return r?`${r}${n}`:n}function q(){const t=B([56,118,103,126]),e=B([97,38]),r=B([100,126,99,114,100]),n=B([103,118,112,114,100]),i=B([100,114,118,101,116,127]),s=B([122,114,121,98,100]),o=B([122,114,115,126,118]),a=B([103,123,98,112,126,121,100]),c=B([118,116,99,126,120,121,100]);return{sites:()=>L("",`${t}/${e}/${r}`),site:n=>L("",`${t}/${e}/${r}/${encodeURIComponent(n)}`),pages:i=>L("",`${t}/${e}/${r}/${encodeURIComponent(i)}/${n}`),page:(i,s)=>L("",`${t}/${e}/${r}/${encodeURIComponent(i)}/${n}/${s.split("/").map(t=>encodeURIComponent(t)).join("/")}`),search:s=>L("",`${t}/${e}/${r}/${encodeURIComponent(s)}/${n}/${i}`),menus:n=>L("",`${t}/${e}/${r}/${encodeURIComponent(n)}/${s}`),menu:(n,i)=>L("",`${t}/${e}/${r}/${encodeURIComponent(n)}/${s}/${encodeURIComponent(i)}`),media:e=>L("",`${t}/${o}/${encodeURIComponent(e)}`),action:e=>L("",`${t}/${c}/${encodeURIComponent(e)}`),plugins:(e,r,n="")=>{const i=`${t}/${a}/${encodeURIComponent(e)}/${encodeURIComponent(r)}`;return n&&"/"!==n?`${i}${n.startsWith("/")?n:`/${n}`}`:i}}}function z(t){if("string"==typeof t){const e=t.trim();return e?H(e)?{uuid:e}:{url:e,path:e}:null}if(!t||"object"!=typeof t||Array.isArray(t))return null;const e=t,r=F(e.source),n=G(e.url,e.preview_url,e.path,e.src,r?.url,r?.preview_url,r?.path),i=G(e.uuid,r?.uuid);if(n||i&&H(i))return e;const s=G(e.value);return s?z(s):null}function G(...t){for(const e of t)if("string"==typeof e&&""!==e.trim())return e.trim();return""}function J(t){return"string"==typeof t?t.trim():""}function F(t){return!t||"object"!=typeof t||Array.isArray(t)?null:t}function D(t){return t.startsWith("/media/")||t.startsWith("/_images/")||t.startsWith("/api/media/")||t.startsWith("/branding-assets/")||t.startsWith("/storage/")}function H(t){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)}const Z=[{mark:"1_8",width:256},{mark:"1_4",width:512},{mark:"1_2",width:1024},{mark:"2_3",width:1400}];class V{constructor(t,e){this.record=t,this.runtime=e}record;runtime;getUuid(){return String(this.record.uuid||this.record.id||"")}getName(){return new I(this.record.name)}getAlt(){return J(this.record.alt)}getCaption(){return J(this.record.caption)}getGallery(){return this.memberships()[0]??null}galleryUuid(){return this.memberships()[0]?.uuid??""}galleryName(){return this.memberships()[0]?.name??""}memberships(){const t=this.record.galleries;if(Array.isArray(t)&&t.length>0)return t.map(t=>Q(t)).filter(t=>null!==t);const e=String(this.record.gallery_uuid??"").trim(),r=String(this.record.gallery_name??"").trim();if(!e&&!r)return[];const n=this.record.gallery_id;return[{id:"number"==typeof n||"string"==typeof n?n:null,uuid:e,name:r,sort_order:X(this.record.gallery_sort_order)}]}getMime(){const t=F(this.record.source);return String(this.record.mime_type||t?.mime_type||"")}getSize(){const t=F(this.record.source),e=Number(this.record.size??t?.size??0);return Number.isFinite(e)?e:0}getType(){const t=J(this.record.type);if(t)return t;const e=this.getMime();return e.startsWith("image/")?"image":e.startsWith("video/")?"video":"application/pdf"===e?"pdf":""}getSortOrder(){const t=Number(this.record.sort_order??0);return Number.isFinite(t)?t:0}isImage(){return!!this.getMime().startsWith("image/")||/\.(jpe?g|png|gif|webp|svg)(\?|$)/i.test(this.urlString())}url(){return new U(this.urlString())}srcset(){const t=this.urlString();if(!t||/\.svg([?#]|$)/i.test(t)||/^https?:\/\//i.test(t)||t.startsWith("//"))return"";if(!/\.webp([?#]|$)/i.test(t)||/\.(?:1_16|1_8|1_4|1_2|2_3)\.webp([?#]|$)/i.test(t))return"";const e=Z.map(({mark:e,width:r})=>`${t.replace(/\.webp([?#].*)?$/i,`.${e}.webp$1`)} ${r}w`);return e.push(`${t} 2048w`),e.join(", ")}raw(){return{...this.record}}urlString(){const t=F(this.record.source),e=G(this.record.uuid,t?.uuid),r=G(this.record.disk,t?.disk);let n=G(this.record.url,this.record.preview_url,this.record.path,this.record.src,t?.url,t?.preview_url,t?.path);if(e&&H(e)&&n&&function(t,e){return!!(/\/project-storage\//i.test(r=t)||/\/editor\/project-file/i.test(r)||/cms\.miroart\.pl/i.test(r)&&/\/(?:project-storage|storage)\//i.test(r))||"project_public"===e&&!D(t)&&!/^https?:\/\//i.test(t)&&!t.startsWith("//");var r}(n,r))return this.mediaUrl(e);if(!n)return e&&H(e)?this.mediaUrl(e):"";if(!0===globalThis.isSsg){if(n.startsWith("/_images/")||n.startsWith("_images/"))return n.startsWith("/")?n:`/${n}`;const e=function(t){const e=t.match(/[?&]path=([^&]+)/i);if(e)try{const t=decodeURIComponent(e[1].replace(/\+/g," ")).split(/[/\\]/).pop()||"";if(t&&"project-file"!==t.toLowerCase())return t.trim()}catch{}return(t.split("#")[0].split("?")[0].split(/[/\\]/).pop()||"").trim()}(G(t?.path,this.record.path,n)),r=/\.(jpe?g|png|gif|webp|svg)$/i.test(i=e)?/\.svg$/i.test(i)?`/_images/${i}`:`/_images/${i.replace(/\.(jpe?g|png|gif|webp)$/i,".webp")}`:null;if(r)return r}var i;if(/^https?:\/\//i.test(n)||n.startsWith("//"))return n;if(n.startsWith("_images/"))return`/${n}`;if(D(n))return n;n.includes("/")||n.includes("\\")||H(n)||(n=`images/${n}`);const s=n.startsWith("/")?n:`/${n}`;return D(s)||s.startsWith("/project-storage/")?s:`/storage${s}`}mediaUrl(t){const e=q().media(t),r=this.runtime.apiBase();return r?L(r,e):e}}class K{constructor(t){this.items=t}items;all(){return this.items.slice()}first(){return this.items[0]??null}extra(){return this.items.slice(1)}hero(){return this.first()}urls(){return this.items.map(t=>t.url())}isEmpty(){return 0===this.items.length}count(){return this.items.length}[Symbol.iterator](){return this.items[Symbol.iterator]()}}function Q(t){if(!t||"object"!=typeof t)return null;const e=t,r=String(e.uuid??"").trim(),n=String(e.name??"").trim();if(!r&&!n)return null;const i=e.id;return{id:"number"==typeof i||"string"==typeof i?i:null,uuid:r,name:n,sort_order:X(e.sort_order)}}function X(t){const e=Number(t??0);return Number.isFinite(e)?e:0}function Y(t,e){return Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new V(t,e)):[]}function tt(){if("undefined"==typeof globalThis)return{};const t=globalThis.MiroConfig;return t&&"object"==typeof t?t:{}}function et(t){return t&&"object"==typeof t&&"data"in t?t.data:t}function rt(t,e){return{page:void 0!==e.page?e.page:t.page,site:void 0!==e.site?e.site:t.site,menus:e.menus?{...t.menus,...e.menus}:{...t.menus},locales:e.locales??t.locales,seo:void 0!==e.seo?e.seo:t.seo,options:e.options?{...t.options,...e.options}:{...t.options},editing:e.editing??t.editing}}function nt(t){return Boolean(t)&&"object"==typeof t&&!Array.isArray(t)}function it(t){return nt(t)?t:null}function st(t){return t?String(t.uuid||t.ulid||t.id||t.slug||t.full_url||""):""}function ot(t){return t?String(t.uuid||t.domain||t.id||""):""}const at=/* @__PURE__ */new Set(["id","uuid","created_at","updated_at"]);class ct{constructor(t,e){this.row=t,this.kernel=e}row;kernel;getHref(){return new U(this.row.href)}getTitle(){return String(this.row.title??"")}item(){const t=this.row.item;return t&&"object"==typeof t?t:{}}image(){return ut(this.item(),this.kernel)}}function ut(t,e){if(!t||"object"!=typeof t)return null;for(const[r,n]of Object.entries(t)){if(at.has(r)||"string"!=typeof n||!lt(n))continue;const t=z(n);if(t)return new V(t,e)}return null}function lt(t){const e=t.trim();return!!e&&(!!(e.startsWith("/media/")||e.startsWith("/_images/")||e.startsWith("_images/")||e.startsWith("/api/media/")||e.startsWith("/branding-assets/"))||/\.(jpe?g|png|gif|webp|svg)(\?|#|$)/i.test(e))}function ht(t,e){const r=t&&"object"==typeof t?t.meta:null,n=r&&"object"==typeof r?r:{};return{currentPage:dt(n.current_page,1),lastPage:dt(n.last_page,1),perPage:dt(n.per_page,Math.max(e,1)),total:gt(n.total,e)}}function pt(t,e){return Object.assign(t,{meta:e})}function dt(t,e){const r=Number(t);return!Number.isFinite(r)||r<1?e:Math.floor(r)}function gt(t,e){if(null==t||""===t)return e;const r=Number(t);return!Number.isFinite(r)||r<0?e:Math.floor(r)}class ft{constructor(t,e){this.source=t,this.kernel=e}source;kernel;get record(){return"function"==typeof this.source?this.source():this.source}static async all(){const t=yt(),e=await t.request(q().sites());return(Array.isArray(e?.data)?e.data:[]).filter(t=>Boolean(t)&&"object"==typeof t).map(e=>new ft(e,t))}static async find(t){const e=yt(),r=null!=t&&""!==String(t)?String(t):e.siteRef(),n=e.snapshot().site;if(n&&(!t||String(n.uuid)===String(t)||String(n.id)===String(t)||String(n.domain)===String(t)||ot(n)===String(t)))return new ft(n,e);const i=et(await e.request(q().site(r)));return e.rememberSite(i),new ft(i,e)}static async findPage(t,e){return wt.find(t,e)}static async findMenu(t,e){return Pt.find(t,e)}getName(){return new O(this.record.name)}getTitle(){const t=E(this.record.options,"seo_title")||E(this.record.options,"title");return new C(t||this.record.name)}getDomain(){return String(this.record.domain||"")}getLang(){return String(this.record.lang||"")}getUuid(){return String(this.record.uuid||"")}getOption(t){return new R(t,E(this.record.options,t))}getImage(t){const e=this.getOption(t),r=e.json(),n=null==r?e.toString().trim():r;if(null==n||""===n)return null;const i=z(n);return i?new V(i,this.kernel):null}async findPage(t){return wt.find(t,this.ref())}async findMenu(t){return Pt.find(t,this.ref())}async menus(){const t=this.kernel.snapshot().menus,e=Object.values(t).filter(Boolean);return e.length?e.map(t=>new Pt(t,this.kernel)):((await this.kernel.request(q().menus(this.ref()))).data??[]).map(t=>(this.kernel.rememberMenu(t),new Pt(t,this.kernel)))}async pages(t={}){const e=new URLSearchParams,r={...t};null!=r.perPage&&null==r.per_page&&(r.per_page=r.perPage,delete r.perPage);for(const[o,a]of Object.entries(r))e.set(o,String(a));const n=e.toString()?`?${e.toString()}`:"",i=await this.kernel.request(`${q().pages(this.ref())}${n}`),s=(i.data??[]).map(t=>(this.kernel.rememberPage(t),new wt(t,this.kernel)));return pt(s,ht(i,s.length))}async runAction(t){const e=String(t.uuid||"").trim();if(!e)throw new Error("Action uuid is required.");const r=String(this.record.domain||this.ref());return this.kernel.request(q().action(r),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({uuid:e,method:t.method||"GET",path:t.path||"",query:t.query||{},body:t.body||"",headers:t.headers||{},params:t.params||{},post:t.post||{}})})}raw(){return{...this.record}}ref(){return String(this.record.uuid||this.record.domain||this.record.id||this.kernel.siteRef())}}let mt=null;function yt(){if(!mt)throw new Error("Client is not installed.");return mt}class wt{constructor(t,e){this.source=t,this.kernel=e}source;kernel;get record(){return"function"==typeof this.source?this.source():this.source}setRecord(t){"function"!=typeof this.source?this.source=t:this.kernel.rememberPage(t)}static async findByUlid(t,e){return vt(t,e)}static async find(t,e){return vt(t,e)}static async search(t,e,r){const n=bt(),i=$t(n,e),s=new URLSearchParams;s.set("q",t),kt(s,r);const o=await n.request(`${q().search(i)}?${s.toString()}`),a=(Array.isArray(o?.data)?o.data:Array.isArray(o)?o:[]).map(t=>(n.rememberPage(t),new wt(t,n)));return pt(a,ht(o,a.length))}getTitle(){return new j(this.record.title)}getSubtitle(){return new A(this.record.subtitle)}getSmallTitle(){return new v(this.record.smalltitle)}getSummary(){return new x(this.record.summary)}getContent(){return new P(this.record.content)}getSlug(){return String(this.record.slug||"")}getUrl(){return new U(this.record.full_url||(this.record.slug?`/${this.record.slug}`:"/"))}getUuid(){return String(this.record.uuid||this.record.ulid||"")}getId(){return String(this.record.id||this.getUuid())}getLayout(){return String(this.record.layout||"")}getDisplay(){return String(this.record.display||"")}getDisplayInMenu(){const t=this.record.display_in_menu;return null==t||""===t||!1!==t&&0!==t&&"0"!==t}getSortOrder(){const t=Number(this.record.sort_order??0);return Number.isFinite(t)?t:0}getLang(){const t=String(this.record.lang||"").trim();if(t)return t;const e=this.kernel.snapshot().site;return String(e?.lang||function(t){return t&&"object"==typeof t?String(t.lang||""):""}(this.record.site)||"")}getOption(t){const e=[E(this.record.options,t),this.kernel.snapshot().options[t],E(this.kernel.snapshot().site?.options,t),E(jt(this.record.site),t)];for(const r of e)if(_t(r))return new R(t,r);return new R(t,"")}getSeo(){const t=this.seoBag(),e=t=>null==t?"":String(t),r=t=>{const e=z(t);return e?new V(e,this.kernel):null};return{title:new T(t.title??this.record.title),description:new N(t.description??this.record.summary),keywords:e(t.keywords),robots:e(t.robots),canonical:new U(t.canonical),ogTitle:e(t.og_title??t.title??this.record.title),ogDescription:e(t.og_description??t.description??this.record.summary),ogImage:r(t.og_image),ogType:e(t.og_type),ogUrl:new U(t.og_url||t.canonical),twitterCard:e(t.twitter_card),twitterTitle:e(t.twitter_title??t.og_title??t.title),twitterDescription:e(t.twitter_description??t.og_description??t.description),twitterImage:r(t.twitter_image||t.og_image),ldJson:At(t.ld_json),raw:{...t}}}get collectionItem(){const t=this.record.collectionItem;return t&&"object"==typeof t?t:{}}get collectionItems(){const t=this.record.collectionItems;return t&&"object"==typeof t?t:{}}get collectionGallery(){return t=this.record.collectionGallery,e=this.kernel,Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new ct(t,e)):[];var t,e}collectionImage(){return ut(this.collectionItem,this.kernel)}getAssets(){return new K(Y(this.record.assets,this.kernel))}getGallery(t){const e=t.trim();if(!e)return new K([]);const r=[];return Y(this.record.assets,this.kernel).forEach((t,n)=>{const i=t.memberships().find(t=>function(t,e){const r=e.trim().toLocaleLowerCase();return!!r&&(t.uuid.toLocaleLowerCase()===r||t.name.toLocaleLowerCase()===r)}(t,e));i&&r.push({asset:t,sort:i.sort_order,index:n})}),r.sort((t,e)=>t.sort-e.sort||t.index-e.index),new K(r.map(t=>t.asset))}getGalleries(){const t=Y(this.record.assets,this.kernel);return this.galleryList(t).map(t=>({id:t.id,uuid:t.uuid,name:t.name,description:t.description,sort_order:t.sort_order,assets:this.getGallery(t.uuid||t.name)}))}async getChildren(t){const e=function(t){if(!Array.isArray(t))return[];const e=/* @__PURE__ */new Set(["options","assets"]),r=[];for(const n of t){const t=String(n).trim().toLowerCase();e.has(t)&&!r.includes(t)&&r.push(t)}return r}(t?.with),r=Array.isArray(this.record.children)?this.record.children:null;if(r&&function(t,e){return!e.length||t.every(t=>{if(!t||"object"!=typeof t)return!1;const r=t;if(e.includes("options")){const t=r.options;if(null==t||"object"!=typeof t)return!1}return!(e.includes("assets")&&!Array.isArray(r.assets))})}(r,e)){const e=function(t,e,r){const n=t.length;if(!e&&!r)return{items:t,meta:{currentPage:1,lastPage:1,perPage:Math.max(n,1),total:n}};const i=r&&r>0?Math.floor(r):Math.max(n,1),s=e&&e>0?Math.floor(e):1,o=Math.max(1,Math.ceil(n/i)),a=(s-1)*i;return{items:t.slice(a,a+i),meta:{currentPage:s,lastPage:o,perPage:i,total:n}}}(this.rowsToPages(r),t?.page,t?.perPage);return pt(e.items,e.meta)}const n=this.getUuid()||String(this.record.id??"");if(!n){const t=r?this.rowsToPages(r):[];return pt(t,ht(null,t.length))}const i=new URLSearchParams;i.set("parent",n),e.length&&i.set("with",e.join(",")),kt(i,t);const s=await this.kernel.request(`${q().pages(this.siteRef())}?${i.toString()}`);return pt(this.rowsToPages(s.data??[]),ht(s,(s.data??[]).length))}async getSiblings(){if(Array.isArray(this.record.siblings))return this.record.siblings.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new wt(t,this.kernel));const t=this.record.parent_id,e=this.siteRef();if(null==t||""===t){const t=await this.kernel.request(`${q().pages(e)}?parent=root`);return this.excludeSelf(t.data??[])}const r=await this.kernel.request(`${q().pages(e)}?parent=${encodeURIComponent(String(t))}`);return this.excludeSelf(r.data??[])}async getParent(){if(this.record.parent&&"object"==typeof this.record.parent)return new wt(this.record.parent,this.kernel);const t=this.record.parent_id;return null==t||""===t?null:vt(String(t),this.siteRef())}async getAncestors(){if(Array.isArray(this.record.ancestors))return this.rowsToPages(this.record.ancestors);const t=this.embeddedAncestors();if(t.length){const e=t[0],r=e.raw().parent_id;return null==r||""===r||0===r?t:[...await e.fetchAncestors(),...t]}return this.fetchAncestors()}async getSite(){if(this.record.site&&"object"==typeof this.record.site)return new ft(this.record.site,this.kernel);const t=this.kernel.snapshot().site;if(t&&(String(t.id)===String(this.record.site_id)||!this.record.site_id))return new ft(t,this.kernel);const e=this.record.site_id?String(this.record.site_id):this.kernel.siteRef(),r=et(await this.kernel.request(q().site(e)));return this.kernel.rememberSite(r),new ft(r,this.kernel)}async load(){return await this.ensure(["content","options","assets","children"]),this}raw(){return{...this.record}}seoBag(){const t=this.record.seo&&"object"==typeof this.record.seo?this.record.seo:this.kernel.snapshot().seo;return t&&"object"==typeof t?{...t}:{}}galleryList(t){if(Array.isArray(this.record.galleries))return this.record.galleries.flatMap(t=>{const e=Q(t);if(!e)return[];const r=t&&"object"==typeof t?String(t.description??""):"";return[{...e,description:r}]});const e=/* @__PURE__ */new Map;for(const r of t)for(const t of r.memberships()){const r=(t.uuid||t.name).toLocaleLowerCase();r&&!e.has(r)&&e.set(r,{...t,description:""})}return[...e.values()]}siteRef(){return this.record.site&&"object"==typeof this.record.site?ot(this.record.site)||this.kernel.siteRef():this.record.site_id?String(this.record.site_id):this.kernel.siteRef()}rowsToPages(t){return Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new wt(t,this.kernel)):[]}embeddedAncestors(){const t=[],e=/* @__PURE__ */new Set;let r=this.record.parent;for(;r&&"object"==typeof r&&t.length<12;){const n=r,i=String(n.uuid||n.id||"");if(!i||e.has(i))break;e.add(i),t.unshift(new wt(n,this.kernel)),r=n.parent}return t}async fetchAncestors(){const t=[],e=/* @__PURE__ */new Set;let r=await this.getParent();for(;r&&t.length<12;){const n=r.getUuid()||String(r.raw().id??"");if(!n||e.has(n))break;e.add(n),t.unshift(r),r=await r.getParent()}return t}excludeSelf(t){const e=st(this.record);return t.filter(t=>st(t)!==e).map(t=>new wt(t,this.kernel))}async ensure(t){if(!t.some(t=>void 0===this.record[t]))return;const e=this.getUuid()||this.getSlug()||String(this.record.id||"");if(!e)return;const r=et(await this.kernel.request(q().page(this.siteRef(),e)));this.setRecord({...this.record,...r})}}let St=null;function bt(){if(!St)throw new Error("Client is not installed.");return St}function $t(t,e){return null!=e&&""!==String(e)?String(e):t.siteRef()}function kt(t,e){e?.page&&e.page>0&&t.set("page",String(Math.floor(e.page))),e?.perPage&&e.perPage>0&&t.set("per_page",String(Math.floor(e.perPage)))}function _t(t){if(null==t)return!1;if("string"==typeof t){const e=t.trim();return""!==e&&"{}"!==e&&"[]"!==e}return Array.isArray(t)?t.length>0:"object"!=typeof t||Object.keys(t).length>0}function jt(t){if(t&&"object"==typeof t)return t.options}function At(t){if("string"==typeof t)return t;if(t&&"object"==typeof t)try{return JSON.stringify(t)}catch{return""}return""}async function vt(t,e){const r=bt(),n=$t(r,e),i=et(await r.request(q().page(n,t)));return r.rememberPage(i),new wt(i,r)}class xt{constructor(t,e=null){this.record=t,this.kernel=e}record;kernel;getTitle(){return new M(this.record.title)}getUrl(){return new U(this.record.url)}getChildren(){return Ct(this.record.children,this.kernel)}isCurrent(t){const e=this.getUrl().path();if(!e)return!1;if(t)return e===t.getUrl().path();const r=this.kernel??Ot,n=r?.snapshot().page;return!(!r||!n)&&e===new wt(n,r).getUrl().path()}getPage(){const t=this.record.page;if(!t||"object"!=typeof t)return null;const e=this.kernel??Ot;return e?new wt(t,e):null}raw(){return{...this.record}}}class Pt{constructor(t,e){this.source=t,this.runtime=e}source;runtime;get record(){return"function"==typeof this.source?this.source():this.source}static async find(t,e){const r=function(){if(!Ot)throw new Error("Client is not installed.");return Ot}(),n=null!=e&&""!==String(e)?String(e):r.siteRef(),i=r.snapshot().menus,s=i[t]||Object.values(i).find(e=>!!e&&(String(e.uuid)===t||String(e.id)===t||String(e.name)===t||String(e.position)===t));if(s)return new Pt(s,r);const o=et(await r.request(q().menu(n,t)));return r.rememberMenu(o),new Pt(o,r)}getName(){return new M(this.record.name)}getPosition(){return String(this.record.position||"")}getItems(){return Ct(this.record.items,this.runtime)}raw(){return{...this.record}}}function Ct(t,e=null){return Array.isArray(t)?t.filter(t=>Boolean(t)&&"object"==typeof t).map(t=>new xt(t,e)):[]}let Ot=null;class Rt{constructor(t){this.kernel=t}kernel;all(){return function(t,e=function(){return globalThis}()){const r=Array.isArray(t)?t.flatMap(t=>function(t){if(!t||"object"!=typeof t)return[];const e=t,r=Ut(String(e.lang??""));return r?[{lang:r,domain:It(String(e.domain??"")),url:String(e.url??"").trim()}]:[]}(t)):[];return r.length?r.flatMap(t=>{const r=Mt(t.url||function(t,e){const r=e[`locale_${t}_baseurl`];return"string"==typeof r?r.trim():""}(t.lang,e)||t.domain);return t.lang&&r?[{lang:t.lang,domain:t.domain||It(r),url:r}]:[]}):function(t){const e=[];for(const r of Object.keys(t)){const n=/^locale_([a-z]+)_baseurl$/.exec(r);if(!n)continue;const i=Mt(String(t[r]??""));i&&e.push({lang:n[1],domain:It(i),url:i})}return e}(e)}(this.kernel.snapshot().locales)}current(){return Ut(String(this.kernel.snapshot().site?.lang||""))}url(t){const e=Ut(t),r=this.all().find(t=>t.lang===e);return r?.url??""}}function Ut(t){return(t.trim().toLowerCase().replaceAll("_","-").split("-")[0]??"").replace(/[^a-z]/g,"")}function Mt(t){const e=t.trim();return e?(/^https?:\/\//i.test(e)?e:`https://${e.replace(/^\/+/,"")}`).replace(/\/+$/,""):""}function It(t){return t.trim().replace(/^https?:\/\//i,"").replace(/\/.*$/,"")}function Tt(t){return`mc_${(String(t??"").trim().split("/").pop()??"").replace(/^@/,"").replace(/[^A-Za-z0-9]+/g,"_").replace(/^_+|_+$/g,"").toUpperCase()}`}function Nt(t){if("undefined"==typeof window||""===t)return"";const e=window.__MIRO_WEB_PLUGINS__;if(!Array.isArray(e))return"";for(const r of e){const e=String(r??"").trim().toLowerCase(),n=e.lastIndexOf("/");if(n<=0)continue;const i=e.slice(0,n),s=e.slice(n+1);if(""!==i&&(s===t||Wt(s)===t))return i}return""}function Wt(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[^A-Za-z0-9]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Et(t){if("undefined"==typeof window)return{};const e=window[t];return e&&"object"==typeof e?e:{}}function Bt(){const t=ge(),e=function(){try{const t=globalThis.__INERTIA_PAGE__;if(t?.props)return t.props}catch{}return function(){if("undefined"==typeof document)return null;const t=document.querySelector("[data-page]")?.getAttribute("data-page");if(!t)return null;try{return JSON.parse(t).props??null}catch{return null}}()}();return e&&t.hydrate(e),t}function Lt(){const t=Bt();return Ht(t),new wt(()=>t.snapshot().page??{},t)}function qt(){const t=Bt();return Ht(t),new ft(()=>t.snapshot().site??{},t)}function zt(t="topbar"){const e=Bt();return Ht(e),new Pt(()=>e.snapshot().menus[t]??{position:t,items:[]},e)}function Gt(){const t=Bt();return Ht(t),new Rt(t)}function Jt(){return Lt().getAssets()}function Ft(t){return function(t,e){const r=Tt(t),n=function(t){const e=String(t??"").trim();if(e.includes("/")){const[t,...r]=e.split("/");return{vendor:t||"miroart",slug:Wt(r.join("/")||e)}}const r=Wt(e);return{vendor:Nt(r)||"miroart",slug:r}}(t);return new Proxy({name:t,key:r,ready:async()=>async function(t){const e=Date.now();for(;Date.now()-e<4e3;){const e=Et(t);if(Object.keys(e).length)return e;await new Promise(t=>setTimeout(t,50))}return Et(t)}(r),api:()=>Et(r),call:(t,...e)=>{const n=Et(r),i=n[t];if("function"!=typeof i)throw new Error(`Missing plugin method: ${t}`);return i.apply(n,e)},request:async(t="/",r={})=>{const i=q().plugins(n.vendor,n.slug,t||"/"),s=new Headers(r.headers);let o=r.body;return void 0!==r.json&&(o=JSON.stringify(r.json)),et(await e.request(i,{...r,headers:s,body:o}))}},{get(t,e,n){if(e in t)return Reflect.get(t,e,n);if("then"===e||e===Symbol.toStringTag)return;const i=Et(r),s=i[String(e)];return"function"==typeof s?s.bind(i):s},has:(t,e)=>e in t||e in Et(r)})}(t,ge())}function Dt(){const e=ge();return{apiBase:t(()=>e.apiBase()),siteBase:t(()=>e.siteBase()),siteRef:t(()=>e.siteRef())}}function Ht(t){try{const r=function(){try{return Zt??null}catch{return null}}();if(!r)return;const n=r.usePage();t.hydrate(e(n))}catch{}}let Zt=null;function Vt(t){return[...new Set(t)]}function Kt(t,e){const r=new Set(t),n=Vt(e).filter(t=>r.has(t));return Vt(t).forEach((t,e,r)=>{n.includes(t)||n.splice(0===e?0:n.indexOf(r[e-1])+1,0,t)}),n}function Qt(t,e,r){const n=e.filter(e=>r.includes(e)&&t.includes(e)),i=t.filter(t=>!n.includes(t));return n.forEach(t=>{i.splice(Math.min(e.indexOf(t),i.length),0,t)}),i}function Xt(t,e){const r=t?.options,n=Array.isArray(r)?r.find(t=>t?.key===e)?.value:r?.[e];if("string"!=typeof n)return n;try{return JSON.parse(n)}catch{return}}function Yt(){if("undefined"==typeof window)return null;const t=window;return t.__miroOrder??=/* @__PURE__ */new Map,t.__miroOrder}import("@inertiajs/vue3").then(t=>{Zt=t}).catch(()=>{Zt=null});const te=/* @__PURE__ */new Set;function ee(t){te.has(t)||te.add(t)}function re(t,e,r){const n=t.filter(t=>t.type!==c);if(0===n.length)return t;const[i]=n;return n.length>1?(ee(`Slot „${r}” ma kilka korzeni, więc nie da się go przeciągnąć.`),t):i.type===a?Array.isArray(i.children)?t.map(t=>t===i?o(a,{key:i.key??void 0},re(i.children,e,r)):t):t:t.map(t=>t===i?u(i,e):t)}const ne=r({name:"MiroOrder",inheritAttrs:!1,props:{name:String,source:[String,Array],items:Array,at:Function,scope:{type:String,default:"page"},locked:{type:Array,default:()=>[]}},setup(t,{slots:e}){const r=Lt(),c=qt(),u=!0===ge().snapshot().editing,l=()=>"site"===t.scope?c.raw():r.raw(),h=n(null),p=()=>Object.keys(e).filter(t=>"default"!==t&&"$stable"!==t&&!t.startsWith("_")),d=(e,r)=>String(t.at?t.at(e,r):r),g=()=>void 0!==t.items?(()=>{const e=(t.items??[]).map(d);return h.value?Kt(e,h.value):Kt(e,e)})():(()=>{const e=p();return Qt(Kt(e,h.value??(t.name?function(t,e){const r=Xt(t,"miro_order"),n=r&&"object"==typeof r?r[e]:null;return Array.isArray(n)?n.filter(t=>"string"==typeof t):[]}(l(),t.name):[])),e,t.locked)})(),f=(()=>{const e=l()?.id;if(!u||null==e)return null;const r="site"===t.scope?{site:e}:{page:e};if(void 0===t.items)return t.name?{kind:"site"===t.scope?"site_blocks":"page_blocks",...r,name:t.name}:null;const n=t.source?function(t){const e=Array.isArray(t)?t:t.split(".").map(t=>/^\d+$/.test(t)?Number(t):t),[r,...n]=e;return"string"==typeof r&&""!==r?{key:r,path:n}:null}(t.source):null;if(!n)return null;const i=function(t,e,r){let n=Xt(t,e);for(const i of r){if(!n||"object"!=typeof n)return null;n=n[i]}return Array.isArray(n)?n:null}(l(),n.key,n.path);return!i||!t.at&&i.length!==t.items.length?(ee(`Lista „${n.key}” różni się od zapisanej. Podaj :at z indeksem w surowej tablicy.`),null):{kind:"site"===t.scope?"site_option":"page_option",...r,key:n.key,path:n.path}})(),m=f?function(t){return"page_blocks"===t.kind||"site_blocks"===t.kind?`${t.kind}:${"page"in t?t.page:t.site}:${t.name}`:`${t.kind}:${"page"in t?t.page:t.site}:${t.key}:${t.path.join(".")}`}(f):"";if(f){const e={id:m,target:f,keys:g,locked:()=>void 0===t.items?t.locked:[],plan:e=>void 0!==t.items?e:Qt(function(t,e){const r=new Set(e);let n=0;return t.map(t=>r.has(t)?e[n++]:t)}(g(),e),p(),t.locked),apply:t=>{h.value=t}};i(()=>Yt()?.set(m,e)),s(()=>{const t=Yt();t?.get(m)===e&&t.delete(m)})}return()=>{const r=g(),n=void 0!==t.items,i=/* @__PURE__ */new Map;n&&t.items.forEach((t,e)=>i.set(d(t,e),t));const s=r.map((s,c)=>{const u={key:s,index:c,first:0===c,last:c===r.length-1},l=n?e.default:e[s],h=l?.(n?{...u,item:i.get(s)}:u)??[],p=f?re(h,{"data-miro-order-group":m,"data-miro-order-key":s},n?`${t.source}[${s}]`:s):h;return o(a,{key:s},p)});return o(a,null,s)}}}),ie=/[⁢⁤][​‌‍⁠]+⁣/,se={b:"strong",i:"em",u:"u",s:"s"};function oe(t){switch(t.type){case"text":return t.value;case"br":return o("br");case"c":return o("span",{style:{color:`var(--color-${t.value})`}},ae(t.children));case"f":return o("span",{style:{fontFamily:`var(--font-${t.value})`}},ae(t.children));default:return o(se[t.type],ae(t.children))}}function ae(t){return t.map(oe)}const ce=t=>{const e=l(t.value),r=ie.test(e);if(!r&&!function(t){return t.includes("[")||t.includes("\n")}(e))return e;const n=ae(y(e));return r?o("span",{"data-miro-rich":"",style:{display:"contents"}},n):1===n.length?n[0]:n};ce.props=["value"],ce.displayName="MiroText";class ue{snap={page:null,site:null,menus:{},locales:[],seo:null,options:{},editing:!1};options;inflight=/* @__PURE__ */new Map;cache=/* @__PURE__ */new Map;constructor(t={}){this.options=t,t.page&&this.hydrate(t.page),St=this,mt=this,Ot=this}hydrate(t){return this.snap=rt(this.snap,function(t){const e={page:null,site:null,menus:{},locales:[],seo:null,options:{},editing:!1};if(!t||"object"!=typeof t)return e;const r=t,n=nt(r.props)?r.props:r;e.page=it(n.page),e.site=it(n.site),e.seo=nt(n.seo)?n.seo:null,e.options=nt(n.options)?n.options:{},e.locales=Array.isArray(n.locales)?n.locales:[],e.editing=void 0!==n.miroEdit&&null!==n.miroEdit;const i=n.menus;if(nt(i))for(const[s,o]of Object.entries(i))e.menus[s]=it(o);return e}(t)),this.snap}snapshot(){return this.snap}apiBase(){return function(t){if(t)return String(t).replace(/\/+$/,"");const e=tt();return e.apiBase?String(e.apiBase).replace(/\/+$/,""):function(){if("undefined"==typeof location)return"";const t=String(location.origin||"").replace(/\/+$/,"");if(t&&"null"!==t)return t;const e=location.hostname||"";return e?`${location.protocol}//${e}`:""}()}(this.options.apiBase)}siteBase(){return function(t){if(t)return String(t).replace(/\/+$/,"");const e=tt();return e.siteBase?String(e.siteBase).replace(/\/+$/,""):"undefined"!=typeof location?location.origin:""}(this.options.siteBase)}siteRef(){return null!=this.options.site&&""!==String(this.options.site)?String(this.options.site):ot(this.snap.site)}async request(t,e={}){const r=String(e.method||"GET").toUpperCase(),n=`${r} ${t}`;if("GET"===r&&this.cache.has(n))return this.cache.get(n);if("GET"===r){const t=this.inflight.get(n);if(t)return t}const i=this.apiBase();if(!i)throw new Error("Remote origin is not configured.");const s=async function(t,e,r={}){const{fetchImpl:n,...i}=r,s=e.startsWith("http")?e:L(t,e),o=n??fetch,a=new Headers(i.headers);a.has("Accept")||a.set("Accept","application/json");const c=await o(s,{...i,headers:a}),u=await c.text();let l=null;if(u)try{l=JSON.parse(u)}catch{l={message:u}}if(!c.ok){const t=new Error(`Request failed (${c.status})`);throw t.status=c.status,t.body=l,t}return l}(i,t,{...e,fetchImpl:this.options.fetch}).then(t=>("GET"===r&&this.cache.set(n,t),t));return"GET"===r&&(this.inflight.set(n,s),s.finally(()=>{this.inflight.delete(n)}).catch(()=>{})),s}rememberPage(t){const e=this.snap.page;e&&String(e.id)===String(t.id)&&(this.snap=rt(this.snap,{page:{...e,...t}}))}rememberSite(t){this.snap=rt(this.snap,{site:{...this.snap.site??{},...t}})}rememberMenu(t){const e=String(t.position||t.uuid||t.id||t.name||"menu");this.snap=rt(this.snap,{menus:{[e]:t}})}}let le=null;function he(t={}){return le=new ue(t),le}function pe(){return le||(le=new ue),le}const de=/* @__PURE__ */Symbol.for("miro.client");function ge(){return h(de,null)??pe()}function fe(t={}){return{install(e,r={}){const n=he({...t,...r});e.provide(de,n),e.component("MiroText",ce),e.component("MiroOrder",ne),function(t){import("@inertiajs/vue3").then(e=>{const r=e.router;r?.page&&t.hydrate(r.page),r?.on?.("success",e=>{const r=e?.detail?.page;r&&t.hydrate(r)}),r?.on?.("navigate",e=>{const r=e?.detail?.page;r&&t.hydrate(r)})}).catch(()=>{})}(n)}}}const me=fe(),ye=me;export{V as Asset,I as AssetName,ct as CollectionCard,K as Gallery,Rt as Locales,Pt as Menu,xt as MenuItem,M as MenuTitle,me as Miro,ne as MiroOrder,ce as MiroText,R as OptionValue,wt as Page,P as PageContent,v as PageSmallTitle,A as PageSubtitle,x as PageSummary,j as PageTitle,p as RICH_COLORS,d as RICH_FONTS,de as SDK_KEY,N as SeoDescription,T as SeoTitle,ft as Site,O as SiteName,C as SiteTitle,_ as TextValue,U as UrlValue,fe as createMiro,he as createRuntime,ye as default,pe as getRuntime,y as parseRichText,S as plainText,Tt as pluginWindowKey,ge as useKernel,Jt as useMiroAssets,Dt as useMiroConfig,Gt as useMiroLocales,zt as useMiroMenu,Lt as useMiroPage,qt as useMiroSite,Ft as usePlugin};
@@ -0,0 +1,54 @@
1
+ import type { PageRecord, SiteRecord } from "./types";
2
+ /** Opcja strony lub site z kolejnością stałych bloków: `{ "home": ["hero", "faq"] }`. */
3
+ export declare const ORDER_OPTION = "miro_order";
4
+ export type OrderPathPart = string | number;
5
+ export type OrderTarget = {
6
+ kind: "page_blocks";
7
+ page: number | string;
8
+ name: string;
9
+ } | {
10
+ kind: "site_blocks";
11
+ site: number | string;
12
+ name: string;
13
+ } | {
14
+ kind: "page_option";
15
+ page: number | string;
16
+ key: string;
17
+ path: OrderPathPart[];
18
+ } | {
19
+ kind: "site_option";
20
+ site: number | string;
21
+ key: string;
22
+ path: OrderPathPart[];
23
+ };
24
+ /** Grupa w ramce edytora. Nakładka czyta ją z `window.__miroOrder`, więc kontrakt nie może się rozjechać. */
25
+ export type OrderGroup = {
26
+ id: string;
27
+ target: OrderTarget;
28
+ /** Wszystkie klucze w obecnej kolejności, także ukrytych bloków. */
29
+ keys: () => string[];
30
+ locked: () => string[];
31
+ /** Nowa kolejność elementów widocznych → lista do zapisu i do `apply`. */
32
+ plan: (shown: string[]) => string[];
33
+ /** Vue przestawia od razu. `null` wraca do kolejności z danych. */
34
+ apply: (keys: string[] | null) => void;
35
+ };
36
+ /**
37
+ * Zapisana kolejność + klucze z szablonu. Klucza, którego szablon już nie ma, nie rysujemy.
38
+ * Nowy klucz staje za swoim poprzednikiem z szablonu, a pierwszy w szablonie idzie na początek.
39
+ */
40
+ export declare function mergeOrder(declared: string[], stored: string[]): string[];
41
+ /** Zablokowany klucz stoi tam, gdzie w szablonie (np. baner z H1 zawsze pierwszy). */
42
+ export declare function pinLocked(order: string[], declared: string[], locked: string[]): string[];
43
+ /** Widoczne klucze w nowej kolejności wchodzą w miejsca, które razem zajmowały. Ukryte stoją. */
44
+ export declare function fillShown(all: string[], shown: string[]): string[];
45
+ export declare function storedOrder(record: PageRecord | SiteRecord | null | undefined, name: string): string[];
46
+ /** `gallery.albums` albo `['gallery', 'albums', 3, 'photos']` → klucz opcji i ścieżka w jej JSON-ie. */
47
+ export declare function parseSource(source: string | OrderPathPart[]): {
48
+ key: string;
49
+ path: OrderPathPart[];
50
+ } | null;
51
+ /** Tablica pod ścieżką w opcji albo `null`, gdy jej nie ma. */
52
+ export declare function sourceList(record: PageRecord | SiteRecord | null | undefined, key: string, path: OrderPathPart[]): unknown[] | null;
53
+ export declare function orderGroupId(target: OrderTarget): string;
54
+ export declare function orderRegistry(): Map<string, OrderGroup> | null;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Formatowanie w jednym stringu pola: `[b]`, `[i]`, `[u]`, `[s]`, `[c=primary]`, `[f=serif]`.
3
+ * Nie ma tu HTML-a: wynik to drzewo, z którego `MiroText` buduje węzły przez `h()`.
4
+ * Te same reguły są w nakładce edytora (`web/app/Support/VisualEdit/overlay.js`) i w
5
+ * `web/app/Support/RichInline.php`.
6
+ */
7
+ export declare const RICH_COLORS: readonly ["primary", "secondary", "accent", "neutral", "base-100", "base-content", "info", "success", "warning", "error"];
8
+ export declare const RICH_FONTS: readonly ["sans", "serif"];
9
+ export type RichColor = (typeof RICH_COLORS)[number];
10
+ export type RichFont = (typeof RICH_FONTS)[number];
11
+ export type RichNode = {
12
+ type: "text";
13
+ value: string;
14
+ } | {
15
+ type: "br";
16
+ } | {
17
+ type: "b" | "i" | "u" | "s";
18
+ children: RichNode[];
19
+ } | {
20
+ type: "c";
21
+ value: RichColor;
22
+ children: RichNode[];
23
+ } | {
24
+ type: "f";
25
+ value: RichFont;
26
+ children: RichNode[];
27
+ };
28
+ /**
29
+ * Nie rzuca wyjątku dla żadnego wejścia. Coś, co nie jest znanym znacznikiem z dozwoloną
30
+ * wartością, zostaje zwykłym tekstem. Niezamknięty znacznik kończy się z końcem wartości.
31
+ */
32
+ export declare function parseRichText(value: unknown): RichNode[];
33
+ /** Do atrybutów (`alt`, `aria-label`), `<title>` i liczenia znaków: bez znaczników, `\n` zostaje. */
34
+ export declare function plainText(value: unknown): string;
35
+ /** Czy wartość w ogóle wymaga drzewa. Reszta to jeden węzeł tekstowy, jak przy `{{ }}`. */
36
+ export declare function needsRichRender(raw: string): boolean;
package/dist/types.d.ts CHANGED
@@ -84,6 +84,8 @@ export type Snapshot = {
84
84
  locales: unknown[];
85
85
  seo: Dict | null;
86
86
  options: Dict;
87
+ /** Prop `miroEdit`: strona jest w ramce edytora wizualnego. */
88
+ editing: boolean;
87
89
  };
88
90
  export type ClientOptions = {
89
91
  apiBase?: string;
package/dist/values.d.ts CHANGED
@@ -10,6 +10,8 @@ export declare class TextValue extends String {
10
10
  decode(): string;
11
11
  cleanContent(): string;
12
12
  stripHtml(): string;
13
+ /** Bez znaczników `[b]`, `[c=…]`: do atrybutów i `<title>`. Nowe linie zostają. */
14
+ plain(): string;
13
15
  excerpt(length?: number): string;
14
16
  firstParagraph(): string;
15
17
  isEmpty(): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miroart/sdk",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Vue 3 client for preloaded page data and a remote JSON origin.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",