@inpageedit/core 0.13.1 → 0.14.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.
Files changed (74) hide show
  1. package/LICENSE +20 -20
  2. package/dist/{BasePlugin-Bf2UuIHF.js → BasePlugin-CU8beLYu.js} +17 -26
  3. package/dist/BasePlugin-CU8beLYu.js.map +1 -0
  4. package/dist/IconQuickEdit-CMCQncyj.js.map +1 -1
  5. package/dist/InputBox-nQKtiWtZ.js.map +1 -1
  6. package/dist/{PluginPrefSync-Dn1Xsiqz.js → PluginPrefSync-B-gPsC2n.js} +124 -128
  7. package/dist/PluginPrefSync-B-gPsC2n.js.map +1 -0
  8. package/dist/PluginStoreApp-CDteVCBG.js +453 -0
  9. package/dist/PluginStoreApp-CDteVCBG.js.map +1 -0
  10. package/dist/{endpoints-DgyuoRZd.js → Preferences-85Q9FAmb.js} +589 -565
  11. package/dist/Preferences-85Q9FAmb.js.map +1 -0
  12. package/dist/WatchlistAction-BbNAyryN.js.map +1 -1
  13. package/dist/components/index.js.map +1 -1
  14. package/dist/{index-DqA6EAM6.js → index-19CgGBI0.js} +1419 -921
  15. package/dist/index-19CgGBI0.js.map +1 -0
  16. package/dist/{index-B7c6jL9x.js → index-BKIf3i0I.js} +146 -137
  17. package/dist/index-BKIf3i0I.js.map +1 -0
  18. package/dist/{index-CCRMmnwk.js → index-BrtFJ-M0.js} +67 -66
  19. package/dist/index-BrtFJ-M0.js.map +1 -0
  20. package/dist/index-CG38LlAh.js.map +1 -1
  21. package/dist/index-CM_6yF2v.js.map +1 -1
  22. package/dist/index-CQr1DJ8n.js +173 -0
  23. package/dist/index-CQr1DJ8n.js.map +1 -0
  24. package/dist/{index-BQ-cHWkJ.js → index-CVTBg5O9.js} +66 -48
  25. package/dist/index-CVTBg5O9.js.map +1 -0
  26. package/dist/index-Ci82vLXg.js +179 -0
  27. package/dist/index-Ci82vLXg.js.map +1 -0
  28. package/dist/{index-BwdWyHLe.js → index-D3iZhRMJ.js} +93 -93
  29. package/dist/index-D3iZhRMJ.js.map +1 -0
  30. package/dist/index-DD5CVCfD.js.map +1 -1
  31. package/dist/{index-BJ7_Q1mB.js → index-DGtq21uW.js} +17 -16
  32. package/dist/index-DGtq21uW.js.map +1 -0
  33. package/dist/index-DXL7teb0.js +394 -0
  34. package/dist/index-DXL7teb0.js.map +1 -0
  35. package/dist/index-DjPpAyfE.js +116 -0
  36. package/dist/index-DjPpAyfE.js.map +1 -0
  37. package/dist/{index-eSlbrNqF.js → index-rpiO9fpc.js} +4 -5
  38. package/dist/{index-eSlbrNqF.js.map → index-rpiO9fpc.js.map} +1 -1
  39. package/dist/index.d.ts +318 -25
  40. package/dist/index.js +32 -26
  41. package/dist/index.js.map +1 -1
  42. package/dist/makeCallable-LDU0xZMJ.js.map +1 -1
  43. package/dist/models/index.js +174 -154
  44. package/dist/models/index.js.map +1 -1
  45. package/dist/noop-ClDc6zv4.js.map +1 -1
  46. package/dist/plugins/index.js +10 -10
  47. package/dist/services/index.js +1 -1
  48. package/dist/style.css +1 -1
  49. package/dist/vueHooks-l04s8cIl.js.map +1 -1
  50. package/lib/index.umd.js +20 -12
  51. package/lib/index.umd.js.map +1 -1
  52. package/lib/style.css +1 -1
  53. package/package.json +4 -4
  54. package/dist/BasePlugin-Bf2UuIHF.js.map +0 -1
  55. package/dist/PluginPrefSync-Dn1Xsiqz.js.map +0 -1
  56. package/dist/PluginStoreApp-CpOLArL7.js +0 -452
  57. package/dist/PluginStoreApp-CpOLArL7.js.map +0 -1
  58. package/dist/Preferences-DS4-CFWe.js +0 -9
  59. package/dist/Preferences-DS4-CFWe.js.map +0 -1
  60. package/dist/endpoints-DgyuoRZd.js.map +0 -1
  61. package/dist/index-2RfILgXm.js +0 -180
  62. package/dist/index-2RfILgXm.js.map +0 -1
  63. package/dist/index-B7c6jL9x.js.map +0 -1
  64. package/dist/index-BJ7_Q1mB.js.map +0 -1
  65. package/dist/index-BNh95-x2.js +0 -115
  66. package/dist/index-BNh95-x2.js.map +0 -1
  67. package/dist/index-BQ-cHWkJ.js.map +0 -1
  68. package/dist/index-BwdWyHLe.js.map +0 -1
  69. package/dist/index-CCRMmnwk.js.map +0 -1
  70. package/dist/index-CnIpUF9x.js +0 -173
  71. package/dist/index-CnIpUF9x.js.map +0 -1
  72. package/dist/index-CyG7_IYz.js +0 -394
  73. package/dist/index-CyG7_IYz.js.map +0 -1
  74. package/dist/index-DqA6EAM6.js.map +0 -1
package/lib/index.umd.js CHANGED
@@ -1,7 +1,15 @@
1
- (function(J,re){typeof exports=="object"&&typeof module<"u"?re(exports):typeof define=="function"&&define.amd?define(["exports"],re):(J=typeof globalThis<"u"?globalThis:J||self,re(J.InPageEditBundle={}))})(this,(function(J){"use strict";var Yv=Object.defineProperty;var Sf=J=>{throw TypeError(J)};var Qv=(J,re,Se)=>re in J?Yv(J,re,{enumerable:!0,configurable:!0,writable:!0,value:Se}):J[re]=Se;var F=(J,re,Se)=>Qv(J,typeof re!="symbol"?re+"":re,Se),sa=(J,re,Se)=>re.has(J)||Sf("Cannot "+Se);var X=(J,re,Se)=>(sa(J,re,"read from private field"),Se?Se.call(J):re.get(J)),Hi=(J,re,Se)=>re.has(J)?Sf("Cannot add the same private member more than once"):re instanceof WeakSet?re.add(J):re.set(J,Se),Qe=(J,re,Se,K)=>(sa(J,re,"write to private field"),K?K.call(J,Se):re.set(J,Se),Se),lt=(J,re,Se)=>(sa(J,re,"access private method"),Se);var at,ji,pi,Ui,Fi,Bi,qi,_e,it,fe,Ve,oa,Cf,aa,Rf,Af,$t,If,Of,Tf,Lf,In,pt,mi;const re=()=>{let t,e;return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}};Promise.withResolvers||(Promise.withResolvers=re);var Se=Object.defineProperty,K=(t,e)=>Se(t,"name",{value:e,configurable:!0});function Nf(){}K(Nf,"noop");function be(t){return t==null}K(be,"isNullable");function Mf(t){return!be(t)}K(Mf,"isNonNullable");function Mn(t){return t&&typeof t=="object"&&!Array.isArray(t)}K(Mn,"isPlainObject");function la(t,e){return Object.fromEntries(Object.entries(t).filter(([i,n])=>e(i,n)))}K(la,"filterKeys");function It(t,e){return Object.fromEntries(Object.entries(t).map(([i,n])=>[i,e(n,i)]))}K(It,"mapValues");function ca(t,e,i){if(!e)return{...t};const n={};for(const r of e)(i||t[r]!==void 0)&&(n[r]=t[r]);return n}K(ca,"pick");function Df(t,e){if(!e)return{...t};const i={...t};for(const n of e)Reflect.deleteProperty(i,n);return i}K(Df,"omit");function Ie(t,e,i){return Object.defineProperty(t,e,{writable:!0,value:i,enumerable:!1})}K(Ie,"defineProperty");function jf(t,e){return e.every(i=>t.includes(i))}K(jf,"contain");function Uf(t,e){return t.filter(i=>e.includes(i))}K(Uf,"intersection");function Ff(t,e){return t.filter(i=>!e.includes(i))}K(Ff,"difference");function Bf(t,e){return Array.from(new Set([...t,...e]))}K(Bf,"union");function qf(t){return[...new Set(t)]}K(qf,"deduplicate");function zt(t,e){const i=t?.indexOf(e);return i>=0?(t.splice(i,1),!0):!1}K(zt,"remove");function Hf(t){return Array.isArray(t)?t:be(t)?[]:[t]}K(Hf,"makeArray");function Kt(t,e){return arguments.length===1?i=>Kt(t,i):t in globalThis&&e instanceof globalThis[t]||Object.prototype.toString.call(e).slice(8,-1)===t}K(Kt,"is");function zi(t){return Kt("ArrayBuffer",t)||Kt("SharedArrayBuffer",t)}K(zi,"isArrayBufferLike");function ua(t){return zi(t)||ArrayBuffer.isView(t)}K(ua,"isArrayBufferSource");var gt;(t=>{t.is=zi,t.isSource=ua;function e(o){return ArrayBuffer.isView(o)?o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength):o}t.fromSource=e,K(e,"fromSource");function i(o){if(typeof Buffer<"u")return Buffer.from(o).toString("base64");let a="";const l=new Uint8Array(o);for(let c=0;c<l.byteLength;c++)a+=String.fromCharCode(l[c]);return btoa(a)}t.toBase64=i,K(i,"toBase64");function n(o){return typeof Buffer<"u"?e(Buffer.from(o,"base64")):Uint8Array.from(atob(o),a=>a.charCodeAt(0))}t.fromBase64=n,K(n,"fromBase64");function r(o){return typeof Buffer<"u"?Buffer.from(o).toString("hex"):Array.from(new Uint8Array(o),a=>a.toString(16).padStart(2,"0")).join("")}t.toHex=r,K(r,"toHex");function s(o){if(typeof Buffer<"u")return e(Buffer.from(o,"hex"));const a=o.length%2===0?o:o.slice(0,o.length-1),l=[];for(let c=0;c<a.length;c+=2)l.push(parseInt(`${a[c]}${a[c+1]}`,16));return Uint8Array.from(l).buffer}t.fromHex=s,K(s,"fromHex")})(gt||(gt={})),gt.fromBase64,gt.toBase64,gt.fromHex,gt.toHex;function Dn(t,e=new Map){if(!t||typeof t!="object")return t;if(Kt("Date",t))return new Date(t.valueOf());if(Kt("RegExp",t))return new RegExp(t.source,t.flags);if(zi(t))return t.slice(0);if(ArrayBuffer.isView(t))return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);const i=e.get(t);if(i)return i;if(Array.isArray(t)){const r=[];return e.set(t,r),t.forEach((s,o)=>{r[o]=Reflect.apply(Dn,null,[s,e])}),r}const n=Object.create(Object.getPrototypeOf(t));e.set(t,n);for(const r of Reflect.ownKeys(t)){const s={...Reflect.getOwnPropertyDescriptor(t,r)};"value"in s&&(s.value=Reflect.apply(Dn,null,[s.value,e])),Reflect.defineProperty(n,r,s)}return n}K(Dn,"clone");function Zt(t,e,i){if(t===e||!i&&be(t)&&be(e))return!0;if(typeof t!=typeof e||typeof t!="object"||!t||!e)return!1;function n(r,s){return r(t)?r(e)?s(t,e):!1:r(e)?!1:void 0}return K(n,"check"),n(Array.isArray,(r,s)=>r.length===s.length&&r.every((o,a)=>Zt(o,s[a])))??n(Kt("Date"),(r,s)=>r.valueOf()===s.valueOf())??n(Kt("RegExp"),(r,s)=>r.source===s.source&&r.flags===s.flags)??n(zi,(r,s)=>{if(r.byteLength!==s.byteLength)return!1;const o=new Uint8Array(r),a=new Uint8Array(s);for(let l=0;l<o.length;l++)if(o[l]!==a[l])return!1;return!0})??Object.keys({...t,...e}).every(r=>Zt(t[r],e[r],i))}K(Zt,"deepEqual");function zf(t){return t.charAt(0).toUpperCase()+t.slice(1)}K(zf,"capitalize");function Kf(t){return t.charAt(0).toLowerCase()+t.slice(1)}K(Kf,"uncapitalize");function Wf(t){return t.replace(/[_-][a-z]/g,e=>e.slice(1).toUpperCase())}K(Wf,"camelCase");function Xr(t,e,i){const n=[];let r=0;for(let s=0;s<t.length;s++){const o=t.charCodeAt(s);if(o>=65&&o<=90){if(r===1){const a=t.charCodeAt(s+1);a>=97&&a<=122&&n.push(i),n.push(o+32)}else r!==0&&n.push(i),n.push(o+32);r=1}else o>=97&&o<=122?(n.push(o),r=2):e.includes(o)?(r!==0&&n.push(i),r=0):n.push(o)}return String.fromCharCode(...n)}K(Xr,"tokenize");function Vf(t){return Xr(t,[45,95],45)}K(Vf,"paramCase");function Gf(t){return Xr(t,[45,95],95)}K(Gf,"snakeCase");function Yf(t){return typeof t!="string"?`[${t.toString()}]`:/^[a-z_$][\w$]*$/i.test(t)?`.${t}`:`[${JSON.stringify(t)}]`}K(Yf,"formatProperty");function fa(t){return t.replace(/\/$/,"")}K(fa,"trimSlash");function Qf(t){return t.startsWith("/")||(t="/"+t),fa(t)}K(Qf,"sanitize");var da;(t=>{t.millisecond=1,t.second=1e3,t.minute=t.second*60,t.hour=t.minute*60,t.day=t.hour*24,t.week=t.day*7;let e=new Date().getTimezoneOffset();function i(p){e=p}t.setTimezoneOffset=i,K(i,"setTimezoneOffset");function n(){return e}t.getTimezoneOffset=n,K(n,"getTimezoneOffset");function r(p=new Date,f){return typeof p=="number"&&(p=new Date(p)),f===void 0&&(f=e),Math.floor((p.valueOf()/t.minute-f)/1440)}t.getDateNumber=r,K(r,"getDateNumber");function s(p,f){const _=new Date(p*t.day);return f===void 0&&(f=e),new Date(+_+f*t.minute)}t.fromDateNumber=s,K(s,"fromDateNumber");const o=/\d+(?:\.\d+)?/.source,a=new RegExp(`^${["w(?:eek(?:s)?)?","d(?:ay(?:s)?)?","h(?:our(?:s)?)?","m(?:in(?:ute)?(?:s)?)?","s(?:ec(?:ond)?(?:s)?)?"].map(p=>`(${o}${p})?`).join("")}$`);function l(p){const f=a.exec(p);return f?(parseFloat(f[1])*t.week||0)+(parseFloat(f[2])*t.day||0)+(parseFloat(f[3])*t.hour||0)+(parseFloat(f[4])*t.minute||0)+(parseFloat(f[5])*t.second||0):0}t.parseTime=l,K(l,"parseTime");function c(p){const f=l(p);return f?p=Date.now()+f:/^\d{1,2}(:\d{1,2}){1,2}$/.test(p)?p=`${new Date().toLocaleDateString()}-${p}`:/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(p)&&(p=`${new Date().getFullYear()}-${p}`),p?new Date(p):new Date}t.parseDate=c,K(c,"parseDate");function u(p){const f=Math.abs(p);return f>=t.day-t.hour/2?Math.round(p/t.day)+"d":f>=t.hour-t.minute/2?Math.round(p/t.hour)+"h":f>=t.minute-t.second/2?Math.round(p/t.minute)+"m":f>=t.second?Math.round(p/t.second)+"s":p+"ms"}t.format=u,K(u,"format");function d(p,f=2){return p.toString().padStart(f,"0")}t.toDigits=d,K(d,"toDigits");function h(p,f=new Date){return p.replace("yyyy",f.getFullYear().toString()).replace("yy",f.getFullYear().toString().slice(2)).replace("MM",d(f.getMonth()+1)).replace("dd",d(f.getDate())).replace("hh",d(f.getHours())).replace("mm",d(f.getMinutes())).replace("ss",d(f.getSeconds())).replace("SSS",d(f.getMilliseconds(),3))}t.template=h,K(h,"template")})(da||(da={}));var Jf=Object.defineProperty,W=(t,e)=>Jf(t,"name",{value:e,configurable:!0}),M={shadow:Symbol.for("cordis.shadow"),receiver:Symbol.for("cordis.receiver"),original:Symbol.for("cordis.original"),store:Symbol.for("cordis.store"),events:Symbol.for("cordis.events"),static:Symbol.for("cordis.static"),filter:Symbol.for("cordis.filter"),expose:Symbol.for("cordis.expose"),isolate:Symbol.for("cordis.isolate"),internal:Symbol.for("cordis.internal"),intercept:Symbol.for("cordis.intercept"),setup:Symbol.for("cordis.setup"),invoke:Symbol.for("cordis.invoke"),extend:Symbol.for("cordis.extend"),tracker:Symbol.for("cordis.tracker"),provide:Symbol.for("cordis.provide"),immediate:Symbol.for("cordis.immediate")},Xf=function*(){}.constructor,ha=async function*(){}.constructor;function Zr(t){return!(!t.prototype||t instanceof Xf||ha!==Function&&t instanceof ha)}W(Zr,"isConstructor");function Ki(t,e){const i=t.Config||t.schema;return i&&t.schema!==!1&&(e=i(e)),e??{}}W(Ki,"resolveConfig");function pa(t){return[Map,Set,Date,Promise].some(e=>t instanceof e)}W(pa,"isUnproxyable");function es(t,e){if(t===Object.prototype)return e;const i=Object.create(es(Object.getPrototypeOf(t),e));for(const n of Reflect.ownKeys(t))Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n));return i}W(es,"joinPrototype");function ts(t){return t&&(typeof t=="object"||typeof t=="function")}W(ts,"isObject");function yt(t,e,i){if(!ts(e))return e;if(Object.hasOwn(e,M.shadow))return Object.getPrototypeOf(e);const n=e[M.tracker];return n?Un(t,e,n,i):e}W(yt,"getTraceable");function Wi(t,e){return e?new Proxy(t,{get:W((i,n,r)=>n in e&&n!=="constructor"?Reflect.get(e,n,r):Reflect.get(i,n,r),"get"),set:W((i,n,r,s)=>n in e&&n!=="constructor"?Reflect.set(e,n,r,s):Reflect.set(i,n,r,s),"set")}):t}W(Wi,"withProps");function jn(t,e,i){return Wi(t,Object.defineProperty(Object.create(null),e,{value:i,writable:!1}))}W(jn,"withProp");function is(t,e,i,n){if(!i)return n;const r=Reflect.getOwnPropertyDescriptor(e,i)?.value;return r?jn(n,i,t.extend({[M.shadow]:r})):n}W(is,"createShadow");function ma(t,e,i,n){return new Proxy(e,{apply:W((r,s,o)=>(s===i&&(s=n),o=o.map(a=>typeof a!="function"||a[M.original]?a:new Proxy(a,{get:W((l,c,u)=>{if(c===M.original)return l;const d=Reflect.get(l,c,u);return c==="toString"&&d===Function.prototype.toString?function(...h){return Reflect.apply(d,this===u?l:this,h)}:d},"get"),apply:W((l,c,u)=>Reflect.apply(l,yt(t,c),u.map(d=>yt(t,d))),"apply"),construct:W((l,c,u)=>Reflect.construct(l,c.map(d=>yt(t,d)),u),"construct")})),yt(t,Reflect.apply(r,s,o))),"apply")})}W(ma,"createShadowMethod");function Un(t,e,i,n){t[M.shadow]&&(t=Object.getPrototypeOf(t));const r=new Proxy(e,{get:W((s,o,a)=>{if(o===M.original)return s;if(o===i.property)return t;if(typeof o=="symbol")return Reflect.get(s,o,a);if(i.associate&&t[M.internal][`${i.associate}.${o}`])return Reflect.get(t,`${i.associate}.${o}`,jn(t,M.receiver,a));const l=is(t,s,i.property,a),c=Reflect.get(s,o,l),u=c?.[M.tracker];return u?Un(t,c,u):!n&&typeof c=="function"?ma(t,c,a,l):c},"get"),set:W((s,o,a,l)=>{if(o===M.original||o===i.property)return!1;if(typeof o=="symbol")return Reflect.set(s,o,a,l);if(i.associate&&t[M.internal][`${i.associate}.${o}`])return Reflect.set(t,`${i.associate}.${o}`,a,jn(t,M.receiver,l));const c=is(t,s,i.property,l);return Reflect.set(s,o,a,c)},"set"),apply:W((s,o,a)=>ns(r,s,o,a),"apply")});return r}W(Un,"createTraceable");function ns(t,e,i,n){return e[M.invoke]?e[M.invoke].apply(t,n):Reflect.apply(e,i,n)}W(ns,"applyTraceable");function rs(t,e,i){const n=W(function(...r){const s=Un(n.ctx,n,i);return ns(s,n,this,r)},"self");return Ie(n,"name",t),Object.setPrototypeOf(n,e)}W(rs,"createCallable");var Zf=(at=class{constructor(e){this.ctx=e,Ie(this,M.tracker,{associate:"reflect",property:"ctx"}),this._mixin("reflect",["get","set","provide","accessor","mixin","alias"]),this._mixin("scope",["config","runtime","effect","collect","accept","decline"]),this._mixin("registry",["using","inject","plugin"]),this._mixin("lifecycle",["on","once","parallel","emit","serial","bail","start","stop"])}static resolveInject(e,i){let n=e[M.internal][i];for(;n?.type==="alias";)i=n.name,n=e[M.internal][i];return[i,n]}static checkInject(e,i,n){if(e=e[M.shadow]??e,["prototype","then","registry","lifecycle"].includes(i)||i[0]==="$"||i[0]==="_"||!e.runtime.plugin||e.bail(e,"internal/inject",i))return;const r=n.stack.split(`
1
+ (function(W,re){typeof exports=="object"&&typeof module<"u"?re(exports):typeof define=="function"&&define.amd?define(["exports"],re):(W=typeof globalThis<"u"?globalThis:W||self,re(W.InPageEditBundle={}))})(this,(function(W){"use strict";var Lw=Object.defineProperty;var Uf=W=>{throw TypeError(W)};var Mw=(W,re,$e)=>re in W?Lw(W,re,{enumerable:!0,configurable:!0,writable:!0,value:$e}):W[re]=$e;var B=(W,re,$e)=>Mw(W,typeof re!="symbol"?re+"":re,$e),da=(W,re,$e)=>re.has(W)||Uf("Cannot "+$e);var ae=(W,re,$e)=>(da(W,re,"read from private field"),$e?$e.call(W):re.get(W)),Wi=(W,re,$e)=>re.has(W)?Uf("Cannot add the same private member more than once"):re instanceof WeakSet?re.add(W):re.set(W,$e),Te=(W,re,$e,G)=>(da(W,re,"write to private field"),G?G.call(W,$e):re.set(W,$e),$e),ot=(W,re,$e)=>(da(W,re,"access private method"),$e);var ut,Fi,mi,Bi,qi,Hi,zi,Se,rt,he,Qe,ha,zf,pa,Kf,Wf,ft,Gf,Vf,Yf,Qf,Xf,Nn,yt,yi;const re=()=>{let t,e;return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}};Promise.withResolvers||(Promise.withResolvers=re);var $e=Object.defineProperty,G=(t,e)=>$e(t,"name",{value:e,configurable:!0});function Jf(){}G(Jf,"noop");function we(t){return t==null}G(we,"isNullable");function Zf(t){return!we(t)}G(Zf,"isNonNullable");function Fn(t){return t&&typeof t=="object"&&!Array.isArray(t)}G(Fn,"isPlainObject");function ga(t,e){return Object.fromEntries(Object.entries(t).filter(([i,n])=>e(i,n)))}G(ga,"filterKeys");function Mt(t,e){return Object.fromEntries(Object.entries(t).map(([i,n])=>[i,e(n,i)]))}G(Mt,"mapValues");function ma(t,e,i){if(!e)return{...t};const n={};for(const r of e)(i||t[r]!==void 0)&&(n[r]=t[r]);return n}G(ma,"pick");function ed(t,e){if(!e)return{...t};const i={...t};for(const n of e)Reflect.deleteProperty(i,n);return i}G(ed,"omit");function Le(t,e,i){return Object.defineProperty(t,e,{writable:!0,value:i,enumerable:!1})}G(Le,"defineProperty");function td(t,e){return e.every(i=>t.includes(i))}G(td,"contain");function id(t,e){return t.filter(i=>e.includes(i))}G(id,"intersection");function nd(t,e){return t.filter(i=>!e.includes(i))}G(nd,"difference");function rd(t,e){return Array.from(new Set([...t,...e]))}G(rd,"union");function sd(t){return[...new Set(t)]}G(sd,"deduplicate");function Kt(t,e){const i=t?.indexOf(e);return i>=0?(t.splice(i,1),!0):!1}G(Kt,"remove");function od(t){return Array.isArray(t)?t:we(t)?[]:[t]}G(od,"makeArray");function Wt(t,e){return arguments.length===1?i=>Wt(t,i):t in globalThis&&e instanceof globalThis[t]||Object.prototype.toString.call(e).slice(8,-1)===t}G(Wt,"is");function Gi(t){return Wt("ArrayBuffer",t)||Wt("SharedArrayBuffer",t)}G(Gi,"isArrayBufferLike");function ya(t){return Gi(t)||ArrayBuffer.isView(t)}G(ya,"isArrayBufferSource");var bt;(t=>{t.is=Gi,t.isSource=ya;function e(o){return ArrayBuffer.isView(o)?o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength):o}t.fromSource=e,G(e,"fromSource");function i(o){if(typeof Buffer<"u")return Buffer.from(o).toString("base64");let a="";const l=new Uint8Array(o);for(let c=0;c<l.byteLength;c++)a+=String.fromCharCode(l[c]);return btoa(a)}t.toBase64=i,G(i,"toBase64");function n(o){return typeof Buffer<"u"?e(Buffer.from(o,"base64")):Uint8Array.from(atob(o),a=>a.charCodeAt(0))}t.fromBase64=n,G(n,"fromBase64");function r(o){return typeof Buffer<"u"?Buffer.from(o).toString("hex"):Array.from(new Uint8Array(o),a=>a.toString(16).padStart(2,"0")).join("")}t.toHex=r,G(r,"toHex");function s(o){if(typeof Buffer<"u")return e(Buffer.from(o,"hex"));const a=o.length%2===0?o:o.slice(0,o.length-1),l=[];for(let c=0;c<a.length;c+=2)l.push(parseInt(`${a[c]}${a[c+1]}`,16));return Uint8Array.from(l).buffer}t.fromHex=s,G(s,"fromHex")})(bt||(bt={})),bt.fromBase64,bt.toBase64,bt.fromHex,bt.toHex;function Bn(t,e=new Map){if(!t||typeof t!="object")return t;if(Wt("Date",t))return new Date(t.valueOf());if(Wt("RegExp",t))return new RegExp(t.source,t.flags);if(Gi(t))return t.slice(0);if(ArrayBuffer.isView(t))return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);const i=e.get(t);if(i)return i;if(Array.isArray(t)){const r=[];return e.set(t,r),t.forEach((s,o)=>{r[o]=Reflect.apply(Bn,null,[s,e])}),r}const n=Object.create(Object.getPrototypeOf(t));e.set(t,n);for(const r of Reflect.ownKeys(t)){const s={...Reflect.getOwnPropertyDescriptor(t,r)};"value"in s&&(s.value=Reflect.apply(Bn,null,[s.value,e])),Reflect.defineProperty(n,r,s)}return n}G(Bn,"clone");function ii(t,e,i){if(t===e||!i&&we(t)&&we(e))return!0;if(typeof t!=typeof e||typeof t!="object"||!t||!e)return!1;function n(r,s){return r(t)?r(e)?s(t,e):!1:r(e)?!1:void 0}return G(n,"check"),n(Array.isArray,(r,s)=>r.length===s.length&&r.every((o,a)=>ii(o,s[a])))??n(Wt("Date"),(r,s)=>r.valueOf()===s.valueOf())??n(Wt("RegExp"),(r,s)=>r.source===s.source&&r.flags===s.flags)??n(Gi,(r,s)=>{if(r.byteLength!==s.byteLength)return!1;const o=new Uint8Array(r),a=new Uint8Array(s);for(let l=0;l<o.length;l++)if(o[l]!==a[l])return!1;return!0})??Object.keys({...t,...e}).every(r=>ii(t[r],e[r],i))}G(ii,"deepEqual");function ad(t){return t.charAt(0).toUpperCase()+t.slice(1)}G(ad,"capitalize");function ld(t){return t.charAt(0).toLowerCase()+t.slice(1)}G(ld,"uncapitalize");function cd(t){return t.replace(/[_-][a-z]/g,e=>e.slice(1).toUpperCase())}G(cd,"camelCase");function ns(t,e,i){const n=[];let r=0;for(let s=0;s<t.length;s++){const o=t.charCodeAt(s);if(o>=65&&o<=90){if(r===1){const a=t.charCodeAt(s+1);a>=97&&a<=122&&n.push(i),n.push(o+32)}else r!==0&&n.push(i),n.push(o+32);r=1}else o>=97&&o<=122?(n.push(o),r=2):e.includes(o)?(r!==0&&n.push(i),r=0):n.push(o)}return String.fromCharCode(...n)}G(ns,"tokenize");function ud(t){return ns(t,[45,95],45)}G(ud,"paramCase");function fd(t){return ns(t,[45,95],95)}G(fd,"snakeCase");function dd(t){return typeof t!="string"?`[${t.toString()}]`:/^[a-z_$][\w$]*$/i.test(t)?`.${t}`:`[${JSON.stringify(t)}]`}G(dd,"formatProperty");function ba(t){return t.replace(/\/$/,"")}G(ba,"trimSlash");function hd(t){return t.startsWith("/")||(t="/"+t),ba(t)}G(hd,"sanitize");var va;(t=>{t.millisecond=1,t.second=1e3,t.minute=t.second*60,t.hour=t.minute*60,t.day=t.hour*24,t.week=t.day*7;let e=new Date().getTimezoneOffset();function i(p){e=p}t.setTimezoneOffset=i,G(i,"setTimezoneOffset");function n(){return e}t.getTimezoneOffset=n,G(n,"getTimezoneOffset");function r(p=new Date,d){return typeof p=="number"&&(p=new Date(p)),d===void 0&&(d=e),Math.floor((p.valueOf()/t.minute-d)/1440)}t.getDateNumber=r,G(r,"getDateNumber");function s(p,d){const w=new Date(p*t.day);return d===void 0&&(d=e),new Date(+w+d*t.minute)}t.fromDateNumber=s,G(s,"fromDateNumber");const o=/\d+(?:\.\d+)?/.source,a=new RegExp(`^${["w(?:eek(?:s)?)?","d(?:ay(?:s)?)?","h(?:our(?:s)?)?","m(?:in(?:ute)?(?:s)?)?","s(?:ec(?:ond)?(?:s)?)?"].map(p=>`(${o}${p})?`).join("")}$`);function l(p){const d=a.exec(p);return d?(parseFloat(d[1])*t.week||0)+(parseFloat(d[2])*t.day||0)+(parseFloat(d[3])*t.hour||0)+(parseFloat(d[4])*t.minute||0)+(parseFloat(d[5])*t.second||0):0}t.parseTime=l,G(l,"parseTime");function c(p){const d=l(p);return d?p=Date.now()+d:/^\d{1,2}(:\d{1,2}){1,2}$/.test(p)?p=`${new Date().toLocaleDateString()}-${p}`:/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(p)&&(p=`${new Date().getFullYear()}-${p}`),p?new Date(p):new Date}t.parseDate=c,G(c,"parseDate");function u(p){const d=Math.abs(p);return d>=t.day-t.hour/2?Math.round(p/t.day)+"d":d>=t.hour-t.minute/2?Math.round(p/t.hour)+"h":d>=t.minute-t.second/2?Math.round(p/t.minute)+"m":d>=t.second?Math.round(p/t.second)+"s":p+"ms"}t.format=u,G(u,"format");function f(p,d=2){return p.toString().padStart(d,"0")}t.toDigits=f,G(f,"toDigits");function h(p,d=new Date){return p.replace("yyyy",d.getFullYear().toString()).replace("yy",d.getFullYear().toString().slice(2)).replace("MM",f(d.getMonth()+1)).replace("dd",f(d.getDate())).replace("hh",f(d.getHours())).replace("mm",f(d.getMinutes())).replace("ss",f(d.getSeconds())).replace("SSS",f(d.getMilliseconds(),3))}t.template=h,G(h,"template")})(va||(va={}));var pd=Object.defineProperty,V=(t,e)=>pd(t,"name",{value:e,configurable:!0}),D={shadow:Symbol.for("cordis.shadow"),receiver:Symbol.for("cordis.receiver"),original:Symbol.for("cordis.original"),store:Symbol.for("cordis.store"),events:Symbol.for("cordis.events"),static:Symbol.for("cordis.static"),filter:Symbol.for("cordis.filter"),expose:Symbol.for("cordis.expose"),isolate:Symbol.for("cordis.isolate"),internal:Symbol.for("cordis.internal"),intercept:Symbol.for("cordis.intercept"),setup:Symbol.for("cordis.setup"),invoke:Symbol.for("cordis.invoke"),extend:Symbol.for("cordis.extend"),tracker:Symbol.for("cordis.tracker"),provide:Symbol.for("cordis.provide"),immediate:Symbol.for("cordis.immediate")},gd=function*(){}.constructor,wa=async function*(){}.constructor;function rs(t){return!(!t.prototype||t instanceof gd||wa!==Function&&t instanceof wa)}V(rs,"isConstructor");function Vi(t,e){const i=t.Config||t.schema;return i&&t.schema!==!1&&(e=i(e)),e??{}}V(Vi,"resolveConfig");function _a(t){return[Map,Set,Date,Promise].some(e=>t instanceof e)}V(_a,"isUnproxyable");function ss(t,e){if(t===Object.prototype)return e;const i=Object.create(ss(Object.getPrototypeOf(t),e));for(const n of Reflect.ownKeys(t))Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n));return i}V(ss,"joinPrototype");function os(t){return t&&(typeof t=="object"||typeof t=="function")}V(os,"isObject");function vt(t,e,i){if(!os(e))return e;if(Object.hasOwn(e,D.shadow))return Object.getPrototypeOf(e);const n=e[D.tracker];return n?Hn(t,e,n,i):e}V(vt,"getTraceable");function Yi(t,e){return e?new Proxy(t,{get:V((i,n,r)=>n in e&&n!=="constructor"?Reflect.get(e,n,r):Reflect.get(i,n,r),"get"),set:V((i,n,r,s)=>n in e&&n!=="constructor"?Reflect.set(e,n,r,s):Reflect.set(i,n,r,s),"set")}):t}V(Yi,"withProps");function qn(t,e,i){return Yi(t,Object.defineProperty(Object.create(null),e,{value:i,writable:!1}))}V(qn,"withProp");function as(t,e,i,n){if(!i)return n;const r=Reflect.getOwnPropertyDescriptor(e,i)?.value;return r?qn(n,i,t.extend({[D.shadow]:r})):n}V(as,"createShadow");function xa(t,e,i,n){return new Proxy(e,{apply:V((r,s,o)=>(s===i&&(s=n),o=o.map(a=>typeof a!="function"||a[D.original]?a:new Proxy(a,{get:V((l,c,u)=>{if(c===D.original)return l;const f=Reflect.get(l,c,u);return c==="toString"&&f===Function.prototype.toString?function(...h){return Reflect.apply(f,this===u?l:this,h)}:f},"get"),apply:V((l,c,u)=>Reflect.apply(l,vt(t,c),u.map(f=>vt(t,f))),"apply"),construct:V((l,c,u)=>Reflect.construct(l,c.map(f=>vt(t,f)),u),"construct")})),vt(t,Reflect.apply(r,s,o))),"apply")})}V(xa,"createShadowMethod");function Hn(t,e,i,n){t[D.shadow]&&(t=Object.getPrototypeOf(t));const r=new Proxy(e,{get:V((s,o,a)=>{if(o===D.original)return s;if(o===i.property)return t;if(typeof o=="symbol")return Reflect.get(s,o,a);if(i.associate&&t[D.internal][`${i.associate}.${o}`])return Reflect.get(t,`${i.associate}.${o}`,qn(t,D.receiver,a));const l=as(t,s,i.property,a),c=Reflect.get(s,o,l),u=c?.[D.tracker];return u?Hn(t,c,u):!n&&typeof c=="function"?xa(t,c,a,l):c},"get"),set:V((s,o,a,l)=>{if(o===D.original||o===i.property)return!1;if(typeof o=="symbol")return Reflect.set(s,o,a,l);if(i.associate&&t[D.internal][`${i.associate}.${o}`])return Reflect.set(t,`${i.associate}.${o}`,a,qn(t,D.receiver,l));const c=as(t,s,i.property,l);return Reflect.set(s,o,a,c)},"set"),apply:V((s,o,a)=>ls(r,s,o,a),"apply")});return r}V(Hn,"createTraceable");function ls(t,e,i,n){return e[D.invoke]?e[D.invoke].apply(t,n):Reflect.apply(e,i,n)}V(ls,"applyTraceable");function cs(t,e,i){const n=V(function(...r){const s=Hn(n.ctx,n,i);return ls(s,n,this,r)},"self");return Le(n,"name",t),Object.setPrototypeOf(n,e)}V(cs,"createCallable");var md=(ut=class{constructor(e){this.ctx=e,Le(this,D.tracker,{associate:"reflect",property:"ctx"}),this._mixin("reflect",["get","set","provide","accessor","mixin","alias"]),this._mixin("scope",["config","runtime","effect","collect","accept","decline"]),this._mixin("registry",["using","inject","plugin"]),this._mixin("lifecycle",["on","once","parallel","emit","serial","bail","start","stop"])}static resolveInject(e,i){let n=e[D.internal][i];for(;n?.type==="alias";)i=n.name,n=e[D.internal][i];return[i,n]}static checkInject(e,i,n){if(e=e[D.shadow]??e,["prototype","then","registry","lifecycle"].includes(i)||i[0]==="$"||i[0]==="_"||!e.runtime.plugin||e.bail(e,"internal/inject",i))return;const r=n.stack.split(`
2
2
  `);r.splice(1,1),n.stack=r.join(`
3
- `),e.emit(e,"internal/warning",n)}get(e){if(this.ctx[M.internal][e]?.type!=="service")return;const n=this.ctx[M.isolate][e],r=this.ctx[M.store][n]?.value;return yt(this.ctx,r)}set(e,i){this.provide(e);const n=this.ctx[M.isolate][e],r=this.ctx[M.store][n]?.value;i??(i=void 0);let s=W(()=>{},"dispose");if(r===i)return s;if(!be(i)&&!be(r))throw new Error(`service ${e} has been registered`);const o=this.ctx;be(i)||(s=o.effect(()=>()=>{o.set(e,void 0)})),pa(i)&&o.emit(o,"internal/warning",new Error(`service ${e} is an unproxyable object, which may lead to unexpected behavior`));const a=Object.create(o);return a[M.filter]=l=>o[M.isolate][e]===l[M.isolate][e],o.emit(a,"internal/before-service",e,i),o[M.store][n]={value:i,source:o},o.emit(a,"internal/service",e,r),s}provide(e,i,n){const r=this.ctx.root[M.internal];if(e in r)return;const s=Symbol(e);r[e]={type:"service",builtin:n},this.ctx.root[M.isolate][e]=s,ts(i)&&(this.ctx[M.store][s]={value:i,source:null},Ie(i,M.tracker,{associate:e,property:"ctx"}))}_accessor(e,i){const n=this.ctx.root[M.internal];return e in n?()=>{}:(n[e]={type:"accessor",...i},()=>delete this.ctx.root[M.isolate][e])}accessor(e,i){this.ctx.scope.effect(()=>this._accessor(e,i))}alias(e,i){const n=this.ctx.root[M.internal];if(!(e in n))for(const r of i)n[r]||(n[r]={type:"alias",name:e})}_mixin(e,i){const n=Array.isArray(i)?i.map(o=>[o,o]):Object.entries(i),r=typeof e=="string"?o=>o[e]:()=>e,s=n.map(([o,a])=>this._accessor(a,{get(l){const c=r(this);if(be(c))return c;const u=l?Wi(l,c):c,d=Reflect.get(c,o,u);return typeof d!="function"?d:d.bind(u??c)},set(l,c){const u=r(this),d=c?Wi(c,u):u;return Reflect.set(u,o,l,d)}}));return()=>s.forEach(o=>o())}mixin(e,i){this.ctx.scope.effect(()=>this._mixin(e,i))}trace(e){return yt(this.ctx,e)}bind(e){return new Proxy(e,{apply:W((i,n,r)=>i.apply(this.trace(n),r.map(s=>this.trace(s))),"apply")})}},W(at,"ReflectService"),F(at,"handler",{get:W((e,i,n)=>{if(typeof i!="string")return Reflect.get(e,i,n);if(Reflect.has(e,i))return yt(n,Reflect.get(e,i,n),!0);const[r,s]=at.resolveInject(e,i),o=new Error(`property ${r} is not registered, declare it as \`inject\` to suppress this warning`);return s?s.type==="accessor"?s.get.call(n,n[M.receiver]):(s.builtin||at.checkInject(n,r,o),n.reflect.get(r)):(at.checkInject(n,r,o),Reflect.get(e,r,n))},"get"),set:W((e,i,n,r)=>{if(typeof i!="string")return Reflect.set(e,i,n,r);const[s,o]=at.resolveInject(e,i);return o?o.type==="accessor"?o.set?o.set.call(r,n,r[M.receiver]):!1:(r.reflect.set(s,n),!0):Reflect.set(e,s,n,r)},"set"),has:W((e,i)=>{if(typeof i!="string")return Reflect.has(e,i);if(Reflect.has(e,i))return!0;const[,n]=at.resolveInject(e,i);return!!n},"has")}),at),ss=Zf;function os(t){return t!==null&&t!==!1&&t!==void 0}W(os,"isBailed");var ed=(ji=class{constructor(e){F(this,"isActive",!1);F(this,"_tasks",new Set);F(this,"_hooks",{});this.ctx=e,Ie(this,M.tracker,{associate:"lifecycle",property:"ctx"}),Ie(this.on("internal/listener",function(n,r,s){const o=s.prepend?"unshift":"push";if(n==="ready")return this.lifecycle.isActive?(this.scope.ensure(async()=>r()),()=>!1):void 0;if(n==="dispose")return this.scope.disposables[o](r),Ie(r,"name","event <dispose>"),()=>zt(this.scope.disposables,r);if(n==="fork")return this.scope.runtime.forkables[o](r),this.scope.collect("event <fork>",()=>zt(this.scope.runtime.forkables,r))}),Be.static,e.scope);for(const n of["info","error","warning"])Ie(this.on(`internal/${n}`,(r,...s)=>{this._hooks[`internal/${n}`].length>1}),Be.static,e.scope);Ie(this.on("internal/before-service",function(n){for(const r of this.registry.values()){if(!r.inject[n]?.required)continue;const s=r.isReusable?r.children:[r];for(const o of s)this[M.filter](o.ctx)&&(o.updateStatus(),o.reset())}},{global:!0}),Be.static,e.scope),Ie(this.on("internal/service",function(n){for(const r of this.registry.values()){if(!r.inject[n]?.required)continue;const s=r.isReusable?r.children:[r];for(const o of s)this[M.filter](o.ctx)&&o.start()}},{global:!0}),Be.static,e.scope);const i=W((n,r)=>{if(!n.runtime.plugin)return!1;for(const s in n.runtime.inject)if(r===ss.resolveInject(n.ctx,s)[0])return!0;return i(n.parent.scope,r)},"checkInject");Ie(this.on("internal/inject",function(n){return i(this.scope,n)},{global:!0}),Be.static,e.scope)}async flush(){for(;this._tasks.size;)await Promise.all(Array.from(this._tasks))}filterHooks(e,i){return i=yt(this.ctx,i),e.slice().filter(n=>{const r=i?.[Be.filter];return n.global||!r||r.call(i,n.ctx)})}*dispatch(e,i){const n=typeof i[0]=="object"||typeof i[0]=="function"?i.shift():null,r=i.shift();r!=="internal/event"&&this.emit("internal/event",e,r,i,n);for(const s of this.filterHooks(this._hooks[r]||[],n))yield s.callback.apply(n,i)}async parallel(...e){await Promise.all(this.dispatch("emit",e))}emit(...e){Array.from(this.dispatch("emit",e))}async serial(...e){for await(const i of this.dispatch("serial",e))if(os(i))return i}bail(...e){for(const i of this.dispatch("bail",e))if(os(i))return i}register(e,i,n,r){const s=r.prepend?"unshift":"push";return i[s]({ctx:this.ctx,callback:n,...r}),this.ctx.state.collect(e,()=>this.unregister(i,n))}unregister(e,i){const n=e.findIndex(r=>r.callback===i);if(n>=0)return e.splice(n,1),!0}on(e,i,n){var a;typeof n!="object"&&(n={prepend:n}),this.ctx.scope.assertActive(),i=this.ctx.reflect.bind(i);const r=this.bail(this.ctx,"internal/listener",e,i,n);if(r)return r;const s=(a=this._hooks)[e]||(a[e]=[]),o=typeof e=="string"?`event <${e}>`:"event (Symbol)";return this.register(o,s,i,n)}once(e,i,n){const r=this.on(e,function(...s){return r(),i.apply(this,s)},n);return r}async start(){this.isActive=!0;const e=this._hooks.ready||[];for(;e.length;){const{ctx:i,callback:n}=e.shift();i.scope.ensure(async()=>n())}await this.flush()}async stop(){this.isActive=!1,this.ctx.scope.reset()}},W(ji,"Lifecycle"),ji),td=ed,as=(pi=class extends Error{constructor(e,i){super(i??pi.Code[e]),this.code=e}},W(pi,"CordisError"),pi);(t=>{t.Code={INACTIVE_EFFECT:"cannot create effect on inactive context"}})(as||(as={}));var ga=(Ui=class{constructor(e,i){F(this,"uid");F(this,"ctx");F(this,"disposables",[]);F(this,"error");F(this,"status",0);F(this,"isActive",!1);F(this,"context");F(this,"proxy");F(this,"acceptors",[]);F(this,"tasks",new Set);F(this,"hasError",!1);this.parent=e,this.config=i,this.uid=e.registry?e.registry.counter:0,this.ctx=this.context=e.extend({scope:this}),this.proxy=new Proxy({},{get:W((n,r)=>Reflect.get(this.config,r),"get")})}get _config(){return this.runtime.isReactive?this.proxy:this.config}assertActive(){if(!(this.uid!==null||this.isActive))throw new as("INACTIVE_EFFECT")}effect(e,i){this.assertActive();const n=Zr(e)?new e(this.ctx,i):e(this.ctx,i);let r=!1;const s=typeof n=="function"?n:n.dispose.bind(n),o=W((...a)=>{if(!r)return r=!0,zt(this.disposables,o),s(...a)},"wrapped");return this.disposables.push(o),typeof n=="function"?o:(n.dispose=o,n)}collect(e,i){const n=Ie(()=>(zt(this.disposables,n),i()),"name",e);return this.disposables.push(n),n}restart(){this.reset(),this.error=null,this.hasError=!1,this.status=0,this.start()}_getStatus(){return this.uid===null?4:this.hasError?3:this.tasks.size?1:this.ready?2:0}updateStatus(e){const i=this.status;e?.(),this.status=this._getStatus(),i!==this.status&&this.context.emit("internal/status",this,i)}ensure(e){const i=e().catch(n=>{this.context.emit(this.ctx,"internal/error",n),this.cancel(n)}).finally(()=>{this.updateStatus(()=>this.tasks.delete(i)),this.context.events._tasks.delete(i)});this.updateStatus(()=>this.tasks.add(i)),this.context.events._tasks.add(i)}cancel(e){this.error=e,this.updateStatus(()=>this.hasError=!0),this.reset()}get ready(){return Object.entries(this.runtime.inject).every(([e,i])=>!i.required||!be(this.ctx.get(e)))}reset(){this.isActive=!1,this.disposables=this.disposables.splice(0).filter(e=>{if(this.uid!==null&&e[Be.static]===this)return!0;(async()=>e())().catch(i=>{this.context.emit(this.ctx,"internal/error",i)})})}init(e){this.config?this.start():this.cancel(e)}start(){if(!this.ready||this.isActive||this.uid===null)return!0;this.isActive=!0,this.updateStatus(()=>this.hasError=!1)}accept(...e){const n={keys:Array.isArray(e[0])?e.shift():null,callback:e[0],...e[1]};return this.effect(()=>(this.acceptors.push(n),n.immediate&&n.callback?.(this.config),()=>zt(this.acceptors,n)))}decline(e){return this.accept(e,()=>!0)}checkUpdate(e,i){if(i||!this.config)return[!0,!0];if(i===!1)return[!1,!1];const n=Object.create(null),r=W(c=>{const u=n[c]??(n[c]=!Zt(this.config[c],e[c]));return o||(o=u),u},"checkPropertyUpdate"),s=new Set;let o=!1,a=!1,l=this.runtime.isReactive||null;for(const{keys:c,callback:u,passive:d}of this.acceptors){if(!c)l||(l=!d);else if(d)c?.forEach(p=>s.add(p));else{let p=!1;for(const f of c)p||(p=r(f));if(!p)continue}u?.(e)&&(a=!0)}for(const c in{...this.config,...e})if(l!==!1&&!(c in n)&&!s.has(c)){const u=r(c);l===null&&(a||(a=u))}return[o,a]}},W(Ui,"EffectScope"),Ui),id=(Fi=class extends ga{constructor(i,n,r,s){super(i,r);F(this,"dispose");this.runtime=n,this.dispose=Ie(i.scope.collect(`fork <${i.runtime.name}>`,()=>{this.uid=null,this.reset(),this.context.emit("internal/fork",this);const o=zt(n.disposables,this.dispose);return zt(n.children,this)&&!n.children.length&&i.registry.delete(n.plugin),o}),Be.static,n),n.children.push(this),n.disposables.push(this.dispose),this.context.emit("internal/fork",this),this.init(s)}start(){if(super.start())return!0;for(const i of this.runtime.forkables)this.ensure(async()=>i(this.context,this._config))}update(i,n){const r=this.config,s=this.runtime.isForkable?this:this.runtime;if(s.config!==r)return;let o;try{o=Ki(this.runtime.plugin,i)}catch(c){return this.context.emit("internal/error",c),this.cancel(c)}const[a,l]=s.checkUpdate(o,n);this.context.emit("internal/before-update",this,i),this.config=o,s.config=o,a&&this.context.emit("internal/update",this,r),l&&s.restart()}},W(Fi,"ForkScope"),Fi),ya=(Bi=class extends ga{constructor(i,n,r,s){super(i,r);F(this,"value");F(this,"runtime",this);F(this,"schema");F(this,"name");F(this,"inject",Object.create(null));F(this,"forkables",[]);F(this,"children",[]);F(this,"isReusable",!1);F(this,"isReactive",!1);F(this,"apply",W((i,n)=>{if(typeof this.plugin!="function")return this.plugin.apply(i,n);if(Zr(this.plugin)){const r=new this.plugin(i,n),s=r[Be.expose];return s&&i.set(s,r),r.fork&&this.forkables.push(r.fork.bind(r)),r}else return this.plugin(i,n)},"apply"));this.plugin=n,n?(this.setup(),this.init(s)):(this.name="root",this.isActive=!0)}get isForkable(){return this.forkables.length>0}fork(i,n,r){return new id(i,this,n,r)}dispose(){return this.uid=null,this.reset(),this.context.emit("internal/runtime",this),!0}setup(){const{name:i}=this.plugin;i&&i!=="apply"&&(this.name=i),this.schema=this.plugin.Config||this.plugin.schema,this.inject=$e.resolve(this.plugin.using||this.plugin.inject),this.isReusable=this.plugin.reusable,this.isReactive=this.plugin.reactive,this.context.emit("internal/runtime",this),this.isReusable&&this.forkables.push(this.apply)}reset(){super.reset();for(const i of this.children)i.reset()}start(){if(super.start())return!0;!this.isReusable&&this.plugin&&this.ensure(async()=>this.value=this.apply(this.ctx,this._config));for(const i of this.children)i.start()}update(i,n){if(this.isForkable){const c=new Error(`attempting to update forkable plugin "${this.plugin.name}", which may lead to unexpected behavior`);this.context.emit(this.ctx,"internal/warning",c)}const r=this.config;let s;try{s=Ki(this.runtime.plugin||this.context.constructor,i)}catch(c){return this.context.emit("internal/error",c),this.cancel(c)}const[o,a]=this.checkUpdate(s,n),l=this.children.find(c=>c.config===r);this.config=s,l&&(this.context.emit("internal/before-update",l,i),l.config=s,o&&this.context.emit("internal/update",l,r)),a&&this.restart()}},W(Bi,"MainScope"),Bi);function ba(t){return t&&typeof t=="object"&&typeof t.apply=="function"}W(ba,"isApplicable");function $e(t){return function(e,i){if(i.kind==="class")e.inject=t;else if(i.kind==="method")i.addInitializer(function(){const n=this[M.tracker]?.property;if(!n)throw new Error("missing context tracker");this[n].inject(t,r=>{e.call(Wi(this,{[n]:r}))})});else throw new Error("@Inject can only be used on class or class methods")}}W($e,"Inject"),(t=>{function e(i){if(!i)return{};if(Array.isArray(i))return Object.fromEntries(i.map(o=>[o,{required:!0}]));const{required:n,optional:r,...s}=i;return Array.isArray(n)&&Object.assign(s,Object.fromEntries(n.map(o=>[o,{required:!0}]))),Array.isArray(r)&&Object.assign(s,Object.fromEntries(r.map(o=>[o,{required:!1}]))),s}t.resolve=e,W(e,"resolve")})($e||($e={}));var nd=(qi=class{constructor(e,i){F(this,"_counter",0);F(this,"_internal",new Map);F(this,"context");this.ctx=e,Ie(this,M.tracker,{associate:"registry",property:"ctx"}),this.context=e;const n=new ya(e,null,i);e.scope=n,n.ctx=e,this.set(null,n)}get counter(){return++this._counter}get size(){return this._internal.size}resolve(e,i=!1){if(e===null||typeof e=="function")return e;if(ba(e))return e.apply;if(i)throw new Error('invalid plugin, expect function or object with an "apply" method, received '+typeof e)}get(e){const i=this.resolve(e);return i&&this._internal.get(i)}has(e){const i=this.resolve(e);return!!i&&this._internal.has(i)}set(e,i){const n=this.resolve(e);this._internal.set(n,i)}delete(e){const i=this.resolve(e),n=i&&this._internal.get(i);if(n)return this._internal.delete(i),n.dispose(),n}keys(){return this._internal.keys()}values(){return this._internal.values()}entries(){return this._internal.entries()}forEach(e){return this._internal.forEach(e)}using(e,i){return this.inject(e,i)}inject(e,i){return this.plugin({inject:e,apply:i,name:i.name})}plugin(e,i,n){if(this.resolve(e,!0),this.ctx.scope.assertActive(),!n)try{i=Ki(e,i)}catch(s){this.context.emit(this.ctx,"internal/error",s),n=s,i=null}let r=this.get(e);return r?(r.isForkable||this.context.emit(this.ctx,"internal/warning",new Error(`duplicate plugin detected: ${e.name}`)),r.fork(this.ctx,i,n)):(r=new ya(this.ctx,e,i,n),this.set(e,r),r.fork(this.ctx,i,n))}},W(qi,"Registry"),qi),rd=nd,Be=(_e=class{static is(e){return!!e?.[_e.is]}static associate(e,i){return e}constructor(e){e=Ki(this.constructor,e),this[M.store]=Object.create(null),this[M.isolate]=Object.create(null),this[M.internal]=Object.create(null),this[M.intercept]=Object.create(null);const i=new Proxy(this,ss.handler);i.root=i,i.reflect=new ss(i),i.registry=new rd(i,e),i.lifecycle=new td(i);const n=W(r=>{if(r){n(Object.getPrototypeOf(r));for(const s of Object.getOwnPropertyNames(r)){const o=r[s].prototype?.constructor;o&&(i[r[s].key]=new o(i,e),Ie(i[r[s].key],"ctx",i))}}},"attach");return n(this[M.internal]),i}[Symbol.for("nodejs.util.inspect.custom")](){return`Context <${this.name}>`}get name(){let e=this.runtime;for(;e&&!e.name;)e=e.parent.runtime;return e?.name}get events(){return this.lifecycle}get state(){return this.scope}extend(e={}){const i=Reflect.getOwnPropertyDescriptor(this,M.shadow)?.value,n=Object.assign(Object.create(yt(this,this)),e);return i?Object.assign(Object.create(n),{[M.shadow]:i}):n}isolate(e,i){const n=Object.create(this[M.isolate]);return n[e]=i??Symbol(e),this.extend({[M.isolate]:n})}intercept(e,i){const n=Object.create(this[M.intercept]);return n[e]=i,this.extend({[M.intercept]:n})}},W(_e,"Context"),F(_e,"store",M.store),F(_e,"events",M.events),F(_e,"static",M.static),F(_e,"filter",M.filter),F(_e,"expose",M.expose),F(_e,"isolate",M.isolate),F(_e,"internal",M.internal),F(_e,"intercept",M.intercept),F(_e,"origin","ctx"),F(_e,"current","ctx"),_e.is[Symbol.toPrimitive]=()=>Symbol.for("cordis.is"),_e.prototype[_e.is]=!0,_e);Be.prototype[Be.internal]=Object.create(null);var Ot=(it=class{constructor(...e){F(this,"ctx");F(this,"name");F(this,"config");let i,n,r,s;Be.is(e[0])?(i=e[0],typeof e[1]=="string"?(n=e[1],r=e[2]):s=e[1]):s=e[0],n??(n=this.constructor[M.provide]),r??(r=this.constructor[M.immediate]);let o=this;const a={associate:n,property:"ctx"};return o[M.invoke]&&(o=rs(n,es(Object.getPrototypeOf(this),Function.prototype),a)),i?o.ctx=i:o[M.setup](),o.name=n,o.config=s,Ie(o,M.tracker,a),o.ctx.provide(n),o.ctx.runtime.name=n,r&&(i?o[M.expose]=n:o.ctx.set(n,o)),o.ctx.on("ready",async()=>{await Promise.resolve(),await o.start(),r||o.ctx.set(n,o)}),o.ctx.on("dispose",()=>o.stop()),o}start(){}stop(){}[M.filter](e){return e[M.isolate][this.name]===this.ctx[M.isolate][this.name]}[M.setup](){this.ctx=new Be}[M.extend](e){let i;return this[it.invoke]?i=rs(this.name,this,this[M.tracker]):i=Object.create(this),Object.assign(i,e)}static[Symbol.hasInstance](e){let i=e.constructor;for(;i;){if(i=i.prototype?.constructor,i===this)return!0;i=Object.getPrototypeOf(i)}return!1}},W(it,"Service"),F(it,"setup",M.setup),F(it,"invoke",M.invoke),F(it,"extend",M.extend),F(it,"tracker",M.tracker),F(it,"provide",M.provide),F(it,"immediate",M.immediate),it),sd=Object.defineProperty,od=Object.getOwnPropertyNames,Z=(t,e)=>sd(t,"name",{value:e,configurable:!0}),ad=(t,e)=>function(){return e||(0,t[od(t)[0]])((e={exports:{}}).exports,e),e.exports},ld=ad({"src/index.ts"(t,e){var R;var i=Symbol.for("schemastery"),n=Symbol.for("ValidationError");globalThis.__schemastery_index__??(globalThis.__schemastery_index__=0);var r=(R=class extends TypeError{constructor(v,w){let S="$";for(const k of w.path||[])typeof k=="string"?S+="."+k:typeof k=="number"?S+="["+k+"]":typeof k=="symbol"&&(S+=`[Symbol(${k.toString()})]`);S.startsWith(".")&&(S=S.slice(1));super((S==="$"?"":`${S} `)+v);F(this,"name","ValidationError");this.options=w}static is(v){return!!v?.[n]}},Z(R,"ValidationError"),R);Object.defineProperty(r.prototype,n,{value:!0});var s=Z(function(y){const g=Z(function(v,w={}){return s.resolve(v,g,w)[0]},"schema");if(y.refs){const v=It(y.refs,S=>new s(S)),w=Z(S=>v[S],"getRef");for(const S in v){const k=v[S];k.sKey=w(k.sKey),k.inner=w(k.inner),k.list=k.list&&k.list.map(w),k.dict=k.dict&&It(k.dict,w)}return v[y.uid]}if(Object.assign(g,y),typeof g.callback=="string")try{g.callback=new Function("return "+g.callback)()}catch{}return Object.defineProperty(g,"uid",{value:globalThis.__schemastery_index__++}),Object.setPrototypeOf(g,s.prototype),g.meta||(g.meta={}),g.toString=g.toString.bind(g),g},"Schema");s.prototype=Object.create(Function.prototype),s.prototype[i]=!0,s.ValidationError=r;var o;s.prototype.toJSON=Z(function(){var v;if(o)return o[v=this.uid]??(o[v]=JSON.parse(JSON.stringify({...this}))),this.uid;o={[this.uid]:{...this}},o[this.uid]=JSON.parse(JSON.stringify({...this}));const g={uid:this.uid,refs:o};return o=void 0,g},"toJSON"),s.prototype.set=Z(function(g,v){return this.dict[g]=v,this},"set"),s.prototype.push=Z(function(g){return this.list.push(g),this},"push");function a(y,g){const v=typeof y=="string"?{"":y}:{...y};for(const w in g){const S=g[w];S?.$description||S?.$desc?v[w]=S.$description||S.$desc:typeof S=="string"&&(v[w]=S)}return v}Z(a,"mergeDesc");function l(y){return y?.$value??y?.$inner}Z(l,"getInner");function c(y){return la(y??{},g=>!g.startsWith("$"))}Z(c,"extractKeys"),s.prototype.i18n=Z(function(g){const v=s(this),w=a(v.meta.description,g);return Object.keys(w).length&&(v.meta.description=w),v.dict&&(v.dict=It(v.dict,(S,k)=>S.i18n(It(g,j=>l(j)?.[k]??j?.[k])))),v.list&&(v.list=v.list.map((S,k)=>S.i18n(It(g,(j={})=>Array.isArray(l(j))?l(j)[k]:Array.isArray(j)?j[k]:c(j))))),v.inner&&(v.inner=v.inner.i18n(It(g,S=>l(S)?l(S):c(S)))),v.sKey&&(v.sKey=v.sKey.i18n(It(g,S=>S?.$key))),v},"i18n"),s.prototype.extra=Z(function(g,v){const w=s(this);return w.meta={...w.meta,[g]:v},w},"extra");for(const y of["required","disabled","collapse","hidden","loose"])Object.assign(s.prototype,{[y](g=!0){const v=s(this);return v.meta={...v.meta,[y]:g},v}});s.prototype.deprecated=Z(function(){var v;const g=s(this);return(v=g.meta).badges||(v.badges=[]),g.meta.badges.push({text:"deprecated",type:"danger"}),g},"deprecated"),s.prototype.experimental=Z(function(){var v;const g=s(this);return(v=g.meta).badges||(v.badges=[]),g.meta.badges.push({text:"experimental",type:"warning"}),g},"experimental"),s.prototype.pattern=Z(function(g){const v=s(this),w=ca(g,["source","flags"]);return v.meta={...v.meta,pattern:w},v},"pattern"),s.prototype.simplify=Z(function(g){if(Zt(g,this.meta.default,this.type==="dict"))return null;if(be(g))return g;if(this.type==="object"||this.type==="dict"){const v={};for(const w in g){const k=(this.type==="object"?this.dict[w]:this.inner)?.simplify(g[w]);(this.type==="dict"||!be(k))&&(v[w]=k)}return Zt(v,this.meta.default,this.type==="dict")?null:v}else if(this.type==="array"||this.type==="tuple"){const v=[];return g.forEach((w,S)=>{const k=this.type==="array"?this.inner:this.list[S],j=k?k.simplify(w):w;v.push(j)}),v}else if(this.type==="intersect"){const v={};for(const w of this.list)Object.assign(v,w.simplify(g));return v}else if(this.type==="union")for(const v of this.list)try{return s.resolve(g,v,{}),v.simplify(g)}catch{}return g},"simplify"),s.prototype.toString=Z(function(g){return P[this.type]?.(this,g)??`Schema<${this.type}>`},"toString"),s.prototype.role=Z(function(y,g){const v=s(this);return v.meta={...v.meta,role:y,extra:g},v},"role");for(const y of["default","link","comment","description","max","min","step"])Object.assign(s.prototype,{[y](g){const v=s(this);return v.meta={...v.meta,[y]:g},v}});var u={};s.extend=Z(function(g,v){u[g]=v},"extend"),s.resolve=Z(function(g,v,w={},S=!1){if(!v)return[g];if(w.ignore?.(g,v))return[g];if(be(g)&&v.type!=="lazy"){if(v.meta.required)throw new r("missing required value",w);let j=v,z=v.meta.default;for(;j?.type==="intersect"&&be(z);)j=j.list[0],z=j?.meta.default;if(be(z))return[g];g=Dn(z)}const k=u[v.type];if(!k)throw new r(`unsupported type "${v.type}"`,w);try{return k(g,v,w,S)}catch(j){if(!v.meta.loose)throw j;return[v.meta.default]}},"resolve"),s.from=Z(function(g){if(be(g))return s.any();if(["string","number","boolean"].includes(typeof g))return s.const(g).required();if(g[i])return g;if(typeof g=="function")switch(g){case String:return s.string().required();case Number:return s.number().required();case Boolean:return s.boolean().required();case Function:return s.function().required();default:return s.is(g).required()}else throw new TypeError(`cannot infer schema from ${g}`)},"from"),s.lazy=Z(function(g){const v=Z(()=>(w.inner[i]||(w.inner=w.builder(),w.inner.meta={...w.meta,...w.inner.meta}),w.inner.toJSON()),"toJSON"),w=new s({type:"lazy",builder:g,inner:{toJSON:v}});return w},"lazy"),s.natural=Z(function(){return s.number().step(1).min(0)},"natural"),s.percent=Z(function(){return s.number().step(.01).min(0).max(1).role("slider")},"percent"),s.date=Z(function(){return s.union([s.is(Date),s.transform(s.string().role("datetime"),(g,v)=>{const w=new Date(g);if(isNaN(+w))throw new r(`invalid date "${g}"`,v);return w},!0)])},"date"),s.regExp=Z(function(g=""){return s.union([s.is(RegExp),s.transform(s.string().role("regexp",{flag:g}),(v,w)=>{try{return new RegExp(v,g)}catch(S){throw new r(S.message,w)}},!0)])},"regExp"),s.arrayBuffer=Z(function(g){return s.union([s.is(ArrayBuffer),s.is(SharedArrayBuffer),s.transform(s.any(),(v,w)=>{if(gt.isSource(v))return gt.fromSource(v);throw new r(`expected ArrayBufferSource but got ${v}`,w)},!0),...g?[s.transform(s.string(),(v,w)=>{try{return g==="base64"?gt.fromBase64(v):gt.fromHex(v)}catch(S){throw new r(S.message,w)}},!0)]:[]])},"arrayBuffer"),s.extend("lazy",(y,g,v,w)=>(g.inner[i]||(g.inner=g.builder(),g.inner.meta={...g.meta,...g.inner.meta}),s.resolve(y,g.inner,v,w))),s.extend("any",y=>[y]),s.extend("never",(y,g,v)=>{throw new r(`expected nullable but got ${y}`,v)}),s.extend("const",(y,{value:g},v)=>{if(Zt(y,g))return[g];throw new r(`expected ${g} but got ${y}`,v)});function d(y,g,v,w,S=!1){const{max:k=1/0,min:j=-1/0}=g;if(y>k)throw new r(`expected ${v} <= ${k} but got ${y}`,w);if(y<j&&!S)throw new r(`expected ${v} >= ${j} but got ${y}`,w)}Z(d,"checkWithinRange"),s.extend("string",(y,{meta:g},v)=>{if(typeof y!="string")throw new r(`expected string but got ${y}`,v);if(g.pattern){const w=new RegExp(g.pattern.source,g.pattern.flags);if(!w.test(y))throw new r(`expect string to match regexp ${w}`,v)}return d(y.length,g,"string length",v),[y]});function h(y,g){const v=y.toString();if(v.includes("e"))return y*Math.pow(10,g);const w=v.indexOf(".");if(w===-1)return y*Math.pow(10,g);const S=v.slice(w+1),k=v.slice(0,w);return S.length<=g?+(k+S.padEnd(g,"0")):+(k+S.slice(0,g)+"."+S.slice(g))}Z(h,"decimalShift");function p(y,g,v){if(v=Math.abs(v),!/^\d+\.\d+$/.test(v.toString()))return(y-g)%v===0;const w=v.toString().indexOf("."),S=v.toString().slice(w+1).length;return Math.abs(h(y,S)-h(g,S))%h(v,S)===0}Z(p,"isMultipleOf"),s.extend("number",(y,{meta:g},v)=>{if(typeof y!="number")throw new r(`expected number but got ${y}`,v);d(y,g,"number",v);const{step:w}=g;if(w&&!p(y,g.min??0,w))throw new r(`expected number multiple of ${w} but got ${y}`,v);return[y]}),s.extend("boolean",(y,g,v)=>{if(typeof y=="boolean")return[y];throw new r(`expected boolean but got ${y}`,v)}),s.extend("bitset",(y,{bits:g,meta:v},w)=>{let S=0,k=[];if(typeof y=="number"){S=y;for(const j in g)y&g[j]&&k.push(j)}else if(Array.isArray(y)){k=y;for(const j of k){if(typeof j!="string")throw new r(`expected string but got ${j}`,w);j in g&&(S|=g[j])}}else throw new r(`expected number or array but got ${y}`,w);return S===v.default?[S]:[S,k]}),s.extend("function",(y,g,v)=>{if(typeof y=="function")return[y];throw new r(`expected function but got ${y}`,v)}),s.extend("is",(y,{constructor:g},v)=>{if(typeof g=="function"){if(y instanceof g)return[y];throw new r(`expected ${g.name} but got ${y}`,v)}else{if(be(y))throw new r(`expected ${g} but got ${y}`,v);let w=Object.getPrototypeOf(y);for(;w;){if(w.constructor?.name===g)return[y];w=Object.getPrototypeOf(w)}throw new r(`expected ${g} but got ${y}`,v)}});function f(y,g,v,w){try{const[S,k]=s.resolve(y[g],v,{...w,path:[...w.path||[],g]});return k!==void 0&&(y[g]=k),S}catch(S){if(!w?.autofix)throw S;return delete y[g],v.meta.default}}Z(f,"property"),s.extend("array",(y,{inner:g,meta:v},w)=>{if(!Array.isArray(y))throw new r(`expected array but got ${y}`,w);return d(y.length,v,"array length",w,!be(g.meta.default)),[y.map((S,k)=>f(y,k,g,w))]}),s.extend("dict",(y,{inner:g,sKey:v},w,S)=>{if(!Mn(y))throw new r(`expected object but got ${y}`,w);const k={};for(const j in y){let z;try{z=s.resolve(j,v,w)[0]}catch(mt){if(S)continue;throw mt}k[z]=f(y,j,g,w),y[z]=y[j],j!==z&&delete y[j]}return[k]}),s.extend("tuple",(y,{list:g},v,w)=>{if(!Array.isArray(y))throw new r(`expected array but got ${y}`,v);const S=g.map((k,j)=>f(y,j,k,v));return w?[S]:(S.push(...y.slice(g.length)),[S])});function _(y,g){for(const v in g)v in y||(y[v]=g[v])}Z(_,"merge"),s.extend("object",(y,{dict:g},v,w)=>{if(!Mn(y))throw new r(`expected object but got ${y}`,v);const S={};for(const k in g){const j=f(y,k,g[k],v);(!be(j)||k in y)&&(S[k]=j)}return w||_(S,y),[S]}),s.extend("union",(y,{list:g,toString:v},w,S)=>{for(const k of g)try{return s.resolve(y,k,w,S)}catch{}throw new r(`expected ${v()} but got ${JSON.stringify(y)}`,w)}),s.extend("intersect",(y,{list:g,toString:v},w,S)=>{if(!g.length)return[y];let k;for(const j of g){const z=s.resolve(y,j,w,!0)[0];if(!be(z))if(be(k))k=z;else{if(typeof k!=typeof z)throw new r(`expected ${v()} but got ${JSON.stringify(y)}`,w);if(typeof z=="object")_(k??(k={}),z);else if(k!==z)throw new r(`expected ${v()} but got ${JSON.stringify(y)}`,w)}}return!S&&Mn(y)&&_(k,y),[k]}),s.extend("transform",(y,{inner:g,callback:v,preserve:w},S)=>{const[k,j=y]=s.resolve(y,g,S,!0);return w?[v(k)]:[v(k),v(j)]});var P={};function C(y,g,v){P[y]=v,Object.assign(s,{[y](...w){const S=new s({type:y});return g.forEach((k,j)=>{switch(k){case"sKey":S.sKey=w[j]??s.string();break;case"inner":S.inner=s.from(w[j]);break;case"list":S.list=w[j].map(s.from);break;case"dict":S.dict=It(w[j],s.from);break;case"bits":{S.bits={};for(const z in w[j])typeof w[j][z]=="number"&&(S.bits[z]=w[j][z]);break}case"callback":{const z=S.callback=w[j];z.toJSON||(z.toJSON=()=>z.toString());break}case"constructor":{const z=S.constructor=w[j];typeof z=="function"&&(z.toJSON||(z.toJSON=()=>z.name));break}default:S[k]=w[j]}}),y==="object"||y==="dict"?S.meta.default={}:y==="array"||y==="tuple"?S.meta.default=[]:y==="bitset"&&(S.meta.default=0),S}})}Z(C,"defineMethod"),C("is",["constructor"],({constructor:y})=>typeof y=="function"?y.name:y),C("any",[],()=>"any"),C("never",[],()=>"never"),C("const",["value"],({value:y})=>typeof y=="string"?JSON.stringify(y):y),C("string",[],()=>"string"),C("number",[],()=>"number"),C("boolean",[],()=>"boolean"),C("bitset",["bits"],()=>"bitset"),C("function",[],()=>"function"),C("array",["inner"],({inner:y})=>`${y.toString(!0)}[]`),C("dict",["inner","sKey"],({inner:y,sKey:g})=>`{ [key: ${g.toString()}]: ${y.toString()} }`),C("tuple",["list"],({list:y})=>`[${y.map(g=>g.toString()).join(", ")}]`),C("object",["dict"],({dict:y})=>Object.keys(y).length===0?"{}":`{ ${Object.entries(y).map(([g,v])=>`${g}${v.meta.required?"":"?"}: ${v.toString()}`).join(", ")} }`),C("union",["list"],({list:y},g)=>{const v=y.map(({toString:w})=>w()).join(" | ");return g?`(${v})`:v}),C("intersect",["list"],({list:y})=>`${y.map(g=>g.toString(!0)).join(" & ")}`),C("transform",["inner","callback","preserve"],({inner:y},g)=>y.toString(g)),e.exports=s}});const L=ld();var ls=(t=>(t[t.debug=-1]="debug",t[t.log=0]="log",t[t.info=1]="info",t[t.warn=2]="warn",t[t.error=3]="error",t[t.silent=4]="silent",t))(ls||{});const cs=globalThis||window,us=Symbol.for("__IPE_LOGGER_COLOR_MAP__");cs[us]||(cs[us]=new Map);const fs=cs[us];function Fn(t){let e=2166136261;for(let i=0;i<t.length;i++)e^=t.charCodeAt(i),e=(e>>>0)*16777619;return e>>>0}const va=[[350,360],[0,15],[15,30],[200,230],[230,250],[250,280],[280,310],[310,330],[140,160],[160,180]];function cd(t,e){const i=va.length,n=Fn(t)%i,[r,s]=va[n],o=s-r,a=Fn(t+":"+e),l=r+a%(o||1),c=Fn(t+":s"),u=Fn(t+":l");let d,h;if(e==="name")d=62+c%18,h=30+u%12;else{const p=l>=0&&l<50||l>330&&l<360,f=l>=200&&l<=300;d=55+c%20,f?h=55+u%8:p?h=48+u%6:h=50+u%8,d<60&&(d+=5)}return`hsl(${l}, ${d}%, ${h}%)`}function Bn(t,e){if(e)return fs.set(t,e),e;const i=fs.get(t);if(i)return i;const n=t.startsWith("name:")?"name":"group",r=cd(t,n);return fs.set(t,r),r}let wa=class kf{constructor(e={}){this._custom=i=>{if(!this._enabled(i.level))return _a;const[n,r]=this._prefix(i.label);return this._consoleMethod(i.method).bind(console,n,...r)},this._name=e.name,this._nameColor=e.color,this._groupPath=e._groupPath?[...e._groupPath]:[],this._dynamicLevels={...e._dynamicLevels},this._levelRef=e._levelRef??{value:e.level??1},this._name&&Bn(`name:${this._name}`,this._nameColor),this._installBuiltinLevels();for(const i of Object.keys(this._dynamicLevels))this._installLevelGetter(i,this._dynamicLevels[i]);return fd(this)}get level(){return this._levelRef.value}set level(e){this._levelRef.value=e}group(e,i){return e&&Bn(`group:${e}`,i?.color),new kf({name:this._name,color:this._nameColor,_groupPath:[...this._groupPath,e],_dynamicLevels:this._dynamicLevels,_levelRef:this._levelRef})}defineLevel(e,i){this._dynamicLevels[e]={...i},this._installLevelGetter(e,i)}get debug(){return this._method("debug")}get log(){return this._method("log")}get info(){return this._method("info")}get warn(){return this._method("warn")}get error(){return this._method("error")}_installBuiltinLevels(){}_installLevelGetter(e,i){Object.defineProperty(this,e,{configurable:!0,enumerable:!1,get:()=>this._custom(i)})}_method(e){const i=ud[e];if(!this._enabled(i.level))return _a;const[n,r]=this._prefix(i.label);return this._consoleMethod(e).bind(console,n,...r)}_consoleMethod(e){return(console[e]||console.log).bind(console)}_enabled(e){return e>=this._levelRef.value&&this._levelRef.value!==4}_prefix(e){const i=[];let n="";if(this._name){const r=Bn(`name:${this._name}`,this._nameColor);n+=`%c${this._name}%c`,i.push(`background:${r}; color:#fff; padding:1px 4px; border-radius:2px; font-weight:700;`,xa)}if(e&&(n+=` ${e}`),this._groupPath.length){const r=this._groupPath.join("/"),s=Bn(`group:${r}`);n+=` %c${r}%c`,i.push(`color:${s}; text-decoration: underline;`,xa)}return[n,i]}};const _a=()=>{},xa="color:inherit; background:transparent; text-decoration:none;",ud={debug:{level:-1,label:"",method:"debug"},log:{level:0,label:"",method:"log"},info:{level:1,label:"[I]",method:"info"},warn:{level:2,label:"[W]",method:"warn"},error:{level:3,label:"[E]",method:"error"}};function fd(t){const e=function(i,n){return t.group(i,n)};return new Proxy(e,{get(i,n,r){return t[n]},set(i,n,r){return t[n]=r,!0},apply(i,n,r){return t.group(r[0],r[1])},has(i,n){return n in t}})}function Sa(t){return new wa(t)}var Je=(t=>(t.BODY_USED="BODY_USED",t.NO_BODY_READER="NO_BODY_READER",t.TIMEOUT="TIMEOUT",t.NETWORK_ERROR="NETWORK_ERROR",t.BODY_NOT_ALLOWED="BODY_NOT_ALLOWED",t.HOOK_CONTEXT_CHANGED="HOOK_CONTEXT_CHANGED",t.ABORTED_BY_HOOK="ABORTED_BY_HOOK",t.INVALID_HOOK_CALLBACK="INVALID_HOOK_CALLBACK",t.UNEXPECTED_HOOK_RETURN="UNEXPECTED_HOOK_RETURN",t))(Je||{});let qe=class Ef extends Error{constructor(i,n,r,s){super(n,s);F(this,"name","FexiosError");this.code=i,this.context=r}static is(i){return i?.constructor===Ef}},dd=class $f extends qe{constructor(i,n,r){super(n.statusText,i,void 0,r);F(this,"name","FexiosResponseError");this.response=n}static is(i){return i?.constructor===$f}};function hd(t,e=2048){if(!(t instanceof Uint8Array))throw new TypeError("Input must be a Uint8Array");if(t.length===0)return!0;const i=Math.min(Math.max(t.length,256),e),n=t.slice(0,i);if(pd(n))return!1;const r=md(n);if(r.nullByteRatio>.05||r.highByteRatio>.95)return!1;const s=["utf-8","utf-16le","utf-16be","iso-8859-1"];let o=-1,a=!1;for(const l of s)try{const c=new TextDecoder(l,{fatal:!0}).decode(n),u=gd(c);u>o&&(o=u,a=u>.7)}catch{continue}return a}function pd(t){if(t.length<4)return!1;const e=[[137,80,78,71],[255,216,255],[71,73,70],[37,80,68,70],[80,75,3,4],[80,75,5,6],[80,75,7,8],[127,69,76,70],[77,90],[202,254,186,190],[0,0,1,0],[82,73,70,70]];for(const i of e)if(t.length>=i.length){let n=!0;for(let r=0;r<i.length;r++)if(t[r]!==i[r]){n=!1;break}if(n)return!0}return!1}function md(t){let e=0,i=0,n=0;for(const r of t)r===0&&e++,r>127&&i++,(r<32&&r!==9&&r!==10&&r!==13||r===127)&&n++;return{nullByteRatio:e/t.length,highByteRatio:i/t.length,controlCharRatio:n/t.length}}function gd(t){if(t.length===0)return 1;let e=1,i=0;for(let r=0;r<t.length;r++){const s=t[r].charCodeAt(0);s>=32&&s<=126||s===9||s===10||s===13||s===32?i++:s>127&&s<65534?!yd(s)&&!bd(s)&&i++:e-=.1}const n=i/t.length;return e*=n,vd(t)&&(e*=1.1),Math.max(0,Math.min(1,e))}function yd(t){return t>=0&&t<=31||t>=127&&t<=159}function bd(t){return t>=57344&&t<=63743||t>=983040&&t<=1048573||t>=1048576&&t<=1114109}function vd(t){return[/\b\w+\b/,/[.!?]+\s/,/\s+/,/[a-zA-Z]{3,}/,/[\u4e00-\u9fa5]+/,/\d+/].some(e=>e.test(t))}function ct(t){if(typeof t!="object"||t===null||Object.prototype.toString.call(t)!=="[object Object]")return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||e===null}const Vi=(t,...e)=>{const i=r=>{if(Array.isArray(r))return r.slice();if(ct(r)){const s={};for(const o of Reflect.ownKeys(r))s[o]=i(r[o]);return s}return r},n=i(t);for(const r of e)if(r!=null)for(const s of Reflect.ownKeys(r)){const o=r[s];if(typeof o>"u")continue;const a=n[s];ct(a)&&ct(o)?n[s]=Vi(a,o):n[s]=i(o)}return n};let Gi=class{constructor(e,i,n){F(this,"ok");F(this,"status");F(this,"statusText");F(this,"headers");this.rawResponse=e,this.data=i,this.ok=e.ok,this.status=e.status,this.statusText=e.statusText,this.headers=e.headers,Object.entries(n||{}).forEach(([r,s])=>{this[r]=s})}};async function ka(t,e,i){if(t.bodyUsed)throw new qe(Je.BODY_USED,"Response body has already been used or locked");const n=t.headers.get("content-type")||"",r=Number(t.headers.get("content-length"))||0,s=(a,l)=>l==="json"||a.startsWith("application/json"),o=(a,l,c)=>c==="blob"||a.startsWith("image/")&&!a.startsWith("image/svg")||a.startsWith("video/")||a.startsWith("audio/")||!hd(l);if((t.status===101||t.status===426||t.headers.get("upgrade"))&&typeof globalThis.WebSocket<"u"){const a=new WebSocket(t.url);return await new Promise((l,c)=>{a.onopen=l,a.onerror=c}),new Gi(t,a,{ok:!0,status:101,statusText:"Switching Protocols"})}else if(n.startsWith("text/event-stream")&&!["text","json"].includes(e||"")&&typeof globalThis.EventSource<"u"){const a=new EventSource(t.url);return await new Promise((l,c)=>{a.onopen=l,a.onerror=c}),new Gi(t,a)}else{if(e==="stream")return new Gi(t,t.body);{const a=t.clone().body?.getReader();if(!a)throw new qe(Je.NO_BODY_READER,"Failed to get ReadableStream from response body");let l=new Uint8Array;for(;;){const{done:u,value:d}=await a.read();if(u)break;if(d&&(l=new Uint8Array([...l,...d]),i&&r>0)){const h=Math.min(l.length/r,1);i(h,l)}}const c=new Gi(t,void 0);if(e==="arrayBuffer")return c.data=l.buffer,c;if(s(n,e))try{const u=new TextDecoder().decode(l);c.data=JSON.parse(u)}catch{}if(typeof c.data!="string"&&o(n,l,e)?c.data=new Blob([l],{type:t.headers.get("content-type")||void 0}):c.data=new TextDecoder().decode(l),typeof c.data=="string"&&e!=="text"){const u=c.data.trim(),d=u[0],h=u[u.length-1];if(d==="{"&&h==="}"||d==="["&&h==="]")try{c.data=JSON.parse(c.data)}catch{}}if(typeof c.data>"u"&&(c.data=l.length>0?l:void 0),c.ok)return c;throw new dd(`Request failed with status code ${t.status}`,c)}}}var qn;(t=>{t.makeSearchParams=r=>{if(!r)return new URLSearchParams;if(r instanceof URLSearchParams)return r;if(typeof r!="object"||r?.constructor!==Object)throw new TypeError("only plain object is supported");const s=new URLSearchParams,o=(c,u)=>{u!=null&&s.append(c,u)},a=(c,u)=>{u!=null&&s.set(c,u)},l=(c,u)=>{if(u!=null){if(Array.isArray(u)){for(const d of u)o(c,d?.toString());return}if(typeof u=="object"&&u.constructor===Object){for(const[d,h]of Object.entries(u)){if(h==null)continue;const p=d.endsWith("[]"),f=p?d.slice(0,-2):d,_=`${c}[${f}]`;if(p){const P=`${_}[]`;if(Array.isArray(h))for(const C of h)o(P,C?.toString());else typeof h=="object"&&h!==null&&h.constructor===Object?l(`${_}[]`,h):o(P,h?.toString())}else if(Array.isArray(h))for(const P of h)o(_,P?.toString());else typeof h=="object"&&h!==null&&h.constructor===Object?l(_,h):a(_,h?.toString())}return}a(c,u?.toString())}};for(const[c,u]of Object.entries(r))l(c,u);return s},t.makeQueryString=r=>(0,t.makeSearchParams)(r).toString(),t.makeURL=(r,s,o,a)=>{const l=typeof window<"u"&&window.location?.origin||"http://localhost",c=typeof r=="string"?new URL(r,a??l):new URL(r),u=(0,t.toQueryRecord)(c.searchParams),d=(0,t.mergeQueries)(u,s||{}),h=(0,t.makeSearchParams)(d);return c.search=h.toString(),c.hash=o||"",c},t.toQueryRecord=r=>{typeof r=="string"&&(r=(0,t.fromString)(r));const s={},o=l=>{if(!l.includes("["))return{path:[l],forceArray:!1};const c=[l.slice(0,l.indexOf("["))],u=/\[([^\]]*)\]/g;let d,h=!1,p=!1;for(;d=u.exec(l);)d[1]===""?(h=!0,p=!0):(c.push(d[1]),p=!1);return h&&p&&(c[c.length-1]=c[c.length-1]+"[]"),{path:c,forceArray:h}},a=(l,c,u,d)=>{let h=l;for(let p=0;p<c.length;p++){const f=c[p];p===c.length-1?d?h[f]===void 0?h[f]=[u]:Array.isArray(h[f])?h[f].push(u):h[f]=[h[f],u]:h[f]===void 0?h[f]=u:Array.isArray(h[f])?h[f].push(u):h[f]=[h[f],u]:((h[f]===void 0||typeof h[f]!="object"||Array.isArray(h[f]))&&(h[f]={}),h=h[f])}};for(const[l,c]of r.entries()){const{path:u,forceArray:d}=o(String(l));a(s,u,c?.toString(),d)}return s},t.fromString=r=>{const s=r.trim();if(!s)return new URLSearchParams;if(s.startsWith("?"))return new URLSearchParams(s.slice(1));const o=s.indexOf("?");if(o>=0){const a=s.indexOf("#",o+1),l=s.slice(o+1,a>=0?a:void 0);return new URLSearchParams(l)}return new URLSearchParams(s)},t.mergeQueries=(r,...s)=>{const o=e(i(r));for(const a of s)a!=null&&n(o,i(a));return o};function e(r){if(Array.isArray(r))return r.map(e);if(ct(r)){const s={};for(const[o,a]of Object.entries(r))s[o]=e(a);return s}if(r instanceof Map){const s={};for(const[o,a]of r.entries())s[o]=e(a);return s}return r}function i(r){if(!r)return{};if(r instanceof URLSearchParams||r instanceof FormData||r instanceof Map)return(0,t.toQueryRecord)(r);if(typeof r=="string")return(0,t.toQueryRecord)((0,t.fromString)(r));if(ct(r))return r;throw new TypeError(`unsupported type transformation, got: ${Object.prototype.toString.call(r)}`)}function n(r,s){for(const[o,a]of Object.entries(s)){if(a===void 0)continue;if(a===null){delete r[o];continue}const l=r[o];ct(l)&&ct(a)?n(l,a):r[o]=e(a)}}})(qn||(qn={}));const Ea=function(t){const e=this.constructor.prototype,i=Reflect.get(e,t,e);function n(...r){return Reflect.apply(i,n,r)}Reflect.setPrototypeOf(n,e);for(const r of Reflect.ownKeys(i)){const s=Reflect.getOwnPropertyDescriptor(i,r);s&&Reflect.defineProperty(n,r,s)}return n};Ea.prototype=Object.create(Function.prototype);var Yi;(t=>{t.makeHeaders=e=>{if(!e)return new Headers;if(e instanceof Headers)return new Headers(e);const i=new Headers;if(e instanceof Map){for(const[n,r]of e.entries())if(r!=null)if(Array.isArray(r))for(const s of r)s!=null&&i.append(n,String(s));else i.append(n,String(r));return i}if(ct(e)){for(const[n,r]of Object.entries(e))if(r!=null)if(Array.isArray(r))for(const s of r)s!=null&&i.append(n,String(s));else i.append(n,String(r));return i}throw new TypeError("only plain object, Map/ReadonlyMap, or Headers is supported")},t.toHeaderRecord=e=>{if(e instanceof Headers){const i={};return e.forEach((n,r)=>{i[r]=i[r]?[...i[r],n]:[n]}),i}if(e instanceof Map){const i={};for(const[n,r]of e.entries())if(r!=null)if(Array.isArray(r)){const s=r.filter(o=>o!=null).map(o=>String(o));s.length&&(i[n]=(i[n]??[]).concat(s))}else{const s=String(r);i[n]=i[n]?[...i[n],s]:[s]}return i}throw new TypeError(`unsupported type transformation, got: ${Object.prototype.toString.call(e)}`)},t.mergeHeaders=(e,...i)=>{const n=e instanceof Headers?new Headers(e):(0,t.makeHeaders)(e),r=s=>{for(const[o,a]of Object.entries(s))if(a!==void 0){if(a===null){n.delete(o);continue}if(Array.isArray(a)){n.delete(o);for(const l of a)l!=null&&n.append(o,String(l))}else n.set(o,String(a))}};for(const s of i){if(s==null)continue;if(s instanceof Headers){s.forEach((a,l)=>{n.set(l,a)});continue}if(ct(s)){r(s);continue}const o=(0,t.toHeaderRecord)(s);for(const[a,l]of Object.entries(o)){n.delete(a);for(const c of l)n.append(a,c)}}return n}})(Yi||(Yi={}));let ds=(fe=class extends Ea{constructor(i={}){super("request");F(this,"baseConfigs");F(this,"hooks",[]);F(this,"mergeQueries",qn.mergeQueries);F(this,"mergeHeaders",Yi.mergeHeaders);F(this,"interceptors",{request:this.createInterceptor("beforeRequest"),response:this.createInterceptor("afterResponse")});F(this,"create",fe.create);F(this,"_plugins",new Map);F(this,"checkIsPlainObject",ct);F(this,"mergeQuery",this.mergeQueries);this.baseConfigs=Vi(fe.DEFAULT_CONFIGS,i),fe.ALL_METHODS.forEach(n=>this.createMethodShortcut(n.toLowerCase()))}async request(i,n){let r=n=n||{};if(typeof i=="string"||i instanceof URL?r.url=i.toString():typeof i=="object"&&(r=Vi(i,r)),r=await this.emit("beforeInit",r,{shouldAdjustRequestParams:!0,shouldHandleShortCircuitResponse:!0}),r[fe.FINAL_SYMBOL])return r;if(fe.METHODS_WITHOUT_BODY.includes(r.method?.toLocaleLowerCase())&&r.body)throw new qe(Je.BODY_NOT_ALLOWED,`Request method "${r.method}" does not allow body`);if(r=await this.emit("beforeRequest",r,{shouldAdjustRequestParams:!0,shouldHandleShortCircuitResponse:!0,preAdjust:!0,requestOptionsOverridesURLSearchParams:!0,preRequestOptionsOverridesURLSearchParams:!0,postRequestOptionsOverridesURLSearchParams:!0}),r[fe.FINAL_SYMBOL])return r;let s;const o={};if(typeof r.body<"u"&&r.body!==null&&(r.body instanceof Blob||r.body instanceof FormData||r.body instanceof URLSearchParams?s=r.body:typeof r.body=="object"&&r.body!==null?(s=JSON.stringify(r.body),r.headers=this.mergeHeaders(r.headers,{"Content-Type":"application/json"})):s=r.body),!Yi.makeHeaders(n.headers||{}).get("content-type")&&s&&(s instanceof FormData||s instanceof URLSearchParams?o["content-type"]=null:typeof s=="string"&&typeof r.body=="object"?o["content-type"]="application/json":s instanceof Blob&&(o["content-type"]=s.type||"application/octet-stream")),r.body=s,r=await this.emit("afterBodyTransformed",r,{shouldAdjustRequestParams:!0,shouldHandleShortCircuitResponse:!0,preAdjust:!0,postRequestOptionsOverridesURLSearchParams:!0}),r[fe.FINAL_SYMBOL])return r;const a=r.abortController||globalThis.AbortController?new AbortController:void 0,l=r.baseURL||this.baseConfigs.baseURL||globalThis.location?.href||"http://localhost",c=new URL(r.url.toString(),l),u=qn.makeURL(c,r.query,c.hash).toString(),d=new Request(u,{method:r.method||"GET",credentials:r.credentials,cache:r.cache,mode:r.mode,headers:Yi.mergeHeaders(this.baseConfigs.headers,r.headers||{},o),body:r.body,signal:a?.signal});if(r.rawRequest=d,r=await this.emit("beforeActualFetch",r,{shouldHandleShortCircuitResponse:!0}),r[fe.FINAL_SYMBOL])return r;const h=r.timeout||this.baseConfigs.timeout||60*1e3;if(r.url.startsWith("ws"))try{const f=new WebSocket(r.url);return await new Promise((_,P)=>{const C=setTimeout(()=>{P(new qe(Je.TIMEOUT,`WebSocket connection timed out after ${h}ms`,r))},h);f.onopen=()=>{clearTimeout(C),_()},f.onerror=R=>{clearTimeout(C),P(new qe(Je.NETWORK_ERROR,"WebSocket connection failed",r))},f.onclose=R=>{R.code!==1e3&&(clearTimeout(C),P(new qe(Je.NETWORK_ERROR,`WebSocket closed with code ${R.code}`,r)))}}),r.rawResponse=new Response,r.response=new Gi(r.rawResponse,f,{ok:!0,status:101,statusText:"Switching Protocols"}),r.data=f,r.headers=new Headers,this.emit("afterResponse",r)}catch(f){throw f instanceof qe?f:new qe(Je.NETWORK_ERROR,`WebSocket creation failed: ${f}`,r)}let p;try{a&&(p=setTimeout(()=>{a.abort()},h));const f=await(n.fetch||this.baseConfigs.fetch||globalThis.fetch)(r.rawRequest).catch(_=>{throw p&&clearTimeout(p),a?.signal.aborted?new qe(Je.TIMEOUT,`Request timed out after ${h}ms`,r):new qe(Je.NETWORK_ERROR,_.message,r)});return p&&clearTimeout(p),r.rawResponse=f,r.response=await ka(f,r.responseType,(_,P)=>{n?.onProgress?.(_,P)}),r.data=r.response.data,r.headers=r.response.headers,this.emit("afterResponse",r)}catch(f){throw p&&clearTimeout(p),f}}normalizeContext(i,n={}){const r=i,s=r.baseURL||this.baseConfigs.baseURL||globalThis.location?.href||"http://localhost",o=new URL(s,globalThis.location?.href||"http://localhost"),a=new URL(r.url.toString(),o),l=!!r[fe.NORMALIZED_SYMBOL];r.baseURL=o?o.origin:a.origin;let c;l?c=n.requestOptionsOverridesURLSearchParams?this.mergeQueries({},a.search,r.query):this.mergeQueries({},r.query,a.search):(c=n.requestOptionsOverridesURLSearchParams?this.mergeQueries(o?.search||"",this.baseConfigs.query,a.search,r.query):this.mergeQueries(o?.search||"",this.baseConfigs.query,r.query,a.search),r[fe.NORMALIZED_SYMBOL]=!0),r.query=c;const u=new URL(a);return u.search="",r.url=u.toString(),r}async emit(i,n,r={}){const s=this.hooks.filter(o=>o.event===i);if(r?.shouldAdjustRequestParams&&r?.preAdjust)try{n=this.normalizeContext(n,{requestOptionsOverridesURLSearchParams:r.preRequestOptionsOverridesURLSearchParams})}catch{}try{let o=0;for(const a of s){const l=`${i}#${a.action.name||`anonymous#${o}`}`,c=Symbol("FEXIOS_HOOK_CONTEXT");n[c]=c;const u=n.url;let d="";try{const p=this.mergeQueries({},n.query||{});d=JSON.stringify(p)}catch{}let h=await a.action.call(this,n);if(h===void 0&&(h=n),h===!1)throw new qe(Je.ABORTED_BY_HOOK,`Request aborted by hook "${l}"`,n);if(h instanceof Response){const p=h,f={...n,rawResponse:p},_=await ka(p,n.responseType,(P,C)=>{n.onProgress?.(P,C)});if(f.response=_,f.data=_.data,f.headers=_.headers,i!=="afterResponse"){const P=await this.emit("afterResponse",f);return P[fe.FINAL_SYMBOL]=!0,P}else return f[fe.FINAL_SYMBOL]=!0,f}else if(typeof h=="object"&&h[c]===c)n=h;else{const p=globalThis["".concat("console")];try{throw new qe(Je.HOOK_CONTEXT_CHANGED,`Hook "${l}" should return the original FexiosContext or return false to abort the request, but got "${h}".`)}catch(f){p.warn(f.stack||f)}}if(r?.shouldAdjustRequestParams)try{const p=n.baseURL||this.baseConfigs.baseURL||globalThis.location?.href||"http://localhost",f=new URL(n.url.toString(),p);let _={};if(d)try{_=JSON.parse(d)}catch{}const P=n.query||{},C=this.mergeQueries(_,f.search,P);n.query=C;const R=new URL(f);R.search="",n.url=R.toString()}catch{}delete n[c],o++}}catch(o){return Promise.reject(o)}return n}on(i,n,r=!1){if(typeof n!="function")throw new qe(Je.INVALID_HOOK_CALLBACK,`Hook should be a function, but got "${typeof n}"`);return this.hooks[r?"unshift":"push"]({event:i,action:n}),this}off(i,n){return i==="*"||!i?this.hooks=this.hooks.filter(r=>r.action!==n):this.hooks=this.hooks.filter(r=>r.event!==i||r.action!==n),this}createInterceptor(i){return{handlers:()=>this.hooks.filter(n=>n.event===i).map(n=>n.action),use:(n,r=!1)=>this.on(i,n,r),clear:()=>{this.hooks=this.hooks.filter(n=>n.event!==i)}}}createMethodShortcut(i){return Reflect.defineProperty(this,i,{get:()=>(n,r,s)=>(fe.METHODS_WITHOUT_BODY.includes(i.toLocaleLowerCase())?s=r:(s=s||{},s.body=r),this.request(n,{...s,method:i}))}),this}extends(i){const n=new fe(Vi(this.baseConfigs,i));return n.hooks=[...this.hooks],n._plugins=new Map(this._plugins),n._plugins.forEach(async r=>{await n.plugin(r)}),n}static create(i){return new fe(i)}async plugin(i){if(typeof i?.name=="string"&&typeof i?.install=="function"){if(this._plugins.has(i.name))return this;const n=await i.install(this);if(this._plugins.set(i.name,i),n instanceof fe)return n}return this}},F(fe,"FINAL_SYMBOL",Symbol("FEXIOS_FINAL_CONTEXT")),F(fe,"NORMALIZED_SYMBOL",Symbol("FEXIOS_NORMALIZED_QUERY")),F(fe,"DEFAULT_CONFIGS",{baseURL:"",timeout:60*1e3,credentials:"same-origin",headers:{},query:{},responseType:void 0,fetch:globalThis.fetch}),F(fe,"ALL_METHODS",["get","post","put","patch","delete","head","options","trace"]),F(fe,"METHODS_WITHOUT_BODY",["get","head","options","trace"]),fe);const wd=ds.create,$a=wd();typeof globalThis<"u"?globalThis.fexios=$a:typeof window<"u"&&(window.fexios=$a);var Hn;(t=>{function e(n){return Array.isArray(n)?n.join("|"):typeof n=="boolean"||n===null?n?"1":void 0:typeof n=="number"?""+n:n}t.normalizeParamValue=e;function i(n){const r=o=>o&&(o instanceof URLSearchParams||o instanceof FormData);if(n==null)return;const s=new FormData;if(r(n))return n.forEach((o,a)=>{const l=e(o);l!=null&&s.append(a,l)}),s;if(ct(n))return Object.entries(n).forEach(([o,a])=>{const l=e(a);l!=null&&s.append(o,l)}),s}t.normalizeBody=i})(Hn||(Hn={}));var Qi=(t=>(t.HTTP_ERROR="HTTP_ERROR",t.LOGIN_FAILED="LOGIN_FAILED",t.LOGIN_RETRY_LIMIT_EXCEEDED="LOGIN_RETRY_LIMIT_EXCEEDED",t.TOKEN_RETRY_LIMIT_EXCEEDED="TOKEN_RETRY_LIMIT_EXCEEDED",t))(Qi||{});let He=class extends Error{constructor(e,i="",n){super(),this.code=e,this.message=i,this.cause=n,this.name="WikiSaikouError"}static is(e,i){return e instanceof this&&(i===void 0||e.code===i)}},bi=class Pf extends Error{constructor(e,i){super(),this.errors=e,this.cause=i,this.name="MediaWikiApiError",this.errors=Pf.normalizeErrors(e),this.message=e.map(n=>n.text).filter(Boolean).join(`
4
- `),this.code=this.isBadTokenError()?"badtoken":this.errors[0]?.code||"Unknown Error"}get firstError(){return this.errors[0]}isBadTokenError(){return this.errors.some(e=>e.code==="badtoken")||["NeedToken","WrongToken"].includes(this.cause?.data?.login?.result)}toString(){return`[${this.name} ${this.code}]`}static is(e){return e instanceof this}static normalizeErrors(e){return Array.isArray(e)===!1?[]:e.filter(i=>typeof i=="object"&&!!i?.code).map(i=>i.text?i:i.info?{...i,text:i.info}:i["*"]?{...i,text:i["*"]}:{...i,text:""})}};(t=>{function e(s){if(s==null)return;if(s?.response?.data!==void 0)return s.response.data;if(s?.data!==void 0)return s.data;const o=s instanceof Error?s.cause:void 0;return o?.response?.data!==void 0?o.response.data:o?.data!==void 0?o.data:s||void 0}function i(s){return n(s).length>0}t.includesMediaWikiApiError=i,t.normalizeMwApiErrors=bi.normalizeErrors;function n(s){let o=e(s);if(typeof o!="object"||o===null)return[];const a=o?.error,l=o?.errors,c=[];return a&&c.push(a),Array.isArray(l)&&c.push(...l),(0,t.normalizeMwApiErrors)(c)}t.extractMediaWikiApiErrors=n;function r(s){if(bi.is(s))return s.isBadTokenError();{const o=n(s);return new bi(o).isBadTokenError()}}t.isBadTokenError=r})(He||(He={}));const Pa=Symbol.for("__FEXIOS_SAIKOU__");function Ca(t){const e=t instanceof ds?t:new ds({baseURL:t instanceof URL?t.toString():String(t),responseType:"json"});return e[Pa]||(Reflect.defineProperty(e,Pa,{get:()=>!0,enumerable:!1,configurable:!1}),e._tokens=new Map,e.on("afterResponse",i=>{const{data:n,rawRequest:r}=i,s=r?.headers.get("x-mw-token-name");s&&He.isBadTokenError(n)&&e._tokens.delete(s);const o=n?.query?.tokens;o&&typeof o=="object"&&Object.entries(o).forEach(([l,c])=>{typeof c=="string"&&e._tokens.set(l.replace(/token$/i,"").toLowerCase(),c)});const a=n?.login?.token;return typeof a=="string"&&e._tokens.set("login",a),i}),e.on("beforeInit",i=>{if(i.method?.toLowerCase()!=="post")return i;if(i.body===void 0||i.body===null)return i.body=void 0,i;const n=i.body=Hn.normalizeBody(i.body),r=new URLSearchParams(i.query);return n.has("format")&&r.delete("format"),n.has("formatversion")&&r.delete("formatversion"),n.has("action")&&r.delete("action"),n.has("origin")&&(r.set("origin",""+n.get("origin")),n.delete("origin")),i.query=Object.fromEntries(r.entries()),i}),e.on("beforeInit",i=>(i.query=Hn.normalizeBody(i.query)||{},i)),e.on("beforeRequest",i=>{const n=new URL(i.url),r=n.searchParams;if(globalThis.location&&(!r.has("origin")&&location.origin!==n.origin?(r.set("origin",location.origin),e.baseConfigs.credentials="include",e.baseConfigs.mode="cors"):location.origin===n.origin&&(r.delete("origin"),e.baseConfigs.credentials=void 0,e.baseConfigs.mode=void 0)),n.searchParams.has("origin")){const s=encodeURIComponent(n.searchParams.get("origin")||"").replace(/\./g,"%2E");i.query={},n.searchParams.delete("origin"),i.url=`${n}${n.search?"&":"?"}origin=${s}`}return i})),e}const ei=(t,...e)=>{const i=s=>Object.prototype.toString.call(s)==="[object Object]",n=s=>{if(Array.isArray(s))return s.slice();if(i(s)){const o={};for(const a of Reflect.ownKeys(s))o[a]=n(s[a]);return o}return s},r=n(t);for(const s of e)if(s!=null)for(const o of Reflect.ownKeys(s)){const a=s[o];if(typeof a>"u")continue;const l=r[o];i(l)&&i(a)?r[o]=ei(l,a):r[o]=n(a)}return r},_d=(t,e,i)=>{let n={...Ra.DEFAULT_CONFIGS};if(typeof t=="string"?n=ei(n,{baseURL:t,fexiosConfigs:e||{},defaultParams:i||{}}):typeof t=="object"&&t!==null&&(n=ei(n,t)),!n.baseURL&&typeof window=="object"&&window.mediaWiki){const{wgServer:r,wgScriptPath:s}=window.mediaWiki?.config?.get(["wgServer","wgScriptPath"])||{};typeof r=="string"&&typeof s=="string"&&(n.baseURL=`${r}${s}/api.php`)}if(typeof n.baseURL!="string")throw new Error("baseURL is required");return n},xd=()=>{},Sd=async(t,e)=>{let i=0;const{retry:n=3,onRetry:r=xd,shouldRetry:s=()=>!0}=e;let o;do try{return await t()}catch(a){if(o=a,s(a,i))r(a,i),i++;else throw a}while(i<n);throw o||new Error("Retry failed")};const Ji=class{constructor(e,i,n){this.version="7.1.2",this.token=this.getToken;const r=this.config=_d(e,i,n);this.request=Ca(r.baseURL)}setBaseURL(e){return this.config.baseURL=e,this.request.baseConfigs.baseURL=e,this}async get(e,i){return this.runRequestWithApiErrorMapping(()=>this.request.get("",ei({},this.config.fexiosConfigs,{query:ei(this.config.defaultParams,e)},i)))}async post(e,i){return this.runRequestWithApiErrorMapping(()=>this.request.post("",e,ei({},this.config.fexiosConfigs,{query:this.config.defaultParams},i)))}async runRequestWithApiErrorMapping(e){try{const i=await e();return this.handleApiResponse(i)}catch(i){throw this.config.throwOnApiError&&He.includesMediaWikiApiError(i)?new bi(He.extractMediaWikiApiErrors(i),i):i}}throwIfApiError(e){const i=He.extractMediaWikiApiErrors(e);if(i.length>0)throw new bi(i,e)}handleApiResponse(e){return this.config.throwOnApiError&&this.throwIfApiError(e.data),e}get tokens(){return this.request._tokens}async fetchTokens(e=["csrf"]){return this.config.fexiosConfigs.credentials="include",await this.get({action:"query",meta:"tokens",type:e}),this.tokens}async getToken(e="csrf",i=!1){return(!this.tokens.get(e)||i)&&(this.tokens.delete(e),await this.fetchTokens([e])),this.tokens.get(e)}badToken(e){return this.tokens.delete(e),this.tokens}async postWithToken(e,i,n){const{tokenName:r="token",retry:s=3,noCache:o=!1,fexiosOptions:a}=n||{};if(s<1)throw new He(Qi.TOKEN_RETRY_LIMIT_EXCEEDED,"The limit of the number of times to automatically re-acquire the token has been exceeded");let l=0;return Sd(async()=>{const c=await this.getToken(e,o||l>0);try{const u=await this.post({[r]:c,...i},ei(a||{},{headers:{"x-mw-token-name":e}}));if(He.isBadTokenError(u.data))throw u;return u}catch(u){throw He.isBadTokenError(u)||u?.ok===!1||bi.is(u)?u:new He(Qi.HTTP_ERROR,"Network/transport or SDK-internal error (not a MediaWiki API error)",u)}},{retry:s,onRetry:(c,u)=>{l=u+1},shouldRetry:c=>He.isBadTokenError(c)||c?.ok===!1}).catch(c=>{throw He.isBadTokenError(c)||c?.ok===!1?new He(Qi.TOKEN_RETRY_LIMIT_EXCEEDED,"Retry attempts for acquiring/using token exhausted",c):c})}postWithEditToken(e){return this.postWithToken("csrf",e)}get baseURL(){return this.config.baseURL}get defaultParams(){return this.config.defaultParams}get defaultOptions(){return this.config.fexiosConfigs}};Ji.INIT_DEFAULT_PARAMS={action:"query",errorformat:"plaintext",format:"json",formatversion:2},Ji.DEFAULT_CONFIGS={baseURL:void 0,fexiosConfigs:{responseType:"json"},defaultParams:Ji.INIT_DEFAULT_PARAMS,throwOnApiError:!1},Ji.createRequestHandler=Ca;let Ra=Ji;let kd=class extends Ra{async clientLogin(e,i,n){n||(n={}),!n.logincontinue&&!n.loginreturnurl&&(n.loginreturnurl=location?.origin);const r=await this.postWithToken("login",{action:"clientlogin",username:e,password:i,...n},{tokenName:"logintoken"});if(r?.data?.clientlogin?.status==="PASS")return r.data.clientlogin;throw new He(Qi.LOGIN_FAILED,r.data.clientlogin.message,r)}};class Ed{constructor(e,i={}){this.ctx=e,location?.href&&i?.baseURL?.toString()?.startsWith("/")&&(i.baseURL=new URL(i.baseURL,location.origin));const n=new kd({baseURL:i.baseURL.toString(),fexiosConfigs:{headers:{"x-api-user-agent":`InPageEdit-NEXT ${e.version}`,...i.headers},...i},throwOnApiError:!0});e.set("api",n)}}var $d=Object.create,hs=Object.defineProperty,Pd=Object.getOwnPropertyDescriptor,Aa=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Ia=t=>{throw TypeError(t)},Cd=(t,e,i)=>e in t?hs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Rd=(t,e)=>hs(t,"name",{value:e,configurable:!0}),Ad=t=>[,,,$d(t?.[Aa("metadata")]??null)],Id=["class","method","getter","setter","accessor","field","value","get","set"],Oa=t=>t!==void 0&&typeof t!="function"?Ia("Function expected"):t,Od=(t,e,i,n,r)=>({kind:Id[t],name:e,metadata:n,addInitializer:s=>i._?Ia("Already initialized"):r.push(Oa(s||null))}),Td=(t,e)=>Cd(e,Aa("metadata"),t[3]),Ld=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Nd=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,h=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&Pd(r,i));Rd(r,i);for(var f=n.length-1;f>=0;f--)l=Od(c,i,a={},t[3],h),o=(0,n[f])(r,l),a._=1,Oa(o)&&(r=o);return Td(t,r),p&&hs(r,i,p),u?c^4?s:p:r},Ta,ps,La;Ta=[$e(["wiki","wikiTitle"])];class zn extends(La=Ot){constructor(i){super(i,"currentPage",!1);Hi(this,Ve);this.ctx=i,this.url=new URL(window.location.href),this.isMainPage=void 0,this.wikiTitle=void 0}get logger(){return this.ctx.logger("CURRENT_PAGE")}async start(){await lt(this,Ve,oa).call(this),lt(this,Ve,Cf).call(this),window.addEventListener("popstate",lt(this,Ve,aa).bind(this)),this.logger.info("initialized",this.wikiTitle)}stop(){window.removeEventListener("popstate",lt(this,Ve,aa).bind(this))}get params(){return this.url.searchParams}get canonicalUrl(){const i=document.querySelector('link[rel="canonical"]')?.href;let n=null;return i&&(n=new URL(i,location.origin)),Reflect.defineProperty(this,"canonicalUrl",{get:()=>n}),n}get wikiAction(){return this.params.get("action")||"view"}}Ve=new WeakSet,oa=async function(){await lt(this,Ve,Af).call(this),await lt(this,Ve,Rf).call(this)},Cf=function(){const i=Symbol.for("InPageEdit.CurrentPageService.UrlChangeListenerInstalled");if(window[i])return;const n=history.pushState,r=history.replaceState;history.pushState=function(s,o,a){n.apply(this,[s,o,a]),window.dispatchEvent(new PopStateEvent("popstate",{state:s}))},history.replaceState=function(s,o,a){r.apply(this,[s,o,a]),window.dispatchEvent(new PopStateEvent("popstate",{state:s}))},window[i]=!0},aa=async function(i){const n=this.url,r=new URL(window.location.href);this.url=r,(n.pathname!==r.pathname||n.searchParams.get("title")!==r.searchParams.get("title")||n.searchParams.get("curid")!==r.searchParams.get("curid"))&&(await lt(this,Ve,oa).call(this),this.logger.info("location changed",r,this.wikiTitle))},Rf=async function(){const n=this.wikiTitle?.getMainDBKey()===this.ctx.wiki.mainPageName;return Reflect.defineProperty(this,"isMainPage",{get:()=>n}),n},Af=async function(){let i=null;return this.canonicalUrl?i=await this.ctx.wikiTitle.newTitleFromUrl(this.canonicalUrl):i=await this.ctx.wikiTitle.newTitleFromUrl(this.url),Object.freeze(i),Reflect.defineProperty(this,"wikiTitle",{get:()=>i}),i},ps=Ad(La),zn=Nd(ps,0,"CurrentPageService",Ta,zn),Ld(ps,1,zn);class Md extends Ot{constructor(e){super(e,"resourceLoader",!0),this.ctx=e}stop(){this.removeAll()}loadScript(e,i){if(!e)return Promise.resolve(null);const n=`script:${e}`,r=document.querySelector(`[data-ipe="${n}"]`);return r?Promise.resolve(r):new Promise((o,a)=>{const l=document.createElement("script");l.src=e,l.dataset.ipe=n,i&&Object.entries(i).forEach(([c,u])=>{typeof u>"u"||u===!1||u===null?l.removeAttribute(c):l.setAttribute(c,u)}),document.body.appendChild(l),l.onload=()=>o(l),l.onerror=c=>a(c)})}loadStyle(e,i){if(!e)return Promise.resolve(null);const n=`style:${e}`,r=document.querySelector(`[data-ipe="${n}"]`);return r?Promise.resolve(r):new Promise((o,a)=>{const l=document.createElement("link");l.rel="stylesheet",l.href=e,l.dataset.ipe=n,i&&Object.entries(i).forEach(([u,d])=>{typeof d>"u"||d===!1||d===null?l.removeAttribute(u):l.setAttribute(u,d)}),(document.querySelector('meta[name="ipe-styles"]')||(()=>{const u=document.createElement("meta");return u.id="ipe-styles",u.name="ipe-styles",document.head.insertAdjacentElement("afterbegin",u),u})()).before(l),l.onload=()=>o(l),l.onerror=u=>a(u)})}removeStyle(e){const i=`style:${e}`,n=document.querySelector(`[data-ipe="${i}"]`);n&&n.remove()}removeScript(e){const i=`script:${e}`,n=document.querySelector(`[data-ipe="${i}"]`);n&&n.remove()}removeAll(){document.querySelectorAll("[data-ipe]").forEach(e=>{e.remove()})}resolveImportPath(e){if(e.startsWith("http")||e.startsWith("//"))return e;const i=document.currentScript?.src;if(!i)return`https://unpkg.com/mediawiki-inpageedit@latest/dist/${e}`;const n=new URL(i);return n.pathname.endsWith(".js")||(n.pathname=n.pathname+"/"),new URL(e,n.toString()).toString()}}const Kn=Object.keys;function Dd(t){return typeof t=="boolean"}function jd(t){return t&&typeof t.nodeType=="number"}function Wn(t){return typeof t=="string"}function Na(t){return typeof t=="number"}function ti(t){return typeof t=="object"?t!==null:Xi(t)}function Xi(t){return typeof t=="function"}function Ud(t){return!!(t&&t.isComponent)}function Fd(t){return ti(t)&&typeof t.length=="number"&&typeof t.nodeType!="number"}function ms(t,e){if(t)for(const i of Kn(t))e(t[i],i)}function Bd(t){return ti(t)&&"current"in t}const gs={animationIterationCount:0,borderImageOutset:0,borderImageSlice:0,borderImageWidth:0,boxFlex:0,boxFlexGroup:0,boxOrdinalGroup:0,columnCount:0,columns:0,flex:0,flexGrow:0,flexPositive:0,flexShrink:0,flexNegative:0,flexOrder:0,gridArea:0,gridRow:0,gridRowEnd:0,gridRowSpan:0,gridRowStart:0,gridColumn:0,gridColumnEnd:0,gridColumnSpan:0,gridColumnStart:0,fontWeight:0,lineClamp:0,lineHeight:0,opacity:0,order:0,orphans:0,tabSize:0,widows:0,zIndex:0,zoom:0,fillOpacity:0,floodOpacity:0,stopOpacity:0,strokeDasharray:0,strokeDashoffset:0,strokeMiterlimit:0,strokeOpacity:0,strokeWidth:0};function qd(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}const Hd=["Webkit","ms","Moz","O"];Kn(gs).forEach(t=>{Hd.forEach(e=>{gs[qd(e,t)]=0})});const zd=Symbol.for("jsx-dom:type");var Ma=(function(t){return t.ShadowRoot="ShadowRoot",t})(Ma||{});function Kd(t){return t!=null&&t[zd]===Ma.ShadowRoot}const Wd="http://www.w3.org/2000/svg",Vd="http://www.w3.org/1999/xlink",Gd="http://www.w3.org/XML/1998/namespace";function Da(t){return!Dd(t)&&t!=null}function ys(t){return Array.isArray(t)?t.map(ys).filter(Boolean).join(" "):ti(t)?Symbol.iterator in t?ys(Array.from(t)):Kn(t).filter(e=>t[e]).join(" "):Da(t)?""+t:""}const Yd={animate:0,circle:0,clipPath:0,defs:0,desc:0,ellipse:0,feBlend:0,feColorMatrix:0,feComponentTransfer:0,feComposite:0,feConvolveMatrix:0,feDiffuseLighting:0,feDisplacementMap:0,feDistantLight:0,feFlood:0,feFuncA:0,feFuncB:0,feFuncG:0,feFuncR:0,feGaussianBlur:0,feImage:0,feMerge:0,feMergeNode:0,feMorphology:0,feOffset:0,fePointLight:0,feSpecularLighting:0,feSpotLight:0,feTile:0,feTurbulence:0,filter:0,foreignObject:0,g:0,image:0,line:0,linearGradient:0,marker:0,mask:0,metadata:0,path:0,pattern:0,polygon:0,polyline:0,radialGradient:0,rect:0,stop:0,svg:0,switch:0,symbol:0,text:0,textPath:0,tspan:0,use:0,view:0},Qd=/^(a(ll|t|u)|base[FP]|c(al|lipPathU|on)|di|ed|ex|filter[RU]|g(lyphR|r)|ke|l(en|im)|ma(rker[HUW]|s)|n|pat|pr|point[^e]|re[^n]|s[puy]|st[^or]|ta|textL|vi|xC|y|z)/;function vi(t){const e=document.createDocumentFragment();return Vn(t.children,e),e}function Jd(t,e,i){e={...e,children:i};const n=new t(e),r=n.render();return"ref"in e&&bs(e.ref,n),r}function m(t,e){let{children:i,...n}=e;!n.namespaceURI&&Yd[t]===0&&(n={...n,namespaceURI:Wd});let r;if(Wn(t)){if(r=n.namespaceURI?document.createElementNS(n.namespaceURI,t):document.createElement(t),eh(n,r),Vn(i,r),r instanceof window.HTMLSelectElement&&n.value!=null)if(n.multiple===!0&&Array.isArray(n.value)){const s=n.value.map(o=>String(o));r.querySelectorAll("option").forEach(o=>o.selected=s.includes(o.value))}else r.value=n.value;bs(n.ref,r)}else if(Xi(t))ti(t.defaultProps)&&(n={...t.defaultProps,...n}),r=Ud(t)?Jd(t,n,i):t({...n,children:i});else throw new TypeError(`Invalid JSX element type: ${t}`);return r}function Zi(t,e){for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r<i;r++)n[r-2]=arguments[r];return(Wn(e)||Array.isArray(e))&&(n.unshift(e),e={}),e=e||{},e.children!=null&&!n.length&&({children:n,...e}=e),m(t,{...e,children:n},e.key)}function bs(t,e){Bd(t)?t.current=e:Xi(t)&&t(e)}function Vn(t,e){if(Fd(t))Xd(t,e);else if(Wn(t)||Na(t))vs(document.createTextNode(t),e);else if(t===null)vs(document.createComment(""),e);else if(jd(t))vs(t,e);else if(Kd(t)){const i=e.attachShadow(t.attr);Vn(t.children,i),bs(t.ref,i)}}function Xd(t,e){for(const i of[...t])Vn(i,e);return e}function vs(t,e){e instanceof window.HTMLTemplateElement?e.content.appendChild(t):e.appendChild(t)}function Gn(t,e){return t.replace(/[A-Z]/g,i=>e+i.toLowerCase())}function ja(t,e){e==null||e===!1||(Array.isArray(e)?e.forEach(i=>ja(t,i)):Wn(e)?t.setAttribute("style",e):ti(e)&&ms(e,(i,n)=>{n.indexOf("-")===0?t.style.setProperty(n,i):Na(i)&&gs[n]!==0?t.style[n]=i+"px":t.style[n]=i}))}function Zd(t,e,i){switch(t){case"xlinkActuate":case"xlinkArcrole":case"xlinkHref":case"xlinkRole":case"xlinkShow":case"xlinkTitle":case"xlinkType":Ua(i,Vd,Gn(t,":"),e);return;case"xmlnsXlink":wi(i,Gn(t,":"),e);return;case"xmlBase":case"xmlLang":case"xmlSpace":Ua(i,Gd,Gn(t,":"),e);return}switch(t){case"htmlFor":wi(i,"for",e);return;case"dataset":ms(e,(n,r)=>{n!=null&&(i.dataset[r]=n)});return;case"innerHTML":case"innerText":case"textContent":Da(e)&&(i[t]=e);return;case"dangerouslySetInnerHTML":ti(e)&&(i.innerHTML=e.__html);return;case"value":if(e==null||i instanceof window.HTMLSelectElement)return;if(i instanceof window.HTMLTextAreaElement){i.value=e;return}break;case"spellCheck":i.spellcheck=e;return;case"class":case"className":Xi(e)?e(i):wi(i,"class",ys(e));return;case"ref":case"namespaceURI":return;case"style":ja(i,e);return;case"on":case"onCapture":ms(e,(n,r)=>{i.addEventListener(r,n,t==="onCapture")});return}if(Xi(e)){if(t[0]==="o"&&t[1]==="n"){let n=t.toLowerCase();const r=n.endsWith("capture");if(n==="ondoubleclick"?n="ondblclick":r&&n==="ondoubleclickcapture"&&(n="ondblclickcapture"),!r&&i[n]===null)i[n]=e;else if(r)i.addEventListener(n.substring(2,n.length-7),e,!0);else{let s;n in window?s=n.substring(2):s=n[2]+t.slice(3),i.addEventListener(s,e)}}}else ti(e)?i[t]=e:e===!0?wi(i,t,""):e!==!1&&e!=null&&(i instanceof SVGElement&&!Qd.test(t)?wi(i,Gn(t,"-"),e):wi(i,t,e))}function wi(t,e,i){t.setAttribute(e,i)}function Ua(t,e,i,n){t.setAttributeNS(e,i,n)}function eh(t,e){for(const i of Kn(t))Zd(i,t[i],e);return e}const Yn=Object.keys;function th(t){return typeof t=="boolean"}function ih(t){return t&&typeof t.nodeType=="number"}function ws(t){return typeof t=="string"}function Fa(t){return typeof t=="number"}function ii(t){return typeof t=="object"?t!==null:en(t)}function en(t){return typeof t=="function"}function nh(t){return!!(t&&t.isComponent)}function rh(t){return ii(t)&&typeof t.length=="number"&&typeof t.nodeType!="number"}function _s(t,e){if(t)for(const i of Yn(t))e(t[i],i)}function sh(t){return ii(t)&&"current"in t}const xs={animationIterationCount:0,borderImageOutset:0,borderImageSlice:0,borderImageWidth:0,boxFlex:0,boxFlexGroup:0,boxOrdinalGroup:0,columnCount:0,columns:0,flex:0,flexGrow:0,flexPositive:0,flexShrink:0,flexNegative:0,flexOrder:0,gridArea:0,gridRow:0,gridRowEnd:0,gridRowSpan:0,gridRowStart:0,gridColumn:0,gridColumnEnd:0,gridColumnSpan:0,gridColumnStart:0,fontWeight:0,lineClamp:0,lineHeight:0,opacity:0,order:0,orphans:0,tabSize:0,widows:0,zIndex:0,zoom:0,fillOpacity:0,floodOpacity:0,stopOpacity:0,strokeDasharray:0,strokeDashoffset:0,strokeMiterlimit:0,strokeOpacity:0,strokeWidth:0};function oh(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}const ah=["Webkit","ms","Moz","O"];Yn(xs).forEach(t=>{ah.forEach(e=>{xs[oh(e,t)]=0})});const lh=Symbol.for("jsx-dom:type");var Ba=(function(t){return t.ShadowRoot="ShadowRoot",t})(Ba||{});function ch(t){return t!=null&&t[lh]===Ba.ShadowRoot}const uh="http://www.w3.org/2000/svg",fh="http://www.w3.org/1999/xlink",dh="http://www.w3.org/XML/1998/namespace";function qa(t){return!th(t)&&t!=null}function Ss(t){return Array.isArray(t)?t.map(Ss).filter(Boolean).join(" "):ii(t)?Symbol.iterator in t?Ss(Array.from(t)):Yn(t).filter(e=>t[e]).join(" "):qa(t)?""+t:""}const hh={animate:0,circle:0,clipPath:0,defs:0,desc:0,ellipse:0,feBlend:0,feColorMatrix:0,feComponentTransfer:0,feComposite:0,feConvolveMatrix:0,feDiffuseLighting:0,feDisplacementMap:0,feDistantLight:0,feFlood:0,feFuncA:0,feFuncB:0,feFuncG:0,feFuncR:0,feGaussianBlur:0,feImage:0,feMerge:0,feMergeNode:0,feMorphology:0,feOffset:0,fePointLight:0,feSpecularLighting:0,feSpotLight:0,feTile:0,feTurbulence:0,filter:0,foreignObject:0,g:0,image:0,line:0,linearGradient:0,marker:0,mask:0,metadata:0,path:0,pattern:0,polygon:0,polyline:0,radialGradient:0,rect:0,stop:0,svg:0,switch:0,symbol:0,text:0,textPath:0,tspan:0,use:0,view:0},ph=/^(a(ll|t|u)|base[FP]|c(al|lipPathU|on)|di|ed|ex|filter[RU]|g(lyphR|r)|ke|l(en|im)|ma(rker[HUW]|s)|n|pat|pr|point[^e]|re[^n]|s[puy]|st[^or]|ta|textL|vi|xC|y|z)/;function mh(t){const e=document.createDocumentFragment();return Qn(t.children,e),e}function gh(t,e,i){e={...e,children:i};const n=new t(e),r=n.render();return"ref"in e&&ks(e.ref,n),r}function ye(t,e){let{children:i,...n}=e;!n.namespaceURI&&hh[t]===0&&(n={...n,namespaceURI:uh});let r;if(ws(t)){if(r=n.namespaceURI?document.createElementNS(n.namespaceURI,t):document.createElement(t),vh(n,r),Qn(i,r),r instanceof window.HTMLSelectElement&&n.value!=null)if(n.multiple===!0&&Array.isArray(n.value)){const s=n.value.map(o=>String(o));r.querySelectorAll("option").forEach(o=>o.selected=s.includes(o.value))}else r.value=n.value;ks(n.ref,r)}else if(en(t))ii(t.defaultProps)&&(n={...t.defaultProps,...n}),r=nh(t)?gh(t,n,i):t({...n,children:i});else throw new TypeError(`Invalid JSX element type: ${t}`);return r}function ks(t,e){sh(t)?t.current=e:en(t)&&t(e)}function Qn(t,e){if(rh(t))yh(t,e);else if(ws(t)||Fa(t))Es(document.createTextNode(t),e);else if(t===null)Es(document.createComment(""),e);else if(ih(t))Es(t,e);else if(ch(t)){const i=e.attachShadow(t.attr);Qn(t.children,i),ks(t.ref,i)}}function yh(t,e){for(const i of[...t])Qn(i,e);return e}function Es(t,e){e instanceof window.HTMLTemplateElement?e.content.appendChild(t):e.appendChild(t)}function Jn(t,e){return t.replace(/[A-Z]/g,i=>e+i.toLowerCase())}function Ha(t,e){e==null||e===!1||(Array.isArray(e)?e.forEach(i=>Ha(t,i)):ws(e)?t.setAttribute("style",e):ii(e)&&_s(e,(i,n)=>{n.indexOf("-")===0?t.style.setProperty(n,i):Fa(i)&&xs[n]!==0?t.style[n]=i+"px":t.style[n]=i}))}function bh(t,e,i){switch(t){case"xlinkActuate":case"xlinkArcrole":case"xlinkHref":case"xlinkRole":case"xlinkShow":case"xlinkTitle":case"xlinkType":za(i,fh,Jn(t,":"),e);return;case"xmlnsXlink":_i(i,Jn(t,":"),e);return;case"xmlBase":case"xmlLang":case"xmlSpace":za(i,dh,Jn(t,":"),e);return}switch(t){case"htmlFor":_i(i,"for",e);return;case"dataset":_s(e,(n,r)=>{n!=null&&(i.dataset[r]=n)});return;case"innerHTML":case"innerText":case"textContent":qa(e)&&(i[t]=e);return;case"dangerouslySetInnerHTML":ii(e)&&(i.innerHTML=e.__html);return;case"value":if(e==null||i instanceof window.HTMLSelectElement)return;if(i instanceof window.HTMLTextAreaElement){i.value=e;return}break;case"spellCheck":i.spellcheck=e;return;case"class":case"className":en(e)?e(i):_i(i,"class",Ss(e));return;case"ref":case"namespaceURI":return;case"style":Ha(i,e);return;case"on":case"onCapture":_s(e,(n,r)=>{i.addEventListener(r,n,t==="onCapture")});return}if(en(e)){if(t[0]==="o"&&t[1]==="n"){let n=t.toLowerCase();const r=n.endsWith("capture");if(n==="ondoubleclick"?n="ondblclick":r&&n==="ondoubleclickcapture"&&(n="ondblclickcapture"),!r&&i[n]===null)i[n]=e;else if(r)i.addEventListener(n.substring(2,n.length-7),e,!0);else{let s;n in window?s=n.substring(2):s=n[2]+t.slice(3),i.addEventListener(s,e)}}}else ii(e)?i[t]=e:e===!0?_i(i,t,""):e!==!1&&e!=null&&(i instanceof SVGElement&&!ph.test(t)?_i(i,Jn(t,"-"),e):_i(i,t,e))}function _i(t,e,i){t.setAttribute(e,i)}function za(t,e,i,n){t.setAttributeNS(e,i,n)}function vh(t,e){for(const i of Yn(t))bh(i,t[i],e);return e}var $s=(t=>(t.Init="modal.init",t.BeforeShow="modal.beforeShow",t.Show="modal.show",t.BeforeClose="modal.beforeClose",t.Close="modal.close",t.Destroy="modal.destroy",t.ToastShow="toast.show",t.ToastClose="toast.close",t))($s||{});let wh=0;const Ka=t=>`${t}-${++wh}`;function tn(t){return t instanceof Node?t:document.createTextNode(String(t))}function Tt(t,e){if(!t)throw new Error(`${e??"Element"} not found`);return t}function Wa(t){const e=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");return Array.from(t.querySelectorAll(e)).filter(i=>!!(i.offsetWidth||i.offsetHeight||i.getClientRects().length))}function Ne(t,e={}){const i=document.createElement(t);if(e.className&&(i.className=e.className),e.html!=null&&(i.innerHTML=e.html),e.text!=null&&(i.textContent=e.text),e.attrs)for(const[n,r]of Object.entries(e.attrs))i.setAttribute(n,r);return i}const _h=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/i.test(navigator.platform),Va=["ctrl","alt","shift","meta"];function xh(t){if(!t)return null;const e=String(t).trim().toLowerCase().split(/[+\-\s]+/g).filter(Boolean),i=[];let n=null;const r=o=>{i.includes(o)||i.push(o)};for(const o of e){let a=o;if(a==="control"||a==="ctrl"){r("ctrl");continue}if(a==="alt"||a==="option"){r("alt");continue}if(a==="shift"){r("shift");continue}if(a==="meta"||a==="cmd"||a==="command"||a==="super"){r("meta");continue}if(a==="mod"){r(_h?"meta":"ctrl");continue}a==="esc"&&(a="escape"),a==="return"&&(a="enter"),(a==="space"||a==="spacebar")&&(a="space"),n=a}const s=Va.filter(o=>i.includes(o));return!n||n===""?s.length?s.join("+"):null:s.length?`${s.join("+")}+${n}`:n}function Sh(t){const e=[];t.ctrlKey&&e.push("ctrl"),t.altKey&&e.push("alt"),t.shiftKey&&e.push("shift"),t.metaKey&&e.push("meta");let i=t.key;i===" "&&(i="space");const n=(i.length,i.toLowerCase()),r=Va.filter(s=>e.includes(s));return r.length?`${r.join("+")}+${n}`:n}class kh{constructor(){this.zBase=1e3,this.stack=[]}push(e){this.stack.push(e),this.syncZ()}remove(e){this.stack=this.stack.filter(i=>i!==e),this.syncZ()}top(){return this.stack[this.stack.length-1]}closeAll(e,i){const n=new Set((Array.isArray(i)?i:i?[i]:[]).map(String)),r=new Set((Array.isArray(e)?e:e?[e]:[]).map(String));[...this.stack].reverse().forEach(s=>{const o=s.modalId,a=r.size?r.has(s.pluginName):!0,l=n.has(o);a&&!l&&s.close()})}removeAll(){[...this.stack].forEach(e=>e.destroy()),this.stack=[]}syncZ(){this.stack.forEach((e,i)=>e.setZIndex(this.zBase+i*2))}lockBodyScroll(){document.body.classList.add("ipe-modal-no-scroll")}unlockBodyScroll(){document.body.classList.remove("ipe-modal-no-scroll")}}const ze=new kh,Cn=class Cn{constructor(e={}){this.backdropId=Ka("ipe-modal-backdrop"),this.modalId=Ka("ipe-modal"),this.numberId=this.modalId.split("-")[1],this._isDestroyed=!1,this.pluginName="normalModal",this.buttonElsLeft=[],this.buttonElsRight=[],this.keyMap=new Map,this.isOpen=!1,this.isToast=!1,this.isDragging=!1,this.dragStartX=0,this.dragStartY=0,this.modalStartX=0,this.modalStartY=0,this.Event=$s,this._hooks=[],this.startCloseTimer=i=>{this.stopCloseTimer(),this.closeTimer=window.setTimeout(()=>this.close(),i)},this.stopCloseTimer=()=>{this.closeTimer&&window.clearTimeout(this.closeTimer),this.closeTimer=void 0},this.onDragMove=i=>{if(!this.isDragging)return;i.preventDefault();const n=i.clientX-this.dragStartX,r=i.clientY-this.dragStartY,s=this.get$modal(),o=this.modalStartX+n,a=this.modalStartY+r;s.style.left=`${o}px`,s.style.top=`${a}px`},this.onDragEnd=()=>{if(!this.isDragging)return;this.isDragging=!1,document.removeEventListener("pointermove",this.onDragMove),document.removeEventListener("pointerup",this.onDragEnd);const i=this.get$modal(),n=this.get$window();i.classList.remove("is-dragging"),n.style.animation="none",requestAnimationFrame(()=>{this.applyAnimation(!0)})},this.options={...Cn.DEFAULT_OPTIONS,...e},this.options.backdrop===!1&&e.bodyScroll===void 0&&(this.options.bodyScroll=!0)}get isDestroyed(){return this._isDestroyed}static extends(e={}){return class extends this{constructor(i={}){super({...e,...i})}}}init(){if(this.$modal)return this;const e=this.options.backdrop!==!1;let i;e&&(i=Ne("div",{className:"ipe-modal-backdrop",attrs:{id:this.backdropId,"data-modal-id":this.modalId}}));const n=Ne("div",{className:"ipe-modal-modal",attrs:{id:this.modalId,role:"dialog","aria-modal":"true",tabindex:"-1"}});if(n.modal=this,!e){n.classList.add("no-backdrop");const p=window.pageYOffset||document.documentElement.scrollTop,f=window.pageXOffset||document.documentElement.scrollLeft,_=window.innerWidth;n.style.top=`${p+60}px`,this.once("modal.show",()=>{n.style.left=`${f+_/2-n.offsetWidth/2}px`})}const r=Ne("div",{className:`ipe-modal-modal__window size--${this.options.sizeClass||"auto"} plugin--${this.pluginName}`});r.modal=this;const s=Ne("div",{className:"ipe-modal-modal__header"}),o=`${this.modalId}-title`,a=Ne("h2",{className:"ipe-modal-modal__title",attrs:{id:o,role:"heading","aria-level":"2"}});n.setAttribute("aria-labelledby",o);const l=Ne("div",{className:"ipe-modal-modal__icons"});if(this.options.closeIcon){const p=Ne("button",{className:"ipe-modal-modal__close",attrs:{type:"button","aria-label":"Close"},html:"&times;"});p.addEventListener("click",()=>{let f=!0;typeof this.options.onClickClose=="function"?this.options.onClickClose(this)===!1&&(f=!1):this.options.onClickClose===!1&&(f=!1),f&&this.close()}),l.appendChild(p)}s.append(a,l),this.options.draggable&&e&&(this.options.draggable=!1),this.options.draggable&&(s.style.cursor="move",s.style.userSelect="none",s.addEventListener("pointerdown",this.onDragStart.bind(this)),n.classList.add("is-draggable"));const c=Ne("div",{className:"ipe-modal-modal__content"}),u=Ne("div",{className:"ipe-modal-modal__footer"}),d=Ne("div",{className:"ipe-modal-modal__buttons ipe-modal-modal__buttons--left"}),h=Ne("div",{className:"ipe-modal-modal__buttons ipe-modal-modal__buttons--right"});return u.append(d,h),r.append(s,c,u),n.appendChild(r),this.$backdrop=i,this.$modal=n,this.$window=r,this.$header=s,this.$title=a,this.$icons=l,this.$content=c,this.$footer=u,this.$buttonsLeft=d,this.$buttonsRight=h,this.options.title&&this.setTitle(this.options.title),this.options.content&&this.setContent(this.options.content),this.options.buttons?.length?this.setButtons(this.options.buttons):u.style.display="none",this.options.center&&this.$modal.classList.add("is-centered"),this.options.fitScreen&&this.$modal.classList.add("is-fullscreen"),this.options.iconButtons&&this.$header.classList.add("has-icon-buttons"),this.options.className&&this.$window.classList.add(...this.options.className.split(/[\s\.#+]+/g).filter(Boolean)),typeof this.options.fixedHeight=="number"?this.$window.style.height=`${Math.max(0,this.options.fixedHeight)}px`:this.options.fixedHeight===!0&&this.$window.classList.add("is-fixed-height"),i&&i.addEventListener("pointerdown",p=>{this.options.outSideClose&&p.target===i&&this.close()}),this.options.draggable&&r.addEventListener("pointerdown",p=>{p.target&&r.contains(p.target)&&this.bringToFront()}),this.onKeyDown=this.onKeyDown.bind(this),this.emit("modal.init"),this}show(){if(this.$modal||this.init(),!this.$modal)throw new Error("Failed to initialize modal");if(this.isOpen)return this;{const n=this.emit("modal.beforeShow",!0),r=this.options.beforeShow?this.options.beforeShow(this)!==!1:!0;if(!n||!r)return this}this.lastFocused=document.activeElement??null,this.$backdrop&&document.body.appendChild(this.$backdrop),document.body.appendChild(this.$modal),this.shouldLockBodyOnOpen()&&ze.lockBodyScroll(),requestAnimationFrame(()=>{this.$backdrop?.classList.add("is-open"),this.$modal.classList.add("is-open"),this.applyAnimation(!0),this.focusFirst()}),document.addEventListener("keydown",this.onKeyDown),ze.push(this),this.isOpen=!0,this.options.onShow?.(this),this.emit("modal.show");const e=typeof this.options.closeAfter=="number"?this.options.closeAfter:this.options.closeAfter?.time,i=typeof this.options.closeAfter=="number"?!0:this.options.closeAfter?.resetOnHover;return e&&(this.startCloseTimer(e),i&&(this.$window?.addEventListener("mouseenter",this.stopCloseTimer),this.$window?.addEventListener("mouseleave",()=>this.startCloseTimer(e)))),this}close(){if(!this.isOpen)return this;{const s=this.emit("modal.beforeClose",!0),o=this.options.beforeClose?this.options.beforeClose(this)!==!1:!0;if(!s||!o)return this}if(this.isToast){this.applyAnimation(!1),this.emit("modal.close"),this.emit("toast.close");const s=this.isAnimationDisabled()?0:this.options.animationSpeed??200;let o=!1;const a=()=>{o||(o=!0,this.destroy(),this.options.onClose?.(this))},l=(c,u)=>{const d=()=>{c.removeEventListener(u,d),a()};c.addEventListener(u,d,{once:!0})};return s>0&&this.$window?(l(this.$window,"transitionend"),l(this.$window,"animationend"),window.setTimeout(a,s+20)):window.setTimeout(a,s),this}this.applyAnimation(!1),this.$backdrop?.classList.remove("is-open"),this.$modal?.classList.remove("is-open"),this.emit("modal.close");const e=this.isAnimationDisabled()?0:this.options.animationSpeed??200;let i=!1;const n=()=>{i||(i=!0,this.destroy(),this.options.onClose?.(this))},r=(s,o)=>{const a=()=>{s.removeEventListener(o,a),n()};s.addEventListener(o,a,{once:!0})};return e>0&&this.$window?(r(this.$window,"transitionend"),r(this.$window,"animationend"),window.setTimeout(n,e+20)):window.setTimeout(n,e),this}destroy(){if(this._isDestroyed)return this;if(this.stopCloseTimer(),document.removeEventListener("keydown",this.onKeyDown),this.isDragging&&this.onDragEnd(),this.$window?.removeEventListener("mouseenter",this.stopCloseTimer),this.isToast){this.$window?.parentElement&&this.$window.parentElement.removeChild(this.$window);const e=ni.indexOf(this);e!==-1&&ni.splice(e,1)}else this.$backdrop?.parentElement&&this.$backdrop.parentElement.removeChild(this.$backdrop),this.$modal?.parentElement&&this.$modal.parentElement.removeChild(this.$modal),ze.remove(this),this.shouldUnlockBodyOnClose()&&ze.unlockBodyScroll();return this.isOpen=!1,this.lastFocused?.focus?.(),this.emit("modal.destroy"),this._isDestroyed=!0,this}get$backdrop(){return this.$backdrop}get$modal(){return Tt(this.$modal,"modal")}get$window(){return Tt(this.$window,"window")}get$header(){return Tt(this.$header,"header")}get$title(){return Tt(this.$title,"title")}get$content(){return Tt(this.$content,"content")}get$icons(){return Tt(this.$icons,"icons")}get$buttons(e){return e==="leftButtons"?Tt(this.$buttonsLeft,"leftButtons"):e==="rightButtons"?Tt(this.$buttonsRight,"rightButtons"):Tt(this.$footer,"buttons")}setTitle(e){const i=this.get$title();return i.innerHTML="",i.append(tn(e)),this}setContent(e,i="replace"){const n=this.get$content();return i==="replace"?(n.innerHTML="",n.append(tn(e))):i==="append"?n.append(tn(e)):n.prepend(tn(e)),this}setIcons(e){const i=this.get$icons();i.innerHTML="";for(const n of e){const r=Ne("button",{className:`ipe-modal-modal__icon ${n.className}`,attrs:{type:"button"}});r.addEventListener("click",n.method),i.appendChild(r)}return this}setButtons(e,i){const n=this.$buttonsLeft,r=this.$buttonsRight;[n,r].forEach(o=>o.innerHTML=""),this.buttonElsLeft=[],this.buttonElsRight=[],this.keyMap.clear();const s=i??this.$footer;if(s===this.$footer)e.forEach(o=>this.addButton(o)),e.length===0&&(this.$footer.style.display="none");else{s.innerHTML="";for(const o of e){const a=this.generateButton(o);s.appendChild(a)}}return this}generateButton(e){const i=e.type??"button",n=i==="link"?Ne("a"):Ne("button",{attrs:{type:"button"}});e.id&&(n.id=e.id),n.className=`ipe-modal-btn ${e.className??""}`.trim();const r=tn(e.label??"OK");if(n.append(r),i==="link"&&e.href&&(n.href=e.href),e.method&&n.addEventListener("click",s=>{if(n._ipe_tmpDisabled){s.preventDefault(),s.stopPropagation();return}e.method.call(n,s,this)}),typeof e.closeAfter=="number"&&e.closeAfter>=0&&n.addEventListener("click",()=>{window.setTimeout(()=>this.close(),e.closeAfter)}),typeof e.enableAfter=="number"&&e.enableAfter>0){i==="button"&&n.setAttribute("disabled","true"),n._ipe_tmpDisabled=!0,n.setAttribute("aria-disabled","true");const s=()=>{i==="button"&&n.removeAttribute("disabled"),delete n._ipe_tmpDisabled,n.removeAttribute("aria-disabled")};window.setTimeout(s,e.enableAfter)}if(e.keyPress){const s=String(e.keyPress).split(/[\,\|]+/g).map(o=>o.trim()).filter(Boolean);for(const o of s){const a=xh(o);a&&this.keyMap.set(a,n)}}return n}addButton(e,i){this.$footer&&(this.$footer.style.display="");const n=e.side??"right",r=n==="left"?this.$buttonsLeft:this.$buttonsRight,s=n==="left"?this.buttonElsLeft:this.buttonElsRight,o=this.generateButton(e),a=Math.max(0,Math.min(i??s.length,s.length));return a>=r.children.length?r.appendChild(o):r.insertBefore(o,r.children[a]),s.splice(a,0,o),this}removeButton(e){const i=this.buttonElsLeft,n=this.buttonElsRight,r=[...i,...n];let s=null;if(e==="*")return r.forEach(a=>{this.keyMap.delete(a.id),a.parentElement?.removeChild(a)}),this.$footer&&(this.$footer.style.display="none"),this;if(typeof e=="number"?s=r[e]??null:typeof e=="string"?s=r.find(a=>a.id===e)??null:e instanceof HTMLElement&&(s=r.find(a=>a===e)??null),!s)return this;for(const[a,l]of this.keyMap.entries())l===s&&this.keyMap.delete(a);let o=i.indexOf(s);return o!==-1?(i.splice(o,1),s.parentElement?.removeChild(s)):(o=n.indexOf(s),o!==-1&&(n.splice(o,1),s.parentElement?.removeChild(s))),i.length===0&&n.length===0&&this.$footer&&(this.$footer.style.display="none"),this}changePreviewState(){return this.get$modal().classList.toggle("is-fullscreen"),this}setModalHeight(e,i="height"){const n=this.get$window(),r=Math.max(0,window.innerHeight-e);return n.style[i]=`${r}px`,r}setOptions(e,i){return typeof e=="string"?this.options[e]=i:Object.assign(this.options,e),this}setPluginName(e){return this.$window&&(this.$window.className=this.$window.className.replace(`plugin--${this.pluginName}`,`plugin--${e}`)),this.pluginName=e,this}applyAnimation(e){const i=this.get$modal(),n=this.get$window(),r=this.$backdrop,s=this.options.modalAnimation??this.options.animation,o=typeof s=="string"?s:s&&(e?s.show:s.hide),a=this.options.backdropAnimation??this.options.animation,l=typeof a=="string"?a:a&&(e?a.show:a.hide);!o||o===!1?(i.style.transition="none",n.style.animation="none",n.style.removeProperty("--ipe-modal-anim")):(i.style.removeProperty("transition"),n.style.setProperty("--ipe-modal-anim",o)),r&&(!l||l===!1?r.style.transition="none":r.style.removeProperty("transition"))}on(e,i){return this._hooks.push({type:e,listener:i}),()=>this.off(e,i)}off(e,i){return this._hooks=this._hooks.filter(n=>n.type!==e&&(i?n.listener!==i:!0)),this}once(e,i){const n=this.on(e,r=>(n(),i(r)));return n}emit(e,i){const n=this._hooks.filter(a=>a.type===e);let r=!0;for(const a of n){const l=new CustomEvent(e,{detail:this,cancelable:i}),c=a.listener(l);if(l.defaultPrevented&&(r=!1),c===!1&&(r=!1),!r)break}const s=this.$modal??document.body,o=new CustomEvent(e,{detail:this,cancelable:i});return(!s.dispatchEvent(o)||o.defaultPrevented)&&(r=!1),r}focusFirst(){const e=this.get$modal(),i=Wa(e);i.length?i[0].focus():e.focus({preventScroll:!0})}onKeyDown(e){if(ze.top()!==this)return;if(e.key==="Escape"){e.preventDefault(),this.close();return}const i=this.get$modal();if(!i.contains(document.activeElement))return;if(e.key==="Tab"){const a=Wa(i);if(!a.length)return;const l=a[0],c=a[a.length-1],u=document.activeElement;e.shiftKey&&u===l?(e.preventDefault(),c.focus()):!e.shiftKey&&u===c&&(e.preventDefault(),l.focus())}const n=e.ctrlKey||e.altKey||e.metaKey,r=e.target;if(!n&&(r&&["INPUT","TEXTAREA"].includes(r.tagName)||r.contentEditable==="true"))return;const s=Sh(e),o=this.keyMap.get(s);if(o){e.preventDefault(),o.click();return}}setZIndex(e){this.$backdrop&&(this.$backdrop.style.zIndex=String(e)),this.$modal&&(this.$modal.style.zIndex=String(e+1))}bringToFront(){return ze.remove(this),ze.push(this),this}isAnimationDisabled(){const e=this.options.modalAnimation??this.options.animation;return e===!1||e==null}shouldLockBodyOnOpen(){return this.options.backdrop===!1||this.options.bodyScroll!==!1?!1:!ze.stack.some(e=>e!==this&&e.options.backdrop!==!1&&e.options.bodyScroll===!1)}shouldUnlockBodyOnClose(){return this.options.backdrop===!1||this.options.bodyScroll!==!1?!1:!ze.stack.some(e=>e!==this&&e.options.backdrop!==!1&&e.options.bodyScroll===!1)}onDragStart(e){if(this.options.backdrop!==!1||!this.options.draggable)return;e.preventDefault(),this.isDragging=!0,this.bringToFront(),this.dragStartX=e.clientX,this.dragStartY=e.clientY;const i=this.get$modal(),n=i.getBoundingClientRect();this.modalStartX=n.left+window.pageXOffset,this.modalStartY=n.top+window.pageYOffset,i.style.transform="none",i.style.left=`${this.modalStartX}px`,i.style.top=`${this.modalStartY}px`,document.addEventListener("pointermove",this.onDragMove),document.addEventListener("pointerup",this.onDragEnd),i.classList.add("is-dragging")}showToast(e){this.$window||this.init();const i=Eh(e.position??"top right"),n=this.get$window();this.isToast=!0,n.style.pointerEvents="auto",this.applyAnimation(!0),i.appendChild(n);const r=(typeof this.options.closeAfter=="number"?this.options.closeAfter:this.options.closeAfter?.time)??3e3,s=(typeof this.options.closeAfter=="number"?!0:this.options.closeAfter?.resetOnHover)??!0;return r>0&&(this.startCloseTimer(r),s&&(n.addEventListener("mouseenter",this.stopCloseTimer),n.addEventListener("mouseleave",()=>this.startCloseTimer(r)))),this.isOpen=!0,this.options.onShow?.(this),ni.push(this),this.emit("toast.show"),this.emit("modal.show"),this}static show(e,i){return new this(e).init().show()}static createObject(e,i){return new this(e)}static close(e){if(!e){const s=ze.top();return s?.close(),s}const i=typeof e=="string"?e:e.id,n=ze.stack.find(s=>s.modalId===i);if(n)return n.close(),n;const r=ni.find(s=>s.modalId===i);return r?.close(),r}static closeAll(e,i){const n=new Set((Array.isArray(i)?i:i?[i]:[]).map(String)),r=new Set((Array.isArray(e)?e:e?[e]:[]).map(String));return ze.closeAll(e,i),[...ni].forEach(s=>{const o=s.modalId,a=r.size?r.has(s.pluginName):!0,l=n.has(o);a&&!l&&s.close()}),ze.top()??new Cn}static removeAll(){ze.removeAll(),[...ni].forEach(e=>e.destroy())}static dialog(e,i){const n=new this({sizeClass:"dialog",buttons:[{label:"OK",className:"is-primary is-ghost",method:(r,s)=>{i?.(r,s),r.defaultPrevented||n.close()},keyPress:"Enter"}],...e});return n.init().show()}static confirm(e,i){e.title??(e.title="Confirm"),e.content??(e.content="Are you sure you want to perform this action?");const n=e.okBtn??{label:"OK",className:"is-primary is-ghost"},r=e.cancelBtn??{label:"Cancel",className:"is-danger is-ghost"};return new this({sizeClass:"dialog",...e,buttons:[{label:r.label,className:r.className,keyPress:"n",method:(s,o)=>{i?.(!1,o,s),o.close()}},{label:n.label,className:n.className,keyPress:"y",method:(s,o)=>{i?.(!0,o,s),s.defaultPrevented||o.close()}}]}).init().show()}static getDefaultNotifyIcon(e){switch(e){case"success":return ye("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-circle-check",children:[ye("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),ye("path",{d:"M17 3.34a10 10 0 1 1 -14.995 8.984l-.005 -.324l.005 -.324a10 10 0 0 1 14.995 -8.336zm-1.293 5.953a1 1 0 0 0 -1.32 -.083l-.094 .083l-3.293 3.292l-1.293 -1.292l-.094 -.083a1 1 0 0 0 -1.403 1.403l.083 .094l2 2l.094 .083a1 1 0 0 0 1.226 0l.094 -.083l4 -4l.083 -.094a1 1 0 0 0 -.083 -1.32z"})]});case"error":return ye("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-alert-triangle",children:[ye("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),ye("path",{d:"M12 1.67c.955 0 1.845 .467 2.39 1.247l.105 .16l8.114 13.548a2.914 2.914 0 0 1 -2.307 4.363l-.195 .008h-16.225a2.914 2.914 0 0 1 -2.582 -4.2l.099 -.185l8.11 -13.538a2.914 2.914 0 0 1 2.491 -1.403zm.01 13.33l-.127 .007a1 1 0 0 0 0 1.986l.117 .007l.127 -.007a1 1 0 0 0 0 -1.986l-.117 -.007zm-.01 -7a1 1 0 0 0 -.993 .883l-.007 .117v4l.007 .117a1 1 0 0 0 1.986 0l.007 -.117v-4l-.007 -.117a1 1 0 0 0 -.993 -.883z"})]});case"warning":return ye("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-alert-circle",children:[ye("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),ye("path",{d:"M12 2c5.523 0 10 4.477 10 10a10 10 0 0 1 -19.995 .324l-.005 -.324l.004 -.28c.148 -5.393 4.566 -9.72 9.996 -9.72zm.01 13l-.127 .007a1 1 0 0 0 0 1.986l.117 .007l.127 -.007a1 1 0 0 0 0 -1.986l-.117 -.007zm-.01 -8a1 1 0 0 0 -.993 .883l-.007 .117v4l.007 .117a1 1 0 0 0 1.986 0l.007 -.117v-4l-.007 -.117a1 1 0 0 0 -.993 -.883z"})]});case"info":return ye("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-info-circle",children:[ye("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),ye("path",{d:"M12 2c5.523 0 10 4.477 10 10a10 10 0 0 1 -19.995 .324l-.005 -.324l.004 -.28c.148 -5.393 4.566 -9.72 9.996 -9.72zm0 9h-1l-.117 .007a1 1 0 0 0 0 1.986l.117 .007v3l.007 .117a1 1 0 0 0 .876 .876l.117 .007h1l.117 -.007a1 1 0 0 0 .876 -.876l.007 -.117l-.007 -.117a1 1 0 0 0 -.764 -.857l-.112 -.02l-.117 -.006v-3l-.007 -.117a1 1 0 0 0 -.876 -.876l-.117 -.007zm.01 -3l-.127 .007a1 1 0 0 0 0 1.986l.117 .007l.127 -.007a1 1 0 0 0 0 -1.986l-.117 -.007z"})]});case"dialog":return ye("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-message-dots",children:[ye("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),ye("path",{d:"M12 11v.01"}),ye("path",{d:"M8 11v.01"}),ye("path",{d:"M16 11v.01"}),ye("path",{d:"M18 4a3 3 0 0 1 3 3v8a3 3 0 0 1 -3 3h-5l-5 3v-3h-2a3 3 0 0 1 -3 -3v-8a3 3 0 0 1 3 -3z"})]});case"confirm":return ye("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-copy-check",children:[ye("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),ye("path",{d:"M18.333 6a3.667 3.667 0 0 1 3.667 3.667v8.666a3.667 3.667 0 0 1 -3.667 3.667h-8.666a3.667 3.667 0 0 1 -3.667 -3.667v-8.666a3.667 3.667 0 0 1 3.667 -3.667zm-3.333 -4c1.094 0 1.828 .533 2.374 1.514a1 1 0 1 1 -1.748 .972c-.221 -.398 -.342 -.486 -.626 -.486h-10c-.548 0 -1 .452 -1 1v9.998c0 .32 .154 .618 .407 .805l.1 .065a1 1 0 1 1 -.99 1.738a3 3 0 0 1 -1.517 -2.606v-10c0 -1.652 1.348 -3 3 -3zm1.293 9.293l-3.293 3.292l-1.293 -1.292a1 1 0 0 0 -1.414 1.414l2 2a1 1 0 0 0 1.414 0l4 -4a1 1 0 0 0 -1.414 -1.414"})]});default:return null}}static notify(e,i,n){var a,l,c,u;if(i?.overrideOther&&[...ni].forEach(d=>d.close()),typeof i.title>"u"){const d=e||"Notification";i.title=d[0].toUpperCase()+d.slice(1).toLowerCase()}const r=i.icon??this.getDefaultNotifyIcon(e);r&&(r instanceof Element&&r.classList.add("ipe-modal-notify-icon"),i.title=ye(mh,{children:[r,i.title]})),e==="confirm"&&(typeof i.closeAfter>"u"&&(i.closeAfter=0),i.okBtn||(i.okBtn={label:"OK"})),i.okBtn&&(typeof i.okBtn!="object"&&(i.okBtn={label:"OK"}),(a=i.okBtn).label??(a.label="OK"),(l=i.okBtn).className??(l.className="is-primary is-text ok-btn"),i.okBtn.method=(d,h)=>{n?.(!0,h,d),h.close()}),i.cancelBtn&&(typeof i.cancelBtn!="object"&&(i.cancelBtn={label:"Cancel"}),(c=i.cancelBtn).label??(c.label="Cancel"),(u=i.cancelBtn).className??(u.className="is-danger is-text cancel-btn"),i.cancelBtn.method=(d,h)=>{n?.(!1,h,d),h.close()}),i.buttons=[i.cancelBtn,i.okBtn,...i.buttons??[]].filter(Boolean);const s=`is-notify type-${e||"default"} ${i.className??""}`,o=new this({...i,className:s,sizeClass:"auto",center:!1,fitScreen:!1,closeIcon:!0,outSideClose:!1,bodyScroll:!0,buttons:i.buttons??[]});return o.setPluginName("toast"),o.showToast({position:i.position??"top right"})}};Cn.DEFAULT_OPTIONS={className:"",sizeClass:"auto",center:!0,fitScreen:!1,closeIcon:!0,bodyScroll:!1,outSideClose:!0,backdrop:!0,animation:{show:"ipe-modal-fade-in",hide:"ipe-modal-fade-out"},animationSpeed:200};let Ps=Cn;const ni=[];function Eh(t="top right"){const e="ipe-modal-toast-container",i=`${e}-${t.replace(/[\s-\.|\/]+/g,"-")}`;let n=document.getElementById(i);return n||(n=Ne("div",{className:`${e} ${t}`,attrs:{id:i,"data-position":t}}),document.body.appendChild(n)),n}const $h={ipe_progress:"_ipe_progress_so6hn_1"},ri=t=>{const e=t.indeterminate??!0,i=m("div",{class:`${$h.ipe_progress}`,"data-indeterminate":`${e}`,style:{width:"100%","--progress":t.progress?`${t.progress}%`:"0%"},...t});return i.setProgress=n=>{typeof n=="number"?(i.dataset.indeterminate="false",i.style.setProperty("--progress",`${n}%`)):(i.dataset.indeterminate="true",i.style.setProperty("--progress","0%"))},i};class Pe extends Ps{constructor(e={}){e.className||(e.className=""),e.className+=" theme-ipe",e.modalAnimation||(e.modalAnimation={show:"ipe-modal-fade-in",hide:"ipe-modal-fade-out"}),super(e)}setLoadingState(e){if(this.get$window().classList.toggle("loading",e),e){const i=this.get$window().querySelectorAll("input:not([disabled]),button:not([disabled])");this._tmpDisabledActiveInputs=i,i.forEach(n=>{n.disabled=!0}),this.get$content().append(m("div",{id:"ipe-modalLoadingWrapper",style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"rgba(255, 255, 255, 0.5)",zIndex:2e3},children:m(ri,{style:{width:"80%",maxWidth:"800px"}})}))}else{this.get$window().querySelector("#ipe-modalLoadingWrapper")?.remove();const i=this._tmpDisabledActiveInputs;i&&i.forEach(n=>{n.disabled=!1})}}}class Ph{constructor(e){this.ctx=e,this.IPEModal=Pe,this.IPEModalEvent=$s,this.show=Pe.show.bind(Pe),this.createObject=Pe.createObject.bind(Pe),this.close=Pe.close.bind(Pe),this.closeAll=Pe.closeAll.bind(Pe),this.removeAll=Pe.removeAll.bind(Pe),this.dialog=Pe.dialog.bind(Pe),this.confirm=Pe.confirm.bind(Pe),this.notify=Pe.notify.bind(Pe),e.set("modal",this),e.on("dispose",()=>{Pe.closeAll()})}}const Ga=t=>{if(!t)return new URLSearchParams;if(t instanceof URLSearchParams)return t;if(typeof t!="object"||t?.constructor!==Object)throw new TypeError("only plain object is supported");const e=new URLSearchParams;for(const[i,n]of Object.entries(t))if(n!=null){if(Array.isArray(n)){for(const r of n)e.append(i,r?.toString());continue}if(typeof n=="object"&&n!==null&&n.constructor===Object){for(const[r,s]of Object.entries(n))s!=null&&e.set(`${i}[${r}]`,s?.toString());continue}e.set(i,n?.toString())}return e},Ya=(t,e,i)=>{const n=typeof t=="string"?new URL(t,window?.location?.origin):new URL(t),r=new URLSearchParams(n.search),s=Ga(e);for(const[o,a]of s.entries())r.set(o,a);return n.search=r.toString(),n.hash="",n};var Ch=Object.create,Cs=Object.defineProperty,Rh=Object.getOwnPropertyDescriptor,Qa=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Ja=t=>{throw TypeError(t)},Ah=(t,e,i)=>e in t?Cs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ih=(t,e)=>Cs(t,"name",{value:e,configurable:!0}),Oh=t=>[,,,Ch(t?.[Qa("metadata")]??null)],Th=["class","method","getter","setter","accessor","field","value","get","set"],Xa=t=>t!==void 0&&typeof t!="function"?Ja("Function expected"):t,Lh=(t,e,i,n,r)=>({kind:Th[t],name:e,metadata:n,addInitializer:s=>i._?Ja("Already initialized"):r.push(Xa(s||null))}),Nh=(t,e)=>Ah(e,Qa("metadata"),t[3]),Mh=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Dh=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,h=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&Rh(r,i));Ih(r,i);for(var f=n.length-1;f>=0;f--)l=Lh(c,i,a={},t[3],h),o=(0,n[f])(r,l),a._=1,Xa(o)&&(r=o);return Nh(t,r),p&&Cs(r,i,p),u?c^4?s:p:r},Za,Rs,el;Za=[$e(["api","storage"])];class Xn extends(el=Ot){constructor(e){super(e,"wiki",!1),this.ctx=e,this._data={},this.CACHE_VERSION=3,this.CACHE_TTL={siteinfo:1e3*60*60*24*3,userinfo:1e3*60*30},this.QUERY_DATA={siteinfo:{meta:"siteinfo",siprop:"general|specialpagealiases|namespacealiases|namespaces|magicwords"},userinfo:{meta:"userinfo",uiprop:"groups|rights|blockinfo|options"}},this.CACHE_DB=void 0,this.mwConfig={get:((i,n)=>window?.mw?.config?.get?.(i,n)??n),has:(i=>window?.mw?.config?.exists?.(i)??!1),get values(){return window?.mw?.config?.values||{}}},this.CACHE_DB=e.storage.createDatabase("wiki-metadata",1/0,this.CACHE_VERSION)}get logger(){return this.ctx.logger("WIKI_METADATA")}get api(){return this.ctx.api}async start(){await Promise.all(Object.keys(this.QUERY_DATA).map(e=>this.initData(e))),this.ctx.set("getUrl",this.getUrl.bind(this)),this.ctx.set("getSciprtUrl",this.getSciprtUrl.bind(this)),this.ctx.set("getMainpageUrl",this.getMainpageUrl.bind(this)),this.ctx.inject(["preferences"],e=>{e.preferences.registerCustomConfig("WikiMetadataService",L.object({WikiMetadataService:L.const(m("div",{children:[m("h3",{children:"Wiki Informations"}),m("ul",{children:[m("li",{children:[m("strong",{children:"Site:"})," ",this.general.sitename," (",this.landingPageUrl,")"]}),m("li",{children:[m("strong",{children:"User"}),": ",this.userInfo.name," (ID: ",this.userInfo.id,")"]}),m("li",{children:[m("strong",{children:"Groups"}),": ",this.userGroups.join(", ")||"None"]})]}),m("div",{children:[m("p",{style:{fontStyle:"italic"},children:"If the information shown above is incorrect (for example, the user is not you), click the button below."}),m("button",{className:"btn danger",onClick:i=>{i.preventDefault(),Promise.all(Object.keys(this.QUERY_DATA).map(n=>this.invalidateCache(n))).then(()=>{window.location.reload()})},children:"🧹 Clear caches & Reload"})]})]})).role("raw-html")}).description("WikiMetadataService"),"about")}),this.logger.info("All initialized",this._data)}async initData(e,i=!1){const n=i?null:await this.fetchFromCache(e);if(n)return this._data[e]=n,this.logger.debug("Using cached",e,n),n;{const r=await this.fetchFromApi(e);return this.saveToCache(e,r),this._data[e]=r,this.logger.debug("Fetched from API",e,r),r}}getCacheKey(e){return`${e}:${new URL(this.ctx.api.config.baseURL).pathname.replace(/^\//,"")}`}async fetchFromApi(e){return this.api.get({action:"query",...this.QUERY_DATA[e]}).then(({data:i})=>{if(typeof i?.query!="object"||i.query===null)throw new Error("Invalid query data",{cause:i});return e==="siteinfo"?i.query:i.query?.[e]||i.query}).catch(i=>(this.logger.error("Failed to fetch",i),Promise.reject(i)))}async fetchFromCache(e){const i=this.getCacheKey(e);return await this.CACHE_DB.get(i,this.CACHE_TTL[e])}async saveToCache(e,i){const n=this.getCacheKey(e);return this.CACHE_DB.set(n,i)}async invalidateCache(e){const i=this.getCacheKey(e);return this.CACHE_DB.delete(i)}get _raw(){return this._data}get siteInfo(){return this._data.siteinfo}get general(){return this.siteInfo.general}get specialPageAliases(){return this.siteInfo.specialpagealiases}get namespaceAliases(){return this.siteInfo.namespacealiases}get namespaces(){return this.siteInfo.namespaces}get namespaceMap(){const e=Object.values(this.namespaces).map(i=>({id:i.id,canonical:i.canonical,aliases:this.namespaceAliases.filter(n=>n.id===i.id).map(n=>n.alias)})).sort((i,n)=>i.id-n.id);return Reflect.defineProperty(this,"namespaceMap",{get:()=>e}),e}get magicWords(){return this.siteInfo.magicwords}get userInfo(){return this._data.userinfo}get userOptions(){return this.userInfo.options}get isUserBlocked(){return this.userInfo.blockedbyid&&this.userInfo.blockexpiry&&new Date(this.userInfo.blockexpiry).getTime()>Date.now()}get userGroups(){return this.userInfo.groups}get userRights(){return this.userInfo.rights}get baseUrl(){const e=this.general.server;return e.startsWith("//")?`${window?.location?.protocol||"https:"}//${e.slice(2)}`:e}get landingPageUrl(){return this.general.base}get mainPageName(){return this.general.mainpage}get mainPageUrl(){return this.getUrl(this.mainPageName)}get articlePath(){return this.general.articlepath}get scriptPath(){return this.general.scriptpath}get articleBaseUrl(){return`${this.baseUrl}${this.articlePath}`}get scriptBaseUrl(){return`${this.baseUrl}${this.scriptPath}`}getSciprtUrl(e="index"){return`${this.scriptBaseUrl}/${e.replace(/\.php$/,"")}.php`}getMainpageUrl(e){return Ya(this.siteInfo.general.base,e).toString()}getUrl(e,i){const n=Ga(i);let r;return typeof e=="string"&&e!==""?r=new URL(`${this.articleBaseUrl.replace("$1",e)}`):typeof e=="number"?(n.set("curid",e.toString()),r=new URL(this.getSciprtUrl("index"))):r=new URL(this.getSciprtUrl("index")),r.search=n.toString(),r.toString()}hasRight(e){return this.userRights.includes(e)}hasAnyRight(...e){return e.some(i=>this.hasRight(i))}hasEveryRights(...e){return e.every(i=>this.hasRight(i))}inGroup(e){return this.userGroups.includes(e)}inAnyGroup(...e){return this.userGroups.some(i=>e.includes(i))}getBlockInfo(){return this.isUserBlocked?{blockid:this.userInfo.blockid,blockedby:this.userInfo.blockedbyid,blockedbyid:this.userInfo.blockedbyid,blockreason:this.userInfo.blockreason,blockedtimestamp:this.userInfo.blockedtimestamp,blockexpiry:this.userInfo.blockexpiry}:null}}Rs=Oh(el),Xn=Dh(Rs,0,"WikiMetadataService",Za,Xn),Mh(Rs,1,Xn);class jh{constructor(){this.values={}}get length(){return Object.keys(this.values).length}clear(){this.values={}}getItem(e){return this.values[e]??null}setItem(e,i){this.values[e]=typeof i=="string"?i:String(i)}removeItem(e){delete this.values[e]}key(e){return Object.keys(this.values)[e]??null}}const Uh=()=>new Proxy(new jh,{set(t,e,i){return typeof e=="string"&&t.setItem(e,i),!0},get(t,e){return typeof e=="string"&&!(e in t)?t.getItem(e):Reflect.get(t,e)}}),Fh=(()=>{const t=Symbol.for("IPE.GlobalMemoryStorage");return t in globalThis||(globalThis[t]=Uh()),globalThis[t]})();class Bh{constructor(e,i,n=1/0,r,s="localStorage"){this.dbName=e,this.storeName=i,this.ttl=n,this.version=r,this.engine=s,typeof n!="number"&&(this.ttl=Number(n)),(isNaN(this.ttl)||this.ttl<=0)&&(this.ttl=1/0),this.engine==="localStorage"&&"localStorage"in window?this.db=window.localStorage:this.engine==="sessionStorage"&&"sessionStorage"in window?this.db=window.sessionStorage:this.db=Fh}makeKey(e){return`${this.dbName?this.dbName+":":""}${this.storeName?this.storeName+"/":""}${e}`}load(e){const i=this.getRaw(e);if(i===null)return null;let n;try{n=JSON.parse(i)}catch{return this.deleteSync(e),null}const r=n;return typeof r.time!="number"||!("value"in r)?(this.deleteSync(e),null):typeof this.version=="number"&&r.version!==this.version?(this.deleteSync(e),null):r}getRaw(e){const i=this.makeKey(e);return this.db.getItem(i)}setRaw(e,i){const n=this.makeKey(e);try{this.db.setItem(n,i)}catch{}}deleteSync(e){const i=this.makeKey(e);this.db.removeItem(i)}isExpired(e,i=this.ttl){return e?Date.now()-e.time>i:!1}async get(e,i=this.ttl,n){const r=this.load(e),s=this.isExpired(r,i);if(!r||s){if(typeof n=="function"){const o=await n();return await this.set(e,o),o}return null}return r.value}async set(e,i){const n=Date.now();if(typeof e=="string"){const o=e,a=i;if(a===null||typeof a>"u"){await this.delete(o);return}const l={time:n,value:a,version:this.version};return this.setRaw(o,JSON.stringify(l)),l}const r=e,s={};for(const[o,a]of Object.entries(r)){if(a===null||typeof a>"u"){this.deleteSync(o);continue}const l={time:n,value:a,version:this.version};this.setRaw(o,JSON.stringify(l)),s[o]=l}return s}async has(e,i=this.ttl){const n=this.load(e);return n!==null&&!this.isExpired(n,i)}async delete(e){this.deleteSync(e)}async updatedAt(e){const i=this.load(e);return i?i.time:0}async clear(){const e=this.makeKey(""),i=[];for(let n=0;n<this.db.length;n++){const r=this.db.key(n);r&&r.startsWith(e)&&i.push(r)}for(const n of i)this.db.removeItem(n);return this}async*keys(){const e=this.makeKey("");for(let i=0;i<this.db.length;i++){const n=this.db.key(i);n&&n.startsWith(e)&&(yield n.slice(e.length))}}async*values(){for await(const e of this.keys()){const i=this.load(e);if(i){if(this.isExpired(i)){this.deleteSync(e);continue}yield i}}}async*entries(){for await(const e of this.keys()){const i=this.load(e);if(i){if(this.isExpired(i)){this.deleteSync(e);continue}yield[e,i]}}}}var we;(t=>{t.cache=new Map,t.defaults=Object.freeze({iterBatch:100,retry:{attempts:3,baseDelayMs:16}}),t.sleep=c=>new Promise(u=>setTimeout(u,c));function e(c){const u=c?.name??"";return u==="AbortError"||u==="InvalidStateError"||u==="TransactionInactiveError"||u==="UnknownError"}t.shouldReconnect=e;async function i(c,u,d){const h=Math.max(1,c.attempts);for(let p=0;p<h;p++)try{return await u(p)}catch(f){if(p===h-1)throw f;await d?.(f,p);const _=c.baseDelayMs*Math.pow(2,p)+Math.floor(Math.random()*10);await(0,t.sleep)(_)}throw new Error("withRetry exhausted unexpectedly")}t.withRetry=i;function n(c,u,d){return new Promise((h,p)=>{const f=indexedDB.open(c,u);f.onupgradeneeded=()=>{try{const _=f.result,P=f.transaction;d?.(_,P)}catch(_){p(_)}},f.onerror=()=>p(f.error),f.onblocked=()=>{},f.onsuccess=()=>{const _=f.result;_.onversionchange=()=>{try{_.close()}finally{t.cache.delete(c)}},h(_)}})}async function r(c,u,d){let h=!c.objectStoreNames.contains(u),p=[];if(!h&&d?.indexes?.length){const P=c.transaction(u,"readonly"),C=P.objectStore(u),R=new Set(Array.from(C.indexNames));p=(d.indexes||[]).filter(y=>!R.has(y.name)),await new Promise((y,g)=>{P.oncomplete=()=>y(),P.onabort=()=>g(P.error),P.onerror=()=>g(P.error)})}if(!h&&p.length===0)return c;const f=c.version+1;c.close();const _=await n(c.name,f,(P,C)=>{let R;P.objectStoreNames.contains(u)?R=C.objectStore(u):R=P.createObjectStore(u,{keyPath:d?.keyPath??void 0,autoIncrement:!!d?.autoIncrement});for(const y of p)R.indexNames.contains(y.name)||R.createIndex(y.name,y.keyPath,y.options)});return _.onversionchange=()=>{try{_.close()}finally{t.cache.delete(_.name)}},_}async function s(c,u,d){let h=t.cache.get(c);return h?(h=h.then(p=>r(p,u,d)),t.cache.set(c,h)):(h=(async()=>{const p=await n(c);return r(p,u,d)})(),t.cache.set(c,h)),h}t.getDB=s;async function o(c){const u=t.cache.get(c);if(t.cache.delete(c),u)try{(await u).close()}catch{}}t.closeConnection=o;function a(c){return new Promise((u,d)=>{c.onsuccess=()=>u(c.result),c.onerror=()=>d(c.error)})}t.asyncRequest=a;function l(c){return new Promise((u,d)=>{c.oncomplete=()=>u(),c.onabort=()=>d(c.error??new DOMException("Aborted","AbortError")),c.onerror=()=>d(c.error??new DOMException("TransactionError","UnknownError"))})}t.waitTx=l})(we||(we={}));let qh=class{constructor(e,i,n={}){this.dbName=e,this.storeName=i,this.options=n}get _iterBatch(){return this.options.iterBatch??we.defaults.iterBatch}get _retryCfg(){const e=this.options.retry??we.defaults.retry;return{attempts:e.attempts??3,baseDelayMs:e.baseDelayMs??16}}async _withStore(e,i){const n=this._retryCfg;return we.withRetry(n,async()=>{const r=await we.getDB(this.dbName,this.storeName,this.options.ensure);try{const s=r.transaction(this.storeName,e),o=s.objectStore(this.storeName),a=await i(o);return await we.waitTx(s),a}catch(s){throw s}},async r=>{we.shouldReconnect(r)&&await we.closeConnection(this.dbName)})}async get(e){return this._withStore("readonly",async i=>{const n=await we.asyncRequest(i.get(e));return n===void 0?void 0:n})}async set(e,i){return await this._withStore("readwrite",async n=>{const r=this.options.ensure?.keyPath!=null?n.put(i):n.put(i,e);await we.asyncRequest(r)}),this}async delete(e){return this._withStore("readwrite",async i=>{const n=await we.asyncRequest(i.get(e))!==void 0;return await we.asyncRequest(i.delete(e)),n})}async clear(){await this._withStore("readwrite",async e=>{await we.asyncRequest(e.clear())})}async has(e){return await this.get(e)!==void 0}async count(){return this._withStore("readonly",async e=>await we.asyncRequest(e.count())??0)}async*_iterateEntries(){let e=null,i=!1;const n=Math.max(1,this._iterBatch);for(;!i;){const r=await this._withStore("readonly",async s=>{const o=[],a=e===null?void 0:IDBKeyRange.lowerBound(e,!0);return await new Promise((l,c)=>{const u=s.openCursor(a);u.onerror=()=>c(u.error),u.onsuccess=()=>{const d=u.result;if(!d){i=!0,l();return}o.push([d.key,d.value]),e=d.key,o.length>=n?l():d.continue()}}),o});for(const s of r)yield s;if(r.length===0)break}}entries(){return this._iterateEntries()}async*keys(){for await(const[e]of this.entries())yield e}async*values(){for await(const[,e]of this.entries())yield e}[Symbol.asyncIterator](){return this.entries()[Symbol.asyncIterator]()}async forEach(e){for await(const[i,n]of this.entries())await e(n,i,this)}async getMany(e){const i=new Map;for await(const n of e)i.set(n,void 0);return await this._withStore("readonly",async n=>{await Promise.all(i.keys().map(async r=>{const s=await we.asyncRequest(n.get(r));i.set(r,s===void 0?void 0:s)}))}),i}async setMany(e){const i=this.options.ensure?.keyPath!=null;return await this._withStore("readwrite",async n=>{for await(const[r,s]of e){const o=i?n.put(s):n.put(s,r);await we.asyncRequest(o)}}),this}async deleteMany(e){let i=0;return await this._withStore("readwrite",async n=>{for await(const r of e)await we.asyncRequest(n.get(r))!==void 0&&i++,await we.asyncRequest(n.delete(r))}),i}async disconnect(){await we.closeConnection(this.dbName)}};class Hh{constructor(e,i,n=1/0,r){this.dbName=e,this.storeName=i,this.ttl=n,this.version=r,this.db=new qh(e,i),this.keys=this.db.keys.bind(this.db),this.values=this.db.values.bind(this.db),this.entries=this.db.entries.bind(this.db),typeof this.ttl!="number"&&(this.ttl=Number(this.ttl)),(isNaN(this.ttl)||this.ttl<=0)&&(this.ttl=1/0),this._clearExpiredEntries().catch(()=>{})}async _clearExpiredEntries(){if(this.ttl===1/0)return;const e=Date.now(),i=[];for await(const[n,r]of this.db.entries())typeof r.time=="number"&&e-r.time>this.ttl&&i.push(n);i.length>0&&await this.db.deleteMany(i)}async get(e,i=this.ttl,n){const r=await this.loadFromDB(e),s=this.checkIfExpired(r,i);if(!r||s){if(typeof n=="function"){const o=await n();return await this.set(e,o),o}return null}return r.value}async set(e,i){const n=Date.now();if(typeof e=="string"){const l=e,c=i;if(c===null||typeof c>"u")return this.delete(l);const u={time:n,value:c,version:this.version};return await this.db.set(l,u),u}const r=e,s=[],o=[],a={};for(const[l,c]of Object.entries(r))if(c===null||typeof c>"u")o.push(l);else{const u={time:n,value:c,version:this.version};s.push([l,u]),a[l]=u}return s.length>0&&await this.db.setMany(s),o.length>0&&await this.db.deleteMany(o),a}async has(e,i=this.ttl){const n=await this.loadFromDB(e),r=this.checkIfExpired(n,i);return n!==null&&!r}async delete(e){await this.db.delete(e)}async updatedAt(e){const i=await this.loadFromDB(e);return i?i.time:0}async loadFromDB(e){const i=await this.db.get(e);if(i===void 0)return null;if(typeof i.time!="number"||typeof i.value>"u"){try{await this.delete(e)}catch{}return null}if(typeof this.version=="number"&&i.version!==this.version){try{await this.delete(e)}catch{}return null}return i}checkIfExpired(e,i=this.ttl){return e?Date.now()-e.time>i:!1}async clear(){return await this.db.clear(),this}}class zh extends Ot{constructor(e,i){super(e,"storage",!1),this.config=i,this.kv=this.createDatabase("key-val",0,1,"indexedDB"),this.simpleKV=this.createDatabase("~",0,1,"localStorage"),this.memoryKV=this.createDatabase("~",0,1,"memory")}createDatabase(e,i,n,r="indexedDB"){const s="indexedDB"in window&&window.indexedDB!==null;switch(r==="indexedDB"&&!s&&(r="localStorage"),r){case"indexedDB":return new Hh(this.config.dbName,e,i,n);case"localStorage":case"sessionStorage":case"memory":return new Bh(this.config.dbName,e,i,n,r);default:throw new Error(`Unsupported storage engine: ${r}`)}}}var rt=(t=>(t.preferences="preferences",t.watch="watch",t.unwatch="unwatch",t.nochange="nochange",t))(rt||{});function Kh(t){const i=class i{constructor(r,s=!0){this._loaded=s,this.api=t,r.revisions?.forEach(o=>{typeof o?.slots?.main=="object"&&Object.assign(o,o.slots.main)}),this.pageInfo={...i.DEFAULT_PAGE_INFO,...r}}static async newFromApi(r){const{data:s}=await this.api.get({...i.DEFAULT_QUERY_PARAMS,...r}),o=s?.query?.pages?.[0];if(!o||!o.title)throw new Error("Invalid page info",{cause:s});return new i(o,!0)}static newBlankPage(r={}){return new i(r,!1)}static async newFromAnyKind(r){const{title:s,pageId:o,revisionId:a}=r||{};return a?this.newFromApi({revids:parseInt(a.toString(),10)}):o?this.newFromApi({pageids:parseInt(o.toString(),10)}):s?this.newFromApi({titles:s.toString()}):null}static async newBatchFromApi(r){const{titles:s,pageids:o,revids:a,...l}=r||{},{data:c}=await this.api.post({...i.DEFAULT_QUERY_PARAMS,titles:s?.join("|")??void 0,pageids:o?.join("|")??void 0,revids:a?.join("|")??void 0,...l});return c?.query?.pages?.map(u=>new i(u,!0))||[]}async parse(r){return this.api.post({action:"parse",page:this.pageInfo.title,prop:"text|langlinks|categories|links|templates|images|externallinks|sections|revid|displaytitle|iwlinks|properties|parsewarnings",...r})}async preview(r,s){return this.parse({action:"parse",page:void 0,title:this.title,text:r,pst:1,preview:1,disableeditsection:1,disablelimitreport:1,...s})}async edit(r,s){const{text:o,prependtext:a,appendtext:l,summary:c="",watchlist:u=rt.preferences,section:d}=r;return this.api.postWithEditToken({action:"edit",title:this.title,starttimestamp:this.pageInfo.touched,basetimestamp:this.revisions[0]?.timestamp,text:o,prependtext:a,appendtext:l,summary:c,watchlist:u,section:d,...s})}async createOnly(r,s){return this.edit(r,{createonly:1,...s})}async delete(r,s){return this.api.postWithEditToken({action:"delete",title:this.pageInfo.title||void 0,pageid:this.pageInfo.pageid||void 0,reason:r,deletetalk:s?.deletetalk,...s})}async moveTo(r,s,o){return this.api.postWithEditToken({action:"move",from:this.pageInfo.title,to:r,reason:s,movetalk:1,movesubpages:1,...o})}userCan(r){return!!this.pageInfo?.actions?.[r]}userCanEdit(){return this.userCan("edit")}async reloadSelfInfo(){const r=await i.newFromApi({pageids:this.pageInfo.pageid,titles:this.pageInfo.title}),s=(this.pageInfo.revisions||[]).concat(r.revisions||[]).sort((o,a)=>o.revid-a.revid).reduce((o,a)=>(o.find(l=>l.revid===a.revid)||o.push(a),o),[]);return this.pageInfo=r.pageInfo,this.pageInfo.revisions=s,this._loaded=!0,this}get pageid(){return this.pageInfo.pageid}get title(){return this.pageInfo.title}get ns(){return this.pageInfo.ns}get contentmodel(){return this.pageInfo.contentmodel}get fullurl(){return this.pageInfo.fullurl}get canonicalurl(){return this.pageInfo.canonicalurl}get editurl(){return this.pageInfo.editurl}get revisions(){return this.pageInfo.revisions||[]}get lastrevid(){return this.pageInfo.lastrevid}get templates(){return this.pageInfo.templates||[]}get images(){return this.pageInfo.images||[]}};i.api=t,i.DEFAULT_QUERY_PARAMS={action:"query",prop:"info|templates|transcludedin|images|pageimages|revisions",inprop:"protection|url|varianttitles",intestactions:"edit|move|delete",tllimit:"max",tilimit:"max",imlimit:"max",piprop:"thumbnail|name|original",pithumbsize:"200",pilimit:"max",rvprop:"ids|timestamp|flags|comment|user|content",rvslots:"main"},i.DEFAULT_PAGE_INFO={pageid:0,ns:0,title:"",contentmodel:"wikitext",pagelanguage:"",pagelanguagehtmlcode:"",pagelanguagedir:"ltr",touched:new Date().toISOString(),lastrevid:0,length:0,protection:[],restrictiontypes:[],fullurl:"",canonicalurl:"",editurl:"",varianttitles:{},actions:{edit:!0,move:!1,delete:!1},revisions:[],templates:[],images:[]};let e=i;return e}const na=class na extends Ot{constructor(e){super(e,"wikiPage",!0),this.ctx=e,this.WikiPage=Kh(this.ctx.api)}async createInstance(e,i=!1){return await this.WikiPage.newFromApi(e)}async newFromTitle(e,i=!1,n,r=!1){return this.createInstance({titles:e.toString(),converttitles:i,rvsection:n},r)}async newFromPageId(e,i,n=!1){return this.createInstance({pageids:e,rvsection:i},n)}async newFromRevision(e,i,n=!1){return await this.createInstance({revids:e,rvsection:i},n)}newBlankPage(e={}){return this.WikiPage.newBlankPage(e)}};na.inject=["api"];let As=na;const tl=new WeakMap,bt={toDBKey:t=>t.replace(/ /g,"_"),toNormalText:t=>t.replace(/_/g," "),ensureCase:(t,e)=>e==="first-letter"?t.charAt(0).toUpperCase()+t.slice(1):t},xi={normalizeSpecialPageName:t=>t.toLowerCase(),buildSpecialPageIndex:t=>{const e=new Map,i=new Map,n=new Map;for(const r of t.specialpagealiases){const s=r.realname;e.set(s,s);const o=xi.normalizeSpecialPageName(s);n.set(o,s);for(const a of r.aliases){i.set(a,s);const l=xi.normalizeSpecialPageName(a);n.set(l,s)}}return{byRealName:e,byAlias:i,byNormalized:n}},findSpecialPageRealName:(t,e)=>{const i=t.split("/")[0];let n=e.byRealName.get(i)??e.byAlias.get(i);if(n!==void 0)return n;const r=xi.normalizeSpecialPageName(i);return e.byNormalized.get(r)??null}},ut={normalizeNamespaceText:t=>t.replace(/[_\s]+/g,"_").toLowerCase().replace(/^_+|_+$/g,""),buildIndex:t=>{const e=new Map,i=new Map,n=new Map,r=new Map;for(const[s,o]of Object.entries(t.namespaces)){const a=parseInt(s);e.set(o.name,a),i.set(o.canonical??"",a);const l=ut.normalizeNamespaceText(o.name),c=ut.normalizeNamespaceText(o.canonical??"");r.set(l,a),r.set(c,a)}for(const s of t.namespacealiases){n.set(s.alias,s.id);const o=ut.normalizeNamespaceText(s.alias);r.set(o,s.id)}return{byName:e,byCanonical:i,byAlias:n,byNormalized:r}},findNamespaceId:(t,e)=>{let i=e.byName.get(t)??e.byCanonical.get(t)??e.byAlias.get(t);if(i!==void 0)return i;const n=ut.normalizeNamespaceText(t);return e.byNormalized.get(n)??null},isTalkPage:t=>t%2===1&&t>0,getDefaultNamespaceInfo:t=>({id:t,name:"",canonical:"",case:"first-letter",content:!1,nonincludable:!1,subpages:!1})};function Wh(t){var s,o;const e=tl.get(t);if(e)return e;const i=ut.buildIndex(t),n=xi.buildSpecialPageIndex(t),a=class a{constructor(c,u){Hi(this,s);Hi(this,o);if(this.newTitle=a.create.bind(a),this.toText=this.getPrefixedText.bind(this),this.toString=this.getPrefixedDBKey.bind(this),Qe(this,s,c||""),Qe(this,o,u??0),u===void 0?this.fixNSByTitle():this.stripNamespaceFromTitle(),this.getMainText()==="")throw new Error("Invalid title")}static create(c,u){return new a(c,u)}fixNSByTitle(){const c=X(this,s).indexOf(":");if(c===-1)return;if(c===0){Qe(this,s,X(this,s).substring(1));return}const u=X(this,s).substring(0,c),d=X(this,s).substring(c+1),h=ut.findNamespaceId(u,a._namespaceIndex);h!==null&&(Qe(this,s,d),Qe(this,o,h))}stripNamespaceFromTitle(){const c=X(this,s).indexOf(":");if(c===-1)return;if(c===0){Qe(this,s,X(this,s).substring(1));return}const u=X(this,s).substring(0,c),d=X(this,s).substring(c+1);ut.findNamespaceId(u,a._namespaceIndex)!==null&&Qe(this,s,d)}getNamespaceInfo(){return a._meta.namespaces[X(this,o)]??ut.getDefaultNamespaceInfo(X(this,o))}getMainDBKey(){const c=this.getNamespaceInfo();if(X(this,o)===-1){const u=xi.findSpecialPageRealName(X(this,s),a._specialPageIndex);if(u){const d=X(this,s).includes("/")?X(this,s).substring(X(this,s).indexOf("/")):"",h=u+d;return bt.ensureCase(bt.toDBKey(h),c.case)}}return bt.ensureCase(bt.toDBKey(X(this,s)),c.case)}getMainText(){const c=this.getNamespaceInfo();if(X(this,o)===-1){const u=xi.findSpecialPageRealName(X(this,s),a._specialPageIndex);if(u){const d=X(this,s).includes("/")?X(this,s).substring(X(this,s).indexOf("/")):"",h=u+d;return bt.ensureCase(bt.toNormalText(h),c.case)}}return bt.ensureCase(bt.toNormalText(X(this,s)),c.case)}getMainRootText(){return this.getMainText().split("/")[0]}getPrefixedDBKey(){return X(this,o)===0?this.getMainDBKey():`${this.getNamespaceDBKey()}:${this.getMainDBKey()}`}getPrefixedText(){return X(this,o)===0?this.getMainText():`${this.getNamespaceText()}:${this.getMainText()}`}getNamespaceId(){return X(this,o)}getNamespaceText(){return this.getNamespaceInfo().name??""}getNamespaceDBKey(){const c=this.getNamespaceInfo();return bt.ensureCase(bt.toDBKey(this.getNamespaceText()),c.case)}getSubjectPage(){if(ut.isTalkPage(X(this,o))){const c=X(this,o)-1;return new a(X(this,s),c)}return this}getTalkPage(){if(ut.isTalkPage(X(this,o)))return this;if(X(this,o)<0)return null;const c=X(this,o)+1;return a._meta.namespaces[c.toString()]?new a(X(this,s),c):null}getURL(c){const u=a._meta.general.articlepath,d=this.getPrefixedDBKey(),h=u.replace("$1",d),p=new URL(h,location.origin);return c&&(c instanceof URLSearchParams?c:new URLSearchParams(c)).forEach((_,P)=>{p.searchParams.set(P,_)}),p}setTitle(c){return Qe(this,s,c),Qe(this,o,0),this.fixNSByTitle(),this}setMainText(c){return Qe(this,s,c),this}setNamespaceText(c){const u=ut.findNamespaceId(c,a._namespaceIndex);return u!==null&&Qe(this,o,u),this}setNamespaceId(c){return Qe(this,o,c),this}equals(c){return typeof c=="string"&&(c=new a(c)),this.getPrefixedDBKey()===c.getPrefixedDBKey()}isSpecial(c){if(X(this,o)!==-1)return!1;const u=new a(c,-1);return this.getMainRootText()===u.getMainRootText()}toJSON(){return{ns:X(this,o),text:this.getMainText(),title:this.getPrefixedText(),url:this.getURL().toString(),isSpecial:X(this,o)<0}}};s=new WeakMap,o=new WeakMap,a._meta=t,a._namespaceIndex=i,a._specialPageIndex=n;let r=a;return tl.set(t,r),r}const Rn=class Rn extends Ot{constructor(e){super(e,"wikiTitle",!0),this.ctx=e,this.logger=this.ctx.logger("WikiTitleService"),this._cachedTitles=new Map,this.wiki=this.ctx.wiki,this.wikiBaseUrl=this.wiki.baseUrl,this.wikiArticlePath=this.wiki.articlePath.replace("$1",""),this.wikiArticleBaseUrl=this.wiki.articleBaseUrl.replace("$1",""),this.wikiIndexPhpUrl=this.wiki.getSciprtUrl("index.php"),this.Title=Wh(this.ctx.wiki.siteInfo)}newTitle(e,i){return new this.Title(e,i)}newMainPageTitle(){return this.newTitle(this.ctx.wiki.mainPageName)}async newTitleFromUrl(e){const i=this.parseWikiLink(e);return i?.title?i.title:i?.pageId?this.newTitleFromPageId(i.pageId):null}async newTitleFromAnyId(e,i=!1){const{title:n,pageId:r,revId:s}=e??{};if(typeof n=="string")return this.newTitle(n);let o,a;if(s?(o=parseInt(s.toString(),10),a="revid"):r&&(o=parseInt(r.toString(),10),a="pageid"),!o||!a||isNaN(o)||o<=0)throw new Error("Invalid id or kind",{cause:e});if(!i&&this._cachedTitles.has(`${a}:${o}`))return await this._cachedTitles.get(`${a}:${o}`);const{promise:l,resolve:c,reject:u}=re();this._cachedTitles.set(`${a}:${o}`,l);try{const{wikiPage:d}=this.ctx;let h=null;if(a==="pageid")h=await d.newFromPageId(o);else if(a==="revid")h=await d.newFromRevision(o);else throw new Error(`Invalid kind: ${a}`);c(this.newTitle(h.title))}catch(d){this._cachedTitles.delete(`${a}:${o}`),u(d)}return l}async newTitleFromPageId(e){return this.newTitleFromAnyId({pageId:e})}async newTitleFromRevision(e){return this.newTitleFromAnyId({revId:e})}resolveSpecialPageTarget(e){const i=typeof e=="string"?this.newTitle(e):e;if(!i||i.getNamespaceId()!==-1)return null;let n,r,s="view";const o=i.getMainDBKey().split("/").slice(1).join("/")||"";if(i.isSpecial("edit")&&o)n=o,s="edit";else if(i.isSpecial("talkpage")&&o){const a=i.newTitle(o).getTalkPage();if(!a)return null;n=a.getPrefixedDBKey()}else if(i.isSpecial("mypage"))n=i.newTitle(this.ctx.wiki.userInfo.name,2).getPrefixedDBKey()+(o?`/${o}`:"");else if(i.isSpecial("mytalk"))n=i.newTitle(this.ctx.wiki.userInfo.name,3).getPrefixedDBKey()+(o?`/${o}`:"");else if(i.isSpecial("newsection")&&o)n=o,r="new",s="edit";else return null;return{title:new this.Title(n),section:r,action:s}}isWikiLink(e){return e.startsWith(this.wikiArticleBaseUrl)||e.startsWith(this.wikiIndexPhpUrl)||e.startsWith(`${this.wikiBaseUrl}/?`)||e===this.ctx.wiki.landingPageUrl}validateHrefAttr(e){return typeof e!="string"?!1:!Rn.REG_SKIPPED_HREF.test(e)}parseWikiLink(e){if(!e||typeof e=="string"&&!this.validateHrefAttr(e))return null;const i=Ya(e);if(!this.isWikiLink(i.toString()))return null;const n=i.searchParams,r=i.hash.replace("#",""),s=n.get("action")||"view",o=n.get("title")||"",a=parseInt(n.get("curid")||"0",10),l=parseInt(n.get("oldid")||"0",10);let c=o||(()=>{try{return decodeURIComponent(i.pathname.substring(this.wikiArticlePath.length))}catch(p){return this.logger.error("parseLink",i,p),""}})();c.endsWith("index.php")&&(c="");let u,d,h;if(l)h=l;else if(a)d=a;else if(c)u=this.newTitle(c);else if(i.origin+i.pathname===this.ctx.wiki.landingPageUrl)u=this.newMainPageTitle();else return null;return{title:u,pageId:d,revId:h,url:i,params:n,hash:r,action:s}}};Rn.inject=["wiki","wikiPage"],Rn.REG_SKIPPED_HREF=/^(#|javascript:|vbscript:|file:)/i;let Is=Rn;const Vh=t=>typeof t=="function";async function Gh(t){return Vh(t)?await t():t}var Yh=Object.create,Os=Object.defineProperty,Qh=Object.getOwnPropertyDescriptor,il=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),nl=t=>{throw TypeError(t)},Jh=(t,e,i)=>e in t?Os(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Xh=(t,e)=>Os(t,"name",{value:e,configurable:!0}),Zh=t=>[,,,Yh(t?.[il("metadata")]??null)],ep=["class","method","getter","setter","accessor","field","value","get","set"],rl=t=>t!==void 0&&typeof t!="function"?nl("Function expected"):t,tp=(t,e,i,n,r)=>({kind:ep[t],name:e,metadata:n,addInitializer:s=>i._?nl("Already initialized"):r.push(rl(s||null))}),ip=(t,e)=>Jh(e,il("metadata"),t[3]),np=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},rp=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,h=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&Qh(r,i));Xh(r,i);for(var f=n.length-1;f>=0;f--)l=tp(c,i,a={},t[3],h),o=(0,n[f])(r,l),a._=1,rl(o)&&(r=o);return ip(t,r),p&&Os(r,i,p),u?c^4?s:p:r},sl,Ts,ol;sl=[$e(["storage","wiki"])];class Zn extends(ol=Ot){constructor(e){super(e,"preferences",!0),this.ctx=e,this.db=void 0,this.customRegistries=[],this.categoryDefinitions=[],this._defaultPreferences={},e.set("prefs",this),this.db=e.storage.createDatabase(`preferences:${e.wiki.userInfo.id}`,1/0);try{this._migrageFromLegacyMasterDB()}catch{}}get logger(){return this.ctx.logger("PREFERENCES")}async start(){this.defineCategory({name:"general",label:"General",description:"General settings",autoGenerateForm:!0}),this.defineCategory({name:"editor",label:"Editor",description:"Settings related to editing content",autoGenerateForm:!0})}async get(e,i){if(!e)return this.getAll();i??(i=()=>{const r=this.defaultOf(e);return this.logger.debug(e,`(fallback value: ${r})`),r});const n=await this.db.get(e,void 0);return n!==null?n:await Gh(i)}async getAll(){const e=this.loadDefaultConfigs();for await(const[i,n]of this.db.entries())i!=="_touched"&&i in e&&(e[i]=n.value);return e}async set(e,i){return(await this.setMany({[e]:i}))[e]}async setMany(e){const i=this.loadDefaultConfigs(),n={};for(const[r,s]of Object.entries(e))s===i[r]||s===void 0?n[r]=void 0:n[r]=s;return await this.db.set(n),this.ctx.emit("preferences/changed",{ctx:this.ctx,input:e,changes:n}),n}defaultOf(e){var i;return(i=this._defaultPreferences)[e]??(i[e]=this.loadDefaultConfigs()[e])}async getExportableRecord(e){e??(e=await this.getAll());const i=this.loadDefaultConfigs(),n={};return Object.entries(i).sort(([r],[s])=>r.localeCompare(s)).forEach(([r,s])=>{const o=e[r];o!==void 0&&o!==s&&(n[r]=o)}),n}loadDefaultConfigs(){const e={};return this.getConfigRegistries().forEach(i=>{try{const n=i.schema({});Object.entries(n).forEach(([r,s])=>{e[r]=s})}catch{}}),Object.entries(e).forEach(([i,n])=>{this._defaultPreferences[i]=n}),e}registerCustomConfig(e,i,n){return this.customRegistries.push({name:e,schema:i,category:n||"general"}),this}getConfigRegistries(e){return Array.from(this.ctx.registry.entries()).map(([i])=>i===null?{name:"@root",schema:Si?.PreferencesSchema||null}:{name:i.name,schema:i?.PreferencesSchema||null}).filter(i=>i.schema!==null).map(i=>({...i,category:i.schema.meta.category||"general"})).concat(this.customRegistries).filter(i=>!e||i.category===e)}getAllSchema(){return new L(L.intersect(this.getConfigRegistries().map(e=>e.schema)))}defineCategory(e){const i=this.categoryDefinitions.findIndex(n=>n.name===e.name);return i<0?this.categoryDefinitions.push(e):this.categoryDefinitions[i]=e,this.categoryDefinitions.sort((n,r)=>(n.index??0)-(r.index??0)),this}getConfigCategories(){return this.categoryDefinitions}async _migrageFromLegacyMasterDB(){const e=this.ctx.storage.createDatabase("preferences",1/0);let i=0;for await(const[n,r]of e.entries())n!=="_touched"&&(await this.db.set(n,r.value),i++);return i&&this.logger.info(`Migrated ${i} preferences from master DB`),await e.clear(),await e?.db?.disconnect?.(),i}}Ts=Zh(ol),Zn=rp(Ts,0,"PreferencesService",sl,Zn),np(Ts,1,Zn);var Lt=(t=>(t.ANALYTICS_API_BASE="https://analytics.ipe.wiki/api/v6",t.ANALYTICS_DASH_URL="https://analytics.ipe.wiki",t.GITHUB_URL="https://github.com/inpageedit/inpageedit-next",t.HOME_URL="https://www.ipe.wiki/",t.UPDATE_LOGS_URL="https://www.ipe.wiki/changelogs/",t.PLUGIN_REGISTRY_URL="https://registry.ipe.wiki/registry.v1.json",t))(Lt||{});const An=class An extends Be{constructor(i){super({name:"InPageEdit"});Hi(this,$t);this.version="0.13.1",this.Endpoints=Lt,this.schema=L,this.config=Vi(An.DEFAULT_CONFIG,i),this.logger=Sa({name:"IPE",color:"#33aaff",level:this.config.logLevel}),lt(this,$t,If).call(this),this.config.autoInstallCorePlugins&&lt(this,$t,Tf).call(this),lt(this,$t,Lf).call(this)}async withInject(i){const{promise:n,resolve:r}=re();return this.inject(i,s=>{r(s)}),n}};$t=new WeakSet,If=async function(){this.plugin(Ed,this.config.apiConfigs),this.plugin(zn),this.plugin(Md),this.plugin(Ph),this.plugin(Zn),this.plugin(zh,{dbName:this.config.storageNamespace}),this.plugin(Xn),this.plugin(As),this.plugin(Is),lt(this,$t,Of).call(this,["api","currentPage","resourceLoader","modal","preferences","storage","wikiPage","wikiTitle","wiki","getUrl","getSciprtUrl","getMainpageUrl"])},Of=function(i){if(typeof i=="string"&&(i=[i]),!Array.isArray(i)||i.length===0)return this;for(const n of i){const r=this[An.internal][n];r?.type==="service"&&(r.builtin=!0)}return this},Tf=async function(){[Promise.resolve().then(()=>vp).then(({PluginAnalytics:n})=>n),Promise.resolve().then(()=>Ap).then(({PluginInArticleLinks:n})=>n),Promise.resolve().then(()=>dy).then(({PluginPluginStore:n})=>n),Promise.resolve().then(()=>Uy).then(({PluginPreferencesUI:n})=>n),Promise.resolve().then(()=>eb).then(({PluginQuickEdit:n})=>n),Promise.resolve().then(()=>fb).then(({PluginQuickMove:n})=>n),Promise.resolve().then(()=>xb).then(({PluginQuickPreview:n})=>n),Promise.resolve().then(()=>Ub).then(({PluginQuickDiff:n})=>n),Promise.resolve().then(()=>Fb).then(({PluginQuickRedirect:n})=>n),Promise.resolve().then(()=>Jb).then(({PluginToolbox:n})=>n)].forEach(async n=>{this.plugin(await n)})},Lf=async function(){this.inject(["resourceLoader"],i=>{})},An.DEFAULT_CONFIG={apiConfigs:{},legacyPreferences:{},logLevel:ls.info,storageNamespace:"InPageEdit",autoloadStyles:!0,autoInstallCorePlugins:!0};let Si=An;function al(t){return t.charAt(0).toLowerCase()+t.slice(1)}function sp(t){return al(t).replace(/_/g,"-").replace(/.[A-Z]+/g,e=>e[0]+"-"+e.slice(1).toLowerCase())}function op(t){return al(t).replace(/-/g,"_").replace(/.[A-Z]+/g,e=>e[0]+"_"+e.slice(1).toLowerCase())}const Vr=class Vr{constructor(e,i=void 0,n){Hi(this,In);this.ctx=e,this.disposeHandlers=[],this.name=n||"",this.config=i||{};const{promise:r,resolve:s,reject:o}=Promise.withResolvers();queueMicrotask(()=>{this.name||(this.name=this.constructor.name);try{const a=this.start();a&&typeof a.then=="function"?a.then(()=>s()).catch(l=>{this.logger.error("start() returns a rejected promise",l),o(l)}):s()}catch(a){this.logger.error("start() threw synchronously",a),o(a)}r.then(()=>{this.logger.debug("started")}),r.catch(a=>{this.logger.error("start failed",a),this.ctx.scope.dispose()})}),this.ctx.once("dispose",()=>{this.disposeHandlers.forEach(a=>a(this.ctx)),this.stop(),this.logger.debug("disposed")})}start(){}stop(){}addDisposeHandler(e){this.disposeHandlers.push(e)}removeDisposeHandler(e){this.disposeHandlers=this.disposeHandlers.filter(i=>i!==e)}set name(e){Qe(this,In,op(e).toUpperCase())}get name(){return X(this,In)}get logger(){return this.ctx.logger(this.name)}};In=new WeakMap,Vr.inject=[],Vr.reusable=!1;let Xe=Vr;function si(t){return function(e){return e.PreferencesSchema=t,e}}window.RLQ||(window.RLQ=[]),window.__IPE_MODULES__||(window.__IPE_MODULES__=[]),lp("InPageEdit#autoload",()=>{const t=ll();t&&ap({baseURL:t,InPageEdit:Si})});async function ap(t={baseURL:ll(),InPageEdit:Si}){const{baseURL:e,InPageEdit:i}=t;typeof window?.ipe?.stop=="function"&&await window.ipe.stop();const n=window.InPageEdit||{},r=new i({apiConfigs:{baseURL:e},legacyPreferences:n?.myPreferences||{}});if(window.ipe=r,await r.start(),window.RLQ.push(()=>{mw.hook("InPageEdit.ready").fire(r)}),Array.isArray(window.__IPE_MODULES__)){const s=[];for(;window.__IPE_MODULES__.length;)try{const o=window.__IPE_MODULES__.shift();typeof o=="function"&&o?.(r),s.push(o)}catch{}window.__IPE_MODULES__={push:o=>{typeof o=="function"&&o(r),s.push(o)}},r.on("dispose",()=>{window.__IPE_MODULES__=s})}r.logger("AUTOLOAD").info(`
3
+ `),e.emit(e,"internal/warning",n)}get(e){if(this.ctx[D.internal][e]?.type!=="service")return;const n=this.ctx[D.isolate][e],r=this.ctx[D.store][n]?.value;return vt(this.ctx,r)}set(e,i){this.provide(e);const n=this.ctx[D.isolate][e],r=this.ctx[D.store][n]?.value;i??(i=void 0);let s=V(()=>{},"dispose");if(r===i)return s;if(!we(i)&&!we(r))throw new Error(`service ${e} has been registered`);const o=this.ctx;we(i)||(s=o.effect(()=>()=>{o.set(e,void 0)})),_a(i)&&o.emit(o,"internal/warning",new Error(`service ${e} is an unproxyable object, which may lead to unexpected behavior`));const a=Object.create(o);return a[D.filter]=l=>o[D.isolate][e]===l[D.isolate][e],o.emit(a,"internal/before-service",e,i),o[D.store][n]={value:i,source:o},o.emit(a,"internal/service",e,r),s}provide(e,i,n){const r=this.ctx.root[D.internal];if(e in r)return;const s=Symbol(e);r[e]={type:"service",builtin:n},this.ctx.root[D.isolate][e]=s,os(i)&&(this.ctx[D.store][s]={value:i,source:null},Le(i,D.tracker,{associate:e,property:"ctx"}))}_accessor(e,i){const n=this.ctx.root[D.internal];return e in n?()=>{}:(n[e]={type:"accessor",...i},()=>delete this.ctx.root[D.isolate][e])}accessor(e,i){this.ctx.scope.effect(()=>this._accessor(e,i))}alias(e,i){const n=this.ctx.root[D.internal];if(!(e in n))for(const r of i)n[r]||(n[r]={type:"alias",name:e})}_mixin(e,i){const n=Array.isArray(i)?i.map(o=>[o,o]):Object.entries(i),r=typeof e=="string"?o=>o[e]:()=>e,s=n.map(([o,a])=>this._accessor(a,{get(l){const c=r(this);if(we(c))return c;const u=l?Yi(l,c):c,f=Reflect.get(c,o,u);return typeof f!="function"?f:f.bind(u??c)},set(l,c){const u=r(this),f=c?Yi(c,u):u;return Reflect.set(u,o,l,f)}}));return()=>s.forEach(o=>o())}mixin(e,i){this.ctx.scope.effect(()=>this._mixin(e,i))}trace(e){return vt(this.ctx,e)}bind(e){return new Proxy(e,{apply:V((i,n,r)=>i.apply(this.trace(n),r.map(s=>this.trace(s))),"apply")})}},V(ut,"ReflectService"),B(ut,"handler",{get:V((e,i,n)=>{if(typeof i!="string")return Reflect.get(e,i,n);if(Reflect.has(e,i))return vt(n,Reflect.get(e,i,n),!0);const[r,s]=ut.resolveInject(e,i),o=new Error(`property ${r} is not registered, declare it as \`inject\` to suppress this warning`);return s?s.type==="accessor"?s.get.call(n,n[D.receiver]):(s.builtin||ut.checkInject(n,r,o),n.reflect.get(r)):(ut.checkInject(n,r,o),Reflect.get(e,r,n))},"get"),set:V((e,i,n,r)=>{if(typeof i!="string")return Reflect.set(e,i,n,r);const[s,o]=ut.resolveInject(e,i);return o?o.type==="accessor"?o.set?o.set.call(r,n,r[D.receiver]):!1:(r.reflect.set(s,n),!0):Reflect.set(e,s,n,r)},"set"),has:V((e,i)=>{if(typeof i!="string")return Reflect.has(e,i);if(Reflect.has(e,i))return!0;const[,n]=ut.resolveInject(e,i);return!!n},"has")}),ut),us=md;function fs(t){return t!==null&&t!==!1&&t!==void 0}V(fs,"isBailed");var yd=(Fi=class{constructor(e){B(this,"isActive",!1);B(this,"_tasks",new Set);B(this,"_hooks",{});this.ctx=e,Le(this,D.tracker,{associate:"lifecycle",property:"ctx"}),Le(this.on("internal/listener",function(n,r,s){const o=s.prepend?"unshift":"push";if(n==="ready")return this.lifecycle.isActive?(this.scope.ensure(async()=>r()),()=>!1):void 0;if(n==="dispose")return this.scope.disposables[o](r),Le(r,"name","event <dispose>"),()=>Kt(this.scope.disposables,r);if(n==="fork")return this.scope.runtime.forkables[o](r),this.scope.collect("event <fork>",()=>Kt(this.scope.runtime.forkables,r))}),ze.static,e.scope);for(const n of["info","error","warning"])Le(this.on(`internal/${n}`,(r,...s)=>{this._hooks[`internal/${n}`].length>1}),ze.static,e.scope);Le(this.on("internal/before-service",function(n){for(const r of this.registry.values()){if(!r.inject[n]?.required)continue;const s=r.isReusable?r.children:[r];for(const o of s)this[D.filter](o.ctx)&&(o.updateStatus(),o.reset())}},{global:!0}),ze.static,e.scope),Le(this.on("internal/service",function(n){for(const r of this.registry.values()){if(!r.inject[n]?.required)continue;const s=r.isReusable?r.children:[r];for(const o of s)this[D.filter](o.ctx)&&o.start()}},{global:!0}),ze.static,e.scope);const i=V((n,r)=>{if(!n.runtime.plugin)return!1;for(const s in n.runtime.inject)if(r===us.resolveInject(n.ctx,s)[0])return!0;return i(n.parent.scope,r)},"checkInject");Le(this.on("internal/inject",function(n){return i(this.scope,n)},{global:!0}),ze.static,e.scope)}async flush(){for(;this._tasks.size;)await Promise.all(Array.from(this._tasks))}filterHooks(e,i){return i=vt(this.ctx,i),e.slice().filter(n=>{const r=i?.[ze.filter];return n.global||!r||r.call(i,n.ctx)})}*dispatch(e,i){const n=typeof i[0]=="object"||typeof i[0]=="function"?i.shift():null,r=i.shift();r!=="internal/event"&&this.emit("internal/event",e,r,i,n);for(const s of this.filterHooks(this._hooks[r]||[],n))yield s.callback.apply(n,i)}async parallel(...e){await Promise.all(this.dispatch("emit",e))}emit(...e){Array.from(this.dispatch("emit",e))}async serial(...e){for await(const i of this.dispatch("serial",e))if(fs(i))return i}bail(...e){for(const i of this.dispatch("bail",e))if(fs(i))return i}register(e,i,n,r){const s=r.prepend?"unshift":"push";return i[s]({ctx:this.ctx,callback:n,...r}),this.ctx.state.collect(e,()=>this.unregister(i,n))}unregister(e,i){const n=e.findIndex(r=>r.callback===i);if(n>=0)return e.splice(n,1),!0}on(e,i,n){var a;typeof n!="object"&&(n={prepend:n}),this.ctx.scope.assertActive(),i=this.ctx.reflect.bind(i);const r=this.bail(this.ctx,"internal/listener",e,i,n);if(r)return r;const s=(a=this._hooks)[e]||(a[e]=[]),o=typeof e=="string"?`event <${e}>`:"event (Symbol)";return this.register(o,s,i,n)}once(e,i,n){const r=this.on(e,function(...s){return r(),i.apply(this,s)},n);return r}async start(){this.isActive=!0;const e=this._hooks.ready||[];for(;e.length;){const{ctx:i,callback:n}=e.shift();i.scope.ensure(async()=>n())}await this.flush()}async stop(){this.isActive=!1,this.ctx.scope.reset()}},V(Fi,"Lifecycle"),Fi),Sa=yd,ka=(t=>(t[t.PENDING=0]="PENDING",t[t.LOADING=1]="LOADING",t[t.ACTIVE=2]="ACTIVE",t[t.FAILED=3]="FAILED",t[t.DISPOSED=4]="DISPOSED",t))(ka||{});W.CordisError=(mi=class extends Error{constructor(e,i){super(i??mi.Code[e]),this.code=e}},V(mi,"CordisError"),mi),(t=>{t.Code={INACTIVE_EFFECT:"cannot create effect on inactive context"}})(W.CordisError||(W.CordisError={}));var ds=(Bi=class{constructor(e,i){B(this,"uid");B(this,"ctx");B(this,"disposables",[]);B(this,"error");B(this,"status",0);B(this,"isActive",!1);B(this,"context");B(this,"proxy");B(this,"acceptors",[]);B(this,"tasks",new Set);B(this,"hasError",!1);this.parent=e,this.config=i,this.uid=e.registry?e.registry.counter:0,this.ctx=this.context=e.extend({scope:this}),this.proxy=new Proxy({},{get:V((n,r)=>Reflect.get(this.config,r),"get")})}get _config(){return this.runtime.isReactive?this.proxy:this.config}assertActive(){if(!(this.uid!==null||this.isActive))throw new W.CordisError("INACTIVE_EFFECT")}effect(e,i){this.assertActive();const n=rs(e)?new e(this.ctx,i):e(this.ctx,i);let r=!1;const s=typeof n=="function"?n:n.dispose.bind(n),o=V((...a)=>{if(!r)return r=!0,Kt(this.disposables,o),s(...a)},"wrapped");return this.disposables.push(o),typeof n=="function"?o:(n.dispose=o,n)}collect(e,i){const n=Le(()=>(Kt(this.disposables,n),i()),"name",e);return this.disposables.push(n),n}restart(){this.reset(),this.error=null,this.hasError=!1,this.status=0,this.start()}_getStatus(){return this.uid===null?4:this.hasError?3:this.tasks.size?1:this.ready?2:0}updateStatus(e){const i=this.status;e?.(),this.status=this._getStatus(),i!==this.status&&this.context.emit("internal/status",this,i)}ensure(e){const i=e().catch(n=>{this.context.emit(this.ctx,"internal/error",n),this.cancel(n)}).finally(()=>{this.updateStatus(()=>this.tasks.delete(i)),this.context.events._tasks.delete(i)});this.updateStatus(()=>this.tasks.add(i)),this.context.events._tasks.add(i)}cancel(e){this.error=e,this.updateStatus(()=>this.hasError=!0),this.reset()}get ready(){return Object.entries(this.runtime.inject).every(([e,i])=>!i.required||!we(this.ctx.get(e)))}reset(){this.isActive=!1,this.disposables=this.disposables.splice(0).filter(e=>{if(this.uid!==null&&e[ze.static]===this)return!0;(async()=>e())().catch(i=>{this.context.emit(this.ctx,"internal/error",i)})})}init(e){this.config?this.start():this.cancel(e)}start(){if(!this.ready||this.isActive||this.uid===null)return!0;this.isActive=!0,this.updateStatus(()=>this.hasError=!1)}accept(...e){const n={keys:Array.isArray(e[0])?e.shift():null,callback:e[0],...e[1]};return this.effect(()=>(this.acceptors.push(n),n.immediate&&n.callback?.(this.config),()=>Kt(this.acceptors,n)))}decline(e){return this.accept(e,()=>!0)}checkUpdate(e,i){if(i||!this.config)return[!0,!0];if(i===!1)return[!1,!1];const n=Object.create(null),r=V(c=>{const u=n[c]??(n[c]=!ii(this.config[c],e[c]));return o||(o=u),u},"checkPropertyUpdate"),s=new Set;let o=!1,a=!1,l=this.runtime.isReactive||null;for(const{keys:c,callback:u,passive:f}of this.acceptors){if(!c)l||(l=!f);else if(f)c?.forEach(p=>s.add(p));else{let p=!1;for(const d of c)p||(p=r(d));if(!p)continue}u?.(e)&&(a=!0)}for(const c in{...this.config,...e})if(l!==!1&&!(c in n)&&!s.has(c)){const u=r(c);l===null&&(a||(a=u))}return[o,a]}},V(Bi,"EffectScope"),Bi),$a=(qi=class extends ds{constructor(i,n,r,s){super(i,r);B(this,"dispose");this.runtime=n,this.dispose=Le(i.scope.collect(`fork <${i.runtime.name}>`,()=>{this.uid=null,this.reset(),this.context.emit("internal/fork",this);const o=Kt(n.disposables,this.dispose);return Kt(n.children,this)&&!n.children.length&&i.registry.delete(n.plugin),o}),ze.static,n),n.children.push(this),n.disposables.push(this.dispose),this.context.emit("internal/fork",this),this.init(s)}start(){if(super.start())return!0;for(const i of this.runtime.forkables)this.ensure(async()=>i(this.context,this._config))}update(i,n){const r=this.config,s=this.runtime.isForkable?this:this.runtime;if(s.config!==r)return;let o;try{o=Vi(this.runtime.plugin,i)}catch(c){return this.context.emit("internal/error",c),this.cancel(c)}const[a,l]=s.checkUpdate(o,n);this.context.emit("internal/before-update",this,i),this.config=o,s.config=o,a&&this.context.emit("internal/update",this,r),l&&s.restart()}},V(qi,"ForkScope"),qi),hs=(Hi=class extends ds{constructor(i,n,r,s){super(i,r);B(this,"value");B(this,"runtime",this);B(this,"schema");B(this,"name");B(this,"inject",Object.create(null));B(this,"forkables",[]);B(this,"children",[]);B(this,"isReusable",!1);B(this,"isReactive",!1);B(this,"apply",V((i,n)=>{if(typeof this.plugin!="function")return this.plugin.apply(i,n);if(rs(this.plugin)){const r=new this.plugin(i,n),s=r[ze.expose];return s&&i.set(s,r),r.fork&&this.forkables.push(r.fork.bind(r)),r}else return this.plugin(i,n)},"apply"));this.plugin=n,n?(this.setup(),this.init(s)):(this.name="root",this.isActive=!0)}get isForkable(){return this.forkables.length>0}fork(i,n,r){return new $a(i,this,n,r)}dispose(){return this.uid=null,this.reset(),this.context.emit("internal/runtime",this),!0}setup(){const{name:i}=this.plugin;i&&i!=="apply"&&(this.name=i),this.schema=this.plugin.Config||this.plugin.schema,this.inject=Ee.resolve(this.plugin.using||this.plugin.inject),this.isReusable=this.plugin.reusable,this.isReactive=this.plugin.reactive,this.context.emit("internal/runtime",this),this.isReusable&&this.forkables.push(this.apply)}reset(){super.reset();for(const i of this.children)i.reset()}start(){if(super.start())return!0;!this.isReusable&&this.plugin&&this.ensure(async()=>this.value=this.apply(this.ctx,this._config));for(const i of this.children)i.start()}update(i,n){if(this.isForkable){const c=new Error(`attempting to update forkable plugin "${this.plugin.name}", which may lead to unexpected behavior`);this.context.emit(this.ctx,"internal/warning",c)}const r=this.config;let s;try{s=Vi(this.runtime.plugin||this.context.constructor,i)}catch(c){return this.context.emit("internal/error",c),this.cancel(c)}const[o,a]=this.checkUpdate(s,n),l=this.children.find(c=>c.config===r);this.config=s,l&&(this.context.emit("internal/before-update",l,i),l.config=s,o&&this.context.emit("internal/update",l,r)),a&&this.restart()}},V(Hi,"MainScope"),Hi);function Ea(t){return t&&typeof t=="object"&&typeof t.apply=="function"}V(Ea,"isApplicable");function Ee(t){return function(e,i){if(i.kind==="class")e.inject=t;else if(i.kind==="method")i.addInitializer(function(){const n=this[D.tracker]?.property;if(!n)throw new Error("missing context tracker");this[n].inject(t,r=>{e.call(Yi(this,{[n]:r}))})});else throw new Error("@Inject can only be used on class or class methods")}}V(Ee,"Inject"),(t=>{function e(i){if(!i)return{};if(Array.isArray(i))return Object.fromEntries(i.map(o=>[o,{required:!0}]));const{required:n,optional:r,...s}=i;return Array.isArray(n)&&Object.assign(s,Object.fromEntries(n.map(o=>[o,{required:!0}]))),Array.isArray(r)&&Object.assign(s,Object.fromEntries(r.map(o=>[o,{required:!1}]))),s}t.resolve=e,V(e,"resolve")})(Ee||(Ee={}));var bd=(zi=class{constructor(e,i){B(this,"_counter",0);B(this,"_internal",new Map);B(this,"context");this.ctx=e,Le(this,D.tracker,{associate:"registry",property:"ctx"}),this.context=e;const n=new hs(e,null,i);e.scope=n,n.ctx=e,this.set(null,n)}get counter(){return++this._counter}get size(){return this._internal.size}resolve(e,i=!1){if(e===null||typeof e=="function")return e;if(Ea(e))return e.apply;if(i)throw new Error('invalid plugin, expect function or object with an "apply" method, received '+typeof e)}get(e){const i=this.resolve(e);return i&&this._internal.get(i)}has(e){const i=this.resolve(e);return!!i&&this._internal.has(i)}set(e,i){const n=this.resolve(e);this._internal.set(n,i)}delete(e){const i=this.resolve(e),n=i&&this._internal.get(i);if(n)return this._internal.delete(i),n.dispose(),n}keys(){return this._internal.keys()}values(){return this._internal.values()}entries(){return this._internal.entries()}forEach(e){return this._internal.forEach(e)}using(e,i){return this.inject(e,i)}inject(e,i){return this.plugin({inject:e,apply:i,name:i.name})}plugin(e,i,n){if(this.resolve(e,!0),this.ctx.scope.assertActive(),!n)try{i=Vi(e,i)}catch(s){this.context.emit(this.ctx,"internal/error",s),n=s,i=null}let r=this.get(e);return r?(r.isForkable||this.context.emit(this.ctx,"internal/warning",new Error(`duplicate plugin detected: ${e.name}`)),r.fork(this.ctx,i,n)):(r=new hs(this.ctx,e,i,n),this.set(e,r),r.fork(this.ctx,i,n))}},V(zi,"Registry"),zi),vd=bd,ze=(Se=class{static is(e){return!!e?.[Se.is]}static associate(e,i){return e}constructor(e){e=Vi(this.constructor,e),this[D.store]=Object.create(null),this[D.isolate]=Object.create(null),this[D.internal]=Object.create(null),this[D.intercept]=Object.create(null);const i=new Proxy(this,us.handler);i.root=i,i.reflect=new us(i),i.registry=new vd(i,e),i.lifecycle=new Sa(i);const n=V(r=>{if(r){n(Object.getPrototypeOf(r));for(const s of Object.getOwnPropertyNames(r)){const o=r[s].prototype?.constructor;o&&(i[r[s].key]=new o(i,e),Le(i[r[s].key],"ctx",i))}}},"attach");return n(this[D.internal]),i}[Symbol.for("nodejs.util.inspect.custom")](){return`Context <${this.name}>`}get name(){let e=this.runtime;for(;e&&!e.name;)e=e.parent.runtime;return e?.name}get events(){return this.lifecycle}get state(){return this.scope}extend(e={}){const i=Reflect.getOwnPropertyDescriptor(this,D.shadow)?.value,n=Object.assign(Object.create(vt(this,this)),e);return i?Object.assign(Object.create(n),{[D.shadow]:i}):n}isolate(e,i){const n=Object.create(this[D.isolate]);return n[e]=i??Symbol(e),this.extend({[D.isolate]:n})}intercept(e,i){const n=Object.create(this[D.intercept]);return n[e]=i,this.extend({[D.intercept]:n})}},V(Se,"Context"),B(Se,"store",D.store),B(Se,"events",D.events),B(Se,"static",D.static),B(Se,"filter",D.filter),B(Se,"expose",D.expose),B(Se,"isolate",D.isolate),B(Se,"internal",D.internal),B(Se,"intercept",D.intercept),B(Se,"origin","ctx"),B(Se,"current","ctx"),Se.is[Symbol.toPrimitive]=()=>Symbol.for("cordis.is"),Se.prototype[Se.is]=!0,Se);ze.prototype[ze.internal]=Object.create(null);var wt=(rt=class{constructor(...e){B(this,"ctx");B(this,"name");B(this,"config");let i,n,r,s;ze.is(e[0])?(i=e[0],typeof e[1]=="string"?(n=e[1],r=e[2]):s=e[1]):s=e[0],n??(n=this.constructor[D.provide]),r??(r=this.constructor[D.immediate]);let o=this;const a={associate:n,property:"ctx"};return o[D.invoke]&&(o=cs(n,ss(Object.getPrototypeOf(this),Function.prototype),a)),i?o.ctx=i:o[D.setup](),o.name=n,o.config=s,Le(o,D.tracker,a),o.ctx.provide(n),o.ctx.runtime.name=n,r&&(i?o[D.expose]=n:o.ctx.set(n,o)),o.ctx.on("ready",async()=>{await Promise.resolve(),await o.start(),r||o.ctx.set(n,o)}),o.ctx.on("dispose",()=>o.stop()),o}start(){}stop(){}[D.filter](e){return e[D.isolate][this.name]===this.ctx[D.isolate][this.name]}[D.setup](){this.ctx=new ze}[D.extend](e){let i;return this[rt.invoke]?i=cs(this.name,this,this[D.tracker]):i=Object.create(this),Object.assign(i,e)}static[Symbol.hasInstance](e){let i=e.constructor;for(;i;){if(i=i.prototype?.constructor,i===this)return!0;i=Object.getPrototypeOf(i)}return!1}},V(rt,"Service"),B(rt,"setup",D.setup),B(rt,"invoke",D.invoke),B(rt,"extend",D.extend),B(rt,"tracker",D.tracker),B(rt,"provide",D.provide),B(rt,"immediate",D.immediate),rt),wd=Object.defineProperty,_d=Object.getOwnPropertyNames,Z=(t,e)=>wd(t,"name",{value:e,configurable:!0}),xd=(t,e)=>function(){return e||(0,t[_d(t)[0]])((e={exports:{}}).exports,e),e.exports},Sd=xd({"src/index.ts"(t,e){var M;var i=Symbol.for("schemastery"),n=Symbol.for("ValidationError");globalThis.__schemastery_index__??(globalThis.__schemastery_index__=0);var r=(M=class extends TypeError{constructor(v,x){let P="$";for(const L of x.path||[])typeof L=="string"?P+="."+L:typeof L=="number"?P+="["+L+"]":typeof L=="symbol"&&(P+=`[Symbol(${L.toString()})]`);P.startsWith(".")&&(P=P.slice(1));super((P==="$"?"":`${P} `)+v);B(this,"name","ValidationError");this.options=x}static is(v){return!!v?.[n]}},Z(M,"ValidationError"),M);Object.defineProperty(r.prototype,n,{value:!0});var s=Z(function(g){const y=Z(function(v,x={}){return s.resolve(v,y,x)[0]},"schema");if(g.refs){const v=Mt(g.refs,P=>new s(P)),x=Z(P=>v[P],"getRef");for(const P in v){const L=v[P];L.sKey=x(L.sKey),L.inner=x(L.inner),L.list=L.list&&L.list.map(x),L.dict=L.dict&&Mt(L.dict,x)}return v[g.uid]}if(Object.assign(y,g),typeof y.callback=="string")try{y.callback=new Function("return "+y.callback)()}catch{}return Object.defineProperty(y,"uid",{value:globalThis.__schemastery_index__++}),Object.setPrototypeOf(y,s.prototype),y.meta||(y.meta={}),y.toString=y.toString.bind(y),y},"Schema");s.prototype=Object.create(Function.prototype),s.prototype[i]=!0,s.ValidationError=r;var o;s.prototype.toJSON=Z(function(){var v;if(o)return o[v=this.uid]??(o[v]=JSON.parse(JSON.stringify({...this}))),this.uid;o={[this.uid]:{...this}},o[this.uid]=JSON.parse(JSON.stringify({...this}));const y={uid:this.uid,refs:o};return o=void 0,y},"toJSON"),s.prototype.set=Z(function(y,v){return this.dict[y]=v,this},"set"),s.prototype.push=Z(function(y){return this.list.push(y),this},"push");function a(g,y){const v=typeof g=="string"?{"":g}:{...g};for(const x in y){const P=y[x];P?.$description||P?.$desc?v[x]=P.$description||P.$desc:typeof P=="string"&&(v[x]=P)}return v}Z(a,"mergeDesc");function l(g){return g?.$value??g?.$inner}Z(l,"getInner");function c(g){return ga(g??{},y=>!y.startsWith("$"))}Z(c,"extractKeys"),s.prototype.i18n=Z(function(y){const v=s(this),x=a(v.meta.description,y);return Object.keys(x).length&&(v.meta.description=x),v.dict&&(v.dict=Mt(v.dict,(P,L)=>P.i18n(Mt(y,C=>l(C)?.[L]??C?.[L])))),v.list&&(v.list=v.list.map((P,L)=>P.i18n(Mt(y,(C={})=>Array.isArray(l(C))?l(C)[L]:Array.isArray(C)?C[L]:c(C))))),v.inner&&(v.inner=v.inner.i18n(Mt(y,P=>l(P)?l(P):c(P)))),v.sKey&&(v.sKey=v.sKey.i18n(Mt(y,P=>P?.$key))),v},"i18n"),s.prototype.extra=Z(function(y,v){const x=s(this);return x.meta={...x.meta,[y]:v},x},"extra");for(const g of["required","disabled","collapse","hidden","loose"])Object.assign(s.prototype,{[g](y=!0){const v=s(this);return v.meta={...v.meta,[g]:y},v}});s.prototype.deprecated=Z(function(){var v;const y=s(this);return(v=y.meta).badges||(v.badges=[]),y.meta.badges.push({text:"deprecated",type:"danger"}),y},"deprecated"),s.prototype.experimental=Z(function(){var v;const y=s(this);return(v=y.meta).badges||(v.badges=[]),y.meta.badges.push({text:"experimental",type:"warning"}),y},"experimental"),s.prototype.pattern=Z(function(y){const v=s(this),x=ma(y,["source","flags"]);return v.meta={...v.meta,pattern:x},v},"pattern"),s.prototype.simplify=Z(function(y){if(ii(y,this.meta.default,this.type==="dict"))return null;if(we(y))return y;if(this.type==="object"||this.type==="dict"){const v={};for(const x in y){const L=(this.type==="object"?this.dict[x]:this.inner)?.simplify(y[x]);(this.type==="dict"||!we(L))&&(v[x]=L)}return ii(v,this.meta.default,this.type==="dict")?null:v}else if(this.type==="array"||this.type==="tuple"){const v=[];return y.forEach((x,P)=>{const L=this.type==="array"?this.inner:this.list[P],C=L?L.simplify(x):x;v.push(C)}),v}else if(this.type==="intersect"){const v={};for(const x of this.list)Object.assign(v,x.simplify(y));return v}else if(this.type==="union")for(const v of this.list)try{return s.resolve(y,v,{}),v.simplify(y)}catch{}return y},"simplify"),s.prototype.toString=Z(function(y){return S[this.type]?.(this,y)??`Schema<${this.type}>`},"toString"),s.prototype.role=Z(function(g,y){const v=s(this);return v.meta={...v.meta,role:g,extra:y},v},"role");for(const g of["default","link","comment","description","max","min","step"])Object.assign(s.prototype,{[g](y){const v=s(this);return v.meta={...v.meta,[g]:y},v}});var u={};s.extend=Z(function(y,v){u[y]=v},"extend"),s.resolve=Z(function(y,v,x={},P=!1){if(!v)return[y];if(x.ignore?.(y,v))return[y];if(we(y)&&v.type!=="lazy"){if(v.meta.required)throw new r("missing required value",x);let C=v,U=v.meta.default;for(;C?.type==="intersect"&&we(U);)C=C.list[0],U=C?.meta.default;if(we(U))return[y];y=Bn(U)}const L=u[v.type];if(!L)throw new r(`unsupported type "${v.type}"`,x);try{return L(y,v,x,P)}catch(C){if(!v.meta.loose)throw C;return[v.meta.default]}},"resolve"),s.from=Z(function(y){if(we(y))return s.any();if(["string","number","boolean"].includes(typeof y))return s.const(y).required();if(y[i])return y;if(typeof y=="function")switch(y){case String:return s.string().required();case Number:return s.number().required();case Boolean:return s.boolean().required();case Function:return s.function().required();default:return s.is(y).required()}else throw new TypeError(`cannot infer schema from ${y}`)},"from"),s.lazy=Z(function(y){const v=Z(()=>(x.inner[i]||(x.inner=x.builder(),x.inner.meta={...x.meta,...x.inner.meta}),x.inner.toJSON()),"toJSON"),x=new s({type:"lazy",builder:y,inner:{toJSON:v}});return x},"lazy"),s.natural=Z(function(){return s.number().step(1).min(0)},"natural"),s.percent=Z(function(){return s.number().step(.01).min(0).max(1).role("slider")},"percent"),s.date=Z(function(){return s.union([s.is(Date),s.transform(s.string().role("datetime"),(y,v)=>{const x=new Date(y);if(isNaN(+x))throw new r(`invalid date "${y}"`,v);return x},!0)])},"date"),s.regExp=Z(function(y=""){return s.union([s.is(RegExp),s.transform(s.string().role("regexp",{flag:y}),(v,x)=>{try{return new RegExp(v,y)}catch(P){throw new r(P.message,x)}},!0)])},"regExp"),s.arrayBuffer=Z(function(y){return s.union([s.is(ArrayBuffer),s.is(SharedArrayBuffer),s.transform(s.any(),(v,x)=>{if(bt.isSource(v))return bt.fromSource(v);throw new r(`expected ArrayBufferSource but got ${v}`,x)},!0),...y?[s.transform(s.string(),(v,x)=>{try{return y==="base64"?bt.fromBase64(v):bt.fromHex(v)}catch(P){throw new r(P.message,x)}},!0)]:[]])},"arrayBuffer"),s.extend("lazy",(g,y,v,x)=>(y.inner[i]||(y.inner=y.builder(),y.inner.meta={...y.meta,...y.inner.meta}),s.resolve(g,y.inner,v,x))),s.extend("any",g=>[g]),s.extend("never",(g,y,v)=>{throw new r(`expected nullable but got ${g}`,v)}),s.extend("const",(g,{value:y},v)=>{if(ii(g,y))return[y];throw new r(`expected ${y} but got ${g}`,v)});function f(g,y,v,x,P=!1){const{max:L=1/0,min:C=-1/0}=y;if(g>L)throw new r(`expected ${v} <= ${L} but got ${g}`,x);if(g<C&&!P)throw new r(`expected ${v} >= ${C} but got ${g}`,x)}Z(f,"checkWithinRange"),s.extend("string",(g,{meta:y},v)=>{if(typeof g!="string")throw new r(`expected string but got ${g}`,v);if(y.pattern){const x=new RegExp(y.pattern.source,y.pattern.flags);if(!x.test(g))throw new r(`expect string to match regexp ${x}`,v)}return f(g.length,y,"string length",v),[g]});function h(g,y){const v=g.toString();if(v.includes("e"))return g*Math.pow(10,y);const x=v.indexOf(".");if(x===-1)return g*Math.pow(10,y);const P=v.slice(x+1),L=v.slice(0,x);return P.length<=y?+(L+P.padEnd(y,"0")):+(L+P.slice(0,y)+"."+P.slice(y))}Z(h,"decimalShift");function p(g,y,v){if(v=Math.abs(v),!/^\d+\.\d+$/.test(v.toString()))return(g-y)%v===0;const x=v.toString().indexOf("."),P=v.toString().slice(x+1).length;return Math.abs(h(g,P)-h(y,P))%h(v,P)===0}Z(p,"isMultipleOf"),s.extend("number",(g,{meta:y},v)=>{if(typeof g!="number")throw new r(`expected number but got ${g}`,v);f(g,y,"number",v);const{step:x}=y;if(x&&!p(g,y.min??0,x))throw new r(`expected number multiple of ${x} but got ${g}`,v);return[g]}),s.extend("boolean",(g,y,v)=>{if(typeof g=="boolean")return[g];throw new r(`expected boolean but got ${g}`,v)}),s.extend("bitset",(g,{bits:y,meta:v},x)=>{let P=0,L=[];if(typeof g=="number"){P=g;for(const C in y)g&y[C]&&L.push(C)}else if(Array.isArray(g)){L=g;for(const C of L){if(typeof C!="string")throw new r(`expected string but got ${C}`,x);C in y&&(P|=y[C])}}else throw new r(`expected number or array but got ${g}`,x);return P===v.default?[P]:[P,L]}),s.extend("function",(g,y,v)=>{if(typeof g=="function")return[g];throw new r(`expected function but got ${g}`,v)}),s.extend("is",(g,{constructor:y},v)=>{if(typeof y=="function"){if(g instanceof y)return[g];throw new r(`expected ${y.name} but got ${g}`,v)}else{if(we(g))throw new r(`expected ${y} but got ${g}`,v);let x=Object.getPrototypeOf(g);for(;x;){if(x.constructor?.name===y)return[g];x=Object.getPrototypeOf(x)}throw new r(`expected ${y} but got ${g}`,v)}});function d(g,y,v,x){try{const[P,L]=s.resolve(g[y],v,{...x,path:[...x.path||[],y]});return L!==void 0&&(g[y]=L),P}catch(P){if(!x?.autofix)throw P;return delete g[y],v.meta.default}}Z(d,"property"),s.extend("array",(g,{inner:y,meta:v},x)=>{if(!Array.isArray(g))throw new r(`expected array but got ${g}`,x);return f(g.length,v,"array length",x,!we(y.meta.default)),[g.map((P,L)=>d(g,L,y,x))]}),s.extend("dict",(g,{inner:y,sKey:v},x,P)=>{if(!Fn(g))throw new r(`expected object but got ${g}`,x);const L={};for(const C in g){let U;try{U=s.resolve(C,v,x)[0]}catch(H){if(P)continue;throw H}L[U]=d(g,C,y,x),g[U]=g[C],C!==U&&delete g[C]}return[L]}),s.extend("tuple",(g,{list:y},v,x)=>{if(!Array.isArray(g))throw new r(`expected array but got ${g}`,v);const P=y.map((L,C)=>d(g,C,L,v));return x?[P]:(P.push(...g.slice(y.length)),[P])});function w(g,y){for(const v in y)v in g||(g[v]=y[v])}Z(w,"merge"),s.extend("object",(g,{dict:y},v,x)=>{if(!Fn(g))throw new r(`expected object but got ${g}`,v);const P={};for(const L in y){const C=d(g,L,y[L],v);(!we(C)||L in g)&&(P[L]=C)}return x||w(P,g),[P]}),s.extend("union",(g,{list:y,toString:v},x,P)=>{for(const L of y)try{return s.resolve(g,L,x,P)}catch{}throw new r(`expected ${v()} but got ${JSON.stringify(g)}`,x)}),s.extend("intersect",(g,{list:y,toString:v},x,P)=>{if(!y.length)return[g];let L;for(const C of y){const U=s.resolve(g,C,x,!0)[0];if(!we(U))if(we(L))L=U;else{if(typeof L!=typeof U)throw new r(`expected ${v()} but got ${JSON.stringify(g)}`,x);if(typeof U=="object")w(L??(L={}),U);else if(L!==U)throw new r(`expected ${v()} but got ${JSON.stringify(g)}`,x)}}return!P&&Fn(g)&&w(L,g),[L]}),s.extend("transform",(g,{inner:y,callback:v,preserve:x},P)=>{const[L,C=g]=s.resolve(g,y,P,!0);return x?[v(L)]:[v(L),v(C)]});var S={};function E(g,y,v){S[g]=v,Object.assign(s,{[g](...x){const P=new s({type:g});return y.forEach((L,C)=>{switch(L){case"sKey":P.sKey=x[C]??s.string();break;case"inner":P.inner=s.from(x[C]);break;case"list":P.list=x[C].map(s.from);break;case"dict":P.dict=Mt(x[C],s.from);break;case"bits":{P.bits={};for(const U in x[C])typeof x[C][U]=="number"&&(P.bits[U]=x[C][U]);break}case"callback":{const U=P.callback=x[C];U.toJSON||(U.toJSON=()=>U.toString());break}case"constructor":{const U=P.constructor=x[C];typeof U=="function"&&(U.toJSON||(U.toJSON=()=>U.name));break}default:P[L]=x[C]}}),g==="object"||g==="dict"?P.meta.default={}:g==="array"||g==="tuple"?P.meta.default=[]:g==="bitset"&&(P.meta.default=0),P}})}Z(E,"defineMethod"),E("is",["constructor"],({constructor:g})=>typeof g=="function"?g.name:g),E("any",[],()=>"any"),E("never",[],()=>"never"),E("const",["value"],({value:g})=>typeof g=="string"?JSON.stringify(g):g),E("string",[],()=>"string"),E("number",[],()=>"number"),E("boolean",[],()=>"boolean"),E("bitset",["bits"],()=>"bitset"),E("function",[],()=>"function"),E("array",["inner"],({inner:g})=>`${g.toString(!0)}[]`),E("dict",["inner","sKey"],({inner:g,sKey:y})=>`{ [key: ${y.toString()}]: ${g.toString()} }`),E("tuple",["list"],({list:g})=>`[${g.map(y=>y.toString()).join(", ")}]`),E("object",["dict"],({dict:g})=>Object.keys(g).length===0?"{}":`{ ${Object.entries(g).map(([y,v])=>`${y}${v.meta.required?"":"?"}: ${v.toString()}`).join(", ")} }`),E("union",["list"],({list:g},y)=>{const v=g.map(({toString:x})=>x()).join(" | ");return y?`(${v})`:v}),E("intersect",["list"],({list:g})=>`${g.map(y=>y.toString(!0)).join(" & ")}`),E("transform",["inner","callback","preserve"],({inner:g},y)=>g.toString(y)),e.exports=s}});const R=Sd();var ps=(t=>(t[t.debug=-1]="debug",t[t.log=0]="log",t[t.info=1]="info",t[t.warn=2]="warn",t[t.error=3]="error",t[t.silent=4]="silent",t))(ps||{});const gs=globalThis||window,ms=Symbol.for("__IPE_LOGGER_COLOR_MAP__");gs[ms]||(gs[ms]=new Map);const ys=gs[ms];function zn(t){let e=2166136261;for(let i=0;i<t.length;i++)e^=t.charCodeAt(i),e=(e>>>0)*16777619;return e>>>0}const Pa=[[350,360],[0,15],[15,30],[200,230],[230,250],[250,280],[280,310],[310,330],[140,160],[160,180]];function kd(t,e){const i=Pa.length,n=zn(t)%i,[r,s]=Pa[n],o=s-r,a=zn(t+":"+e),l=r+a%(o||1),c=zn(t+":s"),u=zn(t+":l");let f,h;if(e==="name")f=62+c%18,h=30+u%12;else{const p=l>=0&&l<50||l>330&&l<360,d=l>=200&&l<=300;f=55+c%20,d?h=55+u%8:p?h=48+u%6:h=50+u%8,f<60&&(f+=5)}return`hsl(${l}, ${f}%, ${h}%)`}function Kn(t,e){if(e)return ys.set(t,e),e;const i=ys.get(t);if(i)return i;const n=t.startsWith("name:")?"name":"group",r=kd(t,n);return ys.set(t,r),r}let Ca=class Ff{constructor(e={}){this._custom=i=>{if(!this._enabled(i.level))return Ra;const[n,r]=this._prefix(i.label);return this._consoleMethod(i.method).bind(console,n,...r)},this._name=e.name,this._nameColor=e.color,this._groupPath=e._groupPath?[...e._groupPath]:[],this._dynamicLevels={...e._dynamicLevels},this._levelRef=e._levelRef??{value:e.level??1},this._name&&Kn(`name:${this._name}`,this._nameColor),this._installBuiltinLevels();for(const i of Object.keys(this._dynamicLevels))this._installLevelGetter(i,this._dynamicLevels[i]);return Ed(this)}get level(){return this._levelRef.value}set level(e){this._levelRef.value=e}group(e,i){return e&&Kn(`group:${e}`,i?.color),new Ff({name:this._name,color:this._nameColor,_groupPath:[...this._groupPath,e],_dynamicLevels:this._dynamicLevels,_levelRef:this._levelRef})}defineLevel(e,i){this._dynamicLevels[e]={...i},this._installLevelGetter(e,i)}get debug(){return this._method("debug")}get log(){return this._method("log")}get info(){return this._method("info")}get warn(){return this._method("warn")}get error(){return this._method("error")}_installBuiltinLevels(){}_installLevelGetter(e,i){Object.defineProperty(this,e,{configurable:!0,enumerable:!1,get:()=>this._custom(i)})}_method(e){const i=$d[e];if(!this._enabled(i.level))return Ra;const[n,r]=this._prefix(i.label);return this._consoleMethod(e).bind(console,n,...r)}_consoleMethod(e){return(console[e]||console.log).bind(console)}_enabled(e){return e>=this._levelRef.value&&this._levelRef.value!==4}_prefix(e){const i=[];let n="";if(this._name){const r=Kn(`name:${this._name}`,this._nameColor);n+=`%c${this._name}%c`,i.push(`background:${r}; color:#fff; padding:1px 4px; border-radius:2px; font-weight:700;`,Ia)}if(e&&(n+=` ${e}`),this._groupPath.length){const r=this._groupPath.join("/"),s=Kn(`group:${r}`);n+=` %c${r}%c`,i.push(`color:${s}; text-decoration: underline;`,Ia)}return[n,i]}};const Ra=()=>{},Ia="color:inherit; background:transparent; text-decoration:none;",$d={debug:{level:-1,label:"",method:"debug"},log:{level:0,label:"",method:"log"},info:{level:1,label:"[I]",method:"info"},warn:{level:2,label:"[W]",method:"warn"},error:{level:3,label:"[E]",method:"error"}};function Ed(t){const e=function(i,n){return t.group(i,n)};return new Proxy(e,{get(i,n,r){return t[n]},set(i,n,r){return t[n]=r,!0},apply(i,n,r){return t.group(r[0],r[1])},has(i,n){return n in t}})}function Aa(t){return new Ca(t)}var Ze=(t=>(t.BODY_USED="BODY_USED",t.NO_BODY_READER="NO_BODY_READER",t.TIMEOUT="TIMEOUT",t.NETWORK_ERROR="NETWORK_ERROR",t.BODY_NOT_ALLOWED="BODY_NOT_ALLOWED",t.HOOK_CONTEXT_CHANGED="HOOK_CONTEXT_CHANGED",t.ABORTED_BY_HOOK="ABORTED_BY_HOOK",t.INVALID_HOOK_CALLBACK="INVALID_HOOK_CALLBACK",t.UNEXPECTED_HOOK_RETURN="UNEXPECTED_HOOK_RETURN",t))(Ze||{});let Ke=class Bf extends Error{constructor(i,n,r,s){super(n,s);B(this,"name","FexiosError");this.code=i,this.context=r}static is(i){return i?.constructor===Bf}},Pd=class qf extends Ke{constructor(i,n,r){super(n.statusText,i,void 0,r);B(this,"name","FexiosResponseError");this.response=n}static is(i){return i?.constructor===qf}};function Cd(t,e=2048){if(!(t instanceof Uint8Array))throw new TypeError("Input must be a Uint8Array");if(t.length===0)return!0;const i=Math.min(Math.max(t.length,256),e),n=t.slice(0,i);if(Rd(n))return!1;const r=Id(n);if(r.nullByteRatio>.05||r.highByteRatio>.95)return!1;const s=["utf-8","utf-16le","utf-16be","iso-8859-1"];let o=-1,a=!1;for(const l of s)try{const c=new TextDecoder(l,{fatal:!0}).decode(n),u=Ad(c);u>o&&(o=u,a=u>.7)}catch{continue}return a}function Rd(t){if(t.length<4)return!1;const e=[[137,80,78,71],[255,216,255],[71,73,70],[37,80,68,70],[80,75,3,4],[80,75,5,6],[80,75,7,8],[127,69,76,70],[77,90],[202,254,186,190],[0,0,1,0],[82,73,70,70]];for(const i of e)if(t.length>=i.length){let n=!0;for(let r=0;r<i.length;r++)if(t[r]!==i[r]){n=!1;break}if(n)return!0}return!1}function Id(t){let e=0,i=0,n=0;for(const r of t)r===0&&e++,r>127&&i++,(r<32&&r!==9&&r!==10&&r!==13||r===127)&&n++;return{nullByteRatio:e/t.length,highByteRatio:i/t.length,controlCharRatio:n/t.length}}function Ad(t){if(t.length===0)return 1;let e=1,i=0;for(let r=0;r<t.length;r++){const s=t[r].charCodeAt(0);s>=32&&s<=126||s===9||s===10||s===13||s===32?i++:s>127&&s<65534?!Od(s)&&!Td(s)&&i++:e-=.1}const n=i/t.length;return e*=n,Ld(t)&&(e*=1.1),Math.max(0,Math.min(1,e))}function Od(t){return t>=0&&t<=31||t>=127&&t<=159}function Td(t){return t>=57344&&t<=63743||t>=983040&&t<=1048573||t>=1048576&&t<=1114109}function Ld(t){return[/\b\w+\b/,/[.!?]+\s/,/\s+/,/[a-zA-Z]{3,}/,/[\u4e00-\u9fa5]+/,/\d+/].some(e=>e.test(t))}function ht(t){if(typeof t!="object"||t===null||Object.prototype.toString.call(t)!=="[object Object]")return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||e===null}const Qi=(t,...e)=>{const i=r=>{if(Array.isArray(r))return r.slice();if(ht(r)){const s={};for(const o of Reflect.ownKeys(r))s[o]=i(r[o]);return s}return r},n=i(t);for(const r of e)if(r!=null)for(const s of Reflect.ownKeys(r)){const o=r[s];if(typeof o>"u")continue;const a=n[s];ht(a)&&ht(o)?n[s]=Qi(a,o):n[s]=i(o)}return n};let Xi=class{constructor(e,i,n){B(this,"ok");B(this,"status");B(this,"statusText");B(this,"headers");this.rawResponse=e,this.data=i,this.ok=e.ok,this.status=e.status,this.statusText=e.statusText,this.headers=e.headers,Object.entries(n||{}).forEach(([r,s])=>{this[r]=s})}};async function Oa(t,e,i){if(t.bodyUsed)throw new Ke(Ze.BODY_USED,"Response body has already been used or locked");const n=t.headers.get("content-type")||"",r=Number(t.headers.get("content-length"))||0,s=(a,l)=>l==="json"||a.startsWith("application/json"),o=(a,l,c)=>c==="blob"||a.startsWith("image/")&&!a.startsWith("image/svg")||a.startsWith("video/")||a.startsWith("audio/")||!Cd(l);if((t.status===101||t.status===426||t.headers.get("upgrade"))&&typeof globalThis.WebSocket<"u"){const a=new WebSocket(t.url);return await new Promise((l,c)=>{a.onopen=l,a.onerror=c}),new Xi(t,a,{ok:!0,status:101,statusText:"Switching Protocols"})}else if(n.startsWith("text/event-stream")&&!["text","json"].includes(e||"")&&typeof globalThis.EventSource<"u"){const a=new EventSource(t.url);return await new Promise((l,c)=>{a.onopen=l,a.onerror=c}),new Xi(t,a)}else{if(e==="stream")return new Xi(t,t.body);{const a=t.clone().body?.getReader();if(!a)throw new Ke(Ze.NO_BODY_READER,"Failed to get ReadableStream from response body");let l=new Uint8Array;for(;;){const{done:u,value:f}=await a.read();if(u)break;if(f&&(l=new Uint8Array([...l,...f]),i&&r>0)){const h=Math.min(l.length/r,1);i(h,l)}}const c=new Xi(t,void 0);if(e==="arrayBuffer")return c.data=l.buffer,c;if(s(n,e))try{const u=new TextDecoder().decode(l);c.data=JSON.parse(u)}catch{}if(typeof c.data!="string"&&o(n,l,e)?c.data=new Blob([l],{type:t.headers.get("content-type")||void 0}):c.data=new TextDecoder().decode(l),typeof c.data=="string"&&e!=="text"){const u=c.data.trim(),f=u[0],h=u[u.length-1];if(f==="{"&&h==="}"||f==="["&&h==="]")try{c.data=JSON.parse(c.data)}catch{}}if(typeof c.data>"u"&&(c.data=l.length>0?l:void 0),c.ok)return c;throw new Pd(`Request failed with status code ${t.status}`,c)}}}var Wn;(t=>{t.makeSearchParams=r=>{if(!r)return new URLSearchParams;if(r instanceof URLSearchParams)return r;if(typeof r!="object"||r?.constructor!==Object)throw new TypeError("only plain object is supported");const s=new URLSearchParams,o=(c,u)=>{u!=null&&s.append(c,u)},a=(c,u)=>{u!=null&&s.set(c,u)},l=(c,u)=>{if(u!=null){if(Array.isArray(u)){for(const f of u)o(c,f?.toString());return}if(typeof u=="object"&&u.constructor===Object){for(const[f,h]of Object.entries(u)){if(h==null)continue;const p=f.endsWith("[]"),d=p?f.slice(0,-2):f,w=`${c}[${d}]`;if(p){const S=`${w}[]`;if(Array.isArray(h))for(const E of h)o(S,E?.toString());else typeof h=="object"&&h!==null&&h.constructor===Object?l(`${w}[]`,h):o(S,h?.toString())}else if(Array.isArray(h))for(const S of h)o(w,S?.toString());else typeof h=="object"&&h!==null&&h.constructor===Object?l(w,h):a(w,h?.toString())}return}a(c,u?.toString())}};for(const[c,u]of Object.entries(r))l(c,u);return s},t.makeQueryString=r=>(0,t.makeSearchParams)(r).toString(),t.makeURL=(r,s,o,a)=>{const l=typeof window<"u"&&window.location?.origin||"http://localhost",c=typeof r=="string"?new URL(r,a??l):new URL(r),u=(0,t.toQueryRecord)(c.searchParams),f=(0,t.mergeQueries)(u,s||{}),h=(0,t.makeSearchParams)(f);return c.search=h.toString(),c.hash=o||"",c},t.toQueryRecord=r=>{typeof r=="string"&&(r=(0,t.fromString)(r));const s={},o=l=>{if(!l.includes("["))return{path:[l],forceArray:!1};const c=[l.slice(0,l.indexOf("["))],u=/\[([^\]]*)\]/g;let f,h=!1,p=!1;for(;f=u.exec(l);)f[1]===""?(h=!0,p=!0):(c.push(f[1]),p=!1);return h&&p&&(c[c.length-1]=c[c.length-1]+"[]"),{path:c,forceArray:h}},a=(l,c,u,f)=>{let h=l;for(let p=0;p<c.length;p++){const d=c[p];p===c.length-1?f?h[d]===void 0?h[d]=[u]:Array.isArray(h[d])?h[d].push(u):h[d]=[h[d],u]:h[d]===void 0?h[d]=u:Array.isArray(h[d])?h[d].push(u):h[d]=[h[d],u]:((h[d]===void 0||typeof h[d]!="object"||Array.isArray(h[d]))&&(h[d]={}),h=h[d])}};for(const[l,c]of r.entries()){const{path:u,forceArray:f}=o(String(l));a(s,u,c?.toString(),f)}return s},t.fromString=r=>{const s=r.trim();if(!s)return new URLSearchParams;if(s.startsWith("?"))return new URLSearchParams(s.slice(1));const o=s.indexOf("?");if(o>=0){const a=s.indexOf("#",o+1),l=s.slice(o+1,a>=0?a:void 0);return new URLSearchParams(l)}return new URLSearchParams(s)},t.mergeQueries=(r,...s)=>{const o=e(i(r));for(const a of s)a!=null&&n(o,i(a));return o};function e(r){if(Array.isArray(r))return r.map(e);if(ht(r)){const s={};for(const[o,a]of Object.entries(r))s[o]=e(a);return s}if(r instanceof Map){const s={};for(const[o,a]of r.entries())s[o]=e(a);return s}return r}function i(r){if(!r)return{};if(r instanceof URLSearchParams||r instanceof FormData||r instanceof Map)return(0,t.toQueryRecord)(r);if(typeof r=="string")return(0,t.toQueryRecord)((0,t.fromString)(r));if(ht(r))return r;throw new TypeError(`unsupported type transformation, got: ${Object.prototype.toString.call(r)}`)}function n(r,s){for(const[o,a]of Object.entries(s)){if(a===void 0)continue;if(a===null){delete r[o];continue}const l=r[o];ht(l)&&ht(a)?n(l,a):r[o]=e(a)}}})(Wn||(Wn={}));const Ta=function(t){const e=this.constructor.prototype,i=Reflect.get(e,t,e);function n(...r){return Reflect.apply(i,n,r)}Reflect.setPrototypeOf(n,e);for(const r of Reflect.ownKeys(i)){const s=Reflect.getOwnPropertyDescriptor(i,r);s&&Reflect.defineProperty(n,r,s)}return n};Ta.prototype=Object.create(Function.prototype);var Ji;(t=>{t.makeHeaders=e=>{if(!e)return new Headers;if(e instanceof Headers)return new Headers(e);const i=new Headers;if(e instanceof Map){for(const[n,r]of e.entries())if(r!=null)if(Array.isArray(r))for(const s of r)s!=null&&i.append(n,String(s));else i.append(n,String(r));return i}if(ht(e)){for(const[n,r]of Object.entries(e))if(r!=null)if(Array.isArray(r))for(const s of r)s!=null&&i.append(n,String(s));else i.append(n,String(r));return i}throw new TypeError("only plain object, Map/ReadonlyMap, or Headers is supported")},t.toHeaderRecord=e=>{if(e instanceof Headers){const i={};return e.forEach((n,r)=>{i[r]=i[r]?[...i[r],n]:[n]}),i}if(e instanceof Map){const i={};for(const[n,r]of e.entries())if(r!=null)if(Array.isArray(r)){const s=r.filter(o=>o!=null).map(o=>String(o));s.length&&(i[n]=(i[n]??[]).concat(s))}else{const s=String(r);i[n]=i[n]?[...i[n],s]:[s]}return i}throw new TypeError(`unsupported type transformation, got: ${Object.prototype.toString.call(e)}`)},t.mergeHeaders=(e,...i)=>{const n=e instanceof Headers?new Headers(e):(0,t.makeHeaders)(e),r=s=>{for(const[o,a]of Object.entries(s))if(a!==void 0){if(a===null){n.delete(o);continue}if(Array.isArray(a)){n.delete(o);for(const l of a)l!=null&&n.append(o,String(l))}else n.set(o,String(a))}};for(const s of i){if(s==null)continue;if(s instanceof Headers){s.forEach((a,l)=>{n.set(l,a)});continue}if(ht(s)){r(s);continue}const o=(0,t.toHeaderRecord)(s);for(const[a,l]of Object.entries(o)){n.delete(a);for(const c of l)n.append(a,c)}}return n}})(Ji||(Ji={}));let bs=(he=class extends Ta{constructor(i={}){super("request");B(this,"baseConfigs");B(this,"hooks",[]);B(this,"mergeQueries",Wn.mergeQueries);B(this,"mergeHeaders",Ji.mergeHeaders);B(this,"interceptors",{request:this.createInterceptor("beforeRequest"),response:this.createInterceptor("afterResponse")});B(this,"create",he.create);B(this,"_plugins",new Map);B(this,"checkIsPlainObject",ht);B(this,"mergeQuery",this.mergeQueries);this.baseConfigs=Qi(he.DEFAULT_CONFIGS,i),he.ALL_METHODS.forEach(n=>this.createMethodShortcut(n.toLowerCase()))}async request(i,n){let r=n=n||{};if(typeof i=="string"||i instanceof URL?r.url=i.toString():typeof i=="object"&&(r=Qi(i,r)),r=await this.emit("beforeInit",r,{shouldAdjustRequestParams:!0,shouldHandleShortCircuitResponse:!0}),r[he.FINAL_SYMBOL])return r;if(he.METHODS_WITHOUT_BODY.includes(r.method?.toLocaleLowerCase())&&r.body)throw new Ke(Ze.BODY_NOT_ALLOWED,`Request method "${r.method}" does not allow body`);if(r=await this.emit("beforeRequest",r,{shouldAdjustRequestParams:!0,shouldHandleShortCircuitResponse:!0,preAdjust:!0,requestOptionsOverridesURLSearchParams:!0,preRequestOptionsOverridesURLSearchParams:!0,postRequestOptionsOverridesURLSearchParams:!0}),r[he.FINAL_SYMBOL])return r;let s;const o={};if(typeof r.body<"u"&&r.body!==null&&(r.body instanceof Blob||r.body instanceof FormData||r.body instanceof URLSearchParams?s=r.body:typeof r.body=="object"&&r.body!==null?(s=JSON.stringify(r.body),r.headers=this.mergeHeaders(r.headers,{"Content-Type":"application/json"})):s=r.body),!Ji.makeHeaders(n.headers||{}).get("content-type")&&s&&(s instanceof FormData||s instanceof URLSearchParams?o["content-type"]=null:typeof s=="string"&&typeof r.body=="object"?o["content-type"]="application/json":s instanceof Blob&&(o["content-type"]=s.type||"application/octet-stream")),r.body=s,r=await this.emit("afterBodyTransformed",r,{shouldAdjustRequestParams:!0,shouldHandleShortCircuitResponse:!0,preAdjust:!0,postRequestOptionsOverridesURLSearchParams:!0}),r[he.FINAL_SYMBOL])return r;const a=r.abortController||globalThis.AbortController?new AbortController:void 0,l=r.baseURL||this.baseConfigs.baseURL||globalThis.location?.href||"http://localhost",c=new URL(r.url.toString(),l),u=Wn.makeURL(c,r.query,c.hash).toString(),f=new Request(u,{method:r.method||"GET",credentials:r.credentials,cache:r.cache,mode:r.mode,headers:Ji.mergeHeaders(this.baseConfigs.headers,r.headers||{},o),body:r.body,signal:a?.signal});if(r.rawRequest=f,r=await this.emit("beforeActualFetch",r,{shouldHandleShortCircuitResponse:!0}),r[he.FINAL_SYMBOL])return r;const h=r.timeout||this.baseConfigs.timeout||60*1e3;if(r.url.startsWith("ws"))try{const d=new WebSocket(r.url);return await new Promise((w,S)=>{const E=setTimeout(()=>{S(new Ke(Ze.TIMEOUT,`WebSocket connection timed out after ${h}ms`,r))},h);d.onopen=()=>{clearTimeout(E),w()},d.onerror=M=>{clearTimeout(E),S(new Ke(Ze.NETWORK_ERROR,"WebSocket connection failed",r))},d.onclose=M=>{M.code!==1e3&&(clearTimeout(E),S(new Ke(Ze.NETWORK_ERROR,`WebSocket closed with code ${M.code}`,r)))}}),r.rawResponse=new Response,r.response=new Xi(r.rawResponse,d,{ok:!0,status:101,statusText:"Switching Protocols"}),r.data=d,r.headers=new Headers,this.emit("afterResponse",r)}catch(d){throw d instanceof Ke?d:new Ke(Ze.NETWORK_ERROR,`WebSocket creation failed: ${d}`,r)}let p;try{a&&(p=setTimeout(()=>{a.abort()},h));const d=await(n.fetch||this.baseConfigs.fetch||globalThis.fetch)(r.rawRequest).catch(w=>{throw p&&clearTimeout(p),a?.signal.aborted?new Ke(Ze.TIMEOUT,`Request timed out after ${h}ms`,r):new Ke(Ze.NETWORK_ERROR,w.message,r)});return p&&clearTimeout(p),r.rawResponse=d,r.response=await Oa(d,r.responseType,(w,S)=>{n?.onProgress?.(w,S)}),r.data=r.response.data,r.headers=r.response.headers,this.emit("afterResponse",r)}catch(d){throw p&&clearTimeout(p),d}}normalizeContext(i,n={}){const r=i,s=r.baseURL||this.baseConfigs.baseURL||globalThis.location?.href||"http://localhost",o=new URL(s,globalThis.location?.href||"http://localhost"),a=new URL(r.url.toString(),o),l=!!r[he.NORMALIZED_SYMBOL];r.baseURL=o?o.origin:a.origin;let c;l?c=n.requestOptionsOverridesURLSearchParams?this.mergeQueries({},a.search,r.query):this.mergeQueries({},r.query,a.search):(c=n.requestOptionsOverridesURLSearchParams?this.mergeQueries(o?.search||"",this.baseConfigs.query,a.search,r.query):this.mergeQueries(o?.search||"",this.baseConfigs.query,r.query,a.search),r[he.NORMALIZED_SYMBOL]=!0),r.query=c;const u=new URL(a);return u.search="",r.url=u.toString(),r}async emit(i,n,r={}){const s=this.hooks.filter(o=>o.event===i);if(r?.shouldAdjustRequestParams&&r?.preAdjust)try{n=this.normalizeContext(n,{requestOptionsOverridesURLSearchParams:r.preRequestOptionsOverridesURLSearchParams})}catch{}try{let o=0;for(const a of s){const l=`${i}#${a.action.name||`anonymous#${o}`}`,c=Symbol("FEXIOS_HOOK_CONTEXT");n[c]=c;const u=n.url;let f="";try{const p=this.mergeQueries({},n.query||{});f=JSON.stringify(p)}catch{}let h=await a.action.call(this,n);if(h===void 0&&(h=n),h===!1)throw new Ke(Ze.ABORTED_BY_HOOK,`Request aborted by hook "${l}"`,n);if(h instanceof Response){const p=h,d={...n,rawResponse:p},w=await Oa(p,n.responseType,(S,E)=>{n.onProgress?.(S,E)});if(d.response=w,d.data=w.data,d.headers=w.headers,i!=="afterResponse"){const S=await this.emit("afterResponse",d);return S[he.FINAL_SYMBOL]=!0,S}else return d[he.FINAL_SYMBOL]=!0,d}else if(typeof h=="object"&&h[c]===c)n=h;else{const p=globalThis["".concat("console")];try{throw new Ke(Ze.HOOK_CONTEXT_CHANGED,`Hook "${l}" should return the original FexiosContext or return false to abort the request, but got "${h}".`)}catch(d){p.warn(d.stack||d)}}if(r?.shouldAdjustRequestParams)try{const p=n.baseURL||this.baseConfigs.baseURL||globalThis.location?.href||"http://localhost",d=new URL(n.url.toString(),p);let w={};if(f)try{w=JSON.parse(f)}catch{}const S=n.query||{},E=this.mergeQueries(w,d.search,S);n.query=E;const M=new URL(d);M.search="",n.url=M.toString()}catch{}delete n[c],o++}}catch(o){return Promise.reject(o)}return n}on(i,n,r=!1){if(typeof n!="function")throw new Ke(Ze.INVALID_HOOK_CALLBACK,`Hook should be a function, but got "${typeof n}"`);return this.hooks[r?"unshift":"push"]({event:i,action:n}),this}off(i,n){return i==="*"||!i?this.hooks=this.hooks.filter(r=>r.action!==n):this.hooks=this.hooks.filter(r=>r.event!==i||r.action!==n),this}createInterceptor(i){return{handlers:()=>this.hooks.filter(n=>n.event===i).map(n=>n.action),use:(n,r=!1)=>this.on(i,n,r),clear:()=>{this.hooks=this.hooks.filter(n=>n.event!==i)}}}createMethodShortcut(i){return Reflect.defineProperty(this,i,{get:()=>(n,r,s)=>(he.METHODS_WITHOUT_BODY.includes(i.toLocaleLowerCase())?s=r:(s=s||{},s.body=r),this.request(n,{...s,method:i}))}),this}extends(i){const n=new he(Qi(this.baseConfigs,i));return n.hooks=[...this.hooks],n._plugins=new Map(this._plugins),n._plugins.forEach(async r=>{await n.plugin(r)}),n}static create(i){return new he(i)}async plugin(i){if(typeof i?.name=="string"&&typeof i?.install=="function"){if(this._plugins.has(i.name))return this;const n=await i.install(this);if(this._plugins.set(i.name,i),n instanceof he)return n}return this}},B(he,"FINAL_SYMBOL",Symbol("FEXIOS_FINAL_CONTEXT")),B(he,"NORMALIZED_SYMBOL",Symbol("FEXIOS_NORMALIZED_QUERY")),B(he,"DEFAULT_CONFIGS",{baseURL:"",timeout:60*1e3,credentials:"same-origin",headers:{},query:{},responseType:void 0,fetch:globalThis.fetch}),B(he,"ALL_METHODS",["get","post","put","patch","delete","head","options","trace"]),B(he,"METHODS_WITHOUT_BODY",["get","head","options","trace"]),he);const Md=bs.create,La=Md();typeof globalThis<"u"?globalThis.fexios=La:typeof window<"u"&&(window.fexios=La);var Gn;(t=>{function e(n){return Array.isArray(n)?n.join("|"):typeof n=="boolean"||n===null?n?"1":void 0:typeof n=="number"?""+n:n}t.normalizeParamValue=e;function i(n){const r=o=>o&&(o instanceof URLSearchParams||o instanceof FormData);if(n==null)return;const s=new FormData;if(r(n))return n.forEach((o,a)=>{const l=e(o);l!=null&&s.append(a,l)}),s;if(ht(n))return Object.entries(n).forEach(([o,a])=>{const l=e(a);l!=null&&s.append(o,l)}),s}t.normalizeBody=i})(Gn||(Gn={}));var Zi=(t=>(t.HTTP_ERROR="HTTP_ERROR",t.LOGIN_FAILED="LOGIN_FAILED",t.LOGIN_RETRY_LIMIT_EXCEEDED="LOGIN_RETRY_LIMIT_EXCEEDED",t.TOKEN_RETRY_LIMIT_EXCEEDED="TOKEN_RETRY_LIMIT_EXCEEDED",t))(Zi||{});let We=class extends Error{constructor(e,i="",n){super(),this.code=e,this.message=i,this.cause=n,this.name="WikiSaikouError"}static is(e,i){return e instanceof this&&(i===void 0||e.code===i)}},wi=class Hf extends Error{constructor(e,i){super(),this.errors=e,this.cause=i,this.name="MediaWikiApiError",this.errors=Hf.normalizeErrors(e),this.message=e.map(n=>n.text).filter(Boolean).join(`
4
+ `),this.code=this.isBadTokenError()?"badtoken":this.errors[0]?.code||"Unknown Error"}get firstError(){return this.errors[0]}isBadTokenError(){return this.errors.some(e=>e.code==="badtoken")||["NeedToken","WrongToken"].includes(this.cause?.data?.login?.result)}toString(){return`[${this.name} ${this.code}]`}static is(e){return e instanceof this}static normalizeErrors(e){return Array.isArray(e)===!1?[]:e.filter(i=>typeof i=="object"&&!!i?.code).map(i=>i.text?i:i.info?{...i,text:i.info}:i["*"]?{...i,text:i["*"]}:{...i,text:""})}};(t=>{function e(s){if(s==null)return;if(s?.response?.data!==void 0)return s.response.data;if(s?.data!==void 0)return s.data;const o=s instanceof Error?s.cause:void 0;return o?.response?.data!==void 0?o.response.data:o?.data!==void 0?o.data:s||void 0}function i(s){return n(s).length>0}t.includesMediaWikiApiError=i,t.normalizeMwApiErrors=wi.normalizeErrors;function n(s){let o=e(s);if(typeof o!="object"||o===null)return[];const a=o?.error,l=o?.errors,c=[];return a&&c.push(a),Array.isArray(l)&&c.push(...l),(0,t.normalizeMwApiErrors)(c)}t.extractMediaWikiApiErrors=n;function r(s){if(wi.is(s))return s.isBadTokenError();{const o=n(s);return new wi(o).isBadTokenError()}}t.isBadTokenError=r})(We||(We={}));const Ma=Symbol.for("__FEXIOS_SAIKOU__");function Na(t){const e=t instanceof bs?t:new bs({baseURL:t instanceof URL?t.toString():String(t),responseType:"json"});return e[Ma]||(Reflect.defineProperty(e,Ma,{get:()=>!0,enumerable:!1,configurable:!1}),e._tokens=new Map,e.on("afterResponse",i=>{const{data:n,rawRequest:r}=i,s=r?.headers.get("x-mw-token-name");s&&We.isBadTokenError(n)&&e._tokens.delete(s);const o=n?.query?.tokens;o&&typeof o=="object"&&Object.entries(o).forEach(([l,c])=>{typeof c=="string"&&e._tokens.set(l.replace(/token$/i,"").toLowerCase(),c)});const a=n?.login?.token;return typeof a=="string"&&e._tokens.set("login",a),i}),e.on("beforeInit",i=>{if(i.method?.toLowerCase()!=="post")return i;if(i.body===void 0||i.body===null)return i.body=void 0,i;const n=i.body=Gn.normalizeBody(i.body),r=new URLSearchParams(i.query);return n.has("format")&&r.delete("format"),n.has("formatversion")&&r.delete("formatversion"),n.has("action")&&r.delete("action"),n.has("origin")&&(r.set("origin",""+n.get("origin")),n.delete("origin")),i.query=Object.fromEntries(r.entries()),i}),e.on("beforeInit",i=>(i.query=Gn.normalizeBody(i.query)||{},i)),e.on("beforeRequest",i=>{const n=new URL(i.url),r=n.searchParams;if(globalThis.location&&(!r.has("origin")&&location.origin!==n.origin?(r.set("origin",location.origin),e.baseConfigs.credentials="include",e.baseConfigs.mode="cors"):location.origin===n.origin&&(r.delete("origin"),e.baseConfigs.credentials=void 0,e.baseConfigs.mode=void 0)),n.searchParams.has("origin")){const s=encodeURIComponent(n.searchParams.get("origin")||"").replace(/\./g,"%2E");i.query={},n.searchParams.delete("origin"),i.url=`${n}${n.search?"&":"?"}origin=${s}`}return i})),e}const ni=(t,...e)=>{const i=s=>Object.prototype.toString.call(s)==="[object Object]",n=s=>{if(Array.isArray(s))return s.slice();if(i(s)){const o={};for(const a of Reflect.ownKeys(s))o[a]=n(s[a]);return o}return s},r=n(t);for(const s of e)if(s!=null)for(const o of Reflect.ownKeys(s)){const a=s[o];if(typeof a>"u")continue;const l=r[o];i(l)&&i(a)?r[o]=ni(l,a):r[o]=n(a)}return r},Nd=(t,e,i)=>{let n={...Da.DEFAULT_CONFIGS};if(typeof t=="string"?n=ni(n,{baseURL:t,fexiosConfigs:e||{},defaultParams:i||{}}):typeof t=="object"&&t!==null&&(n=ni(n,t)),!n.baseURL&&typeof window=="object"&&window.mediaWiki){const{wgServer:r,wgScriptPath:s}=window.mediaWiki?.config?.get(["wgServer","wgScriptPath"])||{};typeof r=="string"&&typeof s=="string"&&(n.baseURL=`${r}${s}/api.php`)}if(typeof n.baseURL!="string")throw new Error("baseURL is required");return n},Dd=()=>{},jd=async(t,e)=>{let i=0;const{retry:n=3,onRetry:r=Dd,shouldRetry:s=()=>!0}=e;let o;do try{return await t()}catch(a){if(o=a,s(a,i))r(a,i),i++;else throw a}while(i<n);throw o||new Error("Retry failed")};const en=class{constructor(e,i,n){this.version="7.1.2",this.token=this.getToken;const r=this.config=Nd(e,i,n);this.request=Na(r.baseURL)}setBaseURL(e){return this.config.baseURL=e,this.request.baseConfigs.baseURL=e,this}async get(e,i){return this.runRequestWithApiErrorMapping(()=>this.request.get("",ni({},this.config.fexiosConfigs,{query:ni(this.config.defaultParams,e)},i)))}async post(e,i){return this.runRequestWithApiErrorMapping(()=>this.request.post("",e,ni({},this.config.fexiosConfigs,{query:this.config.defaultParams},i)))}async runRequestWithApiErrorMapping(e){try{const i=await e();return this.handleApiResponse(i)}catch(i){throw this.config.throwOnApiError&&We.includesMediaWikiApiError(i)?new wi(We.extractMediaWikiApiErrors(i),i):i}}throwIfApiError(e){const i=We.extractMediaWikiApiErrors(e);if(i.length>0)throw new wi(i,e)}handleApiResponse(e){return this.config.throwOnApiError&&this.throwIfApiError(e.data),e}get tokens(){return this.request._tokens}async fetchTokens(e=["csrf"]){return this.config.fexiosConfigs.credentials="include",await this.get({action:"query",meta:"tokens",type:e}),this.tokens}async getToken(e="csrf",i=!1){return(!this.tokens.get(e)||i)&&(this.tokens.delete(e),await this.fetchTokens([e])),this.tokens.get(e)}badToken(e){return this.tokens.delete(e),this.tokens}async postWithToken(e,i,n){const{tokenName:r="token",retry:s=3,noCache:o=!1,fexiosOptions:a}=n||{};if(s<1)throw new We(Zi.TOKEN_RETRY_LIMIT_EXCEEDED,"The limit of the number of times to automatically re-acquire the token has been exceeded");let l=0;return jd(async()=>{const c=await this.getToken(e,o||l>0);try{const u=await this.post({[r]:c,...i},ni(a||{},{headers:{"x-mw-token-name":e}}));if(We.isBadTokenError(u.data))throw u;return u}catch(u){throw We.isBadTokenError(u)||u?.ok===!1||wi.is(u)?u:new We(Zi.HTTP_ERROR,"Network/transport or SDK-internal error (not a MediaWiki API error)",u)}},{retry:s,onRetry:(c,u)=>{l=u+1},shouldRetry:c=>We.isBadTokenError(c)||c?.ok===!1}).catch(c=>{throw We.isBadTokenError(c)||c?.ok===!1?new We(Zi.TOKEN_RETRY_LIMIT_EXCEEDED,"Retry attempts for acquiring/using token exhausted",c):c})}postWithEditToken(e){return this.postWithToken("csrf",e)}get baseURL(){return this.config.baseURL}get defaultParams(){return this.config.defaultParams}get defaultOptions(){return this.config.fexiosConfigs}};en.INIT_DEFAULT_PARAMS={action:"query",errorformat:"plaintext",format:"json",formatversion:2},en.DEFAULT_CONFIGS={baseURL:void 0,fexiosConfigs:{responseType:"json"},defaultParams:en.INIT_DEFAULT_PARAMS,throwOnApiError:!1},en.createRequestHandler=Na;let Da=en;let Ud=class extends Da{async clientLogin(e,i,n){n||(n={}),!n.logincontinue&&!n.loginreturnurl&&(n.loginreturnurl=location?.origin);const r=await this.postWithToken("login",{action:"clientlogin",username:e,password:i,...n},{tokenName:"logintoken"});if(r?.data?.clientlogin?.status==="PASS")return r.data.clientlogin;throw new We(Zi.LOGIN_FAILED,r.data.clientlogin.message,r)}};class Fd{constructor(e,i={}){this.ctx=e,location?.href&&i?.baseURL?.toString()?.startsWith("/")&&(i.baseURL=new URL(i.baseURL,location.origin));const n=new Ud({baseURL:i.baseURL.toString(),fexiosConfigs:{headers:{"x-api-user-agent":`InPageEdit-NEXT ${e.version}`,...i.headers},...i},throwOnApiError:!0});e.set("api",n)}}var Bd=Object.create,vs=Object.defineProperty,qd=Object.getOwnPropertyDescriptor,ja=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Ua=t=>{throw TypeError(t)},Hd=(t,e,i)=>e in t?vs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,zd=(t,e)=>vs(t,"name",{value:e,configurable:!0}),Kd=t=>[,,,Bd(t?.[ja("metadata")]??null)],Wd=["class","method","getter","setter","accessor","field","value","get","set"],Fa=t=>t!==void 0&&typeof t!="function"?Ua("Function expected"):t,Gd=(t,e,i,n,r)=>({kind:Wd[t],name:e,metadata:n,addInitializer:s=>i._?Ua("Already initialized"):r.push(Fa(s||null))}),Vd=(t,e)=>Hd(e,ja("metadata"),t[3]),Yd=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Qd=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&qd(r,i));zd(r,i);for(var d=n.length-1;d>=0;d--)l=Gd(c,i,a={},t[3],h),o=(0,n[d])(r,l),a._=1,Fa(o)&&(r=o);return Vd(t,r),p&&vs(r,i,p),u?c^4?s:p:r},Ba,ws,qa;Ba=[Ee(["wiki","wikiTitle"])];class Vn extends(qa=wt){constructor(i){super(i,"currentPage",!1);Wi(this,Qe);this.ctx=i,this.url=new URL(window.location.href),this.isMainPage=void 0,this.wikiTitle=void 0}get logger(){return this.ctx.logger("CURRENT_PAGE")}async start(){await ot(this,Qe,ha).call(this),ot(this,Qe,zf).call(this),window.addEventListener("popstate",ot(this,Qe,pa).bind(this)),this.logger.info("initialized",this.wikiTitle)}stop(){window.removeEventListener("popstate",ot(this,Qe,pa).bind(this))}get params(){return this.url.searchParams}get canonicalUrl(){const i=document.querySelector('link[rel="canonical"]')?.href;let n=null;return i&&(n=new URL(i,location.origin)),Reflect.defineProperty(this,"canonicalUrl",{get:()=>n}),n}get wikiAction(){return this.params.get("action")||"view"}}Qe=new WeakSet,ha=async function(){await ot(this,Qe,Wf).call(this),await ot(this,Qe,Kf).call(this)},zf=function(){const i=Symbol.for("InPageEdit.CurrentPageService.UrlChangeListenerInstalled");if(window[i])return;const n=history.pushState,r=history.replaceState;history.pushState=function(s,o,a){n.apply(this,[s,o,a]),window.dispatchEvent(new PopStateEvent("popstate",{state:s}))},history.replaceState=function(s,o,a){r.apply(this,[s,o,a]),window.dispatchEvent(new PopStateEvent("popstate",{state:s}))},window[i]=!0},pa=async function(i){const n=this.url,r=new URL(window.location.href);this.url=r,(n.pathname!==r.pathname||n.searchParams.get("title")!==r.searchParams.get("title")||n.searchParams.get("curid")!==r.searchParams.get("curid"))&&(await ot(this,Qe,ha).call(this),this.logger.info("location changed",r,this.wikiTitle))},Kf=async function(){const n=this.wikiTitle?.getMainDBKey()===this.ctx.wiki.mainPageName;return Reflect.defineProperty(this,"isMainPage",{get:()=>n}),n},Wf=async function(){let i=null;return this.canonicalUrl?i=await this.ctx.wikiTitle.newTitleFromUrl(this.canonicalUrl):i=await this.ctx.wikiTitle.newTitleFromUrl(this.url),Object.freeze(i),Reflect.defineProperty(this,"wikiTitle",{get:()=>i}),i},ws=Kd(qa),Vn=Qd(ws,0,"CurrentPageService",Ba,Vn),Yd(ws,1,Vn);class Xd extends wt{constructor(e){super(e,"resourceLoader",!0),this.ctx=e}stop(){this.removeAll()}loadScript(e,i){if(!e)return Promise.resolve(null);const n=`script:${e}`,r=document.querySelector(`[data-ipe="${n}"]`);return r?Promise.resolve(r):new Promise((o,a)=>{const l=document.createElement("script");l.src=e,l.dataset.ipe=n,i&&Object.entries(i).forEach(([c,u])=>{typeof u>"u"||u===!1||u===null?l.removeAttribute(c):l.setAttribute(c,u)}),document.body.appendChild(l),l.onload=()=>o(l),l.onerror=c=>a(c)})}loadStyle(e,i){if(!e)return Promise.resolve(null);const n=`style:${e}`,r=document.querySelector(`[data-ipe="${n}"]`);return r?Promise.resolve(r):new Promise((o,a)=>{const l=document.createElement("link");l.rel="stylesheet",l.href=e,l.dataset.ipe=n,i&&Object.entries(i).forEach(([u,f])=>{typeof f>"u"||f===!1||f===null?l.removeAttribute(u):l.setAttribute(u,f)}),(document.querySelector('meta[name="ipe-styles"]')||(()=>{const u=document.createElement("meta");return u.id="ipe-styles",u.name="ipe-styles",document.head.insertAdjacentElement("afterbegin",u),u})()).before(l),l.onload=()=>o(l),l.onerror=u=>a(u)})}removeStyle(e){const i=`style:${e}`,n=document.querySelector(`[data-ipe="${i}"]`);n&&n.remove()}removeScript(e){const i=`script:${e}`,n=document.querySelector(`[data-ipe="${i}"]`);n&&n.remove()}removeAll(){document.querySelectorAll("[data-ipe]").forEach(e=>{e.remove()})}resolveImportPath(e){if(e.startsWith("http")||e.startsWith("//"))return e;const i=document.currentScript?.src;if(!i)return`https://unpkg.com/mediawiki-inpageedit@latest/dist/${e}`;const n=new URL(i);return n.pathname.endsWith(".js")||(n.pathname=n.pathname+"/"),new URL(e,n.toString()).toString()}}const Yn=Object.keys;function Jd(t){return typeof t=="boolean"}function Zd(t){return t&&typeof t.nodeType=="number"}function Qn(t){return typeof t=="string"}function Ha(t){return typeof t=="number"}function ri(t){return typeof t=="object"?t!==null:tn(t)}function tn(t){return typeof t=="function"}function eh(t){return!!(t&&t.isComponent)}function th(t){return ri(t)&&typeof t.length=="number"&&typeof t.nodeType!="number"}function _s(t,e){if(t)for(const i of Yn(t))e(t[i],i)}function ih(t){return ri(t)&&"current"in t}const xs={animationIterationCount:0,borderImageOutset:0,borderImageSlice:0,borderImageWidth:0,boxFlex:0,boxFlexGroup:0,boxOrdinalGroup:0,columnCount:0,columns:0,flex:0,flexGrow:0,flexPositive:0,flexShrink:0,flexNegative:0,flexOrder:0,gridArea:0,gridRow:0,gridRowEnd:0,gridRowSpan:0,gridRowStart:0,gridColumn:0,gridColumnEnd:0,gridColumnSpan:0,gridColumnStart:0,fontWeight:0,lineClamp:0,lineHeight:0,opacity:0,order:0,orphans:0,tabSize:0,widows:0,zIndex:0,zoom:0,fillOpacity:0,floodOpacity:0,stopOpacity:0,strokeDasharray:0,strokeDashoffset:0,strokeMiterlimit:0,strokeOpacity:0,strokeWidth:0};function nh(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}const rh=["Webkit","ms","Moz","O"];Yn(xs).forEach(t=>{rh.forEach(e=>{xs[nh(e,t)]=0})});const sh=Symbol.for("jsx-dom:type");var za=(function(t){return t.ShadowRoot="ShadowRoot",t})(za||{});function oh(t){return t!=null&&t[sh]===za.ShadowRoot}const ah="http://www.w3.org/2000/svg",lh="http://www.w3.org/1999/xlink",ch="http://www.w3.org/XML/1998/namespace";function Ka(t){return!Jd(t)&&t!=null}function Ss(t){return Array.isArray(t)?t.map(Ss).filter(Boolean).join(" "):ri(t)?Symbol.iterator in t?Ss(Array.from(t)):Yn(t).filter(e=>t[e]).join(" "):Ka(t)?""+t:""}const uh={animate:0,circle:0,clipPath:0,defs:0,desc:0,ellipse:0,feBlend:0,feColorMatrix:0,feComponentTransfer:0,feComposite:0,feConvolveMatrix:0,feDiffuseLighting:0,feDisplacementMap:0,feDistantLight:0,feFlood:0,feFuncA:0,feFuncB:0,feFuncG:0,feFuncR:0,feGaussianBlur:0,feImage:0,feMerge:0,feMergeNode:0,feMorphology:0,feOffset:0,fePointLight:0,feSpecularLighting:0,feSpotLight:0,feTile:0,feTurbulence:0,filter:0,foreignObject:0,g:0,image:0,line:0,linearGradient:0,marker:0,mask:0,metadata:0,path:0,pattern:0,polygon:0,polyline:0,radialGradient:0,rect:0,stop:0,svg:0,switch:0,symbol:0,text:0,textPath:0,tspan:0,use:0,view:0},fh=/^(a(ll|t|u)|base[FP]|c(al|lipPathU|on)|di|ed|ex|filter[RU]|g(lyphR|r)|ke|l(en|im)|ma(rker[HUW]|s)|n|pat|pr|point[^e]|re[^n]|s[puy]|st[^or]|ta|textL|vi|xC|y|z)/;function _i(t){const e=document.createDocumentFragment();return Xn(t.children,e),e}function dh(t,e,i){e={...e,children:i};const n=new t(e),r=n.render();return"ref"in e&&ks(e.ref,n),r}function m(t,e){let{children:i,...n}=e;!n.namespaceURI&&uh[t]===0&&(n={...n,namespaceURI:ah});let r;if(Qn(t)){if(r=n.namespaceURI?document.createElementNS(n.namespaceURI,t):document.createElement(t),gh(n,r),Xn(i,r),r instanceof window.HTMLSelectElement&&n.value!=null)if(n.multiple===!0&&Array.isArray(n.value)){const s=n.value.map(o=>String(o));r.querySelectorAll("option").forEach(o=>o.selected=s.includes(o.value))}else r.value=n.value;ks(n.ref,r)}else if(tn(t))ri(t.defaultProps)&&(n={...t.defaultProps,...n}),r=eh(t)?dh(t,n,i):t({...n,children:i});else throw new TypeError(`Invalid JSX element type: ${t}`);return r}function nn(t,e){for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r<i;r++)n[r-2]=arguments[r];return(Qn(e)||Array.isArray(e))&&(n.unshift(e),e={}),e=e||{},e.children!=null&&!n.length&&({children:n,...e}=e),m(t,{...e,children:n},e.key)}function ks(t,e){ih(t)?t.current=e:tn(t)&&t(e)}function Xn(t,e){if(th(t))hh(t,e);else if(Qn(t)||Ha(t))$s(document.createTextNode(t),e);else if(t===null)$s(document.createComment(""),e);else if(Zd(t))$s(t,e);else if(oh(t)){const i=e.attachShadow(t.attr);Xn(t.children,i),ks(t.ref,i)}}function hh(t,e){for(const i of[...t])Xn(i,e);return e}function $s(t,e){e instanceof window.HTMLTemplateElement?e.content.appendChild(t):e.appendChild(t)}function Jn(t,e){return t.replace(/[A-Z]/g,i=>e+i.toLowerCase())}function Wa(t,e){e==null||e===!1||(Array.isArray(e)?e.forEach(i=>Wa(t,i)):Qn(e)?t.setAttribute("style",e):ri(e)&&_s(e,(i,n)=>{n.indexOf("-")===0?t.style.setProperty(n,i):Ha(i)&&xs[n]!==0?t.style[n]=i+"px":t.style[n]=i}))}function ph(t,e,i){switch(t){case"xlinkActuate":case"xlinkArcrole":case"xlinkHref":case"xlinkRole":case"xlinkShow":case"xlinkTitle":case"xlinkType":Ga(i,lh,Jn(t,":"),e);return;case"xmlnsXlink":xi(i,Jn(t,":"),e);return;case"xmlBase":case"xmlLang":case"xmlSpace":Ga(i,ch,Jn(t,":"),e);return}switch(t){case"htmlFor":xi(i,"for",e);return;case"dataset":_s(e,(n,r)=>{n!=null&&(i.dataset[r]=n)});return;case"innerHTML":case"innerText":case"textContent":Ka(e)&&(i[t]=e);return;case"dangerouslySetInnerHTML":ri(e)&&(i.innerHTML=e.__html);return;case"value":if(e==null||i instanceof window.HTMLSelectElement)return;if(i instanceof window.HTMLTextAreaElement){i.value=e;return}break;case"spellCheck":i.spellcheck=e;return;case"class":case"className":tn(e)?e(i):xi(i,"class",Ss(e));return;case"ref":case"namespaceURI":return;case"style":Wa(i,e);return;case"on":case"onCapture":_s(e,(n,r)=>{i.addEventListener(r,n,t==="onCapture")});return}if(tn(e)){if(t[0]==="o"&&t[1]==="n"){let n=t.toLowerCase();const r=n.endsWith("capture");if(n==="ondoubleclick"?n="ondblclick":r&&n==="ondoubleclickcapture"&&(n="ondblclickcapture"),!r&&i[n]===null)i[n]=e;else if(r)i.addEventListener(n.substring(2,n.length-7),e,!0);else{let s;n in window?s=n.substring(2):s=n[2]+t.slice(3),i.addEventListener(s,e)}}}else ri(e)?i[t]=e:e===!0?xi(i,t,""):e!==!1&&e!=null&&(i instanceof SVGElement&&!fh.test(t)?xi(i,Jn(t,"-"),e):xi(i,t,e))}function xi(t,e,i){t.setAttribute(e,i)}function Ga(t,e,i,n){t.setAttributeNS(e,i,n)}function gh(t,e){for(const i of Yn(t))ph(i,t[i],e);return e}const Zn=Object.keys;function mh(t){return typeof t=="boolean"}function yh(t){return t&&typeof t.nodeType=="number"}function Es(t){return typeof t=="string"}function Va(t){return typeof t=="number"}function si(t){return typeof t=="object"?t!==null:rn(t)}function rn(t){return typeof t=="function"}function bh(t){return!!(t&&t.isComponent)}function vh(t){return si(t)&&typeof t.length=="number"&&typeof t.nodeType!="number"}function Ps(t,e){if(t)for(const i of Zn(t))e(t[i],i)}function wh(t){return si(t)&&"current"in t}const Cs={animationIterationCount:0,borderImageOutset:0,borderImageSlice:0,borderImageWidth:0,boxFlex:0,boxFlexGroup:0,boxOrdinalGroup:0,columnCount:0,columns:0,flex:0,flexGrow:0,flexPositive:0,flexShrink:0,flexNegative:0,flexOrder:0,gridArea:0,gridRow:0,gridRowEnd:0,gridRowSpan:0,gridRowStart:0,gridColumn:0,gridColumnEnd:0,gridColumnSpan:0,gridColumnStart:0,fontWeight:0,lineClamp:0,lineHeight:0,opacity:0,order:0,orphans:0,tabSize:0,widows:0,zIndex:0,zoom:0,fillOpacity:0,floodOpacity:0,stopOpacity:0,strokeDasharray:0,strokeDashoffset:0,strokeMiterlimit:0,strokeOpacity:0,strokeWidth:0};function _h(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}const xh=["Webkit","ms","Moz","O"];Zn(Cs).forEach(t=>{xh.forEach(e=>{Cs[_h(e,t)]=0})});const Sh=Symbol.for("jsx-dom:type");var Ya=(function(t){return t.ShadowRoot="ShadowRoot",t})(Ya||{});function kh(t){return t!=null&&t[Sh]===Ya.ShadowRoot}const $h="http://www.w3.org/2000/svg",Eh="http://www.w3.org/1999/xlink",Ph="http://www.w3.org/XML/1998/namespace";function Qa(t){return!mh(t)&&t!=null}function Rs(t){return Array.isArray(t)?t.map(Rs).filter(Boolean).join(" "):si(t)?Symbol.iterator in t?Rs(Array.from(t)):Zn(t).filter(e=>t[e]).join(" "):Qa(t)?""+t:""}const Ch={animate:0,circle:0,clipPath:0,defs:0,desc:0,ellipse:0,feBlend:0,feColorMatrix:0,feComponentTransfer:0,feComposite:0,feConvolveMatrix:0,feDiffuseLighting:0,feDisplacementMap:0,feDistantLight:0,feFlood:0,feFuncA:0,feFuncB:0,feFuncG:0,feFuncR:0,feGaussianBlur:0,feImage:0,feMerge:0,feMergeNode:0,feMorphology:0,feOffset:0,fePointLight:0,feSpecularLighting:0,feSpotLight:0,feTile:0,feTurbulence:0,filter:0,foreignObject:0,g:0,image:0,line:0,linearGradient:0,marker:0,mask:0,metadata:0,path:0,pattern:0,polygon:0,polyline:0,radialGradient:0,rect:0,stop:0,svg:0,switch:0,symbol:0,text:0,textPath:0,tspan:0,use:0,view:0},Rh=/^(a(ll|t|u)|base[FP]|c(al|lipPathU|on)|di|ed|ex|filter[RU]|g(lyphR|r)|ke|l(en|im)|ma(rker[HUW]|s)|n|pat|pr|point[^e]|re[^n]|s[puy]|st[^or]|ta|textL|vi|xC|y|z)/;function Ih(t){const e=document.createDocumentFragment();return er(t.children,e),e}function Ah(t,e,i){e={...e,children:i};const n=new t(e),r=n.render();return"ref"in e&&Is(e.ref,n),r}function ve(t,e){let{children:i,...n}=e;!n.namespaceURI&&Ch[t]===0&&(n={...n,namespaceURI:$h});let r;if(Es(t)){if(r=n.namespaceURI?document.createElementNS(n.namespaceURI,t):document.createElement(t),Lh(n,r),er(i,r),r instanceof window.HTMLSelectElement&&n.value!=null)if(n.multiple===!0&&Array.isArray(n.value)){const s=n.value.map(o=>String(o));r.querySelectorAll("option").forEach(o=>o.selected=s.includes(o.value))}else r.value=n.value;Is(n.ref,r)}else if(rn(t))si(t.defaultProps)&&(n={...t.defaultProps,...n}),r=bh(t)?Ah(t,n,i):t({...n,children:i});else throw new TypeError(`Invalid JSX element type: ${t}`);return r}function Is(t,e){wh(t)?t.current=e:rn(t)&&t(e)}function er(t,e){if(vh(t))Oh(t,e);else if(Es(t)||Va(t))As(document.createTextNode(t),e);else if(t===null)As(document.createComment(""),e);else if(yh(t))As(t,e);else if(kh(t)){const i=e.attachShadow(t.attr);er(t.children,i),Is(t.ref,i)}}function Oh(t,e){for(const i of[...t])er(i,e);return e}function As(t,e){e instanceof window.HTMLTemplateElement?e.content.appendChild(t):e.appendChild(t)}function tr(t,e){return t.replace(/[A-Z]/g,i=>e+i.toLowerCase())}function Xa(t,e){e==null||e===!1||(Array.isArray(e)?e.forEach(i=>Xa(t,i)):Es(e)?t.setAttribute("style",e):si(e)&&Ps(e,(i,n)=>{n.indexOf("-")===0?t.style.setProperty(n,i):Va(i)&&Cs[n]!==0?t.style[n]=i+"px":t.style[n]=i}))}function Th(t,e,i){switch(t){case"xlinkActuate":case"xlinkArcrole":case"xlinkHref":case"xlinkRole":case"xlinkShow":case"xlinkTitle":case"xlinkType":Ja(i,Eh,tr(t,":"),e);return;case"xmlnsXlink":Si(i,tr(t,":"),e);return;case"xmlBase":case"xmlLang":case"xmlSpace":Ja(i,Ph,tr(t,":"),e);return}switch(t){case"htmlFor":Si(i,"for",e);return;case"dataset":Ps(e,(n,r)=>{n!=null&&(i.dataset[r]=n)});return;case"innerHTML":case"innerText":case"textContent":Qa(e)&&(i[t]=e);return;case"dangerouslySetInnerHTML":si(e)&&(i.innerHTML=e.__html);return;case"value":if(e==null||i instanceof window.HTMLSelectElement)return;if(i instanceof window.HTMLTextAreaElement){i.value=e;return}break;case"spellCheck":i.spellcheck=e;return;case"class":case"className":rn(e)?e(i):Si(i,"class",Rs(e));return;case"ref":case"namespaceURI":return;case"style":Xa(i,e);return;case"on":case"onCapture":Ps(e,(n,r)=>{i.addEventListener(r,n,t==="onCapture")});return}if(rn(e)){if(t[0]==="o"&&t[1]==="n"){let n=t.toLowerCase();const r=n.endsWith("capture");if(n==="ondoubleclick"?n="ondblclick":r&&n==="ondoubleclickcapture"&&(n="ondblclickcapture"),!r&&i[n]===null)i[n]=e;else if(r)i.addEventListener(n.substring(2,n.length-7),e,!0);else{let s;n in window?s=n.substring(2):s=n[2]+t.slice(3),i.addEventListener(s,e)}}}else si(e)?i[t]=e:e===!0?Si(i,t,""):e!==!1&&e!=null&&(i instanceof SVGElement&&!Rh.test(t)?Si(i,tr(t,"-"),e):Si(i,t,e))}function Si(t,e,i){t.setAttribute(e,i)}function Ja(t,e,i,n){t.setAttributeNS(e,i,n)}function Lh(t,e){for(const i of Zn(t))Th(i,t[i],e);return e}var Os=(t=>(t.Init="modal.init",t.BeforeShow="modal.beforeShow",t.Show="modal.show",t.BeforeClose="modal.beforeClose",t.Close="modal.close",t.Destroy="modal.destroy",t.ToastShow="toast.show",t.ToastClose="toast.close",t))(Os||{});let Mh=0;const Za=t=>`${t}-${++Mh}`;function sn(t){return t instanceof Node?t:document.createTextNode(String(t))}function Nt(t,e){if(!t)throw new Error(`${e??"Element"} not found`);return t}function el(t){const e=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");return Array.from(t.querySelectorAll(e)).filter(i=>!!(i.offsetWidth||i.offsetHeight||i.getClientRects().length))}function je(t,e={}){const i=document.createElement(t);if(e.className&&(i.className=e.className),e.html!=null&&(i.innerHTML=e.html),e.text!=null&&(i.textContent=e.text),e.attrs)for(const[n,r]of Object.entries(e.attrs))i.setAttribute(n,r);return i}const Nh=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/i.test(navigator.platform),tl=["ctrl","alt","shift","meta"];function Dh(t){if(!t)return null;const e=String(t).trim().toLowerCase().split(/[+\-\s]+/g).filter(Boolean),i=[];let n=null;const r=o=>{i.includes(o)||i.push(o)};for(const o of e){let a=o;if(a==="control"||a==="ctrl"){r("ctrl");continue}if(a==="alt"||a==="option"){r("alt");continue}if(a==="shift"){r("shift");continue}if(a==="meta"||a==="cmd"||a==="command"||a==="super"){r("meta");continue}if(a==="mod"){r(Nh?"meta":"ctrl");continue}a==="esc"&&(a="escape"),a==="return"&&(a="enter"),(a==="space"||a==="spacebar")&&(a="space"),n=a}const s=tl.filter(o=>i.includes(o));return!n||n===""?s.length?s.join("+"):null:s.length?`${s.join("+")}+${n}`:n}function jh(t){const e=[];t.ctrlKey&&e.push("ctrl"),t.altKey&&e.push("alt"),t.shiftKey&&e.push("shift"),t.metaKey&&e.push("meta");let i=t.key;i===" "&&(i="space");const n=(i.length,i.toLowerCase()),r=tl.filter(s=>e.includes(s));return r.length?`${r.join("+")}+${n}`:n}class Uh{constructor(){this.zBase=1e3,this.stack=[]}push(e){this.stack.push(e),this.syncZ()}remove(e){this.stack=this.stack.filter(i=>i!==e),this.syncZ()}top(){return this.stack[this.stack.length-1]}closeAll(e,i){const n=new Set((Array.isArray(i)?i:i?[i]:[]).map(String)),r=new Set((Array.isArray(e)?e:e?[e]:[]).map(String));[...this.stack].reverse().forEach(s=>{const o=s.modalId,a=r.size?r.has(s.pluginName):!0,l=n.has(o);a&&!l&&s.close()})}removeAll(){[...this.stack].forEach(e=>e.destroy()),this.stack=[]}syncZ(){this.stack.forEach((e,i)=>e.setZIndex(this.zBase+i*2))}lockBodyScroll(){document.body.classList.add("ipe-modal-no-scroll")}unlockBodyScroll(){document.body.classList.remove("ipe-modal-no-scroll")}}const Ge=new Uh,Tn=class Tn{constructor(e={}){this.backdropId=Za("ipe-modal-backdrop"),this.modalId=Za("ipe-modal"),this.numberId=this.modalId.split("-")[1],this._isDestroyed=!1,this.pluginName="normalModal",this.buttonElsLeft=[],this.buttonElsRight=[],this.keyMap=new Map,this.isOpen=!1,this.isToast=!1,this.isDragging=!1,this.dragStartX=0,this.dragStartY=0,this.modalStartX=0,this.modalStartY=0,this.Event=Os,this._hooks=[],this.startCloseTimer=i=>{this.stopCloseTimer(),this.closeTimer=window.setTimeout(()=>this.close(),i)},this.stopCloseTimer=()=>{this.closeTimer&&window.clearTimeout(this.closeTimer),this.closeTimer=void 0},this.onDragMove=i=>{if(!this.isDragging)return;i.preventDefault();const n=i.clientX-this.dragStartX,r=i.clientY-this.dragStartY,s=this.get$modal(),o=this.modalStartX+n,a=this.modalStartY+r;s.style.left=`${o}px`,s.style.top=`${a}px`},this.onDragEnd=()=>{if(!this.isDragging)return;this.isDragging=!1,document.removeEventListener("pointermove",this.onDragMove),document.removeEventListener("pointerup",this.onDragEnd);const i=this.get$modal(),n=this.get$window();i.classList.remove("is-dragging"),n.style.animation="none",requestAnimationFrame(()=>{this.applyAnimation(!0)})},this.options={...Tn.DEFAULT_OPTIONS,...e},this.options.backdrop===!1&&e.bodyScroll===void 0&&(this.options.bodyScroll=!0)}get isDestroyed(){return this._isDestroyed}static extends(e={}){return class extends this{constructor(i={}){super({...e,...i})}}}init(){if(this.$modal)return this;const e=this.options.backdrop!==!1;let i;e&&(i=je("div",{className:"ipe-modal-backdrop",attrs:{id:this.backdropId,"data-modal-id":this.modalId}}));const n=je("div",{className:"ipe-modal-modal",attrs:{id:this.modalId,role:"dialog","aria-modal":"true",tabindex:"-1"}});if(n.modal=this,!e){n.classList.add("no-backdrop");const p=window.pageYOffset||document.documentElement.scrollTop,d=window.pageXOffset||document.documentElement.scrollLeft,w=window.innerWidth;n.style.top=`${p+60}px`,this.once("modal.show",()=>{n.style.left=`${d+w/2-n.offsetWidth/2}px`})}const r=je("div",{className:`ipe-modal-modal__window size--${this.options.sizeClass||"auto"} plugin--${this.pluginName}`});r.modal=this;const s=je("div",{className:"ipe-modal-modal__header"}),o=`${this.modalId}-title`,a=je("h2",{className:"ipe-modal-modal__title",attrs:{id:o,role:"heading","aria-level":"2"}});n.setAttribute("aria-labelledby",o);const l=je("div",{className:"ipe-modal-modal__icons"});if(this.options.closeIcon){const p=je("button",{className:"ipe-modal-modal__close",attrs:{type:"button","aria-label":"Close"},html:"&times;"});p.addEventListener("click",()=>{let d=!0;typeof this.options.onClickClose=="function"?this.options.onClickClose(this)===!1&&(d=!1):this.options.onClickClose===!1&&(d=!1),d&&this.close()}),l.appendChild(p)}s.append(a,l),this.options.draggable&&e&&(this.options.draggable=!1),this.options.draggable&&(s.style.cursor="move",s.style.userSelect="none",s.addEventListener("pointerdown",this.onDragStart.bind(this)),n.classList.add("is-draggable"));const c=je("div",{className:"ipe-modal-modal__content"}),u=je("div",{className:"ipe-modal-modal__footer"}),f=je("div",{className:"ipe-modal-modal__buttons ipe-modal-modal__buttons--left"}),h=je("div",{className:"ipe-modal-modal__buttons ipe-modal-modal__buttons--right"});return u.append(f,h),r.append(s,c,u),n.appendChild(r),this.$backdrop=i,this.$modal=n,this.$window=r,this.$header=s,this.$title=a,this.$icons=l,this.$content=c,this.$footer=u,this.$buttonsLeft=f,this.$buttonsRight=h,this.options.title&&this.setTitle(this.options.title),this.options.content&&this.setContent(this.options.content),this.options.buttons?.length?this.setButtons(this.options.buttons):u.style.display="none",this.options.center&&this.$modal.classList.add("is-centered"),this.options.fitScreen&&this.$modal.classList.add("is-fullscreen"),this.options.iconButtons&&this.$header.classList.add("has-icon-buttons"),this.options.className&&this.$window.classList.add(...this.options.className.split(/[\s\.#+]+/g).filter(Boolean)),typeof this.options.fixedHeight=="number"?this.$window.style.height=`${Math.max(0,this.options.fixedHeight)}px`:this.options.fixedHeight===!0&&this.$window.classList.add("is-fixed-height"),i&&i.addEventListener("pointerdown",p=>{this.options.outSideClose&&p.target===i&&this.close()}),this.options.draggable&&r.addEventListener("pointerdown",p=>{p.target&&r.contains(p.target)&&this.bringToFront()}),this.onKeyDown=this.onKeyDown.bind(this),this.emit("modal.init"),this}show(){if(this.$modal||this.init(),!this.$modal)throw new Error("Failed to initialize modal");if(this.isOpen)return this;{const n=this.emit("modal.beforeShow",!0),r=this.options.beforeShow?this.options.beforeShow(this)!==!1:!0;if(!n||!r)return this}this.lastFocused=document.activeElement??null,this.$backdrop&&document.body.appendChild(this.$backdrop),document.body.appendChild(this.$modal),this.shouldLockBodyOnOpen()&&Ge.lockBodyScroll(),requestAnimationFrame(()=>{this.$backdrop?.classList.add("is-open"),this.$modal.classList.add("is-open"),this.applyAnimation(!0),this.focusFirst()}),document.addEventListener("keydown",this.onKeyDown),Ge.push(this),this.isOpen=!0,this.options.onShow?.(this),this.emit("modal.show");const e=typeof this.options.closeAfter=="number"?this.options.closeAfter:this.options.closeAfter?.time,i=typeof this.options.closeAfter=="number"?!0:this.options.closeAfter?.resetOnHover;return e&&(this.startCloseTimer(e),i&&(this.$window?.addEventListener("mouseenter",this.stopCloseTimer),this.$window?.addEventListener("mouseleave",()=>this.startCloseTimer(e)))),this}close(){if(!this.isOpen)return this;{const s=this.emit("modal.beforeClose",!0),o=this.options.beforeClose?this.options.beforeClose(this)!==!1:!0;if(!s||!o)return this}if(this.isToast){this.applyAnimation(!1),this.emit("modal.close"),this.emit("toast.close");const s=this.isAnimationDisabled()?0:this.options.animationSpeed??200;let o=!1;const a=()=>{o||(o=!0,this.destroy(),this.options.onClose?.(this))},l=(c,u)=>{const f=()=>{c.removeEventListener(u,f),a()};c.addEventListener(u,f,{once:!0})};return s>0&&this.$window?(l(this.$window,"transitionend"),l(this.$window,"animationend"),window.setTimeout(a,s+20)):window.setTimeout(a,s),this}this.applyAnimation(!1),this.$backdrop?.classList.remove("is-open"),this.$modal?.classList.remove("is-open"),this.emit("modal.close");const e=this.isAnimationDisabled()?0:this.options.animationSpeed??200;let i=!1;const n=()=>{i||(i=!0,this.destroy(),this.options.onClose?.(this))},r=(s,o)=>{const a=()=>{s.removeEventListener(o,a),n()};s.addEventListener(o,a,{once:!0})};return e>0&&this.$window?(r(this.$window,"transitionend"),r(this.$window,"animationend"),window.setTimeout(n,e+20)):window.setTimeout(n,e),this}destroy(){if(this._isDestroyed)return this;if(this.stopCloseTimer(),document.removeEventListener("keydown",this.onKeyDown),this.isDragging&&this.onDragEnd(),this.$window?.removeEventListener("mouseenter",this.stopCloseTimer),this.isToast){this.$window?.parentElement&&this.$window.parentElement.removeChild(this.$window);const e=oi.indexOf(this);e!==-1&&oi.splice(e,1)}else this.$backdrop?.parentElement&&this.$backdrop.parentElement.removeChild(this.$backdrop),this.$modal?.parentElement&&this.$modal.parentElement.removeChild(this.$modal),Ge.remove(this),this.shouldUnlockBodyOnClose()&&Ge.unlockBodyScroll();return this.isOpen=!1,this.lastFocused?.focus?.(),this.emit("modal.destroy"),this._isDestroyed=!0,this}get$backdrop(){return this.$backdrop}get$modal(){return Nt(this.$modal,"modal")}get$window(){return Nt(this.$window,"window")}get$header(){return Nt(this.$header,"header")}get$title(){return Nt(this.$title,"title")}get$content(){return Nt(this.$content,"content")}get$icons(){return Nt(this.$icons,"icons")}get$buttons(e){return e==="leftButtons"?Nt(this.$buttonsLeft,"leftButtons"):e==="rightButtons"?Nt(this.$buttonsRight,"rightButtons"):Nt(this.$footer,"buttons")}setTitle(e){const i=this.get$title();return i.innerHTML="",i.append(sn(e)),this}setContent(e,i="replace"){const n=this.get$content();return i==="replace"?(n.innerHTML="",n.append(sn(e))):i==="append"?n.append(sn(e)):n.prepend(sn(e)),this}setIcons(e){const i=this.get$icons();i.innerHTML="";for(const n of e){const r=je("button",{className:`ipe-modal-modal__icon ${n.className}`,attrs:{type:"button"}});r.addEventListener("click",n.method),i.appendChild(r)}return this}setButtons(e,i){const n=this.$buttonsLeft,r=this.$buttonsRight;[n,r].forEach(o=>o.innerHTML=""),this.buttonElsLeft=[],this.buttonElsRight=[],this.keyMap.clear();const s=i??this.$footer;if(s===this.$footer)e.forEach(o=>this.addButton(o)),e.length===0&&(this.$footer.style.display="none");else{s.innerHTML="";for(const o of e){const a=this.generateButton(o);s.appendChild(a)}}return this}generateButton(e){const i=e.type??"button",n=i==="link"?je("a"):je("button",{attrs:{type:"button"}});e.id&&(n.id=e.id),n.className=`ipe-modal-btn ${e.className??""}`.trim();const r=sn(e.label??"OK");if(n.append(r),i==="link"&&e.href&&(n.href=e.href),e.method&&n.addEventListener("click",s=>{if(n._ipe_tmpDisabled){s.preventDefault(),s.stopPropagation();return}e.method.call(n,s,this)}),typeof e.closeAfter=="number"&&e.closeAfter>=0&&n.addEventListener("click",()=>{window.setTimeout(()=>this.close(),e.closeAfter)}),typeof e.enableAfter=="number"&&e.enableAfter>0){i==="button"&&n.setAttribute("disabled","true"),n._ipe_tmpDisabled=!0,n.setAttribute("aria-disabled","true");const s=()=>{i==="button"&&n.removeAttribute("disabled"),delete n._ipe_tmpDisabled,n.removeAttribute("aria-disabled")};window.setTimeout(s,e.enableAfter)}if(e.keyPress){const s=String(e.keyPress).split(/[\,\|]+/g).map(o=>o.trim()).filter(Boolean);for(const o of s){const a=Dh(o);a&&this.keyMap.set(a,n)}}return n}addButton(e,i){this.$footer&&(this.$footer.style.display="");const n=e.side??"right",r=n==="left"?this.$buttonsLeft:this.$buttonsRight,s=n==="left"?this.buttonElsLeft:this.buttonElsRight,o=this.generateButton(e),a=Math.max(0,Math.min(i??s.length,s.length));return a>=r.children.length?r.appendChild(o):r.insertBefore(o,r.children[a]),s.splice(a,0,o),this}removeButton(e){const i=this.buttonElsLeft,n=this.buttonElsRight,r=[...i,...n];let s=null;if(e==="*")return r.forEach(a=>{this.keyMap.delete(a.id),a.parentElement?.removeChild(a)}),this.$footer&&(this.$footer.style.display="none"),this;if(typeof e=="number"?s=r[e]??null:typeof e=="string"?s=r.find(a=>a.id===e)??null:e instanceof HTMLElement&&(s=r.find(a=>a===e)??null),!s)return this;for(const[a,l]of this.keyMap.entries())l===s&&this.keyMap.delete(a);let o=i.indexOf(s);return o!==-1?(i.splice(o,1),s.parentElement?.removeChild(s)):(o=n.indexOf(s),o!==-1&&(n.splice(o,1),s.parentElement?.removeChild(s))),i.length===0&&n.length===0&&this.$footer&&(this.$footer.style.display="none"),this}changePreviewState(){return this.get$modal().classList.toggle("is-fullscreen"),this}setModalHeight(e,i="height"){const n=this.get$window(),r=Math.max(0,window.innerHeight-e);return n.style[i]=`${r}px`,r}setOptions(e,i){return typeof e=="string"?this.options[e]=i:Object.assign(this.options,e),this}setPluginName(e){return this.$window&&(this.$window.className=this.$window.className.replace(`plugin--${this.pluginName}`,`plugin--${e}`)),this.pluginName=e,this}applyAnimation(e){const i=this.get$modal(),n=this.get$window(),r=this.$backdrop,s=this.options.modalAnimation??this.options.animation,o=typeof s=="string"?s:s&&(e?s.show:s.hide),a=this.options.backdropAnimation??this.options.animation,l=typeof a=="string"?a:a&&(e?a.show:a.hide);!o||o===!1?(i.style.transition="none",n.style.animation="none",n.style.removeProperty("--ipe-modal-anim")):(i.style.removeProperty("transition"),n.style.setProperty("--ipe-modal-anim",o)),r&&(!l||l===!1?r.style.transition="none":r.style.removeProperty("transition"))}on(e,i){return this._hooks.push({type:e,listener:i}),()=>this.off(e,i)}off(e,i){return this._hooks=this._hooks.filter(n=>n.type!==e&&(i?n.listener!==i:!0)),this}once(e,i){const n=this.on(e,r=>(n(),i(r)));return n}emit(e,i){const n=this._hooks.filter(a=>a.type===e);let r=!0;for(const a of n){const l=new CustomEvent(e,{detail:this,cancelable:i}),c=a.listener(l);if(l.defaultPrevented&&(r=!1),c===!1&&(r=!1),!r)break}const s=this.$modal??document.body,o=new CustomEvent(e,{detail:this,cancelable:i});return(!s.dispatchEvent(o)||o.defaultPrevented)&&(r=!1),r}focusFirst(){const e=this.get$modal(),i=el(e);i.length?i[0].focus():e.focus({preventScroll:!0})}onKeyDown(e){if(Ge.top()!==this)return;if(e.key==="Escape"){e.preventDefault(),this.close();return}const i=this.get$modal();if(!i.contains(document.activeElement))return;if(e.key==="Tab"){const a=el(i);if(!a.length)return;const l=a[0],c=a[a.length-1],u=document.activeElement;e.shiftKey&&u===l?(e.preventDefault(),c.focus()):!e.shiftKey&&u===c&&(e.preventDefault(),l.focus())}const n=e.ctrlKey||e.altKey||e.metaKey,r=e.target;if(!n&&(r&&["INPUT","TEXTAREA"].includes(r.tagName)||r.contentEditable==="true"))return;const s=jh(e),o=this.keyMap.get(s);if(o){e.preventDefault(),o.click();return}}setZIndex(e){this.$backdrop&&(this.$backdrop.style.zIndex=String(e)),this.$modal&&(this.$modal.style.zIndex=String(e+1))}bringToFront(){return Ge.remove(this),Ge.push(this),this}isAnimationDisabled(){const e=this.options.modalAnimation??this.options.animation;return e===!1||e==null}shouldLockBodyOnOpen(){return this.options.backdrop===!1||this.options.bodyScroll!==!1?!1:!Ge.stack.some(e=>e!==this&&e.options.backdrop!==!1&&e.options.bodyScroll===!1)}shouldUnlockBodyOnClose(){return this.options.backdrop===!1||this.options.bodyScroll!==!1?!1:!Ge.stack.some(e=>e!==this&&e.options.backdrop!==!1&&e.options.bodyScroll===!1)}onDragStart(e){if(this.options.backdrop!==!1||!this.options.draggable)return;e.preventDefault(),this.isDragging=!0,this.bringToFront(),this.dragStartX=e.clientX,this.dragStartY=e.clientY;const i=this.get$modal(),n=i.getBoundingClientRect();this.modalStartX=n.left+window.pageXOffset,this.modalStartY=n.top+window.pageYOffset,i.style.transform="none",i.style.left=`${this.modalStartX}px`,i.style.top=`${this.modalStartY}px`,document.addEventListener("pointermove",this.onDragMove),document.addEventListener("pointerup",this.onDragEnd),i.classList.add("is-dragging")}showToast(e){this.$window||this.init();const i=Fh(e.position??"top right"),n=this.get$window();this.isToast=!0,n.style.pointerEvents="auto",this.applyAnimation(!0),i.appendChild(n);const r=(typeof this.options.closeAfter=="number"?this.options.closeAfter:this.options.closeAfter?.time)??3e3,s=(typeof this.options.closeAfter=="number"?!0:this.options.closeAfter?.resetOnHover)??!0;return r>0&&(this.startCloseTimer(r),s&&(n.addEventListener("mouseenter",this.stopCloseTimer),n.addEventListener("mouseleave",()=>this.startCloseTimer(r)))),this.isOpen=!0,this.options.onShow?.(this),oi.push(this),this.emit("toast.show"),this.emit("modal.show"),this}static show(e,i){return new this(e).init().show()}static createObject(e,i){return new this(e)}static close(e){if(!e){const s=Ge.top();return s?.close(),s}const i=typeof e=="string"?e:e.id,n=Ge.stack.find(s=>s.modalId===i);if(n)return n.close(),n;const r=oi.find(s=>s.modalId===i);return r?.close(),r}static closeAll(e,i){const n=new Set((Array.isArray(i)?i:i?[i]:[]).map(String)),r=new Set((Array.isArray(e)?e:e?[e]:[]).map(String));return Ge.closeAll(e,i),[...oi].forEach(s=>{const o=s.modalId,a=r.size?r.has(s.pluginName):!0,l=n.has(o);a&&!l&&s.close()}),Ge.top()??new Tn}static removeAll(){Ge.removeAll(),[...oi].forEach(e=>e.destroy())}static dialog(e,i){const n=new this({sizeClass:"dialog",buttons:[{label:"OK",className:"is-primary is-ghost",method:(r,s)=>{i?.(r,s),r.defaultPrevented||n.close()},keyPress:"Enter"}],...e});return n.init().show()}static confirm(e,i){e.title??(e.title="Confirm"),e.content??(e.content="Are you sure you want to perform this action?");const n=e.okBtn??{label:"OK",className:"is-primary is-ghost"},r=e.cancelBtn??{label:"Cancel",className:"is-danger is-ghost"};return new this({sizeClass:"dialog",...e,buttons:[{label:r.label,className:r.className,keyPress:"n",method:(s,o)=>{i?.(!1,o,s),o.close()}},{label:n.label,className:n.className,keyPress:"y",method:(s,o)=>{i?.(!0,o,s),s.defaultPrevented||o.close()}}]}).init().show()}static getDefaultNotifyIcon(e){switch(e){case"success":return ve("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-circle-check",children:[ve("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),ve("path",{d:"M17 3.34a10 10 0 1 1 -14.995 8.984l-.005 -.324l.005 -.324a10 10 0 0 1 14.995 -8.336zm-1.293 5.953a1 1 0 0 0 -1.32 -.083l-.094 .083l-3.293 3.292l-1.293 -1.292l-.094 -.083a1 1 0 0 0 -1.403 1.403l.083 .094l2 2l.094 .083a1 1 0 0 0 1.226 0l.094 -.083l4 -4l.083 -.094a1 1 0 0 0 -.083 -1.32z"})]});case"error":return ve("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-alert-triangle",children:[ve("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),ve("path",{d:"M12 1.67c.955 0 1.845 .467 2.39 1.247l.105 .16l8.114 13.548a2.914 2.914 0 0 1 -2.307 4.363l-.195 .008h-16.225a2.914 2.914 0 0 1 -2.582 -4.2l.099 -.185l8.11 -13.538a2.914 2.914 0 0 1 2.491 -1.403zm.01 13.33l-.127 .007a1 1 0 0 0 0 1.986l.117 .007l.127 -.007a1 1 0 0 0 0 -1.986l-.117 -.007zm-.01 -7a1 1 0 0 0 -.993 .883l-.007 .117v4l.007 .117a1 1 0 0 0 1.986 0l.007 -.117v-4l-.007 -.117a1 1 0 0 0 -.993 -.883z"})]});case"warning":return ve("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-alert-circle",children:[ve("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),ve("path",{d:"M12 2c5.523 0 10 4.477 10 10a10 10 0 0 1 -19.995 .324l-.005 -.324l.004 -.28c.148 -5.393 4.566 -9.72 9.996 -9.72zm.01 13l-.127 .007a1 1 0 0 0 0 1.986l.117 .007l.127 -.007a1 1 0 0 0 0 -1.986l-.117 -.007zm-.01 -8a1 1 0 0 0 -.993 .883l-.007 .117v4l.007 .117a1 1 0 0 0 1.986 0l.007 -.117v-4l-.007 -.117a1 1 0 0 0 -.993 -.883z"})]});case"info":return ve("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-info-circle",children:[ve("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),ve("path",{d:"M12 2c5.523 0 10 4.477 10 10a10 10 0 0 1 -19.995 .324l-.005 -.324l.004 -.28c.148 -5.393 4.566 -9.72 9.996 -9.72zm0 9h-1l-.117 .007a1 1 0 0 0 0 1.986l.117 .007v3l.007 .117a1 1 0 0 0 .876 .876l.117 .007h1l.117 -.007a1 1 0 0 0 .876 -.876l.007 -.117l-.007 -.117a1 1 0 0 0 -.764 -.857l-.112 -.02l-.117 -.006v-3l-.007 -.117a1 1 0 0 0 -.876 -.876l-.117 -.007zm.01 -3l-.127 .007a1 1 0 0 0 0 1.986l.117 .007l.127 -.007a1 1 0 0 0 0 -1.986l-.117 -.007z"})]});case"dialog":return ve("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-message-dots",children:[ve("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),ve("path",{d:"M12 11v.01"}),ve("path",{d:"M8 11v.01"}),ve("path",{d:"M16 11v.01"}),ve("path",{d:"M18 4a3 3 0 0 1 3 3v8a3 3 0 0 1 -3 3h-5l-5 3v-3h-2a3 3 0 0 1 -3 -3v-8a3 3 0 0 1 3 -3z"})]});case"confirm":return ve("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-copy-check",children:[ve("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),ve("path",{d:"M18.333 6a3.667 3.667 0 0 1 3.667 3.667v8.666a3.667 3.667 0 0 1 -3.667 3.667h-8.666a3.667 3.667 0 0 1 -3.667 -3.667v-8.666a3.667 3.667 0 0 1 3.667 -3.667zm-3.333 -4c1.094 0 1.828 .533 2.374 1.514a1 1 0 1 1 -1.748 .972c-.221 -.398 -.342 -.486 -.626 -.486h-10c-.548 0 -1 .452 -1 1v9.998c0 .32 .154 .618 .407 .805l.1 .065a1 1 0 1 1 -.99 1.738a3 3 0 0 1 -1.517 -2.606v-10c0 -1.652 1.348 -3 3 -3zm1.293 9.293l-3.293 3.292l-1.293 -1.292a1 1 0 0 0 -1.414 1.414l2 2a1 1 0 0 0 1.414 0l4 -4a1 1 0 0 0 -1.414 -1.414"})]});default:return null}}static notify(e,i,n){var a,l,c,u;if(i?.overrideOther&&[...oi].forEach(f=>f.close()),typeof i.title>"u"){const f=e||"Notification";i.title=f[0].toUpperCase()+f.slice(1).toLowerCase()}const r=i.icon??this.getDefaultNotifyIcon(e);r&&(r instanceof Element&&r.classList.add("ipe-modal-notify-icon"),i.title=ve(Ih,{children:[r,i.title]})),e==="confirm"&&(typeof i.closeAfter>"u"&&(i.closeAfter=0),i.okBtn||(i.okBtn={label:"OK"})),i.okBtn&&(typeof i.okBtn!="object"&&(i.okBtn={label:"OK"}),(a=i.okBtn).label??(a.label="OK"),(l=i.okBtn).className??(l.className="is-primary is-text ok-btn"),i.okBtn.method=(f,h)=>{n?.(!0,h,f),h.close()}),i.cancelBtn&&(typeof i.cancelBtn!="object"&&(i.cancelBtn={label:"Cancel"}),(c=i.cancelBtn).label??(c.label="Cancel"),(u=i.cancelBtn).className??(u.className="is-danger is-text cancel-btn"),i.cancelBtn.method=(f,h)=>{n?.(!1,h,f),h.close()}),i.buttons=[i.cancelBtn,i.okBtn,...i.buttons??[]].filter(Boolean);const s=`is-notify type-${e||"default"} ${i.className??""}`,o=new this({...i,className:s,sizeClass:"auto",center:!1,fitScreen:!1,closeIcon:!0,outSideClose:!1,bodyScroll:!0,buttons:i.buttons??[]});return o.setPluginName("toast"),o.showToast({position:i.position??"top right"})}};Tn.DEFAULT_OPTIONS={className:"",sizeClass:"auto",center:!0,fitScreen:!1,closeIcon:!0,bodyScroll:!1,outSideClose:!0,backdrop:!0,animation:{show:"ipe-modal-fade-in",hide:"ipe-modal-fade-out"},animationSpeed:200};let Ts=Tn;const oi=[];function Fh(t="top right"){const e="ipe-modal-toast-container",i=`${e}-${t.replace(/[\s-\.|\/]+/g,"-")}`;let n=document.getElementById(i);return n||(n=je("div",{className:`${e} ${t}`,attrs:{id:i,"data-position":t}}),document.body.appendChild(n)),n}const Bh={ipe_progress:"_ipe_progress_so6hn_1"},ai=t=>{const e=t.indeterminate??!0,i=m("div",{class:`${Bh.ipe_progress}`,"data-indeterminate":`${e}`,style:{width:"100%","--progress":t.progress?`${t.progress}%`:"0%"},...t});return i.setProgress=n=>{typeof n=="number"?(i.dataset.indeterminate="false",i.style.setProperty("--progress",`${n}%`)):(i.dataset.indeterminate="true",i.style.setProperty("--progress","0%"))},i};class Re extends Ts{constructor(e={}){e.className||(e.className=""),e.className+=" theme-ipe",e.modalAnimation||(e.modalAnimation={show:"ipe-modal-fade-in",hide:"ipe-modal-fade-out"}),super(e)}setLoadingState(e){if(this.get$window().classList.toggle("loading",e),e){const i=this.get$window().querySelectorAll("input:not([disabled]),button:not([disabled])");this._tmpDisabledActiveInputs=i,i.forEach(n=>{n.disabled=!0}),this.get$content().append(m("div",{id:"ipe-modalLoadingWrapper",style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"rgba(255, 255, 255, 0.5)",zIndex:2e3},children:m(ai,{style:{width:"80%",maxWidth:"800px"}})}))}else{this.get$window().querySelector("#ipe-modalLoadingWrapper")?.remove();const i=this._tmpDisabledActiveInputs;i&&i.forEach(n=>{n.disabled=!1})}}}class qh{constructor(e){this.ctx=e,this.IPEModal=Re,this.IPEModalEvent=Os,this.show=Re.show.bind(Re),this.createObject=Re.createObject.bind(Re),this.close=Re.close.bind(Re),this.closeAll=Re.closeAll.bind(Re),this.removeAll=Re.removeAll.bind(Re),this.dialog=Re.dialog.bind(Re),this.confirm=Re.confirm.bind(Re),this.notify=Re.notify.bind(Re),e.set("modal",this),e.on("dispose",()=>{Re.closeAll()})}}const il=t=>{if(!t)return new URLSearchParams;if(t instanceof URLSearchParams)return t;if(typeof t!="object"||t?.constructor!==Object)throw new TypeError("only plain object is supported");const e=new URLSearchParams;for(const[i,n]of Object.entries(t))if(n!=null){if(Array.isArray(n)){for(const r of n)e.append(i,r?.toString());continue}if(typeof n=="object"&&n!==null&&n.constructor===Object){for(const[r,s]of Object.entries(n))s!=null&&e.set(`${i}[${r}]`,s?.toString());continue}e.set(i,n?.toString())}return e},nl=(t,e,i)=>{const n=typeof t=="string"?new URL(t,window?.location?.origin):new URL(t),r=new URLSearchParams(n.search),s=il(e);for(const[o,a]of s.entries())r.set(o,a);return n.search=r.toString(),n.hash="",n};var Hh=Object.create,Ls=Object.defineProperty,zh=Object.getOwnPropertyDescriptor,rl=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),sl=t=>{throw TypeError(t)},Kh=(t,e,i)=>e in t?Ls(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Wh=(t,e)=>Ls(t,"name",{value:e,configurable:!0}),Gh=t=>[,,,Hh(t?.[rl("metadata")]??null)],Vh=["class","method","getter","setter","accessor","field","value","get","set"],ol=t=>t!==void 0&&typeof t!="function"?sl("Function expected"):t,Yh=(t,e,i,n,r)=>({kind:Vh[t],name:e,metadata:n,addInitializer:s=>i._?sl("Already initialized"):r.push(ol(s||null))}),Qh=(t,e)=>Kh(e,rl("metadata"),t[3]),Xh=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Jh=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&zh(r,i));Wh(r,i);for(var d=n.length-1;d>=0;d--)l=Yh(c,i,a={},t[3],h),o=(0,n[d])(r,l),a._=1,ol(o)&&(r=o);return Qh(t,r),p&&Ls(r,i,p),u?c^4?s:p:r},al,Ms,ll;al=[Ee(["api","storage"])];class ir extends(ll=wt){constructor(e){super(e,"wiki",!1),this.ctx=e,this._data={},this.CACHE_VERSION=3,this.CACHE_TTL={siteinfo:1e3*60*60*24*3,userinfo:1e3*60*30},this.QUERY_DATA={siteinfo:{meta:"siteinfo",siprop:"general|specialpagealiases|namespacealiases|namespaces|magicwords"},userinfo:{meta:"userinfo",uiprop:"groups|rights|blockinfo|options"}},this.CACHE_DB=void 0,this.mwConfig={get:((i,n)=>window?.mw?.config?.get?.(i,n)??n),has:(i=>window?.mw?.config?.exists?.(i)??!1),get values(){return window?.mw?.config?.values||{}}},this.CACHE_DB=e.storage.createDatabase("wiki-metadata",1/0,this.CACHE_VERSION)}get logger(){return this.ctx.logger("WIKI_METADATA")}get api(){return this.ctx.api}async start(){await Promise.all(Object.keys(this.QUERY_DATA).map(e=>this.initData(e))),this.ctx.set("getUrl",this.getUrl.bind(this)),this.ctx.set("getSciprtUrl",this.getSciprtUrl.bind(this)),this.ctx.set("getMainpageUrl",this.getMainpageUrl.bind(this)),this.ctx.inject(["preferences","$"],e=>{const i=e.$;e.preferences.registerCustomConfig("WikiMetadataService",R.object({WikiMetadataService:R.const(m("div",{children:[m("h3",{children:i`Wiki Informations`}),m("ul",{children:[m("li",{children:[m("strong",{children:[i`Site`,":"]})," ",this.general.sitename," (",this.landingPageUrl,")"]}),m("li",{children:[m("strong",{children:i`User`}),": ",this.userInfo.name," (ID: ",this.userInfo.id,")"]}),m("li",{children:[m("strong",{children:i`Groups`}),": ",this.userGroups.join(", ")||"None"]})]}),m("div",{children:[m("p",{style:{fontStyle:"italic"},children:i`If the information shown above is incorrect (for example, the user is not you), click the button below.`}),m("button",{className:"btn danger",onClick:n=>{n.preventDefault(),Promise.all(Object.keys(this.QUERY_DATA).map(r=>this.invalidateCache(r))).then(()=>{window.location.reload()})},children:["🧹 ",i`Clear caches & Reload`]})]})]})).role("raw-html")}).description("WikiMetadataService"),"about")}),this.logger.info("All initialized",this._data)}async initData(e,i=!1){const n=i?null:await this.fetchFromCache(e);if(n)return this._data[e]=n,this.logger.debug("Using cached",e,n),n;{const r=await this.fetchFromApi(e);return this.saveToCache(e,r),this._data[e]=r,this.logger.debug("Fetched from API",e,r),r}}getCacheKey(e){return`${e}:${new URL(this.ctx.api.config.baseURL).pathname.replace(/^\//,"")}`}async fetchFromApi(e){return this.api.get({action:"query",...this.QUERY_DATA[e]}).then(({data:i})=>{if(typeof i?.query!="object"||i.query===null)throw new Error("Invalid query data",{cause:i});return e==="siteinfo"?i.query:i.query?.[e]||i.query}).catch(i=>(this.logger.error("Failed to fetch",i),Promise.reject(i)))}async fetchFromCache(e){const i=this.getCacheKey(e);return await this.CACHE_DB.get(i,this.CACHE_TTL[e])}async saveToCache(e,i){const n=this.getCacheKey(e);return this.CACHE_DB.set(n,i)}async invalidateCache(e){const i=this.getCacheKey(e);return this.CACHE_DB.delete(i)}get _raw(){return this._data}get siteInfo(){return this._data.siteinfo}get general(){return this.siteInfo.general}get specialPageAliases(){return this.siteInfo.specialpagealiases}get namespaceAliases(){return this.siteInfo.namespacealiases}get namespaces(){return this.siteInfo.namespaces}get namespaceMap(){const e=Object.values(this.namespaces).map(i=>({id:i.id,canonical:i.canonical,aliases:this.namespaceAliases.filter(n=>n.id===i.id).map(n=>n.alias)})).sort((i,n)=>i.id-n.id);return Reflect.defineProperty(this,"namespaceMap",{get:()=>e}),e}get magicWords(){return this.siteInfo.magicwords}get userInfo(){return this._data.userinfo}get userOptions(){return this.userInfo.options}get isUserBlocked(){return this.userInfo.blockedbyid&&this.userInfo.blockexpiry&&new Date(this.userInfo.blockexpiry).getTime()>Date.now()}get userGroups(){return this.userInfo.groups}get userRights(){return this.userInfo.rights}get baseUrl(){const e=this.general.server;return e.startsWith("//")?`${window?.location?.protocol||"https:"}//${e.slice(2)}`:e}get landingPageUrl(){return this.general.base}get mainPageName(){return this.general.mainpage}get mainPageUrl(){return this.getUrl(this.mainPageName)}get articlePath(){return this.general.articlepath}get scriptPath(){return this.general.scriptpath}get articleBaseUrl(){return`${this.baseUrl}${this.articlePath}`}get scriptBaseUrl(){return`${this.baseUrl}${this.scriptPath}`}getSciprtUrl(e="index"){return`${this.scriptBaseUrl}/${e.replace(/\.php$/,"")}.php`}getMainpageUrl(e){return nl(this.siteInfo.general.base,e).toString()}getUrl(e,i){const n=il(i);let r;return typeof e=="string"&&e!==""?r=new URL(`${this.articleBaseUrl.replace("$1",e)}`):typeof e=="number"?(n.set("curid",e.toString()),r=new URL(this.getSciprtUrl("index"))):r=new URL(this.getSciprtUrl("index")),r.search=n.toString(),r.toString()}hasRight(e){return this.userRights.includes(e)}hasAnyRight(...e){return e.some(i=>this.hasRight(i))}hasEveryRights(...e){return e.every(i=>this.hasRight(i))}inGroup(e){return this.userGroups.includes(e)}inAnyGroup(...e){return this.userGroups.some(i=>e.includes(i))}getBlockInfo(){return this.isUserBlocked?{blockid:this.userInfo.blockid,blockedby:this.userInfo.blockedbyid,blockedbyid:this.userInfo.blockedbyid,blockreason:this.userInfo.blockreason,blockedtimestamp:this.userInfo.blockedtimestamp,blockexpiry:this.userInfo.blockexpiry}:null}}Ms=Gh(ll),ir=Jh(Ms,0,"WikiMetadataService",al,ir),Xh(Ms,1,ir);class Zh{constructor(){this.values={}}get length(){return Object.keys(this.values).length}clear(){this.values={}}getItem(e){return this.values[e]??null}setItem(e,i){this.values[e]=typeof i=="string"?i:String(i)}removeItem(e){delete this.values[e]}key(e){return Object.keys(this.values)[e]??null}}const ep=()=>new Proxy(new Zh,{set(t,e,i){return typeof e=="string"&&t.setItem(e,i),!0},get(t,e){return typeof e=="string"&&!(e in t)?t.getItem(e):Reflect.get(t,e)}}),tp=(()=>{const t=Symbol.for("IPE.GlobalMemoryStorage");return t in globalThis||(globalThis[t]=ep()),globalThis[t]})();class ip{constructor(e,i,n=1/0,r,s="localStorage"){this.dbName=e,this.storeName=i,this.ttl=n,this.version=r,this.engine=s,typeof n!="number"&&(this.ttl=Number(n)),(isNaN(this.ttl)||this.ttl<=0)&&(this.ttl=1/0),this.engine==="localStorage"&&"localStorage"in window?this.db=window.localStorage:this.engine==="sessionStorage"&&"sessionStorage"in window?this.db=window.sessionStorage:this.db=tp}makeKey(e){return`${this.dbName?this.dbName+":":""}${this.storeName?this.storeName+"/":""}${e}`}load(e){const i=this.getRaw(e);if(i===null)return null;let n;try{n=JSON.parse(i)}catch{return this.deleteSync(e),null}const r=n;return typeof r.time!="number"||!("value"in r)?(this.deleteSync(e),null):typeof this.version<"u"&&typeof this.version<"u"&&r.version!==this.version?(this.deleteSync(e),null):r}getRaw(e){const i=this.makeKey(e);return this.db.getItem(i)}setRaw(e,i){const n=this.makeKey(e);try{this.db.setItem(n,i)}catch{}}deleteSync(e){const i=this.makeKey(e);this.db.removeItem(i)}isExpired(e,i=this.ttl){return e?Date.now()-e.time>i:!1}async get(e,i=this.ttl,n){const r=this.load(e),s=this.isExpired(r,i);if(!r||s){if(typeof n=="function"){const o=await n();return await this.set(e,o),o}return null}return r.value}async set(e,i){const n=Date.now();if(typeof e=="string"){const o=e,a=i;if(a===null||typeof a>"u"){await this.delete(o);return}const l={time:n,value:a,version:this.version};return this.setRaw(o,JSON.stringify(l)),l}const r=e,s={};for(const[o,a]of Object.entries(r)){if(a===null||typeof a>"u"){this.deleteSync(o);continue}const l={time:n,value:a,version:this.version};this.setRaw(o,JSON.stringify(l)),s[o]=l}return s}async has(e,i=this.ttl){const n=this.load(e);return n!==null&&!this.isExpired(n,i)}async delete(e){this.deleteSync(e)}async updatedAt(e){const i=this.load(e);return i?i.time:0}async clear(){const e=this.makeKey(""),i=[];for(let n=0;n<this.db.length;n++){const r=this.db.key(n);r&&r.startsWith(e)&&i.push(r)}for(const n of i)this.db.removeItem(n);return this}async*keys(){const e=this.makeKey("");for(let i=0;i<this.db.length;i++){const n=this.db.key(i);n&&n.startsWith(e)&&(yield n.slice(e.length))}}async*values(){for await(const e of this.keys()){const i=this.load(e);if(i){if(this.isExpired(i)){this.deleteSync(e);continue}yield i}}}async*entries(){for await(const e of this.keys()){const i=this.load(e);if(i){if(this.isExpired(i)){this.deleteSync(e);continue}yield[e,i]}}}}var xe;(t=>{t.cache=new Map,t.defaults=Object.freeze({iterBatch:100,retry:{attempts:3,baseDelayMs:16}}),t.sleep=c=>new Promise(u=>setTimeout(u,c));function e(c){const u=c?.name??"";return u==="AbortError"||u==="InvalidStateError"||u==="TransactionInactiveError"||u==="UnknownError"}t.shouldReconnect=e;async function i(c,u,f){const h=Math.max(1,c.attempts);for(let p=0;p<h;p++)try{return await u(p)}catch(d){if(p===h-1)throw d;await f?.(d,p);const w=c.baseDelayMs*Math.pow(2,p)+Math.floor(Math.random()*10);await(0,t.sleep)(w)}throw new Error("withRetry exhausted unexpectedly")}t.withRetry=i;function n(c,u,f){return new Promise((h,p)=>{const d=indexedDB.open(c,u);d.onupgradeneeded=()=>{try{const w=d.result,S=d.transaction;f?.(w,S)}catch(w){p(w)}},d.onerror=()=>p(d.error),d.onblocked=()=>{},d.onsuccess=()=>{const w=d.result;w.onversionchange=()=>{try{w.close()}finally{t.cache.delete(c)}},h(w)}})}async function r(c,u,f){let h=!c.objectStoreNames.contains(u),p=[];if(!h&&f?.indexes?.length){const S=c.transaction(u,"readonly"),E=S.objectStore(u),M=new Set(Array.from(E.indexNames));p=(f.indexes||[]).filter(g=>!M.has(g.name)),await new Promise((g,y)=>{S.oncomplete=()=>g(),S.onabort=()=>y(S.error),S.onerror=()=>y(S.error)})}if(!h&&p.length===0)return c;const d=c.version+1;c.close();const w=await n(c.name,d,(S,E)=>{let M;S.objectStoreNames.contains(u)?M=E.objectStore(u):M=S.createObjectStore(u,{keyPath:f?.keyPath??void 0,autoIncrement:!!f?.autoIncrement});for(const g of p)M.indexNames.contains(g.name)||M.createIndex(g.name,g.keyPath,g.options)});return w.onversionchange=()=>{try{w.close()}finally{t.cache.delete(w.name)}},w}async function s(c,u,f){let h=t.cache.get(c);return h?(h=h.then(p=>r(p,u,f)),t.cache.set(c,h)):(h=(async()=>{const p=await n(c);return r(p,u,f)})(),t.cache.set(c,h)),h}t.getDB=s;async function o(c){const u=t.cache.get(c);if(t.cache.delete(c),u)try{(await u).close()}catch{}}t.closeConnection=o;function a(c){return new Promise((u,f)=>{c.onsuccess=()=>u(c.result),c.onerror=()=>f(c.error)})}t.asyncRequest=a;function l(c){return new Promise((u,f)=>{c.oncomplete=()=>u(),c.onabort=()=>f(c.error??new DOMException("Aborted","AbortError")),c.onerror=()=>f(c.error??new DOMException("TransactionError","UnknownError"))})}t.waitTx=l})(xe||(xe={}));let np=class{constructor(e,i,n={}){this.dbName=e,this.storeName=i,this.options=n}get _iterBatch(){return this.options.iterBatch??xe.defaults.iterBatch}get _retryCfg(){const e=this.options.retry??xe.defaults.retry;return{attempts:e.attempts??3,baseDelayMs:e.baseDelayMs??16}}async _withStore(e,i){const n=this._retryCfg;return xe.withRetry(n,async()=>{const r=await xe.getDB(this.dbName,this.storeName,this.options.ensure);try{const s=r.transaction(this.storeName,e),o=s.objectStore(this.storeName),a=await i(o);return await xe.waitTx(s),a}catch(s){throw s}},async r=>{xe.shouldReconnect(r)&&await xe.closeConnection(this.dbName)})}async get(e){return this._withStore("readonly",async i=>{const n=await xe.asyncRequest(i.get(e));return n===void 0?void 0:n})}async set(e,i){return await this._withStore("readwrite",async n=>{const r=this.options.ensure?.keyPath!=null?n.put(i):n.put(i,e);await xe.asyncRequest(r)}),this}async delete(e){return this._withStore("readwrite",async i=>{const n=await xe.asyncRequest(i.get(e))!==void 0;return await xe.asyncRequest(i.delete(e)),n})}async clear(){await this._withStore("readwrite",async e=>{await xe.asyncRequest(e.clear())})}async has(e){return await this.get(e)!==void 0}async count(){return this._withStore("readonly",async e=>await xe.asyncRequest(e.count())??0)}async*_iterateEntries(){let e=null,i=!1;const n=Math.max(1,this._iterBatch);for(;!i;){const r=await this._withStore("readonly",async s=>{const o=[],a=e===null?void 0:IDBKeyRange.lowerBound(e,!0);return await new Promise((l,c)=>{const u=s.openCursor(a);u.onerror=()=>c(u.error),u.onsuccess=()=>{const f=u.result;if(!f){i=!0,l();return}o.push([f.key,f.value]),e=f.key,o.length>=n?l():f.continue()}}),o});for(const s of r)yield s;if(r.length===0)break}}entries(){return this._iterateEntries()}async*keys(){for await(const[e]of this.entries())yield e}async*values(){for await(const[,e]of this.entries())yield e}[Symbol.asyncIterator](){return this.entries()[Symbol.asyncIterator]()}async forEach(e){for await(const[i,n]of this.entries())await e(n,i,this)}async getMany(e){const i=new Map;for await(const n of e)i.set(n,void 0);return await this._withStore("readonly",async n=>{await Promise.all(i.keys().map(async r=>{const s=await xe.asyncRequest(n.get(r));i.set(r,s===void 0?void 0:s)}))}),i}async setMany(e){const i=this.options.ensure?.keyPath!=null;return await this._withStore("readwrite",async n=>{for await(const[r,s]of e){const o=i?n.put(s):n.put(s,r);await xe.asyncRequest(o)}}),this}async deleteMany(e){let i=0;return await this._withStore("readwrite",async n=>{for await(const r of e)await xe.asyncRequest(n.get(r))!==void 0&&i++,await xe.asyncRequest(n.delete(r))}),i}async disconnect(){await xe.closeConnection(this.dbName)}};class rp{constructor(e,i,n=1/0,r){this.dbName=e,this.storeName=i,this.ttl=n,this.version=r,this.db=new np(e,i),this.keys=this.db.keys.bind(this.db),this.values=this.db.values.bind(this.db),this.entries=this.db.entries.bind(this.db),typeof this.ttl!="number"&&(this.ttl=Number(this.ttl)),(isNaN(this.ttl)||this.ttl<=0)&&(this.ttl=1/0),this._clearExpiredEntries().catch(()=>{})}async _clearExpiredEntries(){if(this.ttl===1/0)return;const e=Date.now(),i=[];for await(const[n,r]of this.db.entries())typeof r.time=="number"&&e-r.time>this.ttl&&i.push(n);i.length>0&&await this.db.deleteMany(i)}async get(e,i=this.ttl,n){const r=await this.loadFromDB(e),s=this.checkIfExpired(r,i);if(!r||s){if(typeof n=="function"){const o=await n();return await this.set(e,o),o}return null}return r.value}async set(e,i){const n=Date.now();if(typeof e=="string"){const l=e,c=i;if(c===null||typeof c>"u")return this.delete(l);const u={time:n,value:c,version:this.version};return await this.db.set(l,u),u}const r=e,s=[],o=[],a={};for(const[l,c]of Object.entries(r))if(c===null||typeof c>"u")o.push(l);else{const u={time:n,value:c,version:this.version};s.push([l,u]),a[l]=u}return s.length>0&&await this.db.setMany(s),o.length>0&&await this.db.deleteMany(o),a}async has(e,i=this.ttl){const n=await this.loadFromDB(e),r=this.checkIfExpired(n,i);return n!==null&&!r}async delete(e){await this.db.delete(e)}async updatedAt(e){const i=await this.loadFromDB(e);return i?i.time:0}async loadFromDB(e){const i=await this.db.get(e);if(i===void 0)return null;if(typeof i.time!="number"||typeof i.value>"u"){try{await this.delete(e)}catch{}return null}if(typeof this.version<"u"&&typeof this.version<"u"&&i.version!==this.version){try{await this.delete(e)}catch{}return null}return i}checkIfExpired(e,i=this.ttl){return e?Date.now()-e.time>i:!1}async clear(){return await this.db.clear(),this}}class sp extends wt{constructor(e,i){super(e,"storage",!1),this.config=i,this.kv=this.createDatabase("key-val",0,1,"indexedDB"),this.simpleKV=this.createDatabase("~",0,1,"localStorage"),this.memoryKV=this.createDatabase("~",0,1,"memory")}createDatabase(e,i,n,r="indexedDB"){const s="indexedDB"in window&&window.indexedDB!==null;switch(r==="indexedDB"&&!s&&(r="localStorage"),r){case"indexedDB":return new rp(this.config.dbName,e,i,n);case"localStorage":case"sessionStorage":case"memory":return new ip(this.config.dbName,e,i,n,r);default:throw new Error(`Unsupported storage engine: ${r}`)}}}var at=(t=>(t.preferences="preferences",t.watch="watch",t.unwatch="unwatch",t.nochange="nochange",t))(at||{});function op(t){const i=class i{constructor(r,s=!0){this._loaded=s,this.api=t,r.revisions?.forEach(o=>{typeof o?.slots?.main=="object"&&Object.assign(o,o.slots.main)}),this.pageInfo={...i.DEFAULT_PAGE_INFO,...r}}static async newFromApi(r){const{data:s}=await this.api.get({...i.DEFAULT_QUERY_PARAMS,...r}),o=s?.query?.pages?.[0];if(!o||!o.title)throw new Error("Invalid page info",{cause:s});return new i(o,!0)}static newBlankPage(r={}){return new i(r,!1)}static async newFromAnyKind(r){const{title:s,pageId:o,revisionId:a}=r||{};return a?this.newFromApi({revids:parseInt(a.toString(),10)}):o?this.newFromApi({pageids:parseInt(o.toString(),10)}):s?this.newFromApi({titles:s.toString()}):null}static async newBatchFromApi(r){const{titles:s,pageids:o,revids:a,...l}=r||{},{data:c}=await this.api.post({...i.DEFAULT_QUERY_PARAMS,titles:s?.join("|")??void 0,pageids:o?.join("|")??void 0,revids:a?.join("|")??void 0,...l});return c?.query?.pages?.map(u=>new i(u,!0))||[]}async parse(r){return this.api.post({action:"parse",page:this.pageInfo.title,prop:"text|langlinks|categories|links|templates|images|externallinks|sections|revid|displaytitle|iwlinks|properties|parsewarnings",...r})}async preview(r,s){return this.parse({action:"parse",page:void 0,title:this.title,text:r,pst:1,preview:1,disableeditsection:1,disablelimitreport:1,...s})}async edit(r,s){const{text:o,prependtext:a,appendtext:l,summary:c="",watchlist:u=at.preferences,section:f}=r;return this.api.postWithEditToken({action:"edit",title:this.title,starttimestamp:this.pageInfo.touched,basetimestamp:this.revisions[0]?.timestamp,text:o,prependtext:a,appendtext:l,summary:c,watchlist:u,section:f,...s})}async createOnly(r,s){return this.edit(r,{createonly:1,...s})}async delete(r,s){return this.api.postWithEditToken({action:"delete",title:this.pageInfo.title||void 0,pageid:this.pageInfo.pageid||void 0,reason:r,deletetalk:s?.deletetalk,...s})}async moveTo(r,s,o){return this.api.postWithEditToken({action:"move",from:this.pageInfo.title,to:r,reason:s,movetalk:1,movesubpages:1,...o})}userCan(r){return!!this.pageInfo?.actions?.[r]}userCanEdit(){return this.userCan("edit")}async reloadSelfInfo(){const r=await i.newFromApi({pageids:this.pageInfo.pageid,titles:this.pageInfo.title}),s=(this.pageInfo.revisions||[]).concat(r.revisions||[]).sort((o,a)=>o.revid-a.revid).reduce((o,a)=>(o.find(l=>l.revid===a.revid)||o.push(a),o),[]);return this.pageInfo=r.pageInfo,this.pageInfo.revisions=s,this._loaded=!0,this}get pageid(){return this.pageInfo.pageid}get title(){return this.pageInfo.title}get ns(){return this.pageInfo.ns}get contentmodel(){return this.pageInfo.contentmodel}get fullurl(){return this.pageInfo.fullurl}get canonicalurl(){return this.pageInfo.canonicalurl}get editurl(){return this.pageInfo.editurl}get revisions(){return this.pageInfo.revisions||[]}get lastrevid(){return this.pageInfo.lastrevid}get templates(){return this.pageInfo.templates||[]}get images(){return this.pageInfo.images||[]}};i.api=t,i.DEFAULT_QUERY_PARAMS={action:"query",prop:"info|templates|transcludedin|images|pageimages|revisions",inprop:"protection|url|varianttitles",intestactions:"edit|move|delete",tllimit:"max",tilimit:"max",imlimit:"max",piprop:"thumbnail|name|original",pithumbsize:"200",pilimit:"max",rvprop:"ids|timestamp|flags|comment|user|content",rvslots:"main"},i.DEFAULT_PAGE_INFO={pageid:0,ns:0,title:"",contentmodel:"wikitext",pagelanguage:"",pagelanguagehtmlcode:"",pagelanguagedir:"ltr",touched:new Date().toISOString(),lastrevid:0,length:0,protection:[],restrictiontypes:[],fullurl:"",canonicalurl:"",editurl:"",varianttitles:{},actions:{edit:!0,move:!1,delete:!1},revisions:[],templates:[],images:[]};let e=i;return e}const ua=class ua extends wt{constructor(e){super(e,"wikiPage",!0),this.ctx=e,this.WikiPage=op(this.ctx.api)}async createInstance(e,i=!1){return await this.WikiPage.newFromApi(e)}async newFromTitle(e,i=!1,n,r=!1){return this.createInstance({titles:e.toString(),converttitles:i,rvsection:n},r)}async newFromPageId(e,i,n=!1){return this.createInstance({pageids:e,rvsection:i},n)}async newFromRevision(e,i,n=!1){return await this.createInstance({revids:e,rvsection:i},n)}newBlankPage(e={}){return this.WikiPage.newBlankPage(e)}};ua.inject=["api"];let Ns=ua;const cl=new WeakMap,on={toDBKey:t=>t.replace(/ /g,"_"),toNormalText:t=>t.replace(/_/g," "),ensureCase:(t,e)=>e==="first-letter"?t.charAt(0).toUpperCase()+t.slice(1):t},an={normalizeSpecialPageName:t=>t.toLowerCase(),buildSpecialPageIndex:t=>{const e=new Map,i=new Map,n=new Map;for(const r of t.specialpagealiases){const s=r.realname;e.set(s,s);const o=an.normalizeSpecialPageName(s);n.set(o,s);for(const a of r.aliases){i.set(a,s);const l=an.normalizeSpecialPageName(a);n.set(l,s)}}return{byRealName:e,byAlias:i,byNormalized:n}},findSpecialPageRealName:(t,e)=>{const i=t.split("/")[0];let n=e.byRealName.get(i)??e.byAlias.get(i);if(n!==void 0)return n;const r=an.normalizeSpecialPageName(i);return e.byNormalized.get(r)??null}},_t={normalizeNamespaceText:t=>t.replace(/[_\s]+/g,"_").toLowerCase().replace(/^_+|_+$/g,""),buildIndex:t=>{const e=new Map,i=new Map,n=new Map,r=new Map;for(const[s,o]of Object.entries(t.namespaces)){const a=parseInt(s);e.set(o.name,a),i.set(o.canonical??"",a);const l=_t.normalizeNamespaceText(o.name),c=_t.normalizeNamespaceText(o.canonical??"");r.set(l,a),r.set(c,a)}for(const s of t.namespacealiases){n.set(s.alias,s.id);const o=_t.normalizeNamespaceText(s.alias);r.set(o,s.id)}return{byName:e,byCanonical:i,byAlias:n,byNormalized:r}},findNamespaceId:(t,e)=>{let i=e.byName.get(t)??e.byCanonical.get(t)??e.byAlias.get(t);if(i!==void 0)return i;const n=_t.normalizeNamespaceText(t);return e.byNormalized.get(n)??null},isTalkPage:t=>t%2===1&&t>0,getDefaultNamespaceInfo:t=>({id:t,name:"",canonical:"",case:"first-letter",content:!1,nonincludable:!1,subpages:!1})};function ap(t){var s,o;const e=cl.get(t);if(e)return e;const i=_t.buildIndex(t),n=an.buildSpecialPageIndex(t),a=class a{constructor(c,u){Wi(this,s);Wi(this,o);if(this.newTitle=a.create.bind(a),this.toText=this.getPrefixedText.bind(this),this.toString=this.getPrefixedDBKey.bind(this),Te(this,s,c||""),Te(this,o,u??0),u===void 0)this.fixNSByTitle();else{const f=this.parseTitlePrefix(ae(this,s));f&&f.namespaceId===ae(this,o)&&Te(this,s,f.mainTitle)}if(this.getMainText()==="")throw new Error("Invalid title")}static create(c,u){return new a(c,u)}parseTitlePrefix(c){const u=c.indexOf(":");if(u<=0)return null;const f=c.substring(0,u),h=c.substring(u+1),p=_t.findNamespaceId(f,a._namespaceIndex);return p===null?null:{namespaceId:p,mainTitle:h}}adoptNamespaceFromTitle(){const c=this.parseTitlePrefix(ae(this,s));c&&(Te(this,s,c.mainTitle),Te(this,o,c.namespaceId))}fixNSByTitle(){const c=ae(this,s).indexOf(":");if(c!==-1){if(c===0){Te(this,s,ae(this,s).substring(1));return}this.adoptNamespaceFromTitle()}}getNamespaceInfo(){return a._meta.namespaces[ae(this,o)]??_t.getDefaultNamespaceInfo(ae(this,o))}resolveSpecialFullTitle(){if(ae(this,o)!==-1)return null;const c=an.findSpecialPageRealName(ae(this,s),a._specialPageIndex);if(!c)return null;const u=ae(this,s).includes("/")?ae(this,s).substring(ae(this,s).indexOf("/")):"";return c+u}formatMainForOutput(c){const u=this.getNamespaceInfo(),h=this.resolveSpecialFullTitle()??ae(this,s),p=c==="db"?on.toDBKey(h):on.toNormalText(h);return on.ensureCase(p,u.case)}getMainDBKey(){return this.formatMainForOutput("db")}getMainText(){return this.formatMainForOutput("text")}getMainRootText(){return this.getMainText().split("/")[0]}getPrefixedDBKey(){return ae(this,o)===0?this.getMainDBKey():`${this.getNamespaceDBKey()}:${this.getMainDBKey()}`}getPrefixedText(){return ae(this,o)===0?this.getMainText():`${this.getNamespaceText()}:${this.getMainText()}`}getNamespaceId(){return ae(this,o)}getNamespaceText(){return this.getNamespaceInfo().name??""}getNamespaceDBKey(){const c=this.getNamespaceInfo();return on.ensureCase(on.toDBKey(this.getNamespaceText()),c.case)}getSubjectPage(){if(_t.isTalkPage(ae(this,o))){const c=ae(this,o)-1;return new a(ae(this,s),c)}return this}getTalkPage(){if(_t.isTalkPage(ae(this,o)))return this;if(ae(this,o)<0)return null;const c=ae(this,o)+1;return a._meta.namespaces[c.toString()]?new a(ae(this,s),c):null}getURL(c){const u=this.getPrefixedDBKey();return this.buildArticleURL(u,c)}buildArticleURL(c,u){const h=a._meta.general.articlepath.replace("$1",c),p=new URL(h,location.origin);return u&&(u instanceof URLSearchParams?u:new URLSearchParams(u)).forEach((w,S)=>{p.searchParams.set(S,w)}),p}setTitle(c){Te(this,s,c);const u=ae(this,o);Te(this,o,0);const f=this.parseTitlePrefix(ae(this,s));return f?(u!==0&&f.namespaceId===u?(Te(this,s,f.mainTitle),Te(this,o,u)):(Te(this,s,f.mainTitle),Te(this,o,f.namespaceId)),this):this}setMainText(c){return Te(this,s,c),this}setNamespaceText(c){const u=_t.findNamespaceId(c,a._namespaceIndex);return u!==null&&Te(this,o,u),this}setNamespaceId(c){return Te(this,o,c),this}equals(c){return typeof c=="string"&&(c=new a(c)),this.getPrefixedDBKey()===c.getPrefixedDBKey()}isSpecial(c){if(ae(this,o)!==-1)return!1;const u=new a(c,-1);return this.getMainRootText()===u.getMainRootText()}toJSON(){return{ns:ae(this,o),text:this.getMainText(),title:this.getPrefixedText(),url:this.getURL().toString(),isSpecial:ae(this,o)<0}}};s=new WeakMap,o=new WeakMap,a._meta=t,a._namespaceIndex=i,a._specialPageIndex=n;let r=a;return cl.set(t,r),r}const Ln=class Ln extends wt{constructor(e){super(e,"wikiTitle",!0),this.ctx=e,this.logger=this.ctx.logger("WikiTitleService"),this._cachedTitles=new Map,this.wiki=this.ctx.wiki,this.wikiBaseUrl=this.wiki.baseUrl,this.wikiArticlePath=this.wiki.articlePath.replace("$1",""),this.wikiArticleBaseUrl=this.wiki.articleBaseUrl.replace("$1",""),this.wikiIndexPhpUrl=this.wiki.getSciprtUrl("index.php"),this.Title=ap(this.ctx.wiki.siteInfo)}newTitle(e,i){return new this.Title(e,i)}newMainPageTitle(){return this.newTitle(this.ctx.wiki.mainPageName)}async newTitleFromUrl(e){const i=this.parseWikiLink(e);return i?.title?i.title:i?.pageId?this.newTitleFromPageId(i.pageId):null}async newTitleFromAnyId(e,i=!1){const{title:n,pageId:r,revId:s}=e??{};if(typeof n=="string")return this.newTitle(n);let o,a;if(s?(o=parseInt(s.toString(),10),a="revid"):r&&(o=parseInt(r.toString(),10),a="pageid"),!o||!a||isNaN(o)||o<=0)throw new Error("Invalid id or kind",{cause:e});if(!i&&this._cachedTitles.has(`${a}:${o}`))return await this._cachedTitles.get(`${a}:${o}`);const{promise:l,resolve:c,reject:u}=re();this._cachedTitles.set(`${a}:${o}`,l);try{const{wikiPage:f}=this.ctx;let h=null;if(a==="pageid")h=await f.newFromPageId(o);else if(a==="revid")h=await f.newFromRevision(o);else throw new Error(`Invalid kind: ${a}`);c(this.newTitle(h.title))}catch(f){this._cachedTitles.delete(`${a}:${o}`),u(f)}return l}async newTitleFromPageId(e){return this.newTitleFromAnyId({pageId:e})}async newTitleFromRevision(e){return this.newTitleFromAnyId({revId:e})}resolveSpecialPageTarget(e){const i=typeof e=="string"?this.newTitle(e):e;if(!i||i.getNamespaceId()!==-1)return null;let n,r,s="view";const o=i.getMainDBKey().split("/").slice(1).join("/")||"";if(i.isSpecial("edit")&&o)n=o,s="edit";else if(i.isSpecial("talkpage")&&o){const a=i.newTitle(o).getTalkPage();if(!a)return null;n=a.getPrefixedDBKey()}else if(i.isSpecial("mypage"))n=i.newTitle(this.ctx.wiki.userInfo.name,2).getPrefixedDBKey()+(o?`/${o}`:"");else if(i.isSpecial("mytalk"))n=i.newTitle(this.ctx.wiki.userInfo.name,3).getPrefixedDBKey()+(o?`/${o}`:"");else if(i.isSpecial("newsection")&&o)n=o,r="new",s="edit";else return null;return{title:new this.Title(n),section:r,action:s}}isWikiLink(e){return e.startsWith(this.wikiArticleBaseUrl)||e.startsWith(this.wikiIndexPhpUrl)||e.startsWith(`${this.wikiBaseUrl}/?`)||e===this.ctx.wiki.landingPageUrl}validateHrefAttr(e){return typeof e!="string"?!1:!Ln.REG_SKIPPED_HREF.test(e)}parseWikiLink(e){if(!e||typeof e=="string"&&!this.validateHrefAttr(e))return null;const i=nl(e);if(!this.isWikiLink(i.toString()))return null;const n=i.searchParams,r=i.hash.replace("#",""),s=n.get("action")||"view",o=n.get("title")||"",a=parseInt(n.get("curid")||"0",10),l=parseInt(n.get("oldid")||"0",10);let c=o||(()=>{try{return decodeURIComponent(i.pathname.substring(this.wikiArticlePath.length))}catch(p){return this.logger.error("parseLink",i,p),""}})();c.endsWith("index.php")&&(c="");let u,f,h;if(l)h=l;else if(a)f=a;else if(c)u=this.newTitle(c);else if(i.origin+i.pathname===this.ctx.wiki.landingPageUrl)u=this.newMainPageTitle();else return null;return{title:u,pageId:f,revId:h,url:i,params:n,hash:r,action:s}}};Ln.inject=["wiki","wikiPage"],Ln.REG_SKIPPED_HREF=/^(#|javascript:|vbscript:|file:)/i;let Ds=Ln;const lp=t=>typeof t=="function";async function cp(t){return lp(t)?await t():t}var up=Object.create,js=Object.defineProperty,fp=Object.getOwnPropertyDescriptor,ul=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),fl=t=>{throw TypeError(t)},dp=(t,e,i)=>e in t?js(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,hp=(t,e)=>js(t,"name",{value:e,configurable:!0}),pp=t=>[,,,up(t?.[ul("metadata")]??null)],gp=["class","method","getter","setter","accessor","field","value","get","set"],dl=t=>t!==void 0&&typeof t!="function"?fl("Function expected"):t,mp=(t,e,i,n,r)=>({kind:gp[t],name:e,metadata:n,addInitializer:s=>i._?fl("Already initialized"):r.push(dl(s||null))}),yp=(t,e)=>dp(e,ul("metadata"),t[3]),bp=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},vp=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&fp(r,i));hp(r,i);for(var d=n.length-1;d>=0;d--)l=mp(c,i,a={},t[3],h),o=(0,n[d])(r,l),a._=1,dl(o)&&(r=o);return yp(t,r),p&&js(r,i,p),u?c^4?s:p:r},hl,Us,pl;hl=[Ee(["storage","wiki"])];class nr extends(pl=wt){constructor(e){super(e,"preferences",!0),this.ctx=e,this.db=void 0,this.customRegistries=[],this.categoryDefinitions=[],this._defaultPreferences={},e.set("prefs",this),this.db=e.storage.createDatabase(`preferences:${e.wiki.userInfo.id}`,1/0);try{this._migrageFromLegacyMasterDB()}catch{}}get logger(){return this.ctx.logger("PREFERENCES")}async start(){}async get(e,i){if(!e)return this.getAll();i??(i=()=>{const r=this.defaultOf(e);return this.logger.debug(e,`(fallback value: ${r})`),r});const n=await this.db.get(e,void 0);return n!==null?n:await cp(i)}async getAll(){const e=this.loadDefaultConfigs();for await(const[i,n]of this.db.entries())i!=="_touched"&&i in e&&(e[i]=n.value);return e}async set(e,i){return(await this.setMany({[e]:i}))[e]}async setMany(e){const i=this.loadDefaultConfigs(),n={};for(const[r,s]of Object.entries(e))s===i[r]||s===void 0?n[r]=void 0:n[r]=s;return await this.db.set(n),this.ctx.emit("preferences/changed",{ctx:this.ctx,input:e,changes:n}),n}defaultOf(e){var i;return(i=this._defaultPreferences)[e]??(i[e]=this.loadDefaultConfigs()[e])}async getExportableRecord(e){e??(e=await this.getAll());const i=this.loadDefaultConfigs(),n={};return Object.entries(i).sort(([r],[s])=>r.localeCompare(s)).forEach(([r,s])=>{const o=e[r];o!==void 0&&o!==s&&(n[r]=o)}),n}loadDefaultConfigs(){const e={};return this.getConfigRegistries().forEach(i=>{try{const n=i.schema({});Object.entries(n).forEach(([r,s])=>{e[r]=s})}catch{}}),Object.entries(e).forEach(([i,n])=>{this._defaultPreferences[i]=n}),e}registerCustomConfig(e,i,n){const r={name:e,schema:i,category:n||"general"},s=this.customRegistries.findIndex(o=>o.name===e);return s>=0?this.customRegistries[s]=r:this.customRegistries.push(r),this}getConfigRegistries(e){return Array.from(this.ctx.registry.entries()).map(([i])=>i===null?{name:"@root",schema:$i?.PreferencesSchema||null}:{name:i.name,schema:i?.PreferencesSchema||null}).filter(i=>i.schema!==null).map(i=>({...i,category:i.schema.meta.category||"general"})).concat(this.customRegistries).filter(i=>!e||i.category===e)}getAllSchema(){return new R(R.intersect(this.getConfigRegistries().map(e=>e.schema)))}defineCategory(e){const i=this.categoryDefinitions.findIndex(n=>n.name===e.name);return i<0?this.categoryDefinitions.push(e):this.categoryDefinitions[i]=e,this.categoryDefinitions.sort((n,r)=>(n.index??0)-(r.index??0)),this}getConfigCategories(){return this.categoryDefinitions}async _migrageFromLegacyMasterDB(){const e=this.ctx.storage.createDatabase("preferences",1/0);let i=0;for await(const[n,r]of e.entries())n!=="_touched"&&(await this.db.set(n,r.value),i++);return i&&this.logger.info(`Migrated ${i} preferences from master DB`),await e.clear(),await e?.db?.disconnect?.(),i}}Us=pp(pl),nr=vp(Us,0,"PreferencesService",hl,nr),bp(Us,1,nr);var xt=(t=>(t.ANALYTICS_API_BASE="https://analytics.ipe.wiki/api/v6",t.ANALYTICS_DASH_URL="https://analytics.ipe.wiki",t.GITHUB_URL="https://github.com/inpageedit/inpageedit-next",t.GITHUB_OWNER="inpageedit",t.GITHUB_REPO="inpageedit-next",t.HOME_URL="https://www.ipe.wiki/",t.UPDATE_LOGS_URL="https://www.ipe.wiki/changelogs/",t.PLUGIN_REGISTRY_URL="https://registry.ipe.wiki/registry.v1.json",t.I18N_INDEX_URL="https://registry.ipe.wiki/i18n/index.json",t.QQ_GROUP_ID="1026023666",t))(xt||{});const gl="",ml="",wp=/\\\{/g,_p=/\\\}/g,xp=new RegExp(gl,"g"),Sp=new RegExp(ml,"g");function yl(t){const e=t?{...t}:void 0;return(n,...r)=>kp(e,n,...r)}function kp(t,e,...i){if(!e)return"";let n=String(e).replace(wp,gl).replace(_p,ml),r={},s=[];i.length===1&&Array.isArray(i[0])?s=i[0]:i.length===1&&$p(i[0])?r=i[0]:i.length>0&&(s=i);const o=Object.create(null);if(s&&s.length)for(let a=0;a<s.length;a++)o[`$${a+1}`]=s[a];if(r&&Object.keys(r).length)for(const a of Object.keys(r))o[a]=r[a];if(t&&Object.keys(t).length)for(const a of Object.keys(t))typeof o[a]>"u"&&(o[a]=t[a]);return n=n.replace(/\{\{\s*([\s\S]*?)\s*\}\}/g,(a,l)=>{const c=String(l).trim();if(!c)return"";try{const u=Ep(c,o);return u==null?"":String(u)}catch{return""}}),n.replace(xp,"{").replace(Sp,"}")}function $p(t){return typeof t=="object"&&t!==null&&t.constructor===Object}const Ep=Pp();function Pp(){const t=new Set(["eval","Object","Array","String","Number","Boolean","Date","Math","JSON","undefined","null","true","false","NaN","Infinity","isNaN","isFinite","parseInt","parseFloat"]),e=new Function("__expr__","ctx",`
5
+ try {
6
+ with (ctx) {
7
+ return (eval(__expr__));
8
+ }
9
+ } catch (e) {
10
+ throw e;
11
+ }
12
+ `);return(i,n)=>{const r=new Proxy(n,{has:(s,o)=>typeof o=="symbol"?o in s:!(typeof o=="string"&&(t.has(o)||o==="__expr__")),get:(s,o)=>{if(o in s)return s[o]}});return e(i,r)}}function bl(t){return t.charAt(0).toLowerCase()+t.slice(1)}function ki(t){return bl(t).replace(/_/g,"-").replace(/.[A-Z]+/g,e=>e[0]+"-"+e.slice(1).toLowerCase())}function Cp(t){return bl(t).replace(/-/g,"_").replace(/.[A-Z]+/g,e=>e[0]+"_"+e.slice(1).toLowerCase())}function Gt(t,e){let i=t[0]??"";for(let n=0;n<e.length;n++)i+=String(e[n])+(t[n+1]??"");return i}class Rp{constructor(e,i){this.languages=new Map,this.currentLanguage="en",this.missingKeys=new Map,this.usedKeys=new Set;const n=i?.language||"en";this.currentLanguage=n,this.interpolate=yl(i?.globals),e&&Object.keys(e).length&&this.setLanguageData(n,e)}setGlobals(e){return this.interpolate=yl(e),this}set(e,i){const n=this.currentLanguage,r=this.ensureLanguageMap(n);if(typeof e=="string"&&typeof i=="string")r.set(e,i);else if(typeof e=="object"){const s=this.toStringRecord(e);for(const[o,a]of Object.entries(s))r.set(o,a)}return this}setLanguageData(e,i){e=ki(e).toLowerCase();const n=this.ensureLanguageMap(e),r=this.toStringRecord(i);for(const[s,o]of Object.entries(r))n.set(s,o);return this}setLanguage(e){return e=ki(e).toLowerCase(),this.currentLanguage=e,this}getLanguage(){return this.currentLanguage}hasLanguage(e){e=ki(e).toLowerCase();const i=this.languages.get(e);return i&&Object.keys(i).length>0}toStringRecord(e,i){const n={};for(const[r,s]of Object.entries(e)){const o=i?`${i}.${r}`:r;if(s&&typeof s=="object"&&!Array.isArray(s)){const a=this.toStringRecord(s,o);for(const[l,c]of Object.entries(a))n[l]=String(c)}else n[o]=String(s)}return n}has(e){const i=this.resolveLanguageOrder(this.currentLanguage);for(const n of i)if(this.languages.get(n)?.has(e))return!0;return!1}get(e){this.recordUsedKey(e);const i=this.resolveLanguageOrder(this.currentLanguage),n=[];for(const r of i){const o=this.languages.get(r)?.get(e);if(typeof o<"u")return n.length&&this.recordMissing(e,n),o;n.push(r)}n.length&&this.recordMissing(e,n)}translate(e,...i){if(!e)return"";if(this.currentLanguage==="qqx")return`⧼${e}⧽`;const n=this.get(e);return typeof n>"u"?this.interpolate(e,...i):this.interpolate(n,...i)}$(...e){if(Array.isArray(e[0])&&e[0]?.raw){const r=e[0],s=e.slice(1),o=Gt(r,s);return this.translate(o)}const n=e;return(r,...s)=>{const o=Gt(r,s);return this.translate(o,...n)}}translateRaw(e){return e?this.currentLanguage==="qqx"?`⧼${e}⧽`:this.get(e)??e:""}$raw(...e){if(Array.isArray(e[0])&&e[0]?.raw){const n=e[0],r=e.slice(1),s=Gt(n,r);return this.translateRaw(s)}return(n,...r)=>{const s=Gt(n,r);return this.translateRaw(s)}}message(e,...i){if(!e)return"";if(this.currentLanguage==="qqx")return`⧼${e}⧽`;const n=this.get(e);return typeof n>"u"?`(${e})`:this.interpolate(n,...i)}$$(...e){if(Array.isArray(e[0])&&e[0]?.raw){const r=e[0],s=e.slice(1),o=Gt(r,s);return this.message(o)}const n=e;return(r,...s)=>{const o=Gt(r,s);return this.message(o,...n)}}messageRaw(e){return e?this.currentLanguage==="qqx"?`⧼${e}⧽`:this.get(e)??`(${e})`:""}$$raw(...e){if(Array.isArray(e[0])&&e[0].raw){const n=e[0],r=e.slice(1),s=Gt(n,r);return this.messageRaw(s)}return(n,...r)=>{const s=Gt(n,r);return this.messageRaw(s)}}getAvailableLanguages(){return Array.from(this.languages.keys())}ensureLanguageMap(e){let i=this.languages.get(e);return i||(i=new Map,this.languages.set(e,i)),i}resolveLanguageOrder(e){const i=e;return i==="en"?["en"]:[i,"en"]}getMissingReport(){return Object.fromEntries(this.missingKeys.entries())}clearMissingReport(){this.missingKeys.clear()}recordMissing(e,i){if(!i.length)return;const n=this.missingKeys.get(e)||[];for(const r of i)n.includes(r)||n.push(r);this.missingKeys.set(e,n)}recordUsedKey(e){this.usedKeys.add(e)}getUsedKeys(){return Array.from(this.usedKeys)}generateBlankKeyRecord(){const e={};for(const i of this.getUsedKeys())e[i]="";return e}}function Vt(t){return function(e){return e.PreferencesSchema=t,e}}var Ip=Object.create,Fs=Object.defineProperty,Ap=Object.getOwnPropertyDescriptor,vl=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),wl=t=>{throw TypeError(t)},Op=(t,e,i)=>e in t?Fs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Tp=(t,e)=>Fs(t,"name",{value:e,configurable:!0}),Lp=t=>[,,,Ip(t?.[vl("metadata")]??null)],Mp=["class","method","getter","setter","accessor","field","value","get","set"],_l=t=>t!==void 0&&typeof t!="function"?wl("Function expected"):t,Np=(t,e,i,n,r)=>({kind:Mp[t],name:e,metadata:n,addInitializer:s=>i._?wl("Already initialized"):r.push(_l(s||null))}),Dp=(t,e)=>Op(e,vl("metadata"),t[3]),jp=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Up=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&Ap(r,i));Tp(r,i);for(var d=n.length-1;d>=0;d--)l=Np(c,i,a={},t[3],h),o=(0,n[d])(r,l),a._=1,_l(o)&&(r=o);return Dp(t,r),p&&Fs(r,i,p),u?c^4?s:p:r},xl,Bs,Sl;const kl=new R(R.object({manifest_version:R.const(1).required(),base_language:R.string().required(),last_modified:R.string().required(),languages:R.dict(R.object({file:R.string().required(),fallback:R.string(),data:R.transform(R.dict(R.any()).default({}),t=>Object.keys(t).length>0?t:void 0)})).required()}));xl=[Ee(["wiki","preferences"]),Vt(R.object({"i18n.index_url":R.string().description("I18n index URL (DO NOT CHANGE THIS) ").default(xt.I18N_INDEX_URL)}).description("").extra("category","general"))];class rr extends(Sl=wt){constructor(e){super(e,"i18n",!1),this.ctx=e,this.logger=void 0,this._indexUrl=void 0,this._indexCache=null,this.manager=void 0,this.i18nIndexDB=void 0,this.i18nDataDB=void 0,this.$=void 0,this.$raw=void 0,this.$$=void 0,this.$$raw=void 0,this.logger=this.ctx.logger("I18nService"),this.manager=new Rp({},{language:"",globals:{getUrl:(...i)=>e.wiki.getUrl(...i)}}),this.i18nIndexDB=e.storage.createDatabase("i18n-index",1e3*60*60*24*3,this.ctx.version,"indexedDB"),this.i18nDataDB=e.storage.createDatabase("i18n-data",1e3*60*60*24*3,this.ctx.version,"indexedDB"),this.$=this.manager.$.bind(this.manager),this.$raw=this.manager.$raw.bind(this.manager),this.$$=this.manager.$$.bind(this.manager),this.$$raw=this.manager.$$raw.bind(this.manager)}async start(){this.ctx.preferences.registerCustomConfig("language",R.object({language:R.union(["@user","@site",R.string().description("Custom language code")]).description("UI language").default("@user")}).description("UI language"));const e=this._indexUrl=await this.ctx.preferences.get("i18n.index_url")||"";if(!e){this.logger.error("I18n index URL is not set"),this.setupShortcuts();return}let i=null;try{i=await this.getI18nIndex(e)}catch(s){this.logger.error("Failed to fetch i18n index",s),this.setupShortcuts();return}this._indexCache=i,Object.entries(i.languages).forEach(([s,o])=>{o.data&&Object.keys(o.data).length>0&&this.manager.setLanguageData(s,o.data)});const n=await this.ctx.preferences.get("language"),r=this.normalizeLanguageCode(n);this.logger.debug("Settings",{prefer:n,normalized:r});try{await this.switchLanguage(r),this.logger.info(`Initialized for language: ${this.language}`)}catch(s){this.logger.error("Failed to fetch i18n index",s),this.manager.setLanguage("en")}this.ctx.preferences.registerCustomConfig("language",R.object({language:R.union([R.const("@user").description(this.$`Same as your personal language`),R.const("@site").description(this.$`Same as the site language`),...this.getAvailableLanguageCodes().map(s=>R.const(s).description(s))]).default("@user")}).description(this.$`InPageEdit UI language`)),this.setupShortcuts(),this.ctx.on("preferences/changed",async({changes:s})=>{if(!("language"in s))return;const o=this.normalizeLanguageCode(s.language);o&&o!==this.language&&await this.switchLanguage(o)})}setupShortcuts(){if(!this.manager)throw new Error("I18nManager is not initialized");this.ctx.set("$",this.manager.$.bind(this.manager)),this.ctx.set("$raw",this.manager.$raw.bind(this.manager)),this.ctx.set("$$",this.manager.$$.bind(this.manager)),this.ctx.set("$$raw",this.manager.$$raw.bind(this.manager))}normalizeLanguageCode(e){return!e||typeof e!="string"?"en":(e==="@user"&&(e=this.ctx.wiki.userInfo.options.language||"en"),e==="@site"&&(e=this.ctx.wiki.siteInfo.general.lang||"en"),ki(String(e)).toLowerCase())}get language(){return this.manager.getLanguage()}async setLanguagePreference(e){await this.ctx.preferences.set("language",e)}async switchLanguage(e){const i=this.normalizeLanguageCode(e);await this.ensureLanguageLoaded(i),this.manager.setLanguage(i),this.ctx.emit("i18n/changed",{ctx:this.ctx,language:i})}async registerMessages(e,i,n){const r=n?.namespace?{[n.namespace]:i}:i;this.manager.setLanguageData(e,r),e===this.language&&this.ctx.emit("i18n/changed",{ctx:this.ctx,language:this.language})}getAvailableLanguageCodes(){if(!this._indexCache)throw new Error("I18n index is not loaded");return Object.entries(this._indexCache.languages).filter(([e,i])=>!i.fallback).reduce((e,[i,n])=>(e.push(i),e),[])}findLanguageMeta(e,i){const n=ki(String(i)).toLowerCase(),r=e.languages[n];if(r)return{code:n,...r};{const s=e.languages.en;if(s)return{code:"en",...s}}}async getI18nIndex(e,i=!1){if(!i){const r=await this.i18nIndexDB.get(e);if(r)try{return kl(r)}catch(s){this.logger.error("Failed to parse cached i18n index",s),this.i18nIndexDB.delete(e)}}const n=await this.fetchI18nIndex(e);return this.i18nIndexDB.set(e,n),n}async fetchI18nIndex(e){const i=await fetch(e).then(n=>n.json());return kl(i)}async ensureLanguageLoaded(e){if(!this.manager||!this._indexCache)throw new Error("I18nManager is not initialized");if(this.manager.hasLanguage(e))return this.logger.debug("Language already loaded",e);const i=await this.getLanguageData(e);this.manager.setLanguageData(e,i),this.logger.debug("Language data ensured",e,i)}async getLanguageData(e,i=!1){if(!this._indexCache)throw new Error("I18n index is not loaded");const n=this.findLanguageMeta(this._indexCache,e);if(!n)return{};const r=`${this._indexUrl}#${n.file}`;if(!i){const o=await this.i18nDataDB.get(r);if(o&&Object.keys(o).length>0)return this.logger.debug("Using cached language data",e,o),o}const s=n.data||await fetch(new URL(n.file,this._indexUrl).toString()).then(o=>o.json());return this.i18nDataDB.set(r,s),this.logger.debug("Language data fetched",e,n.file,s),s}getMissingReport(){return this.manager.getMissingReport()}clearMissingReport(){this.manager.clearMissingReport()}}Bs=Lp(Sl),rr=Up(Bs,0,"I18nService",xl,rr),jp(Bs,1,rr);const Mn=class Mn extends ze{constructor(i){super({name:"InPageEdit"});Wi(this,ft);this.version="0.14.0",this.Endpoints=xt,this.schema=R,this.config=Qi(Mn.DEFAULT_CONFIG,i),this.logger=Aa({name:"IPE",color:"#33aaff",level:this.config.logLevel}),ot(this,ft,Gf).call(this)}async withInject(i){const{promise:n,resolve:r}=re();return this.inject(i,s=>{r(s)}),n}};ft=new WeakSet,Gf=async function(){await ot(this,ft,Vf).call(this),this.config.autoInstallCorePlugins&&ot(this,ft,Qf).call(this),ot(this,ft,Xf).call(this)},Vf=async function(){this.plugin(rr),this.plugin(Fd,this.config.apiConfigs),this.plugin(Vn),this.plugin(Xd),this.plugin(qh),this.plugin(nr),this.plugin(sp,{dbName:this.config.storageNamespace}),this.plugin(ir),this.plugin(Ns),this.plugin(Ds),ot(this,ft,Yf).call(this,["i18n","$","$$","api","currentPage","resourceLoader","modal","preferences","storage","wikiPage","wikiTitle","wiki","getUrl","getSciprtUrl","getMainpageUrl"])},Yf=function(i){if(!Array.isArray(i)||i.length===0)return this;for(const n of i){const r=this[Mn.internal][n];r?.type==="service"&&(r.builtin=!0)}return this},Qf=async function(){[Promise.resolve().then(()=>Jp).then(({PluginAnalytics:n})=>n),Promise.resolve().then(()=>cg).then(({PluginInArticleLinks:n})=>n),Promise.resolve().then(()=>Ky).then(({PluginPluginStore:n})=>n),Promise.resolve().then(()=>bb).then(({PluginPreferencesUI:n})=>n),Promise.resolve().then(()=>Tb).then(({PluginQuickEdit:n})=>n),Promise.resolve().then(()=>zb).then(({PluginQuickMove:n})=>n),Promise.resolve().then(()=>tv).then(({PluginQuickPreview:n})=>n),Promise.resolve().then(()=>bv).then(({PluginQuickDiff:n})=>n),Promise.resolve().then(()=>vv).then(({PluginQuickRedirect:n})=>n),Promise.resolve().then(()=>Iv).then(({PluginToolbox:n})=>n)].forEach(async n=>{this.plugin(await n)})},Xf=async function(){this.inject(["resourceLoader"],i=>{})},Mn.DEFAULT_CONFIG={apiConfigs:{},legacyPreferences:{},logLevel:ps.info,storageNamespace:"InPageEdit",autoloadStyles:!0,autoInstallCorePlugins:!0};let $i=Mn;const Jr=class Jr{constructor(e,i=void 0,n){Wi(this,Nn);this.ctx=e,this.disposeHandlers=[],this.name=n||"",this.config=i||{};const{promise:r,resolve:s,reject:o}=Promise.withResolvers();queueMicrotask(()=>{this.name||(this.name=this.constructor.name);try{const a=this.start();a&&typeof a.then=="function"?a.then(()=>s()).catch(l=>{this.logger.error("start() returns a rejected promise",l),o(l)}):s()}catch(a){this.logger.error("start() threw synchronously",a),o(a)}r.then(()=>{this.logger.debug("started")}),r.catch(a=>{this.logger.error("start failed",a),this.ctx.scope.dispose()})}),this.ctx.once("dispose",()=>{this.disposeHandlers.forEach(a=>a(this.ctx)),this.stop(),this.logger.debug("disposed")})}start(){}stop(){}addDisposeHandler(e){this.disposeHandlers.push(e)}removeDisposeHandler(e){this.disposeHandlers=this.disposeHandlers.filter(i=>i!==e)}set name(e){Te(this,Nn,Cp(e).toUpperCase())}get name(){return ae(this,Nn)}get logger(){return this.ctx.logger(this.name)}};Nn=new WeakMap,Jr.inject=[],Jr.reusable=!1;let et=Jr;window.RLQ||(window.RLQ=[]),window.__IPE_MODULES__||(window.__IPE_MODULES__=[]),Bp("InPageEdit#autoload",()=>{const t=$l();t&&Fp({baseURL:t,InPageEdit:$i})});async function Fp(t={baseURL:$l(),InPageEdit:$i}){const{baseURL:e,InPageEdit:i}=t;typeof window?.ipe?.stop=="function"&&await window.ipe.stop();const n=window.InPageEdit||{},r=new i({apiConfigs:{baseURL:e},legacyPreferences:n?.myPreferences||{}});if(window.ipe=r,await r.start(),window.RLQ.push(()=>{mw.hook("InPageEdit.ready").fire(r)}),Array.isArray(window.__IPE_MODULES__)){const s=[];for(;window.__IPE_MODULES__.length;)try{const o=window.__IPE_MODULES__.shift();typeof o=="function"&&o?.(r),s.push(o)}catch{}window.__IPE_MODULES__={push:o=>{typeof o=="function"&&o(r),s.push(o)}},r.on("dispose",()=>{window.__IPE_MODULES__=s})}r.logger("AUTOLOAD").info(`
5
13
  ____ ____ ______ ___ __
6
14
  / _/___ / __ \\____ _____ ____ / ____/___/ (_) /_
7
15
  / // __ \\/ /_/ / __ \`/ __ \`/ _ \\/ __/ / __ / / __/
@@ -9,14 +17,14 @@
9
17
  /___/_/ /_/_/ \\__,_/\\__, /\\___/_____/\\__,_/_/\\__/
10
18
  /____/ v`+r.version+`
11
19
  - Wiki API Endpoint: ${e}
12
- - Documentation: ${Lt.HOME_URL}
13
- - Bug Reports: ${Lt.GITHUB_URL}`)}function ll(){const t=document.querySelector('meta[name="generator"][content^="MediaWiki"]')!==null,e=document.querySelector('link[rel="EditURI"]')?.href?.split("?")[0];return t&&e?e:void 0}function lp(t,e){const i=Symbol.for(t);return window[i]?!1:(window[i]=!0,e(),!0)}var cp=Object.create,Ls=Object.defineProperty,up=Object.getOwnPropertyDescriptor,cl=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),ul=t=>{throw TypeError(t)},fp=(t,e,i)=>e in t?Ls(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,dp=(t,e)=>Ls(t,"name",{value:e,configurable:!0}),hp=t=>[,,,cp(t?.[cl("metadata")]??null)],pp=["class","method","getter","setter","accessor","field","value","get","set"],fl=t=>t!==void 0&&typeof t!="function"?ul("Function expected"):t,mp=(t,e,i,n,r)=>({kind:pp[t],name:e,metadata:n,addInitializer:s=>i._?ul("Already initialized"):r.push(fl(s||null))}),gp=(t,e)=>fp(e,cl("metadata"),t[3]),yp=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},bp=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,h=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&up(r,i));dp(r,i);for(var f=n.length-1;f>=0;f--)l=mp(c,i,a={},t[3],h),o=(0,n[f])(r,l),a._=1,fl(o)&&(r=o);return gp(t,r),p&&Ls(r,i,p),u?c^4?s:p:r},dl,Ns,hl;dl=[$e(["wiki","preferences"])];class er extends(hl=Xe){constructor(e){super(e,{},"analytics"),this.ctx=e,this._usages=[],this._timer=null,this.MAX_QUEUE_SIZE=50,this.INTERVAL_MS=60*1e3,this._setupTimer(),this._registerUnloadHandler(),this._showConfirmNotify(),this._initPluginListeners(),e.set("analytics",this)}start(){this.ctx.preferences.registerCustomConfig("analytics",L.object({"analytics._intro":L.const(m("section",{children:[m("h3",{children:"InPageEdit Analytics"}),m("p",{children:"InPageEdit Analytics is the companion analytics platform for the InPageEdit NEXT project. By collecting and displaying usage data from around the world, it helps developers and the community better understand how the tool is used, optimize feature design, and enhance user experience."}),m("h4",{children:"What data will be collected?"}),m("ol",{style:{listStyle:"number",paddingLeft:"1em"},children:[m("li",{children:[m("strong",{children:"Usage data"}),": When and which features you use, what pages you edit, etc."]}),m("li",{children:[m("strong",{children:"User information"}),": Your user name and user ID."]}),m("li",{children:[m("strong",{children:"Site information"}),": This wiki's url and site name."]})]}),m("p",{children:m("strong",{children:"NO sensitive data will be collected."})}),m("div",{style:{display:"grid",gap:"0.5rem"},children:[m("a",{href:this.analyticsDashUrl,target:"_blank",rel:"noopener noreferrer",children:m("button",{className:"btn",style:{width:"100%"},children:"Analytics Platform"})}),m("a",{href:`${this.analyticsDashUrl}/_redirect/user?${new URLSearchParams({siteApi:this.ctx.wiki.getSciprtUrl("api"),mwUserId:this.ctx.wiki.userInfo.id.toString()}).toString()}`,target:"_blank",rel:"noopener noreferrer",children:m("button",{className:"btn",style:{width:"100%"},children:"View My Data"})})]})]})).role("raw-html"),"analytics.enabled":L.boolean().description("Share my usage data with the community.").default(!1)}).description("Analytics settings"),"general")}get analyticsDashUrl(){return Lt.ANALYTICS_DASH_URL}get analyticsApiBase(){return Lt.ANALYTICS_API_BASE}_setupTimer(){this._timer=setInterval(()=>{this._usages.length>0&&this.sendBeacon()},this.INTERVAL_MS)}_registerUnloadHandler(){const e=()=>{this._usages.length>0&&this.sendBeacon()};window.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&e()}),window.addEventListener("pagehide",e),window.addEventListener("beforeunload",e)}async _showConfirmNotify(){this.ctx.inject(["modal","storage"],async e=>{const i="analytics/confirm-shown",n=await e.storage.simpleKV.get(i),r=await e.preferences.get("analytics.enabled");n||r||e.modal.notify("confirm",{title:"Enable Analytics",content:m("div",{children:[m("p",{children:"Help us improve InPageEdit by sharing your usage data with us."}),m("p",{children:"What data will be collected?"}),m("ul",{style:{listStyle:"auto",paddingLeft:"1.5em"},children:[m("li",{children:"Usage data: What features you use, what pages you edit, etc."}),m("li",{children:"User information: Your username, user ID."}),m("li",{children:"Site information: The wiki you are editing."})]}),m("p",{children:m("strong",{children:"NO sensitive data will be collected."})})]}),okBtn:{label:"Enable"},cancelBtn:{label:"Disable"},closeAfter:0,onClose:()=>{this.ctx.storage.simpleKV.set(i,1)}},s=>{e.preferences.set("analytics.enabled",s),s&&this.addEvent("analytics","enabled")})})}_initPluginListeners(){const e=this.ctx;e.on("in-article-links/anchor-clicked",i=>{this.addEvent("in-article-links",sp(i.action))}),e.on("quick-diff/loaded",i=>{this.addEvent("quick-diff","loaded",i.compare.fromtitle)}),e.on("quick-redirect/submit",i=>{this.addEvent("quick-redirect","submit",i.payload.to||void 0)}),e.on("quick-preview/loaded",i=>{this.addEvent("quick-preview","loaded",i.wikiPage.title)}),e.on("quick-edit/wiki-page",i=>{this.addEvent("quick-edit",void 0,i.wikiPage.title)}),e.on("quick-edit/submit",i=>{this.addEvent("quick-edit","submit",i.wikiPage.title)}),e.on("quick-move/submit",i=>{this.addEvent("quick-move","submit")}),e.on("toolbox/button-clicked",i=>{this.addEvent("toolbox",`button-clicked#${i.id||"unknown"}`)})}addEvent(e,i,n){const r={ts:Date.now(),feature:e,subtype:i,page:n};return this._usages.push(r),this._usages.length>=this.MAX_QUEUE_SIZE&&this.sendBeacon(),this}async sendBeacon(){if(this._usages.length===0)return!0;if(!await this.ctx.preferences.get("analytics.enabled",!1))return this.logger.debug("Analytics disabled, skipping"),!0;const i=this._usages.splice(0,this._usages.length),n={siteApi:this.ctx.wiki.getSciprtUrl("api"),siteName:this.ctx.wiki.siteInfo.general.sitename,userId:this.ctx.wiki.userInfo.id,userName:this.ctx.wiki.userInfo.name,version:this.ctx.version.split("-")[0],usages:i},r=JSON.stringify(n),s=`${this.analyticsApiBase}/submit`;if(navigator?.sendBeacon?.(s,r))return this.logger.debug("Beacon sent successfully",n),!0;{this.logger.debug("Beacon failed, sending via XMLHttpRequest");const{promise:a,resolve:l,reject:c}=re();try{const u=new XMLHttpRequest;u.open("POST",s,!0),u.setRequestHeader("Content-Type","application/json"),u.send(r),u.onload=()=>{this.logger.debug("Beacon sent successfully via XMLHttpRequest",n),l(u.status>=200&&u.status<300)},u.onerror=()=>{c(new Error("Failed to send beacon"))}}catch(u){c(u)}return a}}stop(){this._timer!==null&&(clearInterval(this._timer),this._timer=null),this._usages.length>0&&this.sendBeacon()}}Ns=hp(hl),er=bp(Ns,0,"PluginAnalytics",dl,er),yp(Ns,1,er);const vp=Object.freeze(Object.defineProperty({__proto__:null,get PluginAnalytics(){return er}},Symbol.toStringTag,{value:"Module"})),pl=t=>m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...t,class:`icon icon-tabler icons-tabler-outline icon-tabler-pencil-bolt ${t.className||""}`,children:[m("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),m("path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),m("path",{d:"M13.5 6.5l4 4"}),m("path",{d:"M19 16l-2 3h4l-2 3"})]});var wp=Object.create,Ms=Object.defineProperty,_p=Object.getOwnPropertyDescriptor,ml=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),gl=t=>{throw TypeError(t)},xp=(t,e,i)=>e in t?Ms(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Sp=(t,e)=>Ms(t,"name",{value:e,configurable:!0}),kp=t=>[,,,wp(t?.[ml("metadata")]??null)],Ep=["class","method","getter","setter","accessor","field","value","get","set"],yl=t=>t!==void 0&&typeof t!="function"?gl("Function expected"):t,$p=(t,e,i,n,r)=>({kind:Ep[t],name:e,metadata:n,addInitializer:s=>i._?gl("Already initialized"):r.push(yl(s||null))}),Pp=(t,e)=>xp(e,ml("metadata"),t[3]),Cp=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Rp=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,h=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&_p(r,i));Sp(r,i);for(var f=n.length-1;f>=0;f--)l=$p(c,i,a={},t[3],h),o=(0,n[f])(r,l),a._=1,yl(o)&&(r=o);return Pp(t,r),p&&Ms(r,i,p),u?c^4?s:p:r},bl,Ds,vl;bl=[$e(["wiki","wikiTitle","preferences"]),si(L.object({"inArticleLinks.enable":L.boolean().description("Whether to enable in-article links").default(!0),"inArticleLinks.quickDiff.enable":L.boolean().description("Whether to enable in-article links for quick diff").default(!0),"inArticleLinks.quickEdit.enable":L.boolean().description("Whether to enable in-article links for quick edit").default(!0),"inArticleLinks.quickEdit.redlinks":L.boolean().description("Whether to show quick edit button for redlinks").default(!0)}).description("In-article links preferences").extra("category","in-article-links"))];class tr extends(vl=Xe){constructor(e){super(e,{linkClassName:"ipe__in-article-link"},"InArticleLinks"),this._cachedAnchorInfo=new WeakMap,this.ctx.set("inArticleLinks",this),this.ctx.preferences.defineCategory({label:"In Article Links",name:"in-article-links",description:"In-article links preferences",index:9})}async start(){await this.ctx.preferences.get("inArticleLinks.quickEdit.enable")&&this.handleQuickEdit(),await this.ctx.preferences.get("inArticleLinks.quickDiff.enable")&&this.handleQuickDiff()}async stop(){Array.from(document.getElementsByClassName(this.config.linkClassName)).forEach(e=>{e.remove()}),document.querySelectorAll("[data-ipe-edit-mounted]").forEach(e=>{e.dataset.ipeEditMounted=void 0})}parseAnchor(e){if(!(e instanceof HTMLAnchorElement))return null;const i=this._cachedAnchorInfo.get(e);if(i)return i;const n=e.getAttribute("href")||"";if(!this.ctx.wikiTitle.validateHrefAttr(n))return null;const r=e.href||"",s=this.ctx.wikiTitle.parseWikiLink(r);if(!s)return null;const o={$el:e,kind:e.closest('[typeof^="mw:File"]')?"mw:File":"normal",external:e.classList.contains("external")||!!n.startsWith("http"),redlink:e.classList.contains("new")||s.params.has("redlink"),...s};return this._cachedAnchorInfo.set(e,o),this.ctx.emit("in-article-links/anchor-parsed",{ctx:this.ctx,anchor:e,info:o}),o}scanAnchors(e,i){const n=e.querySelectorAll("a[href]");return Array.from(n).map(r=>this.parseAnchor(r)).filter(r=>r!==null&&(!i||i(r)))}async handleQuickEdit(){let e=!1;const i=await this.ctx.preferences.get("inArticleLinks.quickEdit.redlinks");this.ctx.inject(["quickEdit"],n=>{e=!0,n.on("dispose",()=>{e=!1}),window?.mw?.hook?.("wikipage.content").add(r=>{if(!e)return;this.scanAnchors(r.get(0),({action:o,title:a,redlink:l})=>i||!l?["edit","create"].includes(o)?!0:a?.isSpecial("edit")||a?.isSpecial("newsection")?a.getMainText().split("/").length>=2:!1:!1).forEach(o=>{const{$el:a,title:l,pageId:c,params:u}=o;if(a.dataset.ipeEditMounted)return;if(a.dataset.ipeEditMounted="1",u.has("preload")||u.has("redo"))return this.ctx.logger.debug(a,"Not compatible with quick edit");const h=l?.getPrefixedDBKey()||"",p=u.get("section")?.replace(/^T-/,"")||void 0,f=u.get("oldid"),_=u.has("redlink");let P;p==="new"||l?.isSpecial("newsection")?P="new":p&&/^\d+$/.test(p)&&(P=parseInt(p,10));const C=f?parseInt(f,10):void 0,R={title:h,pageId:c||void 0,section:P,revision:C,createOnly:_},y=m("a",{href:"#ipe://quick-edit/",dataset:R,className:`${this.config.linkClassName} ipe-quick-edit ${_?"ipe-quick-edit--create-only":""}`,style:{userSelect:"none",marginLeft:"0.2em"},onClick:g=>{g.preventDefault(),this.ctx.emit("in-article-links/anchor-clicked",{ctx:this.ctx,anchor:a,info:o,event:g,action:"quickEdit"}),n.quickEdit.showModal(R)},children:m(pl,{className:"ipe-icon"})});a.insertAdjacentElement("afterend",y)})})})}handleQuickDiff(){let e=!1;const i=n=>["prev","next","cur"].includes(n);this.ctx.inject(["quickDiff"],n=>{e=!0,n.on("dispose",()=>{e=!1}),window?.mw?.hook?.("wikipage.content").add(r=>{if(!e)return;this.scanAnchors(r.get(0),({params:o,title:a})=>!!(o.has("diff")||a?.isSpecial("diff"))).forEach(o=>{const{$el:a,title:l,params:c}=o;if(a.dataset.ipeDiffMounted)return;a.dataset.ipeDiffMounted="1";let u,d;if(l?.getNamespaceId()===-1?([,d,u]=l.getMainDBKey().split("/"),u||(u="prev")):(u=c.get("diff"),d=c.get("oldid")),!u||!d)return;const h={};i(u)?(h.fromrev=parseInt(d),h.torelative=u):(h.fromrev=parseInt(d),h.torev=parseInt(u));const p=m("a",{href:"#ipe://quick-diff/",dataset:h,className:`${this.config.linkClassName} ipe-quick-diff`,style:{userSelect:"none",marginLeft:"0.2em"},onClick:f=>{f.preventDefault(),this.ctx.emit("in-article-links/anchor-clicked",{ctx:this.ctx,anchor:a,info:o,event:f,action:"quickDiff"}),n.quickDiff.comparePages(h)},children:m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-file-diff ipe-icon",children:[m("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),m("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),m("path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z"}),m("path",{d:"M12 10l0 4"}),m("path",{d:"M10 12l4 0"}),m("path",{d:"M10 17l4 0"})]})});a.insertAdjacentElement("afterend",p)})})})}}Ds=kp(vl),tr=Rp(Ds,0,"PluginInArticleLinks",bl,tr),Cp(Ds,1,tr);const Ap=Object.freeze(Object.defineProperty({__proto__:null,get PluginInArticleLinks(){return tr}},Symbol.toStringTag,{value:"Module"}));function js(t){const e=Object.create(null);for(const i of t.split(","))e[i]=1;return i=>i in e}const ne={},ki=[],vt=()=>{},wl=()=>!1,ir=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&(t.charCodeAt(2)>122||t.charCodeAt(2)<97),Us=t=>t.startsWith("onUpdate:"),Re=Object.assign,Fs=(t,e)=>{const i=t.indexOf(e);i>-1&&t.splice(i,1)},Ip=Object.prototype.hasOwnProperty,se=(t,e)=>Ip.call(t,e),V=Array.isArray,Ei=t=>nr(t)==="[object Map]",_l=t=>nr(t)==="[object Set]",G=t=>typeof t=="function",ve=t=>typeof t=="string",Nt=t=>typeof t=="symbol",pe=t=>t!==null&&typeof t=="object",xl=t=>(pe(t)||G(t))&&G(t.then)&&G(t.catch),Sl=Object.prototype.toString,nr=t=>Sl.call(t),Op=t=>nr(t).slice(8,-1),kl=t=>nr(t)==="[object Object]",Bs=t=>ve(t)&&t!=="NaN"&&t[0]!=="-"&&""+parseInt(t,10)===t,nn=js(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),rr=t=>{const e=Object.create(null);return(i=>e[i]||(e[i]=t(i)))},Tp=/-\w/g,Mt=rr(t=>t.replace(Tp,e=>e.slice(1).toUpperCase())),Lp=/\B([A-Z])/g,Wt=rr(t=>t.replace(Lp,"-$1").toLowerCase()),El=rr(t=>t.charAt(0).toUpperCase()+t.slice(1)),qs=rr(t=>t?`on${El(t)}`:""),Ke=(t,e)=>!Object.is(t,e),sr=(t,...e)=>{for(let i=0;i<t.length;i++)t[i](...e)},$l=(t,e,i,n=!1)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,writable:n,value:i})},Hs=t=>{const e=parseFloat(t);return isNaN(e)?t:e};let Pl;const or=()=>Pl||(Pl=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function zs(t){if(V(t)){const e={};for(let i=0;i<t.length;i++){const n=t[i],r=ve(n)?jp(n):zs(n);if(r)for(const s in r)e[s]=r[s]}return e}else if(ve(t)||pe(t))return t}const Np=/;(?![^(]*\))/g,Mp=/:([^]+)/,Dp=/\/\*[^]*?\*\//g;function jp(t){const e={};return t.replace(Dp,"").split(Np).forEach(i=>{if(i){const n=i.split(Mp);n.length>1&&(e[n[0].trim()]=n[1].trim())}}),e}function ft(t){let e="";if(ve(t))e=t;else if(V(t))for(let i=0;i<t.length;i++){const n=ft(t[i]);n&&(e+=n+" ")}else if(pe(t))for(const i in t)t[i]&&(e+=i+" ");return e.trim()}const Up=js("itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly");function Cl(t){return!!t||t===""}const Rl=t=>!!(t&&t.__v_isRef===!0),ke=t=>ve(t)?t:t==null?"":V(t)||pe(t)&&(t.toString===Sl||!G(t.toString))?Rl(t)?ke(t.value):JSON.stringify(t,Al,2):String(t),Al=(t,e)=>Rl(e)?Al(t,e.value):Ei(e)?{[`Map(${e.size})`]:[...e.entries()].reduce((i,[n,r],s)=>(i[Ks(n,s)+" =>"]=r,i),{})}:_l(e)?{[`Set(${e.size})`]:[...e.values()].map(i=>Ks(i))}:Nt(e)?Ks(e):pe(e)&&!V(e)&&!kl(e)?String(e):e,Ks=(t,e="")=>{var i;return Nt(t)?`Symbol(${(i=t.description)!=null?i:e})`:t};let We;class Fp{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this.parent=We,!e&&We&&(this.index=(We.scopes||(We.scopes=[])).push(this)-1)}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let e,i;if(this.scopes)for(e=0,i=this.scopes.length;e<i;e++)this.scopes[e].pause();for(e=0,i=this.effects.length;e<i;e++)this.effects[e].pause()}}resume(){if(this._active&&this._isPaused){this._isPaused=!1;let e,i;if(this.scopes)for(e=0,i=this.scopes.length;e<i;e++)this.scopes[e].resume();for(e=0,i=this.effects.length;e<i;e++)this.effects[e].resume()}}run(e){if(this._active){const i=We;try{return We=this,e()}finally{We=i}}}on(){++this._on===1&&(this.prevScope=We,We=this)}off(){this._on>0&&--this._on===0&&(We=this.prevScope,this.prevScope=void 0)}stop(e){if(this._active){this._active=!1;let i,n;for(i=0,n=this.effects.length;i<n;i++)this.effects[i].stop();for(this.effects.length=0,i=0,n=this.cleanups.length;i<n;i++)this.cleanups[i]();if(this.cleanups.length=0,this.scopes){for(i=0,n=this.scopes.length;i<n;i++)this.scopes[i].stop(!0);this.scopes.length=0}if(!this.detached&&this.parent&&!e){const r=this.parent.scopes.pop();r&&r!==this&&(this.parent.scopes[this.index]=r,r.index=this.index)}this.parent=void 0}}}function Bp(){return We}let ce;const Ws=new WeakSet;class Il{constructor(e){this.fn=e,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.next=void 0,this.cleanup=void 0,this.scheduler=void 0,We&&We.active&&We.effects.push(this)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,Ws.has(this)&&(Ws.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||Tl(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,jl(this),Ll(this);const e=ce,i=dt;ce=this,dt=!0;try{return this.fn()}finally{Nl(this),ce=e,dt=i,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)Qs(e);this.deps=this.depsTail=void 0,jl(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?Ws.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){Ys(this)&&this.run()}get dirty(){return Ys(this)}}let Ol=0,rn,sn;function Tl(t,e=!1){if(t.flags|=8,e){t.next=sn,sn=t;return}t.next=rn,rn=t}function Vs(){Ol++}function Gs(){if(--Ol>0)return;if(sn){let e=sn;for(sn=void 0;e;){const i=e.next;e.next=void 0,e.flags&=-9,e=i}}let t;for(;rn;){let e=rn;for(rn=void 0;e;){const i=e.next;if(e.next=void 0,e.flags&=-9,e.flags&1)try{e.trigger()}catch(n){t||(t=n)}e=i}}if(t)throw t}function Ll(t){for(let e=t.deps;e;e=e.nextDep)e.version=-1,e.prevActiveLink=e.dep.activeLink,e.dep.activeLink=e}function Nl(t){let e,i=t.depsTail,n=i;for(;n;){const r=n.prevDep;n.version===-1?(n===i&&(i=r),Qs(n),qp(n)):e=n,n.dep.activeLink=n.prevActiveLink,n.prevActiveLink=void 0,n=r}t.deps=e,t.depsTail=i}function Ys(t){for(let e=t.deps;e;e=e.nextDep)if(e.dep.version!==e.version||e.dep.computed&&(Ml(e.dep.computed)||e.dep.version!==e.version))return!0;return!!t._dirty}function Ml(t){if(t.flags&4&&!(t.flags&16)||(t.flags&=-17,t.globalVersion===on)||(t.globalVersion=on,!t.isSSR&&t.flags&128&&(!t.deps&&!t._dirty||!Ys(t))))return;t.flags|=2;const e=t.dep,i=ce,n=dt;ce=t,dt=!0;try{Ll(t);const r=t.fn(t._value);(e.version===0||Ke(r,t._value))&&(t.flags|=128,t._value=r,e.version++)}catch(r){throw e.version++,r}finally{ce=i,dt=n,Nl(t),t.flags&=-3}}function Qs(t,e=!1){const{dep:i,prevSub:n,nextSub:r}=t;if(n&&(n.nextSub=r,t.prevSub=void 0),r&&(r.prevSub=n,t.nextSub=void 0),i.subs===t&&(i.subs=n,!n&&i.computed)){i.computed.flags&=-5;for(let s=i.computed.deps;s;s=s.nextDep)Qs(s,!0)}!e&&!--i.sc&&i.map&&i.map.delete(i.key)}function qp(t){const{prevDep:e,nextDep:i}=t;e&&(e.nextDep=i,t.prevDep=void 0),i&&(i.prevDep=e,t.nextDep=void 0)}let dt=!0;const Dl=[];function wt(){Dl.push(dt),dt=!1}function _t(){const t=Dl.pop();dt=t===void 0?!0:t}function jl(t){const{cleanup:e}=t;if(t.cleanup=void 0,e){const i=ce;ce=void 0;try{e()}finally{ce=i}}}let on=0;class Hp{constructor(e,i){this.sub=e,this.dep=i,this.version=i.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}}class ar{constructor(e){this.computed=e,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0}track(e){if(!ce||!dt||ce===this.computed)return;let i=this.activeLink;if(i===void 0||i.sub!==ce)i=this.activeLink=new Hp(ce,this),ce.deps?(i.prevDep=ce.depsTail,ce.depsTail.nextDep=i,ce.depsTail=i):ce.deps=ce.depsTail=i,Ul(i);else if(i.version===-1&&(i.version=this.version,i.nextDep)){const n=i.nextDep;n.prevDep=i.prevDep,i.prevDep&&(i.prevDep.nextDep=n),i.prevDep=ce.depsTail,i.nextDep=void 0,ce.depsTail.nextDep=i,ce.depsTail=i,ce.deps===i&&(ce.deps=n)}return i}trigger(e){this.version++,on++,this.notify(e)}notify(e){Vs();try{for(let i=this.subs;i;i=i.prevSub)i.sub.notify()&&i.sub.dep.notify()}finally{Gs()}}}function Ul(t){if(t.dep.sc++,t.sub.flags&4){const e=t.dep.computed;if(e&&!t.dep.subs){e.flags|=20;for(let n=e.deps;n;n=n.nextDep)Ul(n)}const i=t.dep.subs;i!==t&&(t.prevSub=i,i&&(i.nextSub=t)),t.dep.subs=t}}const Js=new WeakMap,oi=Symbol(""),Xs=Symbol(""),an=Symbol("");function Oe(t,e,i){if(dt&&ce){let n=Js.get(t);n||Js.set(t,n=new Map);let r=n.get(i);r||(n.set(i,r=new ar),r.map=n,r.key=i),r.track()}}function Dt(t,e,i,n,r,s){const o=Js.get(t);if(!o){on++;return}const a=l=>{l&&l.trigger()};if(Vs(),e==="clear")o.forEach(a);else{const l=V(t),c=l&&Bs(i);if(l&&i==="length"){const u=Number(n);o.forEach((d,h)=>{(h==="length"||h===an||!Nt(h)&&h>=u)&&a(d)})}else switch((i!==void 0||o.has(void 0))&&a(o.get(i)),c&&a(o.get(an)),e){case"add":l?c&&a(o.get("length")):(a(o.get(oi)),Ei(t)&&a(o.get(Xs)));break;case"delete":l||(a(o.get(oi)),Ei(t)&&a(o.get(Xs)));break;case"set":Ei(t)&&a(o.get(oi));break}}Gs()}function $i(t){const e=ie(t);return e===t?e:(Oe(e,"iterate",an),st(t)?e:e.map(Ae))}function lr(t){return Oe(t=ie(t),"iterate",an),t}const zp={__proto__:null,[Symbol.iterator](){return Zs(this,Symbol.iterator,Ae)},concat(...t){return $i(this).concat(...t.map(e=>V(e)?$i(e):e))},entries(){return Zs(this,"entries",t=>(t[1]=Ae(t[1]),t))},every(t,e){return jt(this,"every",t,e,void 0,arguments)},filter(t,e){return jt(this,"filter",t,e,i=>i.map(Ae),arguments)},find(t,e){return jt(this,"find",t,e,Ae,arguments)},findIndex(t,e){return jt(this,"findIndex",t,e,void 0,arguments)},findLast(t,e){return jt(this,"findLast",t,e,Ae,arguments)},findLastIndex(t,e){return jt(this,"findLastIndex",t,e,void 0,arguments)},forEach(t,e){return jt(this,"forEach",t,e,void 0,arguments)},includes(...t){return eo(this,"includes",t)},indexOf(...t){return eo(this,"indexOf",t)},join(t){return $i(this).join(t)},lastIndexOf(...t){return eo(this,"lastIndexOf",t)},map(t,e){return jt(this,"map",t,e,void 0,arguments)},pop(){return ln(this,"pop")},push(...t){return ln(this,"push",t)},reduce(t,...e){return Fl(this,"reduce",t,e)},reduceRight(t,...e){return Fl(this,"reduceRight",t,e)},shift(){return ln(this,"shift")},some(t,e){return jt(this,"some",t,e,void 0,arguments)},splice(...t){return ln(this,"splice",t)},toReversed(){return $i(this).toReversed()},toSorted(t){return $i(this).toSorted(t)},toSpliced(...t){return $i(this).toSpliced(...t)},unshift(...t){return ln(this,"unshift",t)},values(){return Zs(this,"values",Ae)}};function Zs(t,e,i){const n=lr(t),r=n[e]();return n!==t&&!st(t)&&(r._next=r.next,r.next=()=>{const s=r._next();return s.done||(s.value=i(s.value)),s}),r}const Kp=Array.prototype;function jt(t,e,i,n,r,s){const o=lr(t),a=o!==t&&!st(t),l=o[e];if(l!==Kp[e]){const d=l.apply(t,s);return a?Ae(d):d}let c=i;o!==t&&(a?c=function(d,h){return i.call(this,Ae(d),h,t)}:i.length>2&&(c=function(d,h){return i.call(this,d,h,t)}));const u=l.call(o,c,n);return a&&r?r(u):u}function Fl(t,e,i,n){const r=lr(t);let s=i;return r!==t&&(st(t)?i.length>3&&(s=function(o,a,l){return i.call(this,o,a,l,t)}):s=function(o,a,l){return i.call(this,o,Ae(a),l,t)}),r[e](s,...n)}function eo(t,e,i){const n=ie(t);Oe(n,"iterate",an);const r=n[e](...i);return(r===-1||r===!1)&&ro(i[0])?(i[0]=ie(i[0]),n[e](...i)):r}function ln(t,e,i=[]){wt(),Vs();const n=ie(t)[e].apply(t,i);return Gs(),_t(),n}const Wp=js("__proto__,__v_isRef,__isVue"),Bl=new Set(Object.getOwnPropertyNames(Symbol).filter(t=>t!=="arguments"&&t!=="caller").map(t=>Symbol[t]).filter(Nt));function Vp(t){Nt(t)||(t=String(t));const e=ie(this);return Oe(e,"has",t),e.hasOwnProperty(t)}class ql{constructor(e=!1,i=!1){this._isReadonly=e,this._isShallow=i}get(e,i,n){if(i==="__v_skip")return e.__v_skip;const r=this._isReadonly,s=this._isShallow;if(i==="__v_isReactive")return!r;if(i==="__v_isReadonly")return r;if(i==="__v_isShallow")return s;if(i==="__v_raw")return n===(r?s?Gl:Vl:s?Wl:Kl).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(n)?e:void 0;const o=V(e);if(!r){let l;if(o&&(l=zp[i]))return l;if(i==="hasOwnProperty")return Vp}const a=Reflect.get(e,i,Ce(e)?e:n);if((Nt(i)?Bl.has(i):Wp(i))||(r||Oe(e,"get",i),s))return a;if(Ce(a)){const l=o&&Bs(i)?a:a.value;return r&&pe(l)?no(l):l}return pe(a)?r?no(a):io(a):a}}class Hl extends ql{constructor(e=!1){super(!1,e)}set(e,i,n,r){let s=e[i];if(!this._isShallow){const l=Vt(s);if(!st(n)&&!Vt(n)&&(s=ie(s),n=ie(n)),!V(e)&&Ce(s)&&!Ce(n))return l||(s.value=n),!0}const o=V(e)&&Bs(i)?Number(i)<e.length:se(e,i),a=Reflect.set(e,i,n,Ce(e)?e:r);return e===ie(r)&&(o?Ke(n,s)&&Dt(e,"set",i,n):Dt(e,"add",i,n)),a}deleteProperty(e,i){const n=se(e,i);e[i];const r=Reflect.deleteProperty(e,i);return r&&n&&Dt(e,"delete",i,void 0),r}has(e,i){const n=Reflect.has(e,i);return(!Nt(i)||!Bl.has(i))&&Oe(e,"has",i),n}ownKeys(e){return Oe(e,"iterate",V(e)?"length":oi),Reflect.ownKeys(e)}}class zl extends ql{constructor(e=!1){super(!0,e)}set(e,i){return!0}deleteProperty(e,i){return!0}}const Gp=new Hl,Yp=new zl,Qp=new Hl(!0),Jp=new zl(!0),to=t=>t,cr=t=>Reflect.getPrototypeOf(t);function Xp(t,e,i){return function(...n){const r=this.__v_raw,s=ie(r),o=Ei(s),a=t==="entries"||t===Symbol.iterator&&o,l=t==="keys"&&o,c=r[t](...n),u=i?to:e?hr:Ae;return!e&&Oe(s,"iterate",l?Xs:oi),{next(){const{value:d,done:h}=c.next();return h?{value:d,done:h}:{value:a?[u(d[0]),u(d[1])]:u(d),done:h}},[Symbol.iterator](){return this}}}}function ur(t){return function(...e){return t==="delete"?!1:t==="clear"?void 0:this}}function Zp(t,e){const i={get(r){const s=this.__v_raw,o=ie(s),a=ie(r);t||(Ke(r,a)&&Oe(o,"get",r),Oe(o,"get",a));const{has:l}=cr(o),c=e?to:t?hr:Ae;if(l.call(o,r))return c(s.get(r));if(l.call(o,a))return c(s.get(a));s!==o&&s.get(r)},get size(){const r=this.__v_raw;return!t&&Oe(ie(r),"iterate",oi),r.size},has(r){const s=this.__v_raw,o=ie(s),a=ie(r);return t||(Ke(r,a)&&Oe(o,"has",r),Oe(o,"has",a)),r===a?s.has(r):s.has(r)||s.has(a)},forEach(r,s){const o=this,a=o.__v_raw,l=ie(a),c=e?to:t?hr:Ae;return!t&&Oe(l,"iterate",oi),a.forEach((u,d)=>r.call(s,c(u),c(d),o))}};return Re(i,t?{add:ur("add"),set:ur("set"),delete:ur("delete"),clear:ur("clear")}:{add(r){!e&&!st(r)&&!Vt(r)&&(r=ie(r));const s=ie(this);return cr(s).has.call(s,r)||(s.add(r),Dt(s,"add",r,r)),this},set(r,s){!e&&!st(s)&&!Vt(s)&&(s=ie(s));const o=ie(this),{has:a,get:l}=cr(o);let c=a.call(o,r);c||(r=ie(r),c=a.call(o,r));const u=l.call(o,r);return o.set(r,s),c?Ke(s,u)&&Dt(o,"set",r,s):Dt(o,"add",r,s),this},delete(r){const s=ie(this),{has:o,get:a}=cr(s);let l=o.call(s,r);l||(r=ie(r),l=o.call(s,r)),a&&a.call(s,r);const c=s.delete(r);return l&&Dt(s,"delete",r,void 0),c},clear(){const r=ie(this),s=r.size!==0,o=r.clear();return s&&Dt(r,"clear",void 0,void 0),o}}),["keys","values","entries",Symbol.iterator].forEach(r=>{i[r]=Xp(r,t,e)}),i}function fr(t,e){const i=Zp(t,e);return(n,r,s)=>r==="__v_isReactive"?!t:r==="__v_isReadonly"?t:r==="__v_raw"?n:Reflect.get(se(i,r)&&r in n?i:n,r,s)}const em={get:fr(!1,!1)},tm={get:fr(!1,!0)},im={get:fr(!0,!1)},nm={get:fr(!0,!0)},Kl=new WeakMap,Wl=new WeakMap,Vl=new WeakMap,Gl=new WeakMap;function rm(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function sm(t){return t.__v_skip||!Object.isExtensible(t)?0:rm(Op(t))}function io(t){return Vt(t)?t:dr(t,!1,Gp,em,Kl)}function om(t){return dr(t,!1,Qp,tm,Wl)}function no(t){return dr(t,!0,Yp,im,Vl)}function Zv(t){return dr(t,!0,Jp,nm,Gl)}function dr(t,e,i,n,r){if(!pe(t)||t.__v_raw&&!(e&&t.__v_isReactive))return t;const s=sm(t);if(s===0)return t;const o=r.get(t);if(o)return o;const a=new Proxy(t,s===2?n:i);return r.set(t,a),a}function Pi(t){return Vt(t)?Pi(t.__v_raw):!!(t&&t.__v_isReactive)}function Vt(t){return!!(t&&t.__v_isReadonly)}function st(t){return!!(t&&t.__v_isShallow)}function ro(t){return t?!!t.__v_raw:!1}function ie(t){const e=t&&t.__v_raw;return e?ie(e):t}function am(t){return!se(t,"__v_skip")&&Object.isExtensible(t)&&$l(t,"__v_skip",!0),t}const Ae=t=>pe(t)?io(t):t,hr=t=>pe(t)?no(t):t;function Ce(t){return t?t.__v_isRef===!0:!1}function Me(t){return Ql(t,!1)}function Yl(t){return Ql(t,!0)}function Ql(t,e){return Ce(t)?t:new lm(t,e)}class lm{constructor(e,i){this.dep=new ar,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=i?e:ie(e),this._value=i?e:Ae(e),this.__v_isShallow=i}get value(){return this.dep.track(),this._value}set value(e){const i=this._rawValue,n=this.__v_isShallow||st(e)||Vt(e);e=n?e:ie(e),Ke(e,i)&&(this._rawValue=e,this._value=n?e:Ae(e),this.dep.trigger())}}function so(t){return Ce(t)?t.value:t}const cm={get:(t,e,i)=>e==="__v_raw"?t:so(Reflect.get(t,e,i)),set:(t,e,i,n)=>{const r=t[e];return Ce(r)&&!Ce(i)?(r.value=i,!0):Reflect.set(t,e,i,n)}};function Jl(t){return Pi(t)?t:new Proxy(t,cm)}class um{constructor(e){this.__v_isRef=!0,this._value=void 0;const i=this.dep=new ar,{get:n,set:r}=e(i.track.bind(i),i.trigger.bind(i));this._get=n,this._set=r}get value(){return this._value=this._get()}set value(e){this._set(e)}}function fm(t){return new um(t)}class dm{constructor(e,i,n){this.fn=e,this.setter=i,this._value=void 0,this.dep=new ar(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=on-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!i,this.isSSR=n}notify(){if(this.flags|=16,!(this.flags&8)&&ce!==this)return Tl(this,!0),!0}get value(){const e=this.dep.track();return Ml(this),e&&(e.version=this.dep.version),this._value}set value(e){this.setter&&this.setter(e)}}function hm(t,e,i=!1){let n,r;return G(t)?n=t:(n=t.get,r=t.set),new dm(n,r,i)}const pr={},mr=new WeakMap;let ai;function pm(t,e=!1,i=ai){if(i){let n=mr.get(i);n||mr.set(i,n=[]),n.push(t)}}function mm(t,e,i=ne){const{immediate:n,deep:r,once:s,scheduler:o,augmentJob:a,call:l}=i,c=g=>r?g:st(g)||r===!1||r===0?Ut(g,1):Ut(g);let u,d,h,p,f=!1,_=!1;if(Ce(t)?(d=()=>t.value,f=st(t)):Pi(t)?(d=()=>c(t),f=!0):V(t)?(_=!0,f=t.some(g=>Pi(g)||st(g)),d=()=>t.map(g=>{if(Ce(g))return g.value;if(Pi(g))return c(g);if(G(g))return l?l(g,2):g()})):G(t)?e?d=l?()=>l(t,2):t:d=()=>{if(h){wt();try{h()}finally{_t()}}const g=ai;ai=u;try{return l?l(t,3,[p]):t(p)}finally{ai=g}}:d=vt,e&&r){const g=d,v=r===!0?1/0:r;d=()=>Ut(g(),v)}const P=Bp(),C=()=>{u.stop(),P&&P.active&&Fs(P.effects,u)};if(s&&e){const g=e;e=(...v)=>{g(...v),C()}}let R=_?new Array(t.length).fill(pr):pr;const y=g=>{if(!(!(u.flags&1)||!u.dirty&&!g))if(e){const v=u.run();if(r||f||(_?v.some((w,S)=>Ke(w,R[S])):Ke(v,R))){h&&h();const w=ai;ai=u;try{const S=[v,R===pr?void 0:_&&R[0]===pr?[]:R,p];R=v,l?l(e,3,S):e(...S)}finally{ai=w}}}else u.run()};return a&&a(y),u=new Il(d),u.scheduler=o?()=>o(y,!1):y,p=g=>pm(g,!1,u),h=u.onStop=()=>{const g=mr.get(u);if(g){if(l)l(g,4);else for(const v of g)v();mr.delete(u)}},e?n?y(!0):R=u.run():o?o(y.bind(null,!0),!0):u.run(),C.pause=u.pause.bind(u),C.resume=u.resume.bind(u),C.stop=C,C}function Ut(t,e=1/0,i){if(e<=0||!pe(t)||t.__v_skip||(i=i||new Map,(i.get(t)||0)>=e))return t;if(i.set(t,e),e--,Ce(t))Ut(t.value,e,i);else if(V(t))for(let n=0;n<t.length;n++)Ut(t[n],e,i);else if(_l(t)||Ei(t))t.forEach(n=>{Ut(n,e,i)});else if(kl(t)){for(const n in t)Ut(t[n],e,i);for(const n of Object.getOwnPropertySymbols(t))Object.prototype.propertyIsEnumerable.call(t,n)&&Ut(t[n],e,i)}return t}const cn=[];let oo=!1;function ew(t,...e){if(oo)return;oo=!0,wt();const i=cn.length?cn[cn.length-1].component:null,n=i&&i.appContext.config.warnHandler,r=gm();if(n)Ci(n,i,11,[t+e.map(s=>{var o,a;return(a=(o=s.toString)==null?void 0:o.call(s))!=null?a:JSON.stringify(s)}).join(""),i&&i.proxy,r.map(({vnode:s})=>`at <${Vc(i,s.type)}>`).join(`
20
+ - Documentation: ${xt.HOME_URL}
21
+ - Bug Reports: ${xt.GITHUB_URL}`)}function $l(){const t=document.querySelector('meta[name="generator"][content^="MediaWiki"]')!==null,e=document.querySelector('link[rel="EditURI"]')?.href?.split("?")[0];return t&&e?e:void 0}function Bp(t,e){const i=Symbol.for(t);return window[i]?!1:(window[i]=!0,e(),!0)}var qp=Object.create,qs=Object.defineProperty,Hp=Object.getOwnPropertyDescriptor,El=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Pl=t=>{throw TypeError(t)},zp=(t,e,i)=>e in t?qs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Kp=(t,e)=>qs(t,"name",{value:e,configurable:!0}),Wp=t=>[,,,qp(t?.[El("metadata")]??null)],Gp=["class","method","getter","setter","accessor","field","value","get","set"],Cl=t=>t!==void 0&&typeof t!="function"?Pl("Function expected"):t,Vp=(t,e,i,n,r)=>({kind:Gp[t],name:e,metadata:n,addInitializer:s=>i._?Pl("Already initialized"):r.push(Cl(s||null))}),Yp=(t,e)=>zp(e,El("metadata"),t[3]),Qp=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Xp=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&Hp(r,i));Kp(r,i);for(var d=n.length-1;d>=0;d--)l=Vp(c,i,a={},t[3],h),o=(0,n[d])(r,l),a._=1,Cl(o)&&(r=o);return Yp(t,r),p&&qs(r,i,p),u?c^4?s:p:r},Rl,Hs,Il;Rl=[Ee(["wiki","preferences","$"])];class sr extends(Il=et){constructor(e){super(e,{},"analytics"),this.ctx=e,this._usages=[],this._timer=null,this.MAX_QUEUE_SIZE=50,this.INTERVAL_MS=60*1e3,this._setupTimer(),this._registerUnloadHandler(),this._showConfirmNotify(),this._initPluginListeners(),e.set("analytics",this)}start(){const e=this.ctx,i=e.$;e.preferences.registerCustomConfig("analytics",R.object({"analytics._intro":R.const(m("section",{children:[m("h3",{children:i`InPageEdit Analytics`}),m("p",{children:i`InPageEdit Analytics is the companion analytics platform for the InPageEdit NEXT project. By collecting and displaying usage data from around the world, it helps developers and the community better understand how the tool is used, optimize feature design, and enhance user experience.`}),m("h4",{children:i`What data will be collected?`}),m("ol",{style:{listStyle:"number",paddingLeft:"1em"},children:[m("li",{children:[m("strong",{children:i`Usage data`}),":"," ",i`When and which features you use, what pages you edit, etc.`]}),m("li",{children:[m("strong",{children:i`User information`}),": ",i`Your user name and user ID.`]}),m("li",{children:[m("strong",{children:i`Site information`}),": ",i`This wiki's url and site name.`]})]}),m("p",{children:m("strong",{children:i`NO sensitive data will be collected.`})}),m("div",{style:{display:"grid",gap:"0.5rem"},children:[m("a",{href:this.analyticsDashUrl,target:"_blank",rel:"noopener noreferrer",children:m("button",{className:"btn",style:{width:"100%"},children:i`Analytics Platform`})}),m("a",{href:`${this.analyticsDashUrl}/_redirect/user?${new URLSearchParams({siteApi:this.ctx.wiki.getSciprtUrl("api"),mwUserId:this.ctx.wiki.userInfo.id.toString()}).toString()}`,target:"_blank",rel:"noopener noreferrer",children:m("button",{className:"btn",style:{width:"100%"},children:i`View My Data`})})]})]})).role("raw-html"),"analytics.enabled":R.boolean().description(i`prefs.analytics.enabled`).default(!1)}).description(i`prefs.analytics.$`),"general")}get analyticsDashUrl(){return xt.ANALYTICS_DASH_URL}get analyticsApiBase(){return xt.ANALYTICS_API_BASE}_setupTimer(){this._timer=setInterval(()=>{this._usages.length>0&&this.sendBeacon()},this.INTERVAL_MS)}_registerUnloadHandler(){const e=()=>{this._usages.length>0&&this.sendBeacon()};window.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&e()}),window.addEventListener("pagehide",e),window.addEventListener("beforeunload",e)}async _showConfirmNotify(){const e=this.ctx.$;this.ctx.inject(["modal","storage"],async i=>{const n="analytics/confirm-shown",r=await i.storage.simpleKV.get(n),s=await i.preferences.get("analytics.enabled");r||s||i.modal.notify("confirm",{title:e`Enable Analytics`,content:m("div",{children:[m("p",{children:e`Help us improve InPageEdit by sharing your usage data with us.`}),m("p",{children:e`What data will be collected?`}),m("ul",{style:{listStyle:"auto",paddingLeft:"1.5em"},children:[m("li",{children:[e`Usage data`,": ",e`When and which features you use, what pages you edit, etc.`]}),m("li",{children:[e`User information`,": ",e`Your user name and user ID.`]}),m("li",{children:[e`Site information`,": ",e`This wiki's url and site name.`]})]}),m("p",{children:m("strong",{children:e`NO sensitive data will be collected.`})})]}),okBtn:{label:e`Enable`},cancelBtn:{label:e`Disable`},closeAfter:0,onClose:()=>{this.ctx.storage.simpleKV.set(n,1)}},o=>{i.preferences.set("analytics.enabled",o),o&&this.addEvent("analytics","enabled")})})}_initPluginListeners(){const e=this.ctx;e.on("in-article-links/anchor-clicked",i=>{this.addEvent("in-article-links",ki(i.action))}),e.on("quick-diff/loaded",i=>{this.addEvent("quick-diff","loaded",i.compare.fromtitle)}),e.on("quick-redirect/submit",i=>{this.addEvent("quick-redirect","submit",i.payload.to||void 0)}),e.on("quick-preview/loaded",i=>{this.addEvent("quick-preview","loaded",i.wikiPage.title)}),e.on("quick-edit/wiki-page",i=>{this.addEvent("quick-edit",void 0,i.wikiPage.title)}),e.on("quick-edit/submit",i=>{this.addEvent("quick-edit","submit",i.wikiPage.title)}),e.on("quick-move/submit",i=>{this.addEvent("quick-move","submit")}),e.on("toolbox/button-clicked",i=>{this.addEvent("toolbox",`button-clicked#${i.id||"unknown"}`)})}addEvent(e,i,n){const r={ts:Date.now(),feature:e,subtype:i,page:n};return this._usages.push(r),this._usages.length>=this.MAX_QUEUE_SIZE&&this.sendBeacon(),this}async sendBeacon(){if(this._usages.length===0)return!0;if(!await this.ctx.preferences.get("analytics.enabled",!1))return this.logger.debug("Analytics disabled, skipping"),!0;const i=this._usages.splice(0,this._usages.length),n={siteApi:this.ctx.wiki.getSciprtUrl("api"),siteName:this.ctx.wiki.siteInfo.general.sitename,userId:this.ctx.wiki.userInfo.id,userName:this.ctx.wiki.userInfo.name,version:this.ctx.version.split("-")[0],usages:i},r=JSON.stringify(n),s=`${this.analyticsApiBase}/submit`;if(navigator?.sendBeacon?.(s,r))return this.logger.debug("Beacon sent successfully",n),!0;{this.logger.debug("Beacon failed, sending via XMLHttpRequest");const{promise:a,resolve:l,reject:c}=re();try{const u=new XMLHttpRequest;u.open("POST",s,!0),u.setRequestHeader("Content-Type","application/json"),u.send(r),u.onload=()=>{this.logger.debug("Beacon sent successfully via XMLHttpRequest",n),l(u.status>=200&&u.status<300)},u.onerror=()=>{c(new Error("Failed to send beacon"))}}catch(u){c(u)}return a}}stop(){this._timer!==null&&(clearInterval(this._timer),this._timer=null),this._usages.length>0&&this.sendBeacon()}}Hs=Wp(Il),sr=Xp(Hs,0,"PluginAnalytics",Rl,sr),Qp(Hs,1,sr);const Jp=Object.freeze(Object.defineProperty({__proto__:null,get PluginAnalytics(){return sr}},Symbol.toStringTag,{value:"Module"})),Al=t=>m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...t,class:`icon icon-tabler icons-tabler-outline icon-tabler-pencil-bolt ${t.className||""}`,children:[m("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),m("path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),m("path",{d:"M13.5 6.5l4 4"}),m("path",{d:"M19 16l-2 3h4l-2 3"})]});var Zp=Object.create,zs=Object.defineProperty,eg=Object.getOwnPropertyDescriptor,Ol=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Tl=t=>{throw TypeError(t)},tg=(t,e,i)=>e in t?zs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,ig=(t,e)=>zs(t,"name",{value:e,configurable:!0}),ng=t=>[,,,Zp(t?.[Ol("metadata")]??null)],rg=["class","method","getter","setter","accessor","field","value","get","set"],Ll=t=>t!==void 0&&typeof t!="function"?Tl("Function expected"):t,sg=(t,e,i,n,r)=>({kind:rg[t],name:e,metadata:n,addInitializer:s=>i._?Tl("Already initialized"):r.push(Ll(s||null))}),og=(t,e)=>tg(e,Ol("metadata"),t[3]),ag=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},lg=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&eg(r,i));ig(r,i);for(var d=n.length-1;d>=0;d--)l=sg(c,i,a={},t[3],h),o=(0,n[d])(r,l),a._=1,Ll(o)&&(r=o);return og(t,r),p&&zs(r,i,p),u?c^4?s:p:r},Ml,Ks,Nl;Ml=[Ee(["wiki","wikiTitle","preferences","$"]),Vt(R.object({"inArticleLinks.enable":R.boolean().description("Whether to enable in-article links").default(!0),"inArticleLinks.quickDiff.enable":R.boolean().description("Whether to enable in-article links for quick diff").default(!0),"inArticleLinks.quickEdit.enable":R.boolean().description("Whether to enable in-article links for quick edit").default(!0),"inArticleLinks.quickEdit.redlinks":R.boolean().description("Whether to show quick edit button for redlinks").default(!0)}).description("In-article links preferences").extra("category","in-article-links"))];class or extends(Nl=et){constructor(e){super(e,{linkClassName:"ipe__in-article-link"},"InArticleLinks"),this._cachedAnchorInfo=new WeakMap,this.ctx.set("inArticleLinks",this);const i=this.ctx.$;this.ctx.preferences.defineCategory({name:"in-article-links",label:i`prefs.inArticleLinks.label`,description:i`prefs.inArticleLinks.$`,index:9})}async start(){await this.ctx.preferences.get("inArticleLinks.quickEdit.enable")&&this.handleQuickEdit(),await this.ctx.preferences.get("inArticleLinks.quickDiff.enable")&&this.handleQuickDiff()}async stop(){Array.from(document.getElementsByClassName(this.config.linkClassName)).forEach(e=>{e.remove()}),document.querySelectorAll("[data-ipe-edit-mounted]").forEach(e=>{e.dataset.ipeEditMounted=void 0})}parseAnchor(e){if(!(e instanceof HTMLAnchorElement))return null;const i=this._cachedAnchorInfo.get(e);if(i)return i;const n=e.getAttribute("href")||"";if(!this.ctx.wikiTitle.validateHrefAttr(n))return null;const r=e.href||"",s=this.ctx.wikiTitle.parseWikiLink(r);if(!s)return null;const o={$el:e,kind:e.closest('[typeof^="mw:File"]')?"mw:File":"normal",external:e.classList.contains("external")||!!n.startsWith("http"),redlink:e.classList.contains("new")||s.params.has("redlink"),...s};return this._cachedAnchorInfo.set(e,o),this.ctx.emit("in-article-links/anchor-parsed",{ctx:this.ctx,anchor:e,info:o}),o}scanAnchors(e,i){const n=e.querySelectorAll("a[href]");return Array.from(n).map(r=>this.parseAnchor(r)).filter(r=>r!==null&&(!i||i(r)))}async handleQuickEdit(){let e=!1;const i=await this.ctx.preferences.get("inArticleLinks.quickEdit.redlinks");this.ctx.inject(["quickEdit"],n=>{e=!0,n.on("dispose",()=>{e=!1}),window?.mw?.hook?.("wikipage.content").add(r=>{if(!e)return;this.scanAnchors(r.get(0),({action:o,title:a,redlink:l})=>i||!l?["edit","create"].includes(o)?!0:a?.isSpecial("edit")||a?.isSpecial("newsection")?a.getMainText().split("/").length>=2:!1:!1).forEach(o=>{const{$el:a,title:l,pageId:c,params:u}=o;if(a.dataset.ipeEditMounted)return;if(a.dataset.ipeEditMounted="1",u.has("preload")||u.has("redo"))return this.ctx.logger.debug(a,"Not compatible with quick edit");const h=l?.getPrefixedDBKey()||"",p=u.get("section")?.replace(/^T-/,"")||void 0,d=u.get("oldid"),w=u.has("redlink");let S;p==="new"||l?.isSpecial("newsection")?S="new":p&&/^\d+$/.test(p)&&(S=parseInt(p,10));const E=d?parseInt(d,10):void 0,M={title:h,pageId:c||void 0,section:S,revision:E,createOnly:w},g=m("a",{href:"#ipe://quick-edit/",dataset:M,className:`${this.config.linkClassName} ipe-quick-edit ${w?"ipe-quick-edit--create-only":""}`,style:{userSelect:"none",marginLeft:"0.2em"},onClick:y=>{y.preventDefault(),this.ctx.emit("in-article-links/anchor-clicked",{ctx:this.ctx,anchor:a,info:o,event:y,action:"quickEdit"}),n.quickEdit.showModal(M)},children:m(Al,{className:"ipe-icon"})});a.insertAdjacentElement("afterend",g)})})})}handleQuickDiff(){let e=!1;const i=n=>["prev","next","cur"].includes(n);this.ctx.inject(["quickDiff"],n=>{e=!0,n.on("dispose",()=>{e=!1}),window?.mw?.hook?.("wikipage.content").add(r=>{if(!e)return;this.scanAnchors(r.get(0),({params:o,title:a})=>!!(o.has("diff")||a?.isSpecial("diff"))).forEach(o=>{const{$el:a,title:l,params:c}=o;if(a.dataset.ipeDiffMounted)return;a.dataset.ipeDiffMounted="1";let u,f;if(l?.getNamespaceId()===-1?([,f,u]=l.getMainDBKey().split("/"),u||(u="prev")):(u=c.get("diff"),f=c.get("oldid")),!u||!f)return;const h={};i(u)?(h.fromrev=parseInt(f),h.torelative=u):(h.fromrev=parseInt(f),h.torev=parseInt(u));const p=m("a",{href:"#ipe://quick-diff/",dataset:h,className:`${this.config.linkClassName} ipe-quick-diff`,style:{userSelect:"none",marginLeft:"0.2em"},onClick:d=>{d.preventDefault(),this.ctx.emit("in-article-links/anchor-clicked",{ctx:this.ctx,anchor:a,info:o,event:d,action:"quickDiff"}),n.quickDiff.comparePages(h)},children:m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-file-diff ipe-icon",children:[m("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),m("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),m("path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z"}),m("path",{d:"M12 10l0 4"}),m("path",{d:"M10 12l4 0"}),m("path",{d:"M10 17l4 0"})]})});a.insertAdjacentElement("afterend",p)})})})}}Ks=ng(Nl),or=lg(Ks,0,"PluginInArticleLinks",Ml,or),ag(Ks,1,or);const cg=Object.freeze(Object.defineProperty({__proto__:null,get PluginInArticleLinks(){return or}},Symbol.toStringTag,{value:"Module"}));function Ws(t){const e=Object.create(null);for(const i of t.split(","))e[i]=1;return i=>i in e}const ne={},Ei=[],St=()=>{},Dl=()=>!1,ar=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&(t.charCodeAt(2)>122||t.charCodeAt(2)<97),Gs=t=>t.startsWith("onUpdate:"),Ae=Object.assign,Vs=(t,e)=>{const i=t.indexOf(e);i>-1&&t.splice(i,1)},ug=Object.prototype.hasOwnProperty,se=(t,e)=>ug.call(t,e),Y=Array.isArray,Pi=t=>lr(t)==="[object Map]",jl=t=>lr(t)==="[object Set]",Q=t=>typeof t=="function",_e=t=>typeof t=="string",Dt=t=>typeof t=="symbol",ye=t=>t!==null&&typeof t=="object",Ul=t=>(ye(t)||Q(t))&&Q(t.then)&&Q(t.catch),Fl=Object.prototype.toString,lr=t=>Fl.call(t),fg=t=>lr(t).slice(8,-1),Bl=t=>lr(t)==="[object Object]",Ys=t=>_e(t)&&t!=="NaN"&&t[0]!=="-"&&""+parseInt(t,10)===t,ln=Ws(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),cr=t=>{const e=Object.create(null);return(i=>e[i]||(e[i]=t(i)))},dg=/-\w/g,jt=cr(t=>t.replace(dg,e=>e.slice(1).toUpperCase())),hg=/\B([A-Z])/g,Yt=cr(t=>t.replace(hg,"-$1").toLowerCase()),ql=cr(t=>t.charAt(0).toUpperCase()+t.slice(1)),Qs=cr(t=>t?`on${ql(t)}`:""),Ve=(t,e)=>!Object.is(t,e),ur=(t,...e)=>{for(let i=0;i<t.length;i++)t[i](...e)},Hl=(t,e,i,n=!1)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,writable:n,value:i})},Xs=t=>{const e=parseFloat(t);return isNaN(e)?t:e};let zl;const fr=()=>zl||(zl=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function Js(t){if(Y(t)){const e={};for(let i=0;i<t.length;i++){const n=t[i],r=_e(n)?yg(n):Js(n);if(r)for(const s in r)e[s]=r[s]}return e}else if(_e(t)||ye(t))return t}const pg=/;(?![^(]*\))/g,gg=/:([^]+)/,mg=/\/\*[^]*?\*\//g;function yg(t){const e={};return t.replace(mg,"").split(pg).forEach(i=>{if(i){const n=i.split(gg);n.length>1&&(e[n[0].trim()]=n[1].trim())}}),e}function pt(t){let e="";if(_e(t))e=t;else if(Y(t))for(let i=0;i<t.length;i++){const n=pt(t[i]);n&&(e+=n+" ")}else if(ye(t))for(const i in t)t[i]&&(e+=i+" ");return e.trim()}const bg=Ws("itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly");function Kl(t){return!!t||t===""}const Wl=t=>!!(t&&t.__v_isRef===!0),ue=t=>_e(t)?t:t==null?"":Y(t)||ye(t)&&(t.toString===Fl||!Q(t.toString))?Wl(t)?ue(t.value):JSON.stringify(t,Gl,2):String(t),Gl=(t,e)=>Wl(e)?Gl(t,e.value):Pi(e)?{[`Map(${e.size})`]:[...e.entries()].reduce((i,[n,r],s)=>(i[Zs(n,s)+" =>"]=r,i),{})}:jl(e)?{[`Set(${e.size})`]:[...e.values()].map(i=>Zs(i))}:Dt(e)?Zs(e):ye(e)&&!Y(e)&&!Bl(e)?String(e):e,Zs=(t,e="")=>{var i;return Dt(t)?`Symbol(${(i=t.description)!=null?i:e})`:t};let Ye;class vg{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this.parent=Ye,!e&&Ye&&(this.index=(Ye.scopes||(Ye.scopes=[])).push(this)-1)}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let e,i;if(this.scopes)for(e=0,i=this.scopes.length;e<i;e++)this.scopes[e].pause();for(e=0,i=this.effects.length;e<i;e++)this.effects[e].pause()}}resume(){if(this._active&&this._isPaused){this._isPaused=!1;let e,i;if(this.scopes)for(e=0,i=this.scopes.length;e<i;e++)this.scopes[e].resume();for(e=0,i=this.effects.length;e<i;e++)this.effects[e].resume()}}run(e){if(this._active){const i=Ye;try{return Ye=this,e()}finally{Ye=i}}}on(){++this._on===1&&(this.prevScope=Ye,Ye=this)}off(){this._on>0&&--this._on===0&&(Ye=this.prevScope,this.prevScope=void 0)}stop(e){if(this._active){this._active=!1;let i,n;for(i=0,n=this.effects.length;i<n;i++)this.effects[i].stop();for(this.effects.length=0,i=0,n=this.cleanups.length;i<n;i++)this.cleanups[i]();if(this.cleanups.length=0,this.scopes){for(i=0,n=this.scopes.length;i<n;i++)this.scopes[i].stop(!0);this.scopes.length=0}if(!this.detached&&this.parent&&!e){const r=this.parent.scopes.pop();r&&r!==this&&(this.parent.scopes[this.index]=r,r.index=this.index)}this.parent=void 0}}}function wg(){return Ye}let fe;const eo=new WeakSet;class Vl{constructor(e){this.fn=e,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.next=void 0,this.cleanup=void 0,this.scheduler=void 0,Ye&&Ye.active&&Ye.effects.push(this)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,eo.has(this)&&(eo.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||Ql(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,tc(this),Xl(this);const e=fe,i=gt;fe=this,gt=!0;try{return this.fn()}finally{Jl(this),fe=e,gt=i,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)ro(e);this.deps=this.depsTail=void 0,tc(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?eo.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){no(this)&&this.run()}get dirty(){return no(this)}}let Yl=0,cn,un;function Ql(t,e=!1){if(t.flags|=8,e){t.next=un,un=t;return}t.next=cn,cn=t}function to(){Yl++}function io(){if(--Yl>0)return;if(un){let e=un;for(un=void 0;e;){const i=e.next;e.next=void 0,e.flags&=-9,e=i}}let t;for(;cn;){let e=cn;for(cn=void 0;e;){const i=e.next;if(e.next=void 0,e.flags&=-9,e.flags&1)try{e.trigger()}catch(n){t||(t=n)}e=i}}if(t)throw t}function Xl(t){for(let e=t.deps;e;e=e.nextDep)e.version=-1,e.prevActiveLink=e.dep.activeLink,e.dep.activeLink=e}function Jl(t){let e,i=t.depsTail,n=i;for(;n;){const r=n.prevDep;n.version===-1?(n===i&&(i=r),ro(n),_g(n)):e=n,n.dep.activeLink=n.prevActiveLink,n.prevActiveLink=void 0,n=r}t.deps=e,t.depsTail=i}function no(t){for(let e=t.deps;e;e=e.nextDep)if(e.dep.version!==e.version||e.dep.computed&&(Zl(e.dep.computed)||e.dep.version!==e.version))return!0;return!!t._dirty}function Zl(t){if(t.flags&4&&!(t.flags&16)||(t.flags&=-17,t.globalVersion===fn)||(t.globalVersion=fn,!t.isSSR&&t.flags&128&&(!t.deps&&!t._dirty||!no(t))))return;t.flags|=2;const e=t.dep,i=fe,n=gt;fe=t,gt=!0;try{Xl(t);const r=t.fn(t._value);(e.version===0||Ve(r,t._value))&&(t.flags|=128,t._value=r,e.version++)}catch(r){throw e.version++,r}finally{fe=i,gt=n,Jl(t),t.flags&=-3}}function ro(t,e=!1){const{dep:i,prevSub:n,nextSub:r}=t;if(n&&(n.nextSub=r,t.prevSub=void 0),r&&(r.prevSub=n,t.nextSub=void 0),i.subs===t&&(i.subs=n,!n&&i.computed)){i.computed.flags&=-5;for(let s=i.computed.deps;s;s=s.nextDep)ro(s,!0)}!e&&!--i.sc&&i.map&&i.map.delete(i.key)}function _g(t){const{prevDep:e,nextDep:i}=t;e&&(e.nextDep=i,t.prevDep=void 0),i&&(i.prevDep=e,t.nextDep=void 0)}let gt=!0;const ec=[];function kt(){ec.push(gt),gt=!1}function $t(){const t=ec.pop();gt=t===void 0?!0:t}function tc(t){const{cleanup:e}=t;if(t.cleanup=void 0,e){const i=fe;fe=void 0;try{e()}finally{fe=i}}}let fn=0;class xg{constructor(e,i){this.sub=e,this.dep=i,this.version=i.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}}class dr{constructor(e){this.computed=e,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0}track(e){if(!fe||!gt||fe===this.computed)return;let i=this.activeLink;if(i===void 0||i.sub!==fe)i=this.activeLink=new xg(fe,this),fe.deps?(i.prevDep=fe.depsTail,fe.depsTail.nextDep=i,fe.depsTail=i):fe.deps=fe.depsTail=i,ic(i);else if(i.version===-1&&(i.version=this.version,i.nextDep)){const n=i.nextDep;n.prevDep=i.prevDep,i.prevDep&&(i.prevDep.nextDep=n),i.prevDep=fe.depsTail,i.nextDep=void 0,fe.depsTail.nextDep=i,fe.depsTail=i,fe.deps===i&&(fe.deps=n)}return i}trigger(e){this.version++,fn++,this.notify(e)}notify(e){to();try{for(let i=this.subs;i;i=i.prevSub)i.sub.notify()&&i.sub.dep.notify()}finally{io()}}}function ic(t){if(t.dep.sc++,t.sub.flags&4){const e=t.dep.computed;if(e&&!t.dep.subs){e.flags|=20;for(let n=e.deps;n;n=n.nextDep)ic(n)}const i=t.dep.subs;i!==t&&(t.prevSub=i,i&&(i.nextSub=t)),t.dep.subs=t}}const so=new WeakMap,li=Symbol(""),oo=Symbol(""),dn=Symbol("");function Me(t,e,i){if(gt&&fe){let n=so.get(t);n||so.set(t,n=new Map);let r=n.get(i);r||(n.set(i,r=new dr),r.map=n,r.key=i),r.track()}}function Ut(t,e,i,n,r,s){const o=so.get(t);if(!o){fn++;return}const a=l=>{l&&l.trigger()};if(to(),e==="clear")o.forEach(a);else{const l=Y(t),c=l&&Ys(i);if(l&&i==="length"){const u=Number(n);o.forEach((f,h)=>{(h==="length"||h===dn||!Dt(h)&&h>=u)&&a(f)})}else switch((i!==void 0||o.has(void 0))&&a(o.get(i)),c&&a(o.get(dn)),e){case"add":l?c&&a(o.get("length")):(a(o.get(li)),Pi(t)&&a(o.get(oo)));break;case"delete":l||(a(o.get(li)),Pi(t)&&a(o.get(oo)));break;case"set":Pi(t)&&a(o.get(li));break}}io()}function Ci(t){const e=ie(t);return e===t?e:(Me(e,"iterate",dn),lt(t)?e:e.map(Oe))}function hr(t){return Me(t=ie(t),"iterate",dn),t}const Sg={__proto__:null,[Symbol.iterator](){return ao(this,Symbol.iterator,Oe)},concat(...t){return Ci(this).concat(...t.map(e=>Y(e)?Ci(e):e))},entries(){return ao(this,"entries",t=>(t[1]=Oe(t[1]),t))},every(t,e){return Ft(this,"every",t,e,void 0,arguments)},filter(t,e){return Ft(this,"filter",t,e,i=>i.map(Oe),arguments)},find(t,e){return Ft(this,"find",t,e,Oe,arguments)},findIndex(t,e){return Ft(this,"findIndex",t,e,void 0,arguments)},findLast(t,e){return Ft(this,"findLast",t,e,Oe,arguments)},findLastIndex(t,e){return Ft(this,"findLastIndex",t,e,void 0,arguments)},forEach(t,e){return Ft(this,"forEach",t,e,void 0,arguments)},includes(...t){return lo(this,"includes",t)},indexOf(...t){return lo(this,"indexOf",t)},join(t){return Ci(this).join(t)},lastIndexOf(...t){return lo(this,"lastIndexOf",t)},map(t,e){return Ft(this,"map",t,e,void 0,arguments)},pop(){return hn(this,"pop")},push(...t){return hn(this,"push",t)},reduce(t,...e){return nc(this,"reduce",t,e)},reduceRight(t,...e){return nc(this,"reduceRight",t,e)},shift(){return hn(this,"shift")},some(t,e){return Ft(this,"some",t,e,void 0,arguments)},splice(...t){return hn(this,"splice",t)},toReversed(){return Ci(this).toReversed()},toSorted(t){return Ci(this).toSorted(t)},toSpliced(...t){return Ci(this).toSpliced(...t)},unshift(...t){return hn(this,"unshift",t)},values(){return ao(this,"values",Oe)}};function ao(t,e,i){const n=hr(t),r=n[e]();return n!==t&&!lt(t)&&(r._next=r.next,r.next=()=>{const s=r._next();return s.done||(s.value=i(s.value)),s}),r}const kg=Array.prototype;function Ft(t,e,i,n,r,s){const o=hr(t),a=o!==t&&!lt(t),l=o[e];if(l!==kg[e]){const f=l.apply(t,s);return a?Oe(f):f}let c=i;o!==t&&(a?c=function(f,h){return i.call(this,Oe(f),h,t)}:i.length>2&&(c=function(f,h){return i.call(this,f,h,t)}));const u=l.call(o,c,n);return a&&r?r(u):u}function nc(t,e,i,n){const r=hr(t);let s=i;return r!==t&&(lt(t)?i.length>3&&(s=function(o,a,l){return i.call(this,o,a,l,t)}):s=function(o,a,l){return i.call(this,o,Oe(a),l,t)}),r[e](s,...n)}function lo(t,e,i){const n=ie(t);Me(n,"iterate",dn);const r=n[e](...i);return(r===-1||r===!1)&&ho(i[0])?(i[0]=ie(i[0]),n[e](...i)):r}function hn(t,e,i=[]){kt(),to();const n=ie(t)[e].apply(t,i);return io(),$t(),n}const $g=Ws("__proto__,__v_isRef,__isVue"),rc=new Set(Object.getOwnPropertyNames(Symbol).filter(t=>t!=="arguments"&&t!=="caller").map(t=>Symbol[t]).filter(Dt));function Eg(t){Dt(t)||(t=String(t));const e=ie(this);return Me(e,"has",t),e.hasOwnProperty(t)}class sc{constructor(e=!1,i=!1){this._isReadonly=e,this._isShallow=i}get(e,i,n){if(i==="__v_skip")return e.__v_skip;const r=this._isReadonly,s=this._isShallow;if(i==="__v_isReactive")return!r;if(i==="__v_isReadonly")return r;if(i==="__v_isShallow")return s;if(i==="__v_raw")return n===(r?s?fc:uc:s?cc:lc).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(n)?e:void 0;const o=Y(e);if(!r){let l;if(o&&(l=Sg[i]))return l;if(i==="hasOwnProperty")return Eg}const a=Reflect.get(e,i,Ie(e)?e:n);if((Dt(i)?rc.has(i):$g(i))||(r||Me(e,"get",i),s))return a;if(Ie(a)){const l=o&&Ys(i)?a:a.value;return r&&ye(l)?fo(l):l}return ye(a)?r?fo(a):uo(a):a}}class oc extends sc{constructor(e=!1){super(!1,e)}set(e,i,n,r){let s=e[i];if(!this._isShallow){const l=Qt(s);if(!lt(n)&&!Qt(n)&&(s=ie(s),n=ie(n)),!Y(e)&&Ie(s)&&!Ie(n))return l||(s.value=n),!0}const o=Y(e)&&Ys(i)?Number(i)<e.length:se(e,i),a=Reflect.set(e,i,n,Ie(e)?e:r);return e===ie(r)&&(o?Ve(n,s)&&Ut(e,"set",i,n):Ut(e,"add",i,n)),a}deleteProperty(e,i){const n=se(e,i);e[i];const r=Reflect.deleteProperty(e,i);return r&&n&&Ut(e,"delete",i,void 0),r}has(e,i){const n=Reflect.has(e,i);return(!Dt(i)||!rc.has(i))&&Me(e,"has",i),n}ownKeys(e){return Me(e,"iterate",Y(e)?"length":li),Reflect.ownKeys(e)}}class ac extends sc{constructor(e=!1){super(!0,e)}set(e,i){return!0}deleteProperty(e,i){return!0}}const Pg=new oc,Cg=new ac,Rg=new oc(!0),Ig=new ac(!0),co=t=>t,pr=t=>Reflect.getPrototypeOf(t);function Ag(t,e,i){return function(...n){const r=this.__v_raw,s=ie(r),o=Pi(s),a=t==="entries"||t===Symbol.iterator&&o,l=t==="keys"&&o,c=r[t](...n),u=i?co:e?br:Oe;return!e&&Me(s,"iterate",l?oo:li),{next(){const{value:f,done:h}=c.next();return h?{value:f,done:h}:{value:a?[u(f[0]),u(f[1])]:u(f),done:h}},[Symbol.iterator](){return this}}}}function gr(t){return function(...e){return t==="delete"?!1:t==="clear"?void 0:this}}function Og(t,e){const i={get(r){const s=this.__v_raw,o=ie(s),a=ie(r);t||(Ve(r,a)&&Me(o,"get",r),Me(o,"get",a));const{has:l}=pr(o),c=e?co:t?br:Oe;if(l.call(o,r))return c(s.get(r));if(l.call(o,a))return c(s.get(a));s!==o&&s.get(r)},get size(){const r=this.__v_raw;return!t&&Me(ie(r),"iterate",li),r.size},has(r){const s=this.__v_raw,o=ie(s),a=ie(r);return t||(Ve(r,a)&&Me(o,"has",r),Me(o,"has",a)),r===a?s.has(r):s.has(r)||s.has(a)},forEach(r,s){const o=this,a=o.__v_raw,l=ie(a),c=e?co:t?br:Oe;return!t&&Me(l,"iterate",li),a.forEach((u,f)=>r.call(s,c(u),c(f),o))}};return Ae(i,t?{add:gr("add"),set:gr("set"),delete:gr("delete"),clear:gr("clear")}:{add(r){!e&&!lt(r)&&!Qt(r)&&(r=ie(r));const s=ie(this);return pr(s).has.call(s,r)||(s.add(r),Ut(s,"add",r,r)),this},set(r,s){!e&&!lt(s)&&!Qt(s)&&(s=ie(s));const o=ie(this),{has:a,get:l}=pr(o);let c=a.call(o,r);c||(r=ie(r),c=a.call(o,r));const u=l.call(o,r);return o.set(r,s),c?Ve(s,u)&&Ut(o,"set",r,s):Ut(o,"add",r,s),this},delete(r){const s=ie(this),{has:o,get:a}=pr(s);let l=o.call(s,r);l||(r=ie(r),l=o.call(s,r)),a&&a.call(s,r);const c=s.delete(r);return l&&Ut(s,"delete",r,void 0),c},clear(){const r=ie(this),s=r.size!==0,o=r.clear();return s&&Ut(r,"clear",void 0,void 0),o}}),["keys","values","entries",Symbol.iterator].forEach(r=>{i[r]=Ag(r,t,e)}),i}function mr(t,e){const i=Og(t,e);return(n,r,s)=>r==="__v_isReactive"?!t:r==="__v_isReadonly"?t:r==="__v_raw"?n:Reflect.get(se(i,r)&&r in n?i:n,r,s)}const Tg={get:mr(!1,!1)},Lg={get:mr(!1,!0)},Mg={get:mr(!0,!1)},Ng={get:mr(!0,!0)},lc=new WeakMap,cc=new WeakMap,uc=new WeakMap,fc=new WeakMap;function Dg(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function jg(t){return t.__v_skip||!Object.isExtensible(t)?0:Dg(fg(t))}function uo(t){return Qt(t)?t:yr(t,!1,Pg,Tg,lc)}function Ug(t){return yr(t,!1,Rg,Lg,cc)}function fo(t){return yr(t,!0,Cg,Mg,uc)}function jw(t){return yr(t,!0,Ig,Ng,fc)}function yr(t,e,i,n,r){if(!ye(t)||t.__v_raw&&!(e&&t.__v_isReactive))return t;const s=jg(t);if(s===0)return t;const o=r.get(t);if(o)return o;const a=new Proxy(t,s===2?n:i);return r.set(t,a),a}function Ri(t){return Qt(t)?Ri(t.__v_raw):!!(t&&t.__v_isReactive)}function Qt(t){return!!(t&&t.__v_isReadonly)}function lt(t){return!!(t&&t.__v_isShallow)}function ho(t){return t?!!t.__v_raw:!1}function ie(t){const e=t&&t.__v_raw;return e?ie(e):t}function Fg(t){return!se(t,"__v_skip")&&Object.isExtensible(t)&&Hl(t,"__v_skip",!0),t}const Oe=t=>ye(t)?uo(t):t,br=t=>ye(t)?fo(t):t;function Ie(t){return t?t.__v_isRef===!0:!1}function Ue(t){return hc(t,!1)}function dc(t){return hc(t,!0)}function hc(t,e){return Ie(t)?t:new Bg(t,e)}class Bg{constructor(e,i){this.dep=new dr,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=i?e:ie(e),this._value=i?e:Oe(e),this.__v_isShallow=i}get value(){return this.dep.track(),this._value}set value(e){const i=this._rawValue,n=this.__v_isShallow||lt(e)||Qt(e);e=n?e:ie(e),Ve(e,i)&&(this._rawValue=e,this._value=n?e:Oe(e),this.dep.trigger())}}function Pe(t){return Ie(t)?t.value:t}const qg={get:(t,e,i)=>e==="__v_raw"?t:Pe(Reflect.get(t,e,i)),set:(t,e,i,n)=>{const r=t[e];return Ie(r)&&!Ie(i)?(r.value=i,!0):Reflect.set(t,e,i,n)}};function pc(t){return Ri(t)?t:new Proxy(t,qg)}class Hg{constructor(e){this.__v_isRef=!0,this._value=void 0;const i=this.dep=new dr,{get:n,set:r}=e(i.track.bind(i),i.trigger.bind(i));this._get=n,this._set=r}get value(){return this._value=this._get()}set value(e){this._set(e)}}function zg(t){return new Hg(t)}class Kg{constructor(e,i,n){this.fn=e,this.setter=i,this._value=void 0,this.dep=new dr(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=fn-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!i,this.isSSR=n}notify(){if(this.flags|=16,!(this.flags&8)&&fe!==this)return Ql(this,!0),!0}get value(){const e=this.dep.track();return Zl(this),e&&(e.version=this.dep.version),this._value}set value(e){this.setter&&this.setter(e)}}function Wg(t,e,i=!1){let n,r;return Q(t)?n=t:(n=t.get,r=t.set),new Kg(n,r,i)}const vr={},wr=new WeakMap;let ci;function Gg(t,e=!1,i=ci){if(i){let n=wr.get(i);n||wr.set(i,n=[]),n.push(t)}}function Vg(t,e,i=ne){const{immediate:n,deep:r,once:s,scheduler:o,augmentJob:a,call:l}=i,c=y=>r?y:lt(y)||r===!1||r===0?Bt(y,1):Bt(y);let u,f,h,p,d=!1,w=!1;if(Ie(t)?(f=()=>t.value,d=lt(t)):Ri(t)?(f=()=>c(t),d=!0):Y(t)?(w=!0,d=t.some(y=>Ri(y)||lt(y)),f=()=>t.map(y=>{if(Ie(y))return y.value;if(Ri(y))return c(y);if(Q(y))return l?l(y,2):y()})):Q(t)?e?f=l?()=>l(t,2):t:f=()=>{if(h){kt();try{h()}finally{$t()}}const y=ci;ci=u;try{return l?l(t,3,[p]):t(p)}finally{ci=y}}:f=St,e&&r){const y=f,v=r===!0?1/0:r;f=()=>Bt(y(),v)}const S=wg(),E=()=>{u.stop(),S&&S.active&&Vs(S.effects,u)};if(s&&e){const y=e;e=(...v)=>{y(...v),E()}}let M=w?new Array(t.length).fill(vr):vr;const g=y=>{if(!(!(u.flags&1)||!u.dirty&&!y))if(e){const v=u.run();if(r||d||(w?v.some((x,P)=>Ve(x,M[P])):Ve(v,M))){h&&h();const x=ci;ci=u;try{const P=[v,M===vr?void 0:w&&M[0]===vr?[]:M,p];M=v,l?l(e,3,P):e(...P)}finally{ci=x}}}else u.run()};return a&&a(g),u=new Vl(f),u.scheduler=o?()=>o(g,!1):g,p=y=>Gg(y,!1,u),h=u.onStop=()=>{const y=wr.get(u);if(y){if(l)l(y,4);else for(const v of y)v();wr.delete(u)}},e?n?g(!0):M=u.run():o?o(g.bind(null,!0),!0):u.run(),E.pause=u.pause.bind(u),E.resume=u.resume.bind(u),E.stop=E,E}function Bt(t,e=1/0,i){if(e<=0||!ye(t)||t.__v_skip||(i=i||new Map,(i.get(t)||0)>=e))return t;if(i.set(t,e),e--,Ie(t))Bt(t.value,e,i);else if(Y(t))for(let n=0;n<t.length;n++)Bt(t[n],e,i);else if(jl(t)||Pi(t))t.forEach(n=>{Bt(n,e,i)});else if(Bl(t)){for(const n in t)Bt(t[n],e,i);for(const n of Object.getOwnPropertySymbols(t))Object.prototype.propertyIsEnumerable.call(t,n)&&Bt(t[n],e,i)}return t}const pn=[];let po=!1;function Uw(t,...e){if(po)return;po=!0,kt();const i=pn.length?pn[pn.length-1].component:null,n=i&&i.appContext.config.warnHandler,r=Yg();if(n)Ii(n,i,11,[t+e.map(s=>{var o,a;return(a=(o=s.toString)==null?void 0:o.call(s))!=null?a:JSON.stringify(s)}).join(""),i&&i.proxy,r.map(({vnode:s})=>`at <${uu(i,s.type)}>`).join(`
14
22
  `),r]);else{const s=[`[Vue warn]: ${t}`,...e];r.length&&s.push(`
15
- `,...ym(r))}_t(),oo=!1}function gm(){let t=cn[cn.length-1];if(!t)return[];const e=[];for(;t;){const i=e[0];i&&i.vnode===t?i.recurseCount++:e.push({vnode:t,recurseCount:0});const n=t.component&&t.component.parent;t=n&&n.vnode}return e}function ym(t){const e=[];return t.forEach((i,n)=>{e.push(...n===0?[]:[`
16
- `],...bm(i))}),e}function bm({vnode:t,recurseCount:e}){const i=e>0?`... (${e} recursive calls)`:"",n=t.component?t.component.parent==null:!1,r=` at <${Vc(t.component,t.type,n)}`,s=">"+i;return t.props?[r,...vm(t.props),s]:[r+s]}function vm(t){const e=[],i=Object.keys(t);return i.slice(0,3).forEach(n=>{e.push(...Xl(n,t[n]))}),i.length>3&&e.push(" ..."),e}function Xl(t,e,i){return ve(e)?(e=JSON.stringify(e),i?e:[`${t}=${e}`]):typeof e=="number"||typeof e=="boolean"||e==null?i?e:[`${t}=${e}`]:Ce(e)?(e=Xl(t,ie(e.value),!0),i?e:[`${t}=Ref<`,e,">"]):G(e)?[`${t}=fn${e.name?`<${e.name}>`:""}`]:(e=ie(e),i?e:[`${t}=`,e])}function Ci(t,e,i,n){try{return n?t(...n):t()}catch(r){un(r,e,i)}}function xt(t,e,i,n){if(G(t)){const r=Ci(t,e,i,n);return r&&xl(r)&&r.catch(s=>{un(s,e,i)}),r}if(V(t)){const r=[];for(let s=0;s<t.length;s++)r.push(xt(t[s],e,i,n));return r}}function un(t,e,i,n=!0){const r=e?e.vnode:null,{errorHandler:s,throwUnhandledErrorInProduction:o}=e&&e.appContext.config||ne;if(e){let a=e.parent;const l=e.proxy,c=`https://vuejs.org/error-reference/#runtime-${i}`;for(;a;){const u=a.ec;if(u){for(let d=0;d<u.length;d++)if(u[d](t,l,c)===!1)return}a=a.parent}if(s){wt(),Ci(s,null,10,[t,l,c]),_t();return}}wm(t,i,r,n,o)}function wm(t,e,i,n=!0,r=!1){if(r)throw t}const De=[];let St=-1;const Ri=[];let Gt=null,Ai=0;const Zl=Promise.resolve();let gr=null;function fn(t){const e=gr||Zl;return t?e.then(this?t.bind(this):t):e}function _m(t){let e=St+1,i=De.length;for(;e<i;){const n=e+i>>>1,r=De[n],s=dn(r);s<t||s===t&&r.flags&2?e=n+1:i=n}return e}function ao(t){if(!(t.flags&1)){const e=dn(t),i=De[De.length-1];!i||!(t.flags&2)&&e>=dn(i)?De.push(t):De.splice(_m(e),0,t),t.flags|=1,ec()}}function ec(){gr||(gr=Zl.then(nc))}function xm(t){V(t)?Ri.push(...t):Gt&&t.id===-1?Gt.splice(Ai+1,0,t):t.flags&1||(Ri.push(t),t.flags|=1),ec()}function tc(t,e,i=St+1){for(;i<De.length;i++){const n=De[i];if(n&&n.flags&2){if(t&&n.id!==t.uid)continue;De.splice(i,1),i--,n.flags&4&&(n.flags&=-2),n(),n.flags&4||(n.flags&=-2)}}}function ic(t){if(Ri.length){const e=[...new Set(Ri)].sort((i,n)=>dn(i)-dn(n));if(Ri.length=0,Gt){Gt.push(...e);return}for(Gt=e,Ai=0;Ai<Gt.length;Ai++){const i=Gt[Ai];i.flags&4&&(i.flags&=-2),i.flags&8||i(),i.flags&=-2}Gt=null,Ai=0}}const dn=t=>t.id==null?t.flags&2?-1:1/0:t.id;function nc(t){try{for(St=0;St<De.length;St++){const e=De[St];e&&!(e.flags&8)&&(e.flags&4&&(e.flags&=-2),Ci(e,e.i,e.i?15:14),e.flags&4||(e.flags&=-2))}}finally{for(;St<De.length;St++){const e=De[St];e&&(e.flags&=-2)}St=-1,De.length=0,ic(),gr=null,(De.length||Ri.length)&&nc()}}let Te=null,rc=null;function yr(t){const e=Te;return Te=t,rc=t&&t.type.__scopeId||null,e}function hn(t,e=Te,i){if(!e||t._n)return t;const n=(...r)=>{n._d&&Uc(-1);const s=yr(e);let o;try{o=t(...r)}finally{yr(s),n._d&&Uc(1)}return o};return n._n=!0,n._c=!0,n._d=!0,n}function sc(t,e){if(Te===null)return t;const i=Cr(Te),n=t.dirs||(t.dirs=[]);for(let r=0;r<e.length;r++){let[s,o,a,l=ne]=e[r];s&&(G(s)&&(s={mounted:s,updated:s}),s.deep&&Ut(o),n.push({dir:s,instance:i,value:o,oldValue:void 0,arg:a,modifiers:l}))}return t}function li(t,e,i,n){const r=t.dirs,s=e&&e.dirs;for(let o=0;o<r.length;o++){const a=r[o];s&&(a.oldValue=s[o].value);let l=a.dir[n];l&&(wt(),xt(l,i,8,[t.el,a,t,e]),_t())}}const Sm=Symbol("_vte"),km=t=>t.__isTeleport,Em=Symbol("_leaveCb");function lo(t,e){t.shapeFlag&6&&t.component?(t.transition=e,lo(t.component.subTree,e)):t.shapeFlag&128?(t.ssContent.transition=e.clone(t.ssContent),t.ssFallback.transition=e.clone(t.ssFallback)):t.transition=e}function ci(t,e){return G(t)?Re({name:t.name},e,{setup:t}):t}function co(t){t.ids=[t.ids[0]+t.ids[2]+++"-",0,0]}function oc(t){const e=Po(),i=Yl(null);if(e){const r=e.refs===ne?e.refs={}:e.refs;Object.defineProperty(r,t,{enumerable:!0,get:()=>i.value,set:s=>i.value=s})}return i}const br=new WeakMap;function pn(t,e,i,n,r=!1){if(V(t)){t.forEach((f,_)=>pn(f,e&&(V(e)?e[_]:e),i,n,r));return}if(Ii(n)&&!r){n.shapeFlag&512&&n.type.__asyncResolved&&n.component.subTree.component&&pn(t,e,i,n.component.subTree);return}const s=n.shapeFlag&4?Cr(n.component):n.el,o=r?null:s,{i:a,r:l}=t,c=e&&e.r,u=a.refs===ne?a.refs={}:a.refs,d=a.setupState,h=ie(d),p=d===ne?wl:f=>se(h,f);if(c!=null&&c!==l){if(ac(e),ve(c))u[c]=null,p(c)&&(d[c]=null);else if(Ce(c)){c.value=null;const f=e;f.k&&(u[f.k]=null)}}if(G(l))Ci(l,a,12,[o,u]);else{const f=ve(l),_=Ce(l);if(f||_){const P=()=>{if(t.f){const C=f?p(l)?d[l]:u[l]:l.value;if(r)V(C)&&Fs(C,s);else if(V(C))C.includes(s)||C.push(s);else if(f)u[l]=[s],p(l)&&(d[l]=u[l]);else{const R=[s];l.value=R,t.k&&(u[t.k]=R)}}else f?(u[l]=o,p(l)&&(d[l]=o)):_&&(l.value=o,t.k&&(u[t.k]=o))};if(o){const C=()=>{P(),br.delete(t)};C.id=-1,br.set(t,C),Ze(C,i)}else ac(t),P()}}}function ac(t){const e=br.get(t);e&&(e.flags|=8,br.delete(t))}const lc=t=>t.nodeType===8;or().requestIdleCallback,or().cancelIdleCallback;function $m(t,e){if(lc(t)&&t.data==="["){let i=1,n=t.nextSibling;for(;n;){if(n.nodeType===1){if(e(n)===!1)break}else if(lc(n))if(n.data==="]"){if(--i===0)break}else n.data==="["&&i++;n=n.nextSibling}}else e(t)}const Ii=t=>!!t.type.__asyncLoader;function Pm(t){G(t)&&(t={loader:t});const{loader:e,loadingComponent:i,errorComponent:n,delay:r=200,hydrate:s,timeout:o,suspensible:a=!0,onError:l}=t;let c=null,u,d=0;const h=()=>(d++,c=null,p()),p=()=>{let f;return c||(f=c=e().catch(_=>{if(_=_ instanceof Error?_:new Error(String(_)),l)return new Promise((P,C)=>{l(_,()=>P(h()),()=>C(_),d+1)});throw _}).then(_=>f!==c&&c?c:(_&&(_.__esModule||_[Symbol.toStringTag]==="Module")&&(_=_.default),u=_,_)))};return ci({name:"AsyncComponentWrapper",__asyncLoader:p,__asyncHydrate(f,_,P){let C=!1;(_.bu||(_.bu=[])).push(()=>C=!0);const R=()=>{C||P()},y=s?()=>{const g=s(R,v=>$m(f,v));g&&(_.bum||(_.bum=[])).push(g)}:R;u?y():p().then(()=>!_.isUnmounted&&y())},get __asyncResolved(){return u},setup(){const f=Le;if(co(f),u)return()=>vr(u,f);const _=y=>{c=null,un(y,f,13,!n)};if(a&&f.suspense||Ni)return p().then(y=>()=>vr(y,f)).catch(y=>(_(y),()=>n?Ee(n,{error:y}):null));const P=Me(!1),C=Me(),R=Me(!!r);return r&&setTimeout(()=>{R.value=!1},r),o!=null&&setTimeout(()=>{if(!P.value&&!C.value){const y=new Error(`Async component timed out after ${o}ms.`);_(y),C.value=y}},o),p().then(()=>{P.value=!0,f.parent&&uo(f.parent.vnode)&&f.parent.update()}).catch(y=>{_(y),C.value=y}),()=>{if(P.value&&u)return vr(u,f);if(C.value&&n)return Ee(n,{error:C.value});if(i&&!R.value)return vr(i,f)}}})}function vr(t,e){const{ref:i,props:n,children:r,ce:s}=e.vnode,o=Ee(t,n,r);return o.ref=i,o.ce=s,delete e.vnode.ce,o}const uo=t=>t.type.__isKeepAlive;function Cm(t,e){cc(t,"a",e)}function Rm(t,e){cc(t,"da",e)}function cc(t,e,i=Le){const n=t.__wdc||(t.__wdc=()=>{let r=i;for(;r;){if(r.isDeactivated)return;r=r.parent}return t()});if(wr(e,n,i),i){let r=i.parent;for(;r&&r.parent;)uo(r.parent.vnode)&&Am(n,e,i,r),r=r.parent}}function Am(t,e,i,n){const r=wr(e,t,n,!0);ho(()=>{Fs(n[e],r)},i)}function wr(t,e,i=Le,n=!1){if(i){const r=i[t]||(i[t]=[]),s=e.__weh||(e.__weh=(...o)=>{wt();const a=Sn(i),l=xt(e,i,t,o);return a(),_t(),l});return n?r.unshift(s):r.push(s),s}}const Ft=t=>(e,i=Le)=>{(!Ni||t==="sp")&&wr(t,(...n)=>e(...n),i)},uc=Ft("bm"),mn=Ft("m"),Im=Ft("bu"),Om=Ft("u"),fo=Ft("bum"),ho=Ft("um"),Tm=Ft("sp"),Lm=Ft("rtg"),Nm=Ft("rtc");function Mm(t,e=Le){wr("ec",t,e)}const Dm=Symbol.for("v-ndc");function po(t,e,i,n){let r;const s=i,o=V(t);if(o||ve(t)){const a=o&&Pi(t);let l=!1,c=!1;a&&(l=!st(t),c=Vt(t),t=lr(t)),r=new Array(t.length);for(let u=0,d=t.length;u<d;u++)r[u]=e(l?c?hr(Ae(t[u])):Ae(t[u]):t[u],u,void 0,s)}else if(typeof t=="number"){r=new Array(t);for(let a=0;a<t;a++)r[a]=e(a+1,a,void 0,s)}else if(pe(t))if(t[Symbol.iterator])r=Array.from(t,(a,l)=>e(a,l,void 0,s));else{const a=Object.keys(t);r=new Array(a.length);for(let l=0,c=a.length;l<c;l++){const u=a[l];r[l]=e(t[u],u,l,s)}}else r=[];return r}function jm(t,e,i={},n,r){if(Te.ce||Te.parent&&Ii(Te.parent)&&Te.parent.ce){const c=Object.keys(i).length>0;return oe(),Er(Ue,null,[Ee("slot",i,n)],c?-2:64)}let s=t[e];s&&s._c&&(s._d=!1),oe();const o=s&&fc(s(i)),a=i.key||o&&o.key,l=Er(Ue,{key:(a&&!Nt(a)?a:`_${e}`)+(!o&&n?"_fb":"")},o||[],o&&t._===1?64:-2);return l.scopeId&&(l.slotScopeIds=[l.scopeId+"-s"]),s&&s._c&&(s._d=!0),l}function fc(t){return t.some(e=>Eo(e)?!(e.type===Bt||e.type===Ue&&!fc(e.children)):!0)?t:null}const mo=t=>t?zc(t)?Cr(t):mo(t.parent):null,gn=Re(Object.create(null),{$:t=>t,$el:t=>t.vnode.el,$data:t=>t.data,$props:t=>t.props,$attrs:t=>t.attrs,$slots:t=>t.slots,$refs:t=>t.refs,$parent:t=>mo(t.parent),$root:t=>mo(t.root),$host:t=>t.ce,$emit:t=>t.emit,$options:t=>mc(t),$forceUpdate:t=>t.f||(t.f=()=>{ao(t.update)}),$nextTick:t=>t.n||(t.n=fn.bind(t.proxy)),$watch:t=>og.bind(t)}),go=(t,e)=>t!==ne&&!t.__isScriptSetup&&se(t,e),Um={get({_:t},e){if(e==="__v_skip")return!0;const{ctx:i,setupState:n,data:r,props:s,accessCache:o,type:a,appContext:l}=t;let c;if(e[0]!=="$"){const p=o[e];if(p!==void 0)switch(p){case 1:return n[e];case 2:return r[e];case 4:return i[e];case 3:return s[e]}else{if(go(n,e))return o[e]=1,n[e];if(r!==ne&&se(r,e))return o[e]=2,r[e];if((c=t.propsOptions[0])&&se(c,e))return o[e]=3,s[e];if(i!==ne&&se(i,e))return o[e]=4,i[e];yo&&(o[e]=0)}}const u=gn[e];let d,h;if(u)return e==="$attrs"&&Oe(t.attrs,"get",""),u(t);if((d=a.__cssModules)&&(d=d[e]))return d;if(i!==ne&&se(i,e))return o[e]=4,i[e];if(h=l.config.globalProperties,se(h,e))return h[e]},set({_:t},e,i){const{data:n,setupState:r,ctx:s}=t;return go(r,e)?(r[e]=i,!0):n!==ne&&se(n,e)?(n[e]=i,!0):se(t.props,e)||e[0]==="$"&&e.slice(1)in t?!1:(s[e]=i,!0)},has({_:{data:t,setupState:e,accessCache:i,ctx:n,appContext:r,propsOptions:s,type:o}},a){let l,c;return!!(i[a]||t!==ne&&a[0]!=="$"&&se(t,a)||go(e,a)||(l=s[0])&&se(l,a)||se(n,a)||se(gn,a)||se(r.config.globalProperties,a)||(c=o.__cssModules)&&c[a])},defineProperty(t,e,i){return i.get!=null?t._.accessCache[e]=0:se(i,"value")&&this.set(t,e,i.value,null),Reflect.defineProperty(t,e,i)}};function _r(t){return V(t)?t.reduce((e,i)=>(e[i]=null,e),{}):t}function dc(t,e){return!t||!e?t||e:V(t)&&V(e)?t.concat(e):Re({},_r(t),_r(e))}let yo=!0;function Fm(t){const e=mc(t),i=t.proxy,n=t.ctx;yo=!1,e.beforeCreate&&hc(e.beforeCreate,t,"bc");const{data:r,computed:s,methods:o,watch:a,provide:l,inject:c,created:u,beforeMount:d,mounted:h,beforeUpdate:p,updated:f,activated:_,deactivated:P,beforeDestroy:C,beforeUnmount:R,destroyed:y,unmounted:g,render:v,renderTracked:w,renderTriggered:S,errorCaptured:k,serverPrefetch:j,expose:z,inheritAttrs:mt,components:ae,directives:xe,filters:On}=e;if(c&&Bm(c,n,null),o)for(const ge in o){const de=o[ge];G(de)&&(n[ge]=de.bind(i))}if(r){const ge=r.call(i,i);pe(ge)&&(t.data=io(ge))}if(yo=!0,s)for(const ge in s){const de=s[ge],gi=G(de)?de.bind(i,i):G(de.get)?de.get.bind(i,i):vt,Qr=!G(de)&&G(de.set)?de.set.bind(i):vt,yi=qt({get:gi,set:Qr});Object.defineProperty(n,ge,{enumerable:!0,configurable:!0,get:()=>yi.value,set:Pt=>yi.value=Pt})}if(a)for(const ge in a)pc(a[ge],n,i,ge);if(l){const ge=G(l)?l.call(i):l;Reflect.ownKeys(ge).forEach(de=>{vc(de,ge[de])})}u&&hc(u,t,"c");function Fe(ge,de){V(de)?de.forEach(gi=>ge(gi.bind(i))):de&&ge(de.bind(i))}if(Fe(uc,d),Fe(mn,h),Fe(Im,p),Fe(Om,f),Fe(Cm,_),Fe(Rm,P),Fe(Mm,k),Fe(Nm,w),Fe(Lm,S),Fe(fo,R),Fe(ho,g),Fe(Tm,j),V(z))if(z.length){const ge=t.exposed||(t.exposed={});z.forEach(de=>{Object.defineProperty(ge,de,{get:()=>i[de],set:gi=>i[de]=gi,enumerable:!0})})}else t.exposed||(t.exposed={});v&&t.render===vt&&(t.render=v),mt!=null&&(t.inheritAttrs=mt),ae&&(t.components=ae),xe&&(t.directives=xe),j&&co(t)}function Bm(t,e,i=vt){V(t)&&(t=bo(t));for(const n in t){const r=t[n];let s;pe(r)?"default"in r?s=bn(r.from||n,r.default,!0):s=bn(r.from||n):s=bn(r),Ce(s)?Object.defineProperty(e,n,{enumerable:!0,configurable:!0,get:()=>s.value,set:o=>s.value=o}):e[n]=s}}function hc(t,e,i){xt(V(t)?t.map(n=>n.bind(e.proxy)):t.bind(e.proxy),e,i)}function pc(t,e,i,n){let r=n.includes(".")?Oc(i,n):()=>i[n];if(ve(t)){const s=e[t];G(s)&&Ti(r,s)}else if(G(t))Ti(r,t.bind(i));else if(pe(t))if(V(t))t.forEach(s=>pc(s,e,i,n));else{const s=G(t.handler)?t.handler.bind(i):e[t.handler];G(s)&&Ti(r,s,t)}}function mc(t){const e=t.type,{mixins:i,extends:n}=e,{mixins:r,optionsCache:s,config:{optionMergeStrategies:o}}=t.appContext,a=s.get(e);let l;return a?l=a:!r.length&&!i&&!n?l=e:(l={},r.length&&r.forEach(c=>xr(l,c,o,!0)),xr(l,e,o)),pe(e)&&s.set(e,l),l}function xr(t,e,i,n=!1){const{mixins:r,extends:s}=e;s&&xr(t,s,i,!0),r&&r.forEach(o=>xr(t,o,i,!0));for(const o in e)if(!(n&&o==="expose")){const a=qm[o]||i&&i[o];t[o]=a?a(t[o],e[o]):e[o]}return t}const qm={data:gc,props:yc,emits:yc,methods:yn,computed:yn,beforeCreate:je,created:je,beforeMount:je,mounted:je,beforeUpdate:je,updated:je,beforeDestroy:je,beforeUnmount:je,destroyed:je,unmounted:je,activated:je,deactivated:je,errorCaptured:je,serverPrefetch:je,components:yn,directives:yn,watch:zm,provide:gc,inject:Hm};function gc(t,e){return e?t?function(){return Re(G(t)?t.call(this,this):t,G(e)?e.call(this,this):e)}:e:t}function Hm(t,e){return yn(bo(t),bo(e))}function bo(t){if(V(t)){const e={};for(let i=0;i<t.length;i++)e[t[i]]=t[i];return e}return t}function je(t,e){return t?[...new Set([].concat(t,e))]:e}function yn(t,e){return t?Re(Object.create(null),t,e):e}function yc(t,e){return t?V(t)&&V(e)?[...new Set([...t,...e])]:Re(Object.create(null),_r(t),_r(e??{})):e}function zm(t,e){if(!t)return e;if(!e)return t;const i=Re(Object.create(null),t);for(const n in e)i[n]=je(t[n],e[n]);return i}function bc(){return{app:null,config:{isNativeTag:wl,performance:!1,globalProperties:{},optionMergeStrategies:{},errorHandler:void 0,warnHandler:void 0,compilerOptions:{}},mixins:[],components:{},directives:{},provides:Object.create(null),optionsCache:new WeakMap,propsCache:new WeakMap,emitsCache:new WeakMap}}let Km=0;function Wm(t,e){return function(n,r=null){G(n)||(n=Re({},n)),r!=null&&!pe(r)&&(r=null);const s=bc(),o=new WeakSet,a=[];let l=!1;const c=s.app={_uid:Km++,_component:n,_props:r,_container:null,_context:s,_instance:null,version:Cg,get config(){return s.config},set config(u){},use(u,...d){return o.has(u)||(u&&G(u.install)?(o.add(u),u.install(c,...d)):G(u)&&(o.add(u),u(c,...d))),c},mixin(u){return s.mixins.includes(u)||s.mixins.push(u),c},component(u,d){return d?(s.components[u]=d,c):s.components[u]},directive(u,d){return d?(s.directives[u]=d,c):s.directives[u]},mount(u,d,h){if(!l){const p=c._ceVNode||Ee(n,r);return p.appContext=s,h===!0?h="svg":h===!1&&(h=void 0),t(p,u,h),l=!0,c._container=u,u.__vue_app__=c,Cr(p.component)}},onUnmount(u){a.push(u)},unmount(){l&&(xt(a,c._instance,16),t(null,c._container),delete c._container.__vue_app__)},provide(u,d){return s.provides[u]=d,c},runWithContext(u){const d=Oi;Oi=c;try{return u()}finally{Oi=d}}};return c}}let Oi=null;function vc(t,e){if(Le){let i=Le.provides;const n=Le.parent&&Le.parent.provides;n===i&&(i=Le.provides=Object.create(n)),i[t]=e}}function bn(t,e,i=!1){const n=Po();if(n||Oi){let r=Oi?Oi._context.provides:n?n.parent==null||n.ce?n.vnode.appContext&&n.vnode.appContext.provides:n.parent.provides:void 0;if(r&&t in r)return r[t];if(arguments.length>1)return i&&G(e)?e.call(n&&n.proxy):e}}const wc={},_c=()=>Object.create(wc),xc=t=>Object.getPrototypeOf(t)===wc;function Vm(t,e,i,n=!1){const r={},s=_c();t.propsDefaults=Object.create(null),Sc(t,e,r,s);for(const o in t.propsOptions[0])o in r||(r[o]=void 0);i?t.props=n?r:om(r):t.type.props?t.props=r:t.props=s,t.attrs=s}function Gm(t,e,i,n){const{props:r,attrs:s,vnode:{patchFlag:o}}=t,a=ie(r),[l]=t.propsOptions;let c=!1;if((n||o>0)&&!(o&16)){if(o&8){const u=t.vnode.dynamicProps;for(let d=0;d<u.length;d++){let h=u[d];if(Sr(t.emitsOptions,h))continue;const p=e[h];if(l)if(se(s,h))p!==s[h]&&(s[h]=p,c=!0);else{const f=Mt(h);r[f]=vo(l,a,f,p,t,!1)}else p!==s[h]&&(s[h]=p,c=!0)}}}else{Sc(t,e,r,s)&&(c=!0);let u;for(const d in a)(!e||!se(e,d)&&((u=Wt(d))===d||!se(e,u)))&&(l?i&&(i[d]!==void 0||i[u]!==void 0)&&(r[d]=vo(l,a,d,void 0,t,!0)):delete r[d]);if(s!==a)for(const d in s)(!e||!se(e,d))&&(delete s[d],c=!0)}c&&Dt(t.attrs,"set","")}function Sc(t,e,i,n){const[r,s]=t.propsOptions;let o=!1,a;if(e)for(let l in e){if(nn(l))continue;const c=e[l];let u;r&&se(r,u=Mt(l))?!s||!s.includes(u)?i[u]=c:(a||(a={}))[u]=c:Sr(t.emitsOptions,l)||(!(l in n)||c!==n[l])&&(n[l]=c,o=!0)}if(s){const l=ie(i),c=a||ne;for(let u=0;u<s.length;u++){const d=s[u];i[d]=vo(r,l,d,c[d],t,!se(c,d))}}return o}function vo(t,e,i,n,r,s){const o=t[i];if(o!=null){const a=se(o,"default");if(a&&n===void 0){const l=o.default;if(o.type!==Function&&!o.skipFactory&&G(l)){const{propsDefaults:c}=r;if(i in c)n=c[i];else{const u=Sn(r);n=c[i]=l.call(null,e),u()}}else n=l;r.ce&&r.ce._setProp(i,n)}o[0]&&(s&&!a?n=!1:o[1]&&(n===""||n===Wt(i))&&(n=!0))}return n}const Ym=new WeakMap;function kc(t,e,i=!1){const n=i?Ym:e.propsCache,r=n.get(t);if(r)return r;const s=t.props,o={},a=[];let l=!1;if(!G(t)){const u=d=>{l=!0;const[h,p]=kc(d,e,!0);Re(o,h),p&&a.push(...p)};!i&&e.mixins.length&&e.mixins.forEach(u),t.extends&&u(t.extends),t.mixins&&t.mixins.forEach(u)}if(!s&&!l)return pe(t)&&n.set(t,ki),ki;if(V(s))for(let u=0;u<s.length;u++){const d=Mt(s[u]);Ec(d)&&(o[d]=ne)}else if(s)for(const u in s){const d=Mt(u);if(Ec(d)){const h=s[u],p=o[d]=V(h)||G(h)?{type:h}:Re({},h),f=p.type;let _=!1,P=!0;if(V(f))for(let C=0;C<f.length;++C){const R=f[C],y=G(R)&&R.name;if(y==="Boolean"){_=!0;break}else y==="String"&&(P=!1)}else _=G(f)&&f.name==="Boolean";p[0]=_,p[1]=P,(_||se(p,"default"))&&a.push(d)}}const c=[o,a];return pe(t)&&n.set(t,c),c}function Ec(t){return t[0]!=="$"&&!nn(t)}const wo=t=>t==="_"||t==="_ctx"||t==="$stable",_o=t=>V(t)?t.map(kt):[kt(t)],Qm=(t,e,i)=>{if(e._n)return e;const n=hn((...r)=>_o(e(...r)),i);return n._c=!1,n},$c=(t,e,i)=>{const n=t._ctx;for(const r in t){if(wo(r))continue;const s=t[r];if(G(s))e[r]=Qm(r,s,n);else if(s!=null){const o=_o(s);e[r]=()=>o}}},Pc=(t,e)=>{const i=_o(e);t.slots.default=()=>i},Cc=(t,e,i)=>{for(const n in e)(i||!wo(n))&&(t[n]=e[n])},Jm=(t,e,i)=>{const n=t.slots=_c();if(t.vnode.shapeFlag&32){const r=e._;r?(Cc(n,e,i),i&&$l(n,"_",r,!0)):$c(e,n)}else e&&Pc(t,e)},Xm=(t,e,i)=>{const{vnode:n,slots:r}=t;let s=!0,o=ne;if(n.shapeFlag&32){const a=e._;a?i&&a===1?s=!1:Cc(r,e,i):(s=!e.$stable,$c(e,r)),o=e}else e&&(Pc(t,e),o={default:1});if(s)for(const a in r)!wo(a)&&o[a]==null&&delete r[a]},Ze=hg;function Zm(t){return eg(t)}function eg(t,e){const i=or();i.__VUE__=!0;const{insert:n,remove:r,patchProp:s,createElement:o,createText:a,createComment:l,setText:c,setElementText:u,parentNode:d,nextSibling:h,setScopeId:p=vt,insertStaticContent:f}=t,_=(b,x,E,T=null,A=null,I=null,U=void 0,D=null,N=!!x.dynamicChildren)=>{if(b===x)return;b&&!_n(b,x)&&(T=Jr(b),Pt(b,A,I,!0),b=null),x.patchFlag===-2&&(N=!1,x.dynamicChildren=null);const{type:O,ref:H,shapeFlag:B}=x;switch(O){case kr:P(b,x,E,T);break;case Bt:C(b,x,E,T);break;case ko:b==null&&R(x,E,T,U);break;case Ue:ae(b,x,E,T,A,I,U,D,N);break;default:B&1?v(b,x,E,T,A,I,U,D,N):B&6?xe(b,x,E,T,A,I,U,D,N):(B&64||B&128)&&O.process(b,x,E,T,A,I,U,D,N,Ln)}H!=null&&A?pn(H,b&&b.ref,I,x||b,!x):H==null&&b&&b.ref!=null&&pn(b.ref,null,I,b,!0)},P=(b,x,E,T)=>{if(b==null)n(x.el=a(x.children),E,T);else{const A=x.el=b.el;x.children!==b.children&&c(A,x.children)}},C=(b,x,E,T)=>{b==null?n(x.el=l(x.children||""),E,T):x.el=b.el},R=(b,x,E,T)=>{[b.el,b.anchor]=f(b.children,x,E,T,b.el,b.anchor)},y=({el:b,anchor:x},E,T)=>{let A;for(;b&&b!==x;)A=h(b),n(b,E,T),b=A;n(x,E,T)},g=({el:b,anchor:x})=>{let E;for(;b&&b!==x;)E=h(b),r(b),b=E;r(x)},v=(b,x,E,T,A,I,U,D,N)=>{if(x.type==="svg"?U="svg":x.type==="math"&&(U="mathml"),b==null)w(x,E,T,A,I,U,D,N);else{const O=b.el&&b.el._isVueCE?b.el:null;try{O&&O._beginPatch(),j(b,x,A,I,U,D,N)}finally{O&&O._endPatch()}}},w=(b,x,E,T,A,I,U,D)=>{let N,O;const{props:H,shapeFlag:B,transition:q,dirs:Y}=b;if(N=b.el=o(b.type,I,H&&H.is,H),B&8?u(N,b.children):B&16&&k(b.children,N,null,T,A,xo(b,I),U,D),Y&&li(b,null,T,"created"),S(N,b,b.scopeId,U,T),H){for(const he in H)he!=="value"&&!nn(he)&&s(N,he,null,H[he],I,T);"value"in H&&s(N,"value",null,H.value,I),(O=H.onVnodeBeforeMount)&&Et(O,T,b)}Y&&li(b,null,T,"beforeMount");const te=tg(A,q);te&&q.beforeEnter(N),n(N,x,E),((O=H&&H.onVnodeMounted)||te||Y)&&Ze(()=>{O&&Et(O,T,b),te&&q.enter(N),Y&&li(b,null,T,"mounted")},A)},S=(b,x,E,T,A)=>{if(E&&p(b,E),T)for(let I=0;I<T.length;I++)p(b,T[I]);if(A){let I=A.subTree;if(x===I||jc(I.type)&&(I.ssContent===x||I.ssFallback===x)){const U=A.vnode;S(b,U,U.scopeId,U.slotScopeIds,A.parent)}}},k=(b,x,E,T,A,I,U,D,N=0)=>{for(let O=N;O<b.length;O++){const H=b[O]=D?Qt(b[O]):kt(b[O]);_(null,H,x,E,T,A,I,U,D)}},j=(b,x,E,T,A,I,U)=>{const D=x.el=b.el;let{patchFlag:N,dynamicChildren:O,dirs:H}=x;N|=b.patchFlag&16;const B=b.props||ne,q=x.props||ne;let Y;if(E&&ui(E,!1),(Y=q.onVnodeBeforeUpdate)&&Et(Y,E,x,b),H&&li(x,b,E,"beforeUpdate"),E&&ui(E,!0),(B.innerHTML&&q.innerHTML==null||B.textContent&&q.textContent==null)&&u(D,""),O?z(b.dynamicChildren,O,D,E,T,xo(x,A),I):U||de(b,x,D,null,E,T,xo(x,A),I,!1),N>0){if(N&16)mt(D,B,q,E,A);else if(N&2&&B.class!==q.class&&s(D,"class",null,q.class,A),N&4&&s(D,"style",B.style,q.style,A),N&8){const te=x.dynamicProps;for(let he=0;he<te.length;he++){const le=te[he],Ge=B[le],Ye=q[le];(Ye!==Ge||le==="value")&&s(D,le,Ge,Ye,A,E)}}N&1&&b.children!==x.children&&u(D,x.children)}else!U&&O==null&&mt(D,B,q,E,A);((Y=q.onVnodeUpdated)||H)&&Ze(()=>{Y&&Et(Y,E,x,b),H&&li(x,b,E,"updated")},T)},z=(b,x,E,T,A,I,U)=>{for(let D=0;D<x.length;D++){const N=b[D],O=x[D],H=N.el&&(N.type===Ue||!_n(N,O)||N.shapeFlag&198)?d(N.el):E;_(N,O,H,null,T,A,I,U,!0)}},mt=(b,x,E,T,A)=>{if(x!==E){if(x!==ne)for(const I in x)!nn(I)&&!(I in E)&&s(b,I,x[I],null,A,T);for(const I in E){if(nn(I))continue;const U=E[I],D=x[I];U!==D&&I!=="value"&&s(b,I,D,U,A,T)}"value"in E&&s(b,"value",x.value,E.value,A)}},ae=(b,x,E,T,A,I,U,D,N)=>{const O=x.el=b?b.el:a(""),H=x.anchor=b?b.anchor:a("");let{patchFlag:B,dynamicChildren:q,slotScopeIds:Y}=x;Y&&(D=D?D.concat(Y):Y),b==null?(n(O,E,T),n(H,E,T),k(x.children||[],E,H,A,I,U,D,N)):B>0&&B&64&&q&&b.dynamicChildren?(z(b.dynamicChildren,q,E,A,I,U,D),(x.key!=null||A&&x===A.subTree)&&Rc(b,x,!0)):de(b,x,E,H,A,I,U,D,N)},xe=(b,x,E,T,A,I,U,D,N)=>{x.slotScopeIds=D,b==null?x.shapeFlag&512?A.ctx.activate(x,E,T,U,N):On(x,E,T,A,I,U,N):yf(b,x,N)},On=(b,x,E,T,A,I,U)=>{const D=b.component=vg(b,T,A);if(uo(b)&&(D.ctx.renderer=Ln),wg(D,!1,U),D.asyncDep){if(A&&A.registerDep(D,Fe,U),!b.el){const N=D.subTree=Ee(Bt);C(null,N,x,E),b.placeholder=N.el}}else Fe(D,b,x,E,A,I,U)},yf=(b,x,E)=>{const T=x.component=b.component;if(fg(b,x,E))if(T.asyncDep&&!T.asyncResolved){ge(T,x,E);return}else T.next=x,T.update();else x.el=b.el,T.vnode=x},Fe=(b,x,E,T,A,I,U)=>{const D=()=>{if(b.isMounted){let{next:B,bu:q,u:Y,parent:te,vnode:he}=b;{const Rt=Ac(b);if(Rt){B&&(B.el=he.el,ge(b,B,U)),Rt.asyncDep.then(()=>{b.isUnmounted||D()});return}}let le=B,Ge;ui(b,!1),B?(B.el=he.el,ge(b,B,U)):B=he,q&&sr(q),(Ge=B.props&&B.props.onVnodeBeforeUpdate)&&Et(Ge,te,B,he),ui(b,!0);const Ye=Mc(b),Ct=b.subTree;b.subTree=Ye,_(Ct,Ye,d(Ct.el),Jr(Ct),b,A,I),B.el=Ye.el,le===null&&dg(b,Ye.el),Y&&Ze(Y,A),(Ge=B.props&&B.props.onVnodeUpdated)&&Ze(()=>Et(Ge,te,B,he),A)}else{let B;const{el:q,props:Y}=x,{bm:te,m:he,parent:le,root:Ge,type:Ye}=b,Ct=Ii(x);ui(b,!1),te&&sr(te),!Ct&&(B=Y&&Y.onVnodeBeforeMount)&&Et(B,le,x),ui(b,!0);{Ge.ce&&Ge.ce._def.shadowRoot!==!1&&Ge.ce._injectChildStyle(Ye);const Rt=b.subTree=Mc(b);_(null,Rt,E,T,b,A,I),x.el=Rt.el}if(he&&Ze(he,A),!Ct&&(B=Y&&Y.onVnodeMounted)){const Rt=x;Ze(()=>Et(B,le,Rt),A)}(x.shapeFlag&256||le&&Ii(le.vnode)&&le.vnode.shapeFlag&256)&&b.a&&Ze(b.a,A),b.isMounted=!0,x=E=T=null}};b.scope.on();const N=b.effect=new Il(D);b.scope.off();const O=b.update=N.run.bind(N),H=b.job=N.runIfDirty.bind(N);H.i=b,H.id=b.uid,N.scheduler=()=>ao(H),ui(b,!0),O()},ge=(b,x,E)=>{x.component=b;const T=b.vnode.props;b.vnode=x,b.next=null,Gm(b,x.props,T,E),Xm(b,x.children,E),wt(),tc(b),_t()},de=(b,x,E,T,A,I,U,D,N=!1)=>{const O=b&&b.children,H=b?b.shapeFlag:0,B=x.children,{patchFlag:q,shapeFlag:Y}=x;if(q>0){if(q&128){Qr(O,B,E,T,A,I,U,D,N);return}else if(q&256){gi(O,B,E,T,A,I,U,D,N);return}}Y&8?(H&16&&Tn(O,A,I),B!==O&&u(E,B)):H&16?Y&16?Qr(O,B,E,T,A,I,U,D,N):Tn(O,A,I,!0):(H&8&&u(E,""),Y&16&&k(B,E,T,A,I,U,D,N))},gi=(b,x,E,T,A,I,U,D,N)=>{b=b||ki,x=x||ki;const O=b.length,H=x.length,B=Math.min(O,H);let q;for(q=0;q<B;q++){const Y=x[q]=N?Qt(x[q]):kt(x[q]);_(b[q],Y,E,null,A,I,U,D,N)}O>H?Tn(b,A,I,!0,!1,B):k(x,E,T,A,I,U,D,N,B)},Qr=(b,x,E,T,A,I,U,D,N)=>{let O=0;const H=x.length;let B=b.length-1,q=H-1;for(;O<=B&&O<=q;){const Y=b[O],te=x[O]=N?Qt(x[O]):kt(x[O]);if(_n(Y,te))_(Y,te,E,null,A,I,U,D,N);else break;O++}for(;O<=B&&O<=q;){const Y=b[B],te=x[q]=N?Qt(x[q]):kt(x[q]);if(_n(Y,te))_(Y,te,E,null,A,I,U,D,N);else break;B--,q--}if(O>B){if(O<=q){const Y=q+1,te=Y<H?x[Y].el:T;for(;O<=q;)_(null,x[O]=N?Qt(x[O]):kt(x[O]),E,te,A,I,U,D,N),O++}}else if(O>q)for(;O<=B;)Pt(b[O],A,I,!0),O++;else{const Y=O,te=O,he=new Map;for(O=te;O<=q;O++){const nt=x[O]=N?Qt(x[O]):kt(x[O]);nt.key!=null&&he.set(nt.key,O)}let le,Ge=0;const Ye=q-te+1;let Ct=!1,Rt=0;const Nn=new Array(Ye);for(O=0;O<Ye;O++)Nn[O]=0;for(O=Y;O<=B;O++){const nt=b[O];if(Ge>=Ye){Pt(nt,A,I,!0);continue}let At;if(nt.key!=null)At=he.get(nt.key);else for(le=te;le<=q;le++)if(Nn[le-te]===0&&_n(nt,x[le])){At=le;break}At===void 0?Pt(nt,A,I,!0):(Nn[At-te]=O+1,At>=Rt?Rt=At:Ct=!0,_(nt,x[At],E,null,A,I,U,D,N),Ge++)}const wf=Ct?ig(Nn):ki;for(le=wf.length-1,O=Ye-1;O>=0;O--){const nt=te+O,At=x[nt],_f=x[nt+1],xf=nt+1<H?_f.el||_f.placeholder:T;Nn[O]===0?_(null,At,E,xf,A,I,U,D,N):Ct&&(le<0||O!==wf[le]?yi(At,E,xf,2):le--)}}},yi=(b,x,E,T,A=null)=>{const{el:I,type:U,transition:D,children:N,shapeFlag:O}=b;if(O&6){yi(b.component.subTree,x,E,T);return}if(O&128){b.suspense.move(x,E,T);return}if(O&64){U.move(b,x,E,Ln);return}if(U===Ue){n(I,x,E);for(let B=0;B<N.length;B++)yi(N[B],x,E,T);n(b.anchor,x,E);return}if(U===ko){y(b,x,E);return}if(T!==2&&O&1&&D)if(T===0)D.beforeEnter(I),n(I,x,E),Ze(()=>D.enter(I),A);else{const{leave:B,delayLeave:q,afterLeave:Y}=D,te=()=>{b.ctx.isUnmounted?r(I):n(I,x,E)},he=()=>{I._isLeaving&&I[Em](!0),B(I,()=>{te(),Y&&Y()})};q?q(I,te,he):he()}else n(I,x,E)},Pt=(b,x,E,T=!1,A=!1)=>{const{type:I,props:U,ref:D,children:N,dynamicChildren:O,shapeFlag:H,patchFlag:B,dirs:q,cacheIndex:Y}=b;if(B===-2&&(A=!1),D!=null&&(wt(),pn(D,null,E,b,!0),_t()),Y!=null&&(x.renderCache[Y]=void 0),H&256){x.ctx.deactivate(b);return}const te=H&1&&q,he=!Ii(b);let le;if(he&&(le=U&&U.onVnodeBeforeUnmount)&&Et(le,x,b),H&6)Gv(b.component,E,T);else{if(H&128){b.suspense.unmount(E,T);return}te&&li(b,null,x,"beforeUnmount"),H&64?b.type.remove(b,x,E,Ln,T):O&&!O.hasOnce&&(I!==Ue||B>0&&B&64)?Tn(O,x,E,!1,!0):(I===Ue&&B&384||!A&&H&16)&&Tn(N,x,E),T&&bf(b)}(he&&(le=U&&U.onVnodeUnmounted)||te)&&Ze(()=>{le&&Et(le,x,b),te&&li(b,null,x,"unmounted")},E)},bf=b=>{const{type:x,el:E,anchor:T,transition:A}=b;if(x===Ue){Vv(E,T);return}if(x===ko){g(b);return}const I=()=>{r(E),A&&!A.persisted&&A.afterLeave&&A.afterLeave()};if(b.shapeFlag&1&&A&&!A.persisted){const{leave:U,delayLeave:D}=A,N=()=>U(E,I);D?D(b.el,I,N):N()}else I()},Vv=(b,x)=>{let E;for(;b!==x;)E=h(b),r(b),b=E;r(x)},Gv=(b,x,E)=>{const{bum:T,scope:A,job:I,subTree:U,um:D,m:N,a:O}=b;Ic(N),Ic(O),T&&sr(T),A.stop(),I&&(I.flags|=8,Pt(U,b,x,E)),D&&Ze(D,x),Ze(()=>{b.isUnmounted=!0},x)},Tn=(b,x,E,T=!1,A=!1,I=0)=>{for(let U=I;U<b.length;U++)Pt(b[U],x,E,T,A)},Jr=b=>{if(b.shapeFlag&6)return Jr(b.component.subTree);if(b.shapeFlag&128)return b.suspense.next();const x=h(b.anchor||b.el),E=x&&x[Sm];return E?h(E):x};let ra=!1;const vf=(b,x,E)=>{b==null?x._vnode&&Pt(x._vnode,null,null,!0):_(x._vnode||null,b,x,null,null,null,E),x._vnode=b,ra||(ra=!0,tc(),ic(),ra=!1)},Ln={p:_,um:Pt,m:yi,r:bf,mt:On,mc:k,pc:de,pbc:z,n:Jr,o:t};return{render:vf,hydrate:void 0,createApp:Wm(vf)}}function xo({type:t,props:e},i){return i==="svg"&&t==="foreignObject"||i==="mathml"&&t==="annotation-xml"&&e&&e.encoding&&e.encoding.includes("html")?void 0:i}function ui({effect:t,job:e},i){i?(t.flags|=32,e.flags|=4):(t.flags&=-33,e.flags&=-5)}function tg(t,e){return(!t||t&&!t.pendingBranch)&&e&&!e.persisted}function Rc(t,e,i=!1){const n=t.children,r=e.children;if(V(n)&&V(r))for(let s=0;s<n.length;s++){const o=n[s];let a=r[s];a.shapeFlag&1&&!a.dynamicChildren&&((a.patchFlag<=0||a.patchFlag===32)&&(a=r[s]=Qt(r[s]),a.el=o.el),!i&&a.patchFlag!==-2&&Rc(o,a)),a.type===kr&&a.patchFlag!==-1&&(a.el=o.el),a.type===Bt&&!a.el&&(a.el=o.el)}}function ig(t){const e=t.slice(),i=[0];let n,r,s,o,a;const l=t.length;for(n=0;n<l;n++){const c=t[n];if(c!==0){if(r=i[i.length-1],t[r]<c){e[n]=r,i.push(n);continue}for(s=0,o=i.length-1;s<o;)a=s+o>>1,t[i[a]]<c?s=a+1:o=a;c<t[i[s]]&&(s>0&&(e[n]=i[s-1]),i[s]=n)}}for(s=i.length,o=i[s-1];s-- >0;)i[s]=o,o=e[o];return i}function Ac(t){const e=t.subTree.component;if(e)return e.asyncDep&&!e.asyncResolved?e:Ac(e)}function Ic(t){if(t)for(let e=0;e<t.length;e++)t[e].flags|=8}const ng=Symbol.for("v-scx"),rg=()=>bn(ng);function sg(t,e){return So(t,null,{flush:"sync"})}function Ti(t,e,i){return So(t,e,i)}function So(t,e,i=ne){const{immediate:n,deep:r,flush:s,once:o}=i,a=Re({},i),l=e&&n||!e&&s!=="post";let c;if(Ni){if(s==="sync"){const p=rg();c=p.__watcherHandles||(p.__watcherHandles=[])}else if(!l){const p=()=>{};return p.stop=vt,p.resume=vt,p.pause=vt,p}}const u=Le;a.call=(p,f,_)=>xt(p,u,f,_);let d=!1;s==="post"?a.scheduler=p=>{Ze(p,u&&u.suspense)}:s!=="sync"&&(d=!0,a.scheduler=(p,f)=>{f?p():ao(p)}),a.augmentJob=p=>{e&&(p.flags|=4),d&&(p.flags|=2,u&&(p.id=u.uid,p.i=u))};const h=mm(t,e,a);return Ni&&(c?c.push(h):l&&h()),h}function og(t,e,i){const n=this.proxy,r=ve(t)?t.includes(".")?Oc(n,t):()=>n[t]:t.bind(n,n);let s;G(e)?s=e:(s=e.handler,i=e);const o=Sn(this),a=So(r,s.bind(n),i);return o(),a}function Oc(t,e){const i=e.split(".");return()=>{let n=t;for(let r=0;r<i.length&&n;r++)n=n[i[r]];return n}}function Tc(t,e,i=ne){const n=Po(),r=Mt(e),s=Wt(e),o=Lc(t,r),a=fm((l,c)=>{let u,d=ne,h;return sg(()=>{const p=t[r];Ke(u,p)&&(u=p,c())}),{get(){return l(),i.get?i.get(u):u},set(p){const f=i.set?i.set(p):p;if(!Ke(f,u)&&!(d!==ne&&Ke(p,d)))return;const _=n.vnode.props;_&&(e in _||r in _||s in _)&&(`onUpdate:${e}`in _||`onUpdate:${r}`in _||`onUpdate:${s}`in _)||(u=p,c()),n.emit(`update:${e}`,f),Ke(p,f)&&Ke(p,d)&&!Ke(f,h)&&c(),d=p,h=f}}});return a[Symbol.iterator]=()=>{let l=0;return{next(){return l<2?{value:l++?o||ne:a,done:!1}:{done:!0}}}},a}const Lc=(t,e)=>e==="modelValue"||e==="model-value"?t.modelModifiers:t[`${e}Modifiers`]||t[`${Mt(e)}Modifiers`]||t[`${Wt(e)}Modifiers`];function ag(t,e,...i){if(t.isUnmounted)return;const n=t.vnode.props||ne;let r=i;const s=e.startsWith("update:"),o=s&&Lc(n,e.slice(7));o&&(o.trim&&(r=i.map(u=>ve(u)?u.trim():u)),o.number&&(r=i.map(Hs)));let a,l=n[a=qs(e)]||n[a=qs(Mt(e))];!l&&s&&(l=n[a=qs(Wt(e))]),l&&xt(l,t,6,r);const c=n[a+"Once"];if(c){if(!t.emitted)t.emitted={};else if(t.emitted[a])return;t.emitted[a]=!0,xt(c,t,6,r)}}const lg=new WeakMap;function Nc(t,e,i=!1){const n=i?lg:e.emitsCache,r=n.get(t);if(r!==void 0)return r;const s=t.emits;let o={},a=!1;if(!G(t)){const l=c=>{const u=Nc(c,e,!0);u&&(a=!0,Re(o,u))};!i&&e.mixins.length&&e.mixins.forEach(l),t.extends&&l(t.extends),t.mixins&&t.mixins.forEach(l)}return!s&&!a?(pe(t)&&n.set(t,null),null):(V(s)?s.forEach(l=>o[l]=null):Re(o,s),pe(t)&&n.set(t,o),o)}function Sr(t,e){return!t||!ir(e)?!1:(e=e.slice(2).replace(/Once$/,""),se(t,e[0].toLowerCase()+e.slice(1))||se(t,Wt(e))||se(t,e))}function tw(){}function Mc(t){const{type:e,vnode:i,proxy:n,withProxy:r,propsOptions:[s],slots:o,attrs:a,emit:l,render:c,renderCache:u,props:d,data:h,setupState:p,ctx:f,inheritAttrs:_}=t,P=yr(t);let C,R;try{if(i.shapeFlag&4){const g=r||n,v=g;C=kt(c.call(v,g,u,d,p,h,f)),R=a}else{const g=e;C=kt(g.length>1?g(d,{attrs:a,slots:o,emit:l}):g(d,null)),R=e.props?a:cg(a)}}catch(g){vn.length=0,un(g,t,1),C=Ee(Bt)}let y=C;if(R&&_!==!1){const g=Object.keys(R),{shapeFlag:v}=y;g.length&&v&7&&(s&&g.some(Us)&&(R=ug(R,s)),y=Li(y,R,!1,!0))}return i.dirs&&(y=Li(y,null,!1,!0),y.dirs=y.dirs?y.dirs.concat(i.dirs):i.dirs),i.transition&&lo(y,i.transition),C=y,yr(P),C}const cg=t=>{let e;for(const i in t)(i==="class"||i==="style"||ir(i))&&((e||(e={}))[i]=t[i]);return e},ug=(t,e)=>{const i={};for(const n in t)(!Us(n)||!(n.slice(9)in e))&&(i[n]=t[n]);return i};function fg(t,e,i){const{props:n,children:r,component:s}=t,{props:o,children:a,patchFlag:l}=e,c=s.emitsOptions;if(e.dirs||e.transition)return!0;if(i&&l>=0){if(l&1024)return!0;if(l&16)return n?Dc(n,o,c):!!o;if(l&8){const u=e.dynamicProps;for(let d=0;d<u.length;d++){const h=u[d];if(o[h]!==n[h]&&!Sr(c,h))return!0}}}else return(r||a)&&(!a||!a.$stable)?!0:n===o?!1:n?o?Dc(n,o,c):!0:!!o;return!1}function Dc(t,e,i){const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!0;for(let r=0;r<n.length;r++){const s=n[r];if(e[s]!==t[s]&&!Sr(i,s))return!0}return!1}function dg({vnode:t,parent:e},i){for(;e;){const n=e.subTree;if(n.suspense&&n.suspense.activeBranch===t&&(n.el=t.el),n===t)(t=e.vnode).el=i,e=e.parent;else break}}const jc=t=>t.__isSuspense;function hg(t,e){e&&e.pendingBranch?V(t)?e.effects.push(...t):e.effects.push(t):xm(t)}const Ue=Symbol.for("v-fgt"),kr=Symbol.for("v-txt"),Bt=Symbol.for("v-cmt"),ko=Symbol.for("v-stc"),vn=[];let et=null;function oe(t=!1){vn.push(et=t?null:[])}function pg(){vn.pop(),et=vn[vn.length-1]||null}let wn=1;function Uc(t,e=!1){wn+=t,t<0&&et&&e&&(et.hasOnce=!0)}function Fc(t){return t.dynamicChildren=wn>0?et||ki:null,pg(),wn>0&&et&&et.push(t),t}function ue(t,e,i,n,r,s){return Fc(Q(t,e,i,n,r,s,!0))}function Er(t,e,i,n,r){return Fc(Ee(t,e,i,n,r,!0))}function Eo(t){return t?t.__v_isVNode===!0:!1}function _n(t,e){return t.type===e.type&&t.key===e.key}const Bc=({key:t})=>t??null,$r=({ref:t,ref_key:e,ref_for:i})=>(typeof t=="number"&&(t=""+t),t!=null?ve(t)||Ce(t)||G(t)?{i:Te,r:t,k:e,f:!!i}:t:null);function Q(t,e=null,i=null,n=0,r=null,s=t===Ue?0:1,o=!1,a=!1){const l={__v_isVNode:!0,__v_skip:!0,type:t,props:e,key:e&&Bc(e),ref:e&&$r(e),scopeId:rc,slotScopeIds:null,children:i,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:s,patchFlag:n,dynamicProps:r,dynamicChildren:null,appContext:null,ctx:Te};return a?($o(l,i),s&128&&t.normalize(l)):i&&(l.shapeFlag|=ve(i)?8:16),wn>0&&!o&&et&&(l.patchFlag>0||s&6)&&l.patchFlag!==32&&et.push(l),l}const Ee=mg;function mg(t,e=null,i=null,n=0,r=null,s=!1){if((!t||t===Dm)&&(t=Bt),Eo(t)){const a=Li(t,e,!0);return i&&$o(a,i),wn>0&&!s&&et&&(a.shapeFlag&6?et[et.indexOf(t)]=a:et.push(a)),a.patchFlag=-2,a}if(Pg(t)&&(t=t.__vccOpts),e){e=gg(e);let{class:a,style:l}=e;a&&!ve(a)&&(e.class=ft(a)),pe(l)&&(ro(l)&&!V(l)&&(l=Re({},l)),e.style=zs(l))}const o=ve(t)?1:jc(t)?128:km(t)?64:pe(t)?4:G(t)?2:0;return Q(t,e,i,n,r,o,s,!0)}function gg(t){return t?ro(t)||xc(t)?Re({},t):t:null}function Li(t,e,i=!1,n=!1){const{props:r,ref:s,patchFlag:o,children:a,transition:l}=t,c=e?qc(r||{},e):r,u={__v_isVNode:!0,__v_skip:!0,type:t.type,props:c,key:c&&Bc(c),ref:e&&e.ref?i&&s?V(s)?s.concat($r(e)):[s,$r(e)]:$r(e):s,scopeId:t.scopeId,slotScopeIds:t.slotScopeIds,children:a,target:t.target,targetStart:t.targetStart,targetAnchor:t.targetAnchor,staticCount:t.staticCount,shapeFlag:t.shapeFlag,patchFlag:e&&t.type!==Ue?o===-1?16:o|16:o,dynamicProps:t.dynamicProps,dynamicChildren:t.dynamicChildren,appContext:t.appContext,dirs:t.dirs,transition:l,component:t.component,suspense:t.suspense,ssContent:t.ssContent&&Li(t.ssContent),ssFallback:t.ssFallback&&Li(t.ssFallback),placeholder:t.placeholder,el:t.el,anchor:t.anchor,ctx:t.ctx,ce:t.ce};return l&&n&&lo(u,l.clone(u)),u}function xn(t=" ",e=0){return Ee(kr,null,t,e)}function Yt(t="",e=!1){return e?(oe(),Er(Bt,null,t)):Ee(Bt,null,t)}function kt(t){return t==null||typeof t=="boolean"?Ee(Bt):V(t)?Ee(Ue,null,t.slice()):Eo(t)?Qt(t):Ee(kr,null,String(t))}function Qt(t){return t.el===null&&t.patchFlag!==-1||t.memo?t:Li(t)}function $o(t,e){let i=0;const{shapeFlag:n}=t;if(e==null)e=null;else if(V(e))i=16;else if(typeof e=="object")if(n&65){const r=e.default;r&&(r._c&&(r._d=!1),$o(t,r()),r._c&&(r._d=!0));return}else{i=32;const r=e._;!r&&!xc(e)?e._ctx=Te:r===3&&Te&&(Te.slots._===1?e._=1:(e._=2,t.patchFlag|=1024))}else G(e)?(e={default:e,_ctx:Te},i=32):(e=String(e),n&64?(i=16,e=[xn(e)]):i=8);t.children=e,t.shapeFlag|=i}function qc(...t){const e={};for(let i=0;i<t.length;i++){const n=t[i];for(const r in n)if(r==="class")e.class!==n.class&&(e.class=ft([e.class,n.class]));else if(r==="style")e.style=zs([e.style,n.style]);else if(ir(r)){const s=e[r],o=n[r];o&&s!==o&&!(V(s)&&s.includes(o))&&(e[r]=s?[].concat(s,o):o)}else r!==""&&(e[r]=n[r])}return e}function Et(t,e,i,n=null){xt(t,e,7,[i,n])}const yg=bc();let bg=0;function vg(t,e,i){const n=t.type,r=(e?e.appContext:t.appContext)||yg,s={uid:bg++,vnode:t,type:n,parent:e,appContext:r,root:null,next:null,subTree:null,effect:null,update:null,job:null,scope:new Fp(!0),render:null,proxy:null,exposed:null,exposeProxy:null,withProxy:null,provides:e?e.provides:Object.create(r.provides),ids:e?e.ids:["",0,0],accessCache:null,renderCache:[],components:null,directives:null,propsOptions:kc(n,r),emitsOptions:Nc(n,r),emit:null,emitted:null,propsDefaults:ne,inheritAttrs:n.inheritAttrs,ctx:ne,data:ne,props:ne,attrs:ne,slots:ne,refs:ne,setupState:ne,setupContext:null,suspense:i,suspenseId:i?i.pendingId:0,asyncDep:null,asyncResolved:!1,isMounted:!1,isUnmounted:!1,isDeactivated:!1,bc:null,c:null,bm:null,m:null,bu:null,u:null,um:null,bum:null,da:null,a:null,rtg:null,rtc:null,ec:null,sp:null};return s.ctx={_:s},s.root=e?e.root:s,s.emit=ag.bind(null,s),t.ce&&t.ce(s),s}let Le=null;const Po=()=>Le||Te;let Pr,Co;{const t=or(),e=(i,n)=>{let r;return(r=t[i])||(r=t[i]=[]),r.push(n),s=>{r.length>1?r.forEach(o=>o(s)):r[0](s)}};Pr=e("__VUE_INSTANCE_SETTERS__",i=>Le=i),Co=e("__VUE_SSR_SETTERS__",i=>Ni=i)}const Sn=t=>{const e=Le;return Pr(t),t.scope.on(),()=>{t.scope.off(),Pr(e)}},Hc=()=>{Le&&Le.scope.off(),Pr(null)};function zc(t){return t.vnode.shapeFlag&4}let Ni=!1;function wg(t,e=!1,i=!1){e&&Co(e);const{props:n,children:r}=t.vnode,s=zc(t);Vm(t,n,s,e),Jm(t,r,i||e);const o=s?_g(t,e):void 0;return e&&Co(!1),o}function _g(t,e){const i=t.type;t.accessCache=Object.create(null),t.proxy=new Proxy(t.ctx,Um);const{setup:n}=i;if(n){wt();const r=t.setupContext=n.length>1?Sg(t):null,s=Sn(t),o=Ci(n,t,0,[t.props,r]),a=xl(o);if(_t(),s(),(a||t.sp)&&!Ii(t)&&co(t),a){if(o.then(Hc,Hc),e)return o.then(l=>{Kc(t,l)}).catch(l=>{un(l,t,0)});t.asyncDep=o}else Kc(t,o)}else Wc(t)}function Kc(t,e,i){G(e)?t.type.__ssrInlineRender?t.ssrRender=e:t.render=e:pe(e)&&(t.setupState=Jl(e)),Wc(t)}function Wc(t,e,i){const n=t.type;t.render||(t.render=n.render||vt);{const r=Sn(t);wt();try{Fm(t)}finally{_t(),r()}}}const xg={get(t,e){return Oe(t,"get",""),t[e]}};function Sg(t){const e=i=>{t.exposed=i||{}};return{attrs:new Proxy(t.attrs,xg),slots:t.slots,emit:t.emit,expose:e}}function Cr(t){return t.exposed?t.exposeProxy||(t.exposeProxy=new Proxy(Jl(am(t.exposed)),{get(e,i){if(i in e)return e[i];if(i in gn)return gn[i](t)},has(e,i){return i in e||i in gn}})):t.proxy}const kg=/(?:^|[-_])\w/g,Eg=t=>t.replace(kg,e=>e.toUpperCase()).replace(/[-_]/g,"");function $g(t,e=!0){return G(t)?t.displayName||t.name:t.name||e&&t.__name}function Vc(t,e,i=!1){let n=$g(e);if(!n&&e.__file){const r=e.__file.match(/([^/\\]+)\.\w+$/);r&&(n=r[1])}if(!n&&t&&t.parent){const r=s=>{for(const o in s)if(s[o]===e)return o};n=r(t.components||t.parent.type.components)||r(t.appContext.components)}return n?Eg(n):i?"App":"Anonymous"}function Pg(t){return G(t)&&"__vccOpts"in t}const qt=(t,e)=>hm(t,e,Ni),Cg="3.5.24";let Ro;const Gc=typeof window<"u"&&window.trustedTypes;if(Gc)try{Ro=Gc.createPolicy("vue",{createHTML:t=>t})}catch{}const Yc=Ro?t=>Ro.createHTML(t):t=>t,Rg="http://www.w3.org/2000/svg",Ag="http://www.w3.org/1998/Math/MathML",Ht=typeof document<"u"?document:null,Qc=Ht&&Ht.createElement("template"),Ig={insert:(t,e,i)=>{e.insertBefore(t,i||null)},remove:t=>{const e=t.parentNode;e&&e.removeChild(t)},createElement:(t,e,i,n)=>{const r=e==="svg"?Ht.createElementNS(Rg,t):e==="mathml"?Ht.createElementNS(Ag,t):i?Ht.createElement(t,{is:i}):Ht.createElement(t);return t==="select"&&n&&n.multiple!=null&&r.setAttribute("multiple",n.multiple),r},createText:t=>Ht.createTextNode(t),createComment:t=>Ht.createComment(t),setText:(t,e)=>{t.nodeValue=e},setElementText:(t,e)=>{t.textContent=e},parentNode:t=>t.parentNode,nextSibling:t=>t.nextSibling,querySelector:t=>Ht.querySelector(t),setScopeId(t,e){t.setAttribute(e,"")},insertStaticContent(t,e,i,n,r,s){const o=i?i.previousSibling:e.lastChild;if(r&&(r===s||r.nextSibling))for(;e.insertBefore(r.cloneNode(!0),i),!(r===s||!(r=r.nextSibling)););else{Qc.innerHTML=Yc(n==="svg"?`<svg>${t}</svg>`:n==="mathml"?`<math>${t}</math>`:t);const a=Qc.content;if(n==="svg"||n==="mathml"){const l=a.firstChild;for(;l.firstChild;)a.appendChild(l.firstChild);a.removeChild(l)}e.insertBefore(a,i)}return[o?o.nextSibling:e.firstChild,i?i.previousSibling:e.lastChild]}},Og=Symbol("_vtc");function Tg(t,e,i){const n=t[Og];n&&(e=(e?[e,...n]:[...n]).join(" ")),e==null?t.removeAttribute("class"):i?t.setAttribute("class",e):t.className=e}const Jc=Symbol("_vod"),Lg=Symbol("_vsh"),Ng=Symbol(""),Mg=/(?:^|;)\s*display\s*:/;function Dg(t,e,i){const n=t.style,r=ve(i);let s=!1;if(i&&!r){if(e)if(ve(e))for(const o of e.split(";")){const a=o.slice(0,o.indexOf(":")).trim();i[a]==null&&Rr(n,a,"")}else for(const o in e)i[o]==null&&Rr(n,o,"");for(const o in i)o==="display"&&(s=!0),Rr(n,o,i[o])}else if(r){if(e!==i){const o=n[Ng];o&&(i+=";"+o),n.cssText=i,s=Mg.test(i)}}else e&&t.removeAttribute("style");Jc in t&&(t[Jc]=s?n.display:"",t[Lg]&&(n.display="none"))}const Xc=/\s*!important$/;function Rr(t,e,i){if(V(i))i.forEach(n=>Rr(t,e,n));else if(i==null&&(i=""),e.startsWith("--"))t.setProperty(e,i);else{const n=jg(t,e);Xc.test(i)?t.setProperty(Wt(n),i.replace(Xc,""),"important"):t[n]=i}}const Zc=["Webkit","Moz","ms"],Ao={};function jg(t,e){const i=Ao[e];if(i)return i;let n=Mt(e);if(n!=="filter"&&n in t)return Ao[e]=n;n=El(n);for(let r=0;r<Zc.length;r++){const s=Zc[r]+n;if(s in t)return Ao[e]=s}return e}const eu="http://www.w3.org/1999/xlink";function tu(t,e,i,n,r,s=Up(e)){n&&e.startsWith("xlink:")?i==null?t.removeAttributeNS(eu,e.slice(6,e.length)):t.setAttributeNS(eu,e,i):i==null||s&&!Cl(i)?t.removeAttribute(e):t.setAttribute(e,s?"":Nt(i)?String(i):i)}function iu(t,e,i,n,r){if(e==="innerHTML"||e==="textContent"){i!=null&&(t[e]=e==="innerHTML"?Yc(i):i);return}const s=t.tagName;if(e==="value"&&s!=="PROGRESS"&&!s.includes("-")){const a=s==="OPTION"?t.getAttribute("value")||"":t.value,l=i==null?t.type==="checkbox"?"on":"":String(i);(a!==l||!("_value"in t))&&(t.value=l),i==null&&t.removeAttribute(e),t._value=i;return}let o=!1;if(i===""||i==null){const a=typeof t[e];a==="boolean"?i=Cl(i):i==null&&a==="string"?(i="",o=!0):a==="number"&&(i=0,o=!0)}try{t[e]=i}catch{}o&&t.removeAttribute(r||e)}function Mi(t,e,i,n){t.addEventListener(e,i,n)}function Ug(t,e,i,n){t.removeEventListener(e,i,n)}const nu=Symbol("_vei");function Fg(t,e,i,n,r=null){const s=t[nu]||(t[nu]={}),o=s[e];if(n&&o)o.value=n;else{const[a,l]=Bg(e);if(n){const c=s[e]=zg(n,r);Mi(t,a,c,l)}else o&&(Ug(t,a,o,l),s[e]=void 0)}}const ru=/(?:Once|Passive|Capture)$/;function Bg(t){let e;if(ru.test(t)){e={};let n;for(;n=t.match(ru);)t=t.slice(0,t.length-n[0].length),e[n[0].toLowerCase()]=!0}return[t[2]===":"?t.slice(3):Wt(t.slice(2)),e]}let Io=0;const qg=Promise.resolve(),Hg=()=>Io||(qg.then(()=>Io=0),Io=Date.now());function zg(t,e){const i=n=>{if(!n._vts)n._vts=Date.now();else if(n._vts<=i.attached)return;xt(Kg(n,i.value),e,5,[n])};return i.value=t,i.attached=Hg(),i}function Kg(t,e){if(V(e)){const i=t.stopImmediatePropagation;return t.stopImmediatePropagation=()=>{i.call(t),t._stopped=!0},e.map(n=>r=>!r._stopped&&n&&n(r))}else return e}const su=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)>96&&t.charCodeAt(2)<123,Wg=(t,e,i,n,r,s)=>{const o=r==="svg";e==="class"?Tg(t,n,o):e==="style"?Dg(t,i,n):ir(e)?Us(e)||Fg(t,e,i,n,s):(e[0]==="."?(e=e.slice(1),!0):e[0]==="^"?(e=e.slice(1),!1):Vg(t,e,n,o))?(iu(t,e,n),!t.tagName.includes("-")&&(e==="value"||e==="checked"||e==="selected")&&tu(t,e,n,o,s,e!=="value")):t._isVueCE&&(/[A-Z]/.test(e)||!ve(n))?iu(t,Mt(e),n,s,e):(e==="true-value"?t._trueValue=n:e==="false-value"&&(t._falseValue=n),tu(t,e,n,o))};function Vg(t,e,i,n){if(n)return!!(e==="innerHTML"||e==="textContent"||e in t&&su(e)&&G(i));if(e==="spellcheck"||e==="draggable"||e==="translate"||e==="autocorrect"||e==="sandbox"&&t.tagName==="IFRAME"||e==="form"||e==="list"&&t.tagName==="INPUT"||e==="type"&&t.tagName==="TEXTAREA")return!1;if(e==="width"||e==="height"){const r=t.tagName;if(r==="IMG"||r==="VIDEO"||r==="CANVAS"||r==="SOURCE")return!1}return su(e)&&ve(i)?!1:e in t}const ou=t=>{const e=t.props["onUpdate:modelValue"]||!1;return V(e)?i=>sr(e,i):e};function Gg(t){t.target.composing=!0}function au(t){const e=t.target;e.composing&&(e.composing=!1,e.dispatchEvent(new Event("input")))}const Oo=Symbol("_assign");function lu(t,e,i){return e&&(t=t.trim()),i&&(t=Hs(t)),t}const cu={created(t,{modifiers:{lazy:e,trim:i,number:n}},r){t[Oo]=ou(r);const s=n||r.props&&r.props.type==="number";Mi(t,e?"change":"input",o=>{o.target.composing||t[Oo](lu(t.value,i,s))}),(i||s)&&Mi(t,"change",()=>{t.value=lu(t.value,i,s)}),e||(Mi(t,"compositionstart",Gg),Mi(t,"compositionend",au),Mi(t,"change",au))},mounted(t,{value:e}){t.value=e??""},beforeUpdate(t,{value:e,oldValue:i,modifiers:{lazy:n,trim:r,number:s}},o){if(t[Oo]=ou(o),t.composing)return;const a=(s||t.type==="number")&&!/^0\d/.test(t.value)?Hs(t.value):t.value,l=e??"";a!==l&&(document.activeElement===t&&t.type!=="range"&&(n&&e===i||r&&t.value.trim()===l)||(t.value=l))}},Yg=Re({patchProp:Wg},Ig);let uu;function Qg(){return uu||(uu=Zm(Yg))}const Jg=((...t)=>{const e=Qg().createApp(...t),{mount:i}=e;return e.mount=n=>{const r=Zg(n);if(!r)return;const s=e._component;!G(s)&&!s.render&&!s.template&&(s.template=r.innerHTML),r.nodeType===1&&(r.textContent="");const o=i(r,!1,Xg(r));return r instanceof Element&&(r.removeAttribute("v-cloak"),r.setAttribute("data-v-app","")),o},e});function Xg(t){if(t instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&t instanceof MathMLElement)return"mathml"}function Zg(t){return ve(t)?document.querySelector(t):t}const ey=1;var Ar;(t=>{t.PackageLoader=new L(L.object({kind:L.union(["autoload","module","umd","styles"]).required().default("autoload"),entry:L.string(),styles:L.array(L.string()),main_export:L.string()})),t.Package=new L(L.object({id:L.string().required(),name:L.string().required(),version:L.string().required(),description:L.string(),author:L.string(),license:L.string(),loader:t.PackageLoader.required()})),t.RegistryMaintainer=new L(L.object({name:L.string().required(),email:L.string()})),t.RegistryRepository=new L(L.object({type:L.union(["git"]).required().default("git"),url:L.string().required()})),t.Registry=new L(L.object({manifest_version:L.number().min(ey).required(),name:L.string().required(),base_url:L.string().required(),homepage:L.string(),maintainers:L.array(t.RegistryMaintainer),repository:t.RegistryRepository,packages:L.array(t.Package).required()}))})(Ar||(Ar={}));const To=Symbol("IPEInjectKey"),ty=(t,e)=>(e?e.provide(To,t):vc(To,t),t),Lo=()=>{const t=bn(To);if(!t)throw new Error("InPageEdit instance is not provided");return t},fu=(t,...e)=>{const i=Jg(...e);return ty(t,i),i};var iy=Object.create,No=Object.defineProperty,ny=Object.getOwnPropertyDescriptor,du=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),hu=t=>{throw TypeError(t)},ry=(t,e,i)=>e in t?No(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,sy=(t,e)=>No(t,"name",{value:e,configurable:!0}),oy=t=>[,,,iy(t?.[du("metadata")]??null)],ay=["class","method","getter","setter","accessor","field","value","get","set"],pu=t=>t!==void 0&&typeof t!="function"?hu("Function expected"):t,ly=(t,e,i,n,r)=>({kind:ay[t],name:e,metadata:n,addInitializer:s=>i._?hu("Already initialized"):r.push(pu(s||null))}),cy=(t,e)=>ry(e,du("metadata"),t[3]),uy=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},fy=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,h=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&ny(r,i));sy(r,i);for(var f=n.length-1;f>=0;f--)l=ly(c,i,a={},t[3],h),o=(0,n[f])(r,l),a._=1,pu(o)&&(r=o);return cy(t,r),p&&No(r,i,p),u?c^4?s:p:r},mu,Mo,gu;const yu=t=>{if(!t)return null;try{return t.split(".").reduce((e,i)=>e==null?e:e[i],globalThis)}catch{return null}},bu=(t,e,i)=>{if(/^https?:\/\//i.test(t))return t;const n=o=>o.endsWith("/")?o:o+"/";if(/^https?:\/\//i.test(e)){const o=n(e);return new URL(t,o).href}const r=(()=>{try{return new URL(i).href}catch{return new URL(i,location.origin).href}})(),s=new URL(n(e),r).href;return new URL(t,s).href};mu=[$e(["storage","preferences","resourceLoader"])];let Ir=(pt=class extends(gu=Xe){constructor(e){super(e,{},"plugin-store"),this.ctx=e,this.regInfoDB=void 0,this._installedPlugins=new Map,this._onlineRegistryQueries=new Map,e.set("store",this),this.regInfoDB=e.storage.createDatabase(pt.REGISTRY_INFO_STORAGE_NAME,pt.REGISTRY_INFO_CACHE_TTL,1,"indexedDB")}async start(){this._installUserPlugins(),this._injectPreferenceUI()}async _installUserPlugins(){const e=await this.ctx.preferences.get("pluginStore.plugins",[]);if(e?.length)for(const i of e)this.install(i.registry,i.id,i.source)}async _createManagementApp(){const e=await this.ctx.withInject(["store"]);return fu(e,Pm(()=>Promise.resolve().then(()=>Lv)))}async _injectPreferenceUI(){const e=this.ctx;e.preferences.defineCategory({name:"plugin-store",label:"Plugin Store",description:"Plugin Store",index:90,autoGenerateForm:!1,customRenderer:async({onUnmount:i})=>{const n=m("div",{id:"ipe-plugin-store-preferences-vue"}),r=await this._createManagementApp();return r.mount(n),i(()=>{r.unmount(),this.ctx.logger.debug("Plugin Store preferences app unmounted")}),m("section",{children:n})}}),e.preferences.registerCustomConfig("plugin-store",L.object({"pluginStore.registries":L.array(L.string()).default([Lt.PLUGIN_REGISTRY_URL]).description("Registry URLs").hidden(),"pluginStore.cdnForNpm":L.string().description("CDN to install packages from npm").default('https://cdn.jsdelivr.net/npm/{{ package }}{{ version ? "@" + version : "" }}').hidden(),"pluginStore.plugins":L.array(L.object({source:L.union(["online_manifest","npm"]).default("online_manifest"),registry:L.string().required(),id:L.string().required()})).description("Installed plugins").default([]).hidden()}),"plugin-store")}async showModal(){const e=this.ctx.modal.show({title:"Plugin Store",sizeClass:"small"}),i=m("section",{id:"ipe-plugin-store-vue"});e.setContent(i);const n=await this._createManagementApp();return n.mount(i),e.on(e.Event.Close,()=>{n.unmount()}),e}async install(e,i,n="online_manifest"){const r=await this.getRegistryInfo(e,n);if(!r)return this.ctx.logger.warn(`Registry ${e} not found`),null;const s=`${e}#${i}`;if(this._installedPlugins.has(s))return await this._installedPlugins.get(s)??null;const o=this._installOneByRegistryInfo(e,r,i);return this._installedPlugins.set(s,o),await o}async uninstall(e,i){const n=this._installedPlugins.get(`${e}#${i}`);if(n===void 0)return!0;this._installedPlugins.delete(`${e}#${i}`);const r=await n;return r?r.dispose?.()??!0:!0}async addToPreferences(e,i){let n=await this.ctx.preferences.get("pluginStore.plugins")||[];return n.some(s=>s.registry===e&&s.id===i)||(n.push({registry:e,id:i}),await this.ctx.preferences.set("pluginStore.plugins",n)),!0}async removeFromPreferences(e,i){let n=await this.ctx.preferences.get("pluginStore.plugins")||[];return n=n.filter(r=>r.registry!==e||r.id!==i),await this.ctx.preferences.set("pluginStore.plugins",n),!0}async installAndSetPreference(e,i){return await this.addToPreferences(e,i),this.install(e,i)}async uninstallAndRemovePreference(e,i){return await this.removeFromPreferences(e,i),this.uninstall(e,i)}async _installOneByRegistryInfo(e,i,n){const r=i.base_url,s=i.packages.find(f=>f.id===n);if(!s)return this.ctx.logger.warn(`Package ${n} not found in registry ${e}`),null;const o=s.loader,{kind:a,entry:l="index.js",styles:c=[],main_export:u=null}=o;let d=null;if(a!=="styles"){if(!l)return this.ctx.logger.warn(`Entry url missing for ${n}`,o),null;try{d=bu(l,r,e)}catch(f){return this.ctx.logger.warn(`Failed to resolve entry "${l}" with base "${r}" and registry "${e}"`,f),null}}const h={"data-plugin-registry":e,"data-plugin-id":n};let p=null;switch(a){case"autoload":{p=this.ctx.plugin({inject:["resourceLoader"],name:`plugin-store-${e}-${n}`,apply:f=>{d&&f.resourceLoader.loadScript(d,{...h})}});break}case"module":{if(!d)return this.ctx.logger.warn(`Entry url missing for module kind, package ${n}`),null;const f=await import(d).then(_=>(u?_[u]:_.default)??_);if(!f)return this.ctx.logger.warn(`Main export ${u} not found in module ${d}`),null;p=this.ctx.plugin(f);break}case"umd":{let f=yu(u);if(!f){if(!d)return this.ctx.logger.warn(`Entry url missing for umd kind, package ${n}`),null;await this.ctx.resourceLoader.loadScript(d,{...h}),f=yu(u)}if(!f)return this.ctx.logger.warn(`Main export ${u} not found on globalThis after loading ${d}`),null;p=this.ctx.plugin(f);break}}if(c&&c.length>0){let f=[];try{f=c.map(_=>bu(_,r,e)).filter(Boolean)}catch(_){this.ctx.logger.warn(`Failed to resolve styles for ${n}`,c,_)}p||(p=this.ctx.plugin({name:`plugin-store-${e}-${n}`,apply(){}})),p.ctx.plugin({inject:["resourceLoader"],name:`plugin-store-${e}-${n}-styles`,apply:_=>{f.forEach(P=>_.resourceLoader.loadStyle(P,{...h})),_.on("dispose",()=>{try{f.forEach(P=>_.resourceLoader.removeStyle(P))}catch{}})}})}return p}validateRegistry(e){return Ar.Registry(e)}async getRegistryInfo(e,i="online_manifest",n=!1){try{let s;switch(i){case"online_manifest":{s=await this._fetchOnlineRegistryInfo(e,n),this.logger.debug("Fetched registry info from online manifest",s),this.setRegistryCache(e,s);break}default:throw new Error(`Unsupported registry source: ${i}`)}return s}catch(s){this.ctx.logger.warn("Failed to fetch registry info",s)}const r=await this.getRegistryCache(e);if(!r)throw new Error(`Failed to fetch registry info: ${e}`);return r}async _fetchOnlineRegistryInfo(e,i=!1){if(!i&&this._onlineRegistryQueries.has(e))return await this._onlineRegistryQueries.get(e);const r=(async()=>{const s={method:"GET"};i&&(s.cache="no-store");const a=await(await fetch(e,s)).json();return this.validateRegistry(a)})();return this._onlineRegistryQueries.set(e,r),await r}async getRegistryCache(e){const i=await this.regInfoDB.get(e);if(i)try{return this.validateRegistry(i)}catch(n){this.ctx.logger.warn("Invalid cached registry",n,i),this.regInfoDB.delete(e)}return null}async setRegistryCache(e,i){return this.regInfoDB.set(e,i)}async deleteRegistryCache(e){await this.regInfoDB.delete(e)}async clearAllRegistryCaches(){await this.regInfoDB.clear(),this.ctx.logger.debug("All registry caches cleared")}async refreshRegistryCache(e){const i=await this.getRegistryInfo(e,"online_manifest",!0);if(!i)throw new Error(`Failed to refresh registry cache: ${e}`);return this.ctx.logger.debug("Registry cache refreshed:",e),i}async refreshAllRegistryCaches(){const e=await this.ctx.preferences.get("pluginStore.registries")||[],i=await Promise.allSettled(e.map(r=>this.refreshRegistryCache(r))),n={};for(const[r,s]of i.entries())s.status==="fulfilled"?n[e[r]]=s.value:n[e[r]]=null;return n}},pt.PluginStoreSchemas=Ar,pt.REGISTRY_INFO_CACHE_TTL=1e3*60*60*24,pt.REGISTRY_INFO_STORAGE_NAME="plugin-store-registry",pt.REGISTRY_ETAG_STORAGE_NAME="psreg-etag",pt);Mo=oy(gu),Ir=fy(Mo,0,"PluginPluginStore",mu,Ir),uy(Mo,1,Ir);const dy=Object.freeze(Object.defineProperty({__proto__:null,PluginPluginStore:Ir},Symbol.toStringTag,{value:"Module"})),tt='@charset "UTF-8";:host{display:block;font-family:var(--schema-font-family, ui-sans-serif, system-ui, -apple-system);color:var(--schema-color-fg, #111827)}*,*:before,*:after{box-sizing:border-box}.wrapper{display:block;background:var(--schema-color-bg, #ffffff)}.form{display:grid;gap:12px}.field{display:grid;gap:6px;padding:8px 10px;border:1px solid var(--schema-color-muted, #e5e7eb);border-radius:var(--schema-radius, 10px);background:var(--schema-surface, #fff)}.label{font-size:12px;color:var(--schema-color-muted-text, #6b7280)}.input,select,textarea{width:100%;padding:8px 10px;border-radius:8px;border:1px solid var(--schema-color-muted, #e5e7eb);background:var(--schema-input-bg, #fff);color:inherit}.checkbox{display:inline-flex;align-items:center;gap:8px}.helper{font-size:12px;color:var(--schema-color-muted-text, #6b7280)}.row{display:grid;gap:8px}.actions{display:flex;gap:8px}.btn{padding:6px 10px;border:1px solid var(--schema-color-muted, #e5e7eb);background:var(--schema-btn-bg, #f8fafc);border-radius:8px;cursor:pointer}.btn.primary{background:var(--schema-color-primary, #2563eb);color:#fff;border-color:transparent}.btn:disabled{opacity:.5;cursor:not-allowed}.btn.danger{background:var(--schema-color-danger, #dc2626);color:#fff;border-color:transparent}.group{display:grid;gap:10px}.kv{display:grid;grid-template-columns:1fr 1fr auto;gap:8px;align-items:center}.badge{display:inline-flex;padding:2px 6px;border-radius:999px;font-size:11px;background:var(--schema-badge-bg, #eef2ff);color:var(--schema-badge-fg, #4f46e5)}.hidden{display:none!important}.toolbar{display:flex;gap:6px}.schema-collection-row{position:relative;transition:transform var(--schema-collection-transition-duration, .25s) var(--schema-collection-transition-ease, ease),opacity var(--schema-collection-transition-duration, .25s) var(--schema-collection-transition-ease, ease)}.schema-collection-row.enter{opacity:0}.schema-collection-row.enter.enter-active{opacity:1}.schema-collection-row.leaving{opacity:0}.field.schema-type-array .group,.field.schema-type-array .group .row{position:relative}';const vu={arrayAdd:"+",arrayMoveUp:"↑",arrayMoveDown:"↓",arrayRemove:"×",dictAdd:"+",dictRemove:"×",rootLabel:"root"},me=(t,e)=>{customElements.get(t)||customElements.define(t,e)},hy=(t,e,i)=>{if(!e.length)return;let n=t,r=null,s=null;for(let a=0;a<e.length-1;a++){const l=e[a];let c=n?.[l];c==null?(c=typeof e[a+1]=="number"?[]:{},n[l]=c):typeof c!="object"&&(c=typeof e[a+1]=="number"?[]:{},n[l]=c),r=n,s=l,n=c}const o=e[e.length-1];if(n==null||typeof n!="object"){const a=typeof o=="number"?[]:{};if(r)r[s]=a,n=a;else return}try{n[o]=i}catch{try{const a=Array.isArray(n)?n.slice():{...n};a[o]=i,r&&(r[s]=a)}catch{}}},kn=t=>t.map(String).join("."),py=t=>t.replace(/[^a-zA-Z0-9_-]/g,"_"),Jt=t=>`schema_${py(kn(t)||"root")}`,fi=t=>kn(t),ee=(t,...e)=>{const i=new Set(e);i.size&&t.setAttribute("part",Array.from(i).join(" "))},my=["wrapper","form","field","field-intersect","field-string","field-number","field-boolean","field-date","field-const","field-array","field-object","field-tuple","field-union","field-dict","field-label","field-helper","field-group","field-row","field-actions","field-button","field-button-primary","field-button-danger","field-button-secondary","field-toolbar","field-badge","field-input","field-input-text","field-input-number","field-input-date","field-input-select","field-input-textarea","field-input-checkbox","field-const-value","collection-row","field-checkbox","field-checkbox-text","field-toolbar-select"].join(" ");function Do(t,e){if(e==null)return e;switch(t){case"number":case"natural":case"percent":{if(e==="")return;const i=Number(e);return Number.isNaN(i)?void 0:i}case"boolean":return!!e;case"date":{if(!e)return;const i=new Date(e);return Number.isNaN(+i)?void 0:i}case"const":case"string":default:return e}}function wu(t){return typeof t=="function"&&!!t?.type}function _u(t){if(!t)throw new Error("schema is required");if(wu(t))return t;try{const e=Schema.from(t);if(wu(e))return e}catch{}if(t?.type){const e=t.type;if(Schema[e])return Schema[e](t.inner??t.list??t.dict)}throw new Error("无法从传入对象生成 Schemastery 实例,请传入 schema 或 schema.toJSON() 的结果。")}function ot(t){return t?.meta??{}}function gy(t){return t.length>0&&t.every(e=>e?.type==="const")}function di(t){if(!t)return;const e=t,i=e.meta||{};if(Object.prototype.hasOwnProperty.call(i,"default"))return i.default;const n=e.type;try{const r=t();if(r!==void 0)return r}catch{}switch(n){case"string":return"";case"number":case"natural":case"percent":return 0;case"boolean":return!1;case"array":return[];case"tuple":return[];case"object":return{};case"dict":return{};case"union":{const r=e.list||[];return r.length?di(r[0]):void 0}case"const":return e.value;case"date":return;case"intersect":{const r=e.list||[],s=(a,l)=>{if(Array.isArray(a)&&Array.isArray(l))return l.slice();if(a&&l&&typeof a=="object"&&typeof l=="object"){const c={...a};for(const u of Object.keys(l))c[u]=u in c?s(c[u],l[u]):l[u];return c}return l??a};let o={};for(const a of r)o=s(o,di(a));return o}default:return}}class ht extends HTMLElement{constructor(){super(),this._path=[],this._i18n=vu,this.$root=this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=tt,this.$root.appendChild(e)}makeFieldContainer(e,i){const n=document.createElement("div");if(n.className=`field schema-form-item schema-type-${e}`,n.setAttribute("data-path",kn(this._path)),ee(n,"field",`field-${e}`),this._label){const r=document.createElement("label");r.className="label",r.textContent=this._label,ee(r,"field-label"),n.appendChild(r)}if(i&&i!==this._label){const r=document.createElement("div");r.className="helper",r.textContent=i,ee(r,"field-helper"),n.appendChild(r)}return n}set schema(e){this._schema=_u(e),this.render()}get schema(){return this._schema}set path(e){this._path=e??[],this.render()}get path(){return this._path}set label(e){this._label=e,this.render()}get label(){return this._label}set i18n(e){e&&(this._i18n={...this._i18n,...e}),this.render()}get i18n(){return this._i18n}setValue(e){this._value=e,this.render()}getValue(){return this._value}emitChange(e){this._value=e,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{path:this._path,value:e}}))}}class xu extends ht{render(){if(this.$input&&this.$root.contains(this.$input)){const s=!!this.$root.querySelector("label.label");if(!(this._label&&!s)){const o=this._value??"";this.$input.value!==o&&document.activeElement!==this.$input&&(this.$input.value=o);return}}this.$root.innerHTML=`<style>${tt}</style>`;const e=ot(this._schema),i=this.makeFieldContainer("string",e.description),n=document.createElement("input");this.$input=n,n.className="input",ee(n,"field-input","field-input-text"),n.type="text",n.name=fi(this._path),n.id=Jt(this._path),e?.pattern?.source&&(n.pattern=e.pattern.source),e?.max!=null&&(n.maxLength=e.max),n.value=this._value??"",n.oninput=()=>this.emitChange(Do("string",n.value));const r=i.querySelector("label.label");r&&(r.htmlFor=n.id),i.appendChild(n),this.$root.appendChild(i)}}me("schema-form-string",xu);class Su extends ht{render(){if(this.$input&&this.$root.contains(this.$input)){const o=!!this.$root.querySelector("label.label");if(!(this._label&&!o)){const a=this._value??"";this.$input.value!==String(a)&&document.activeElement!==this.$input&&(this.$input.value=a);return}}this.$root.innerHTML=`<style>${tt}</style>`;const e=this._schema?.type??"number",i=ot(this._schema),n=this.makeFieldContainer("number",i.description),r=document.createElement("input");this.$input=r,r.className="input",ee(r,"field-input","field-input-number"),r.name=fi(this._path),r.id=Jt(this._path),i?.min!=null&&(r.min=String(i.min)),i?.max!=null&&(r.max=String(i.max)),i?.step!=null&&(r.step=String(i.step)),e==="percent"&&!r.step&&(r.step="0.01"),r.value=this._value??"",r.oninput=()=>this.emitChange(Do(e,r.value));const s=n.querySelector("label.label");s&&(s.htmlFor=r.id),i.role==="slider"?r.type="range":r.type="number",n.appendChild(r),this.$root.appendChild(n)}}me("schema-form-number",Su);class ku extends ht{render(){this.$root.innerHTML=`<style>${tt}</style>`;const e=ot(this._schema),i=this.makeFieldContainer("boolean",e.description),n=document.createElement("label");n.className="checkbox",ee(n,"field-checkbox");const r=document.createElement("input");r.type="checkbox",r.checked=!!this._value,r.name=fi(this._path),r.id=Jt(this._path),ee(r,"field-input","field-input-checkbox");const s=document.createElement("span");s.textContent=e.description??this._label??"",ee(s,"field-checkbox-text"),r.onchange=()=>this.emitChange(r.checked);const o=i.querySelector("label.label");o&&(o.htmlFor=r.id),n.append(r,s),i.appendChild(n),this.$root.appendChild(i)}}me("schema-form-boolean",ku);function Or(t){return String(t).padStart(2,"0")}function En(t){return`${t.getFullYear()}-${Or(t.getMonth()+1)}-${Or(t.getDate())}`}function jo(t){return`${Or(t.getHours())}:${Or(t.getMinutes())}`}function Tr(t){return`${En(t)}T${jo(t)}`}class Eu extends ht{render(){if(this.$input&&this.$root.contains(this.$input)){const o=!!this.$root.querySelector("label.label");if(!(this._label&&!o)){const a=ot(this._schema).role||"date";if(document.activeElement!==this.$input)if(this._value instanceof Date)a==="date"?this.$input.value=En(this._value):a==="time"?this.$input.value=jo(this._value):a==="datetime"&&(this.$input.value=Tr(this._value));else if(typeof this._value=="string"&&a!=="time"){const l=new Date(this._value);isNaN(+l)||(a==="date"?this.$input.value=En(l):a==="datetime"&&(this.$input.value=Tr(l)))}else this._value||(this.$input.value="");return}}this.$root.innerHTML=`<style>${tt}</style>`;const e=ot(this._schema),i=this.makeFieldContainer("date",e.description),n=document.createElement("input");this.$input=n,n.className="input",ee(n,"field-input","field-input-date");const r=e.role||"date";if(r==="datetime"?n.type="datetime-local":r==="time"?n.type="time":n.type="date",n.name=fi(this._path),n.id=Jt(this._path),this._value instanceof Date)r==="date"?n.value=En(this._value):r==="time"?n.value=jo(this._value):r==="datetime"&&(n.value=Tr(this._value));else if(typeof this._value=="string"&&r!=="time"){const o=new Date(this._value);isNaN(+o)||(r==="date"?n.value=En(o):r==="datetime"&&(n.value=Tr(o)))}n.oninput=()=>{e.role;let o;if(!n.value)o=void 0;else{const a=new Date(n.value);o=Number.isNaN(+a)?void 0:a}this.emitChange(o)};const s=i.querySelector("label.label");s&&(s.htmlFor=n.id),i.appendChild(n),this.$root.appendChild(i)}}me("schema-form-date",Eu);class Uo extends ht{render(){this.$root.innerHTML=`<style>${tt}</style>`;const e=ot(this._schema),i=this._schema.value;if(e.role==="raw-html"){if(i instanceof Node){this.$root.append(i);return}else if(typeof i=="function"){this.$root.append(i());return}else if(typeof i=="string"){const o=document.createElement("div");o.innerHTML=String(i),ee(o,"field-const-value"),this.$root.appendChild(o);return}}const n=this.makeFieldContainer("const",e.description),r=document.createElement("section");r.className="const content",r.textContent=String(i),r.id=Jt(this._path),ee(r,"field-const-value");const s=n.querySelector("label.label");s&&(s.htmlFor=r.id),n.appendChild(r),this.$root.appendChild(n)}}me("schema-form-const",Uo);class $u extends ht{render(){this.$root.innerHTML=`<style>${tt}</style>`;const e=ot(this._schema),i=this.makeFieldContainer("intersect",e.description);i.classList.remove("field");const n=document.createElement("div");n.classList.add("group"),ee(n,"field-group");const r=this._schema.list||[],s=r.length>0&&r.every(a=>a?.type==="object"),o=(a,l)=>{if(Array.isArray(a)&&Array.isArray(l))return l.slice();if(a&&l&&typeof a=="object"&&typeof l=="object"){const c={...a};for(const u of Object.keys(l))c[u]=u in c?o(c[u],l[u]):l[u];return c}return l??a};if(s){const a=this._value&&typeof this._value=="object"?this._value:{};r.forEach((l,c)=>{const u=l?.meta?.description??"",d=Xt(l,this._path,a,u,this._i18n);d.addEventListener("change",h=>{h.stopPropagation();const p=o(this._value??{},h.detail.value);this.emitChange(p)}),n.appendChild(d)})}else{const a=r[r.length-1],l=Xt(a,this._path,this._value,this._label,this._i18n);l.addEventListener("change",c=>{c.stopPropagation(),this.emitChange(c.detail.value)}),n.appendChild(l)}i.appendChild(n),this.$root.appendChild(i)}}me("schema-form-intersect",$u);function yy(t){switch(t.type){case"intersect":return"schema-form-intersect";case"string":return"schema-form-string";case"number":case"natural":case"percent":return"schema-form-number";case"boolean":return"schema-form-boolean";case"date":return"schema-form-date";case"const":return"schema-form-const";case"array":return"schema-form-array";case"object":return"schema-form-object";case"tuple":return"schema-form-tuple";case"dict":return"schema-form-dict";case"union":{const e=t.list||[];return e.length===2&&e[0]?.type==="is"&&e[0]?.constructor===Date&&e[1]?.type==="transform"&&(e[1]?.inner?.meta?.role==="datetime"||e[1]?.inner?.meta?.role==="date"||e[1]?.inner?.meta?.role==="time")?"schema-form-date":"schema-form-union"}default:return"schema-form-string"}}function Xt(t,e,i,n,r){const s=yy(t),o=document.createElement(s);return o.schema=t,o.path=e,o.label=n,r&&(o.i18n=r),o.setValue?.(i),o.setAttribute("exportparts",my),o}class Pu extends ht{render(){this.$root.innerHTML=`<style>${tt}</style>`;const e=ot(this._schema),i=this.makeFieldContainer("union",e.description),n=this._schema.list||[];if(gy(n)){const r=document.createElement("select");r.className="input",ee(r,"field-input","field-input-select"),r.name=fi(this._path),r.id=Jt(this._path),n.forEach(o=>{const a=document.createElement("option");a.value=String(o.value),a.textContent=String(o.meta?.description||o.value||o.type),this._value===o.value&&(a.selected=!0),r.appendChild(a)}),r.onchange=()=>this.emitChange(Do("string",r.value));const s=i.querySelector("label.label");s&&(s.htmlFor=r.id),i.appendChild(r)}else{const r=document.createElement("div");r.className="toolbar",ee(r,"field-toolbar");const s=document.createElement("select");s.className="input",ee(s,"field-input","field-input-select","field-toolbar-select"),s.name=fi(this._path)+".__type",s.id=Jt(this._path)+"__type";let o=0;n.forEach((u,d)=>{const h=document.createElement("option");h.value=String(d),h.textContent=String(u.meta?.description||u.value||u.type),s.appendChild(h)}),s.onchange=()=>{o=Number(s.value);const u=n[o],d=di(u);this.emitChange(d),c()};const a=i.querySelector("label.label");a&&(a.htmlFor=s.id),r.appendChild(s),i.appendChild(r);const l=document.createElement("div");l.className="group",ee(l,"field-group");const c=()=>{l.innerHTML="";const u=n[o],d=Xt(u,this._path,this._value,this._label);d instanceof Uo||(d.addEventListener("change",h=>{h.stopPropagation(),this.emitChange(h.detail.value)}),l.appendChild(d))};c(),i.appendChild(l)}this.$root.appendChild(i)}}me("schema-form-union",Pu);class Cu extends ht{render(){this.$root.innerHTML=`<style>${tt}</style>`;const e=ot(this._schema),i=this.makeFieldContainer("tuple",e.description),n=document.createElement("div");n.className="group",ee(n,"field-group");const r=Array.isArray(this._value)?this._value:[];(this._schema.list||[]).forEach((s,o)=>{const a=Xt(s,[...this._path,o],r[o],`${this._label??""}[${o}]`);a.addEventListener("change",l=>{l.stopPropagation();const c=Array.isArray(this._value)?this._value.slice():[];c[o]=l.detail.value,this.emitChange(c)}),n.appendChild(a)}),i.appendChild(n),this.$root.appendChild(i)}}me("schema-form-tuple",Cu);class Ru extends ht{render(){this.$root.innerHTML=`<style>${tt}</style>`;const e=ot(this._schema),i=this.makeFieldContainer("object",e.description),n=document.createElement("div");n.className="group",ee(n,"field-group");const r=this._schema.dict||{};Object.keys(r).forEach(s=>{if(r[s]?.meta?.hidden)return;const o=(this._value??{})[s],a=Xt(r[s],[...this._path,s],o,s);a.addEventListener("change",l=>{l.stopPropagation();const c={...this._value??{}};c[s]=l.detail.value,this.emitChange(c)}),n.appendChild(a)}),i.appendChild(n),this.$root.appendChild(i)}}me("schema-form-object",Ru);const Gr=class Gr extends ht{constructor(){super(...arguments),this._itemIds=[]}generateItemId(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return"i"+Gr._idCounter++}ensureItemIds(e){for(;this._itemIds.length<e;)this._itemIds.push(this.generateItemId());this._itemIds.length>e&&(this._itemIds.length=e)}capturePositions(e){const i={};return e.querySelectorAll(".row").forEach(n=>{const r=n.dataset.uid;r&&(i[r]=n.getBoundingClientRect())}),i}playFLIP(e,i){Array.from(e.querySelectorAll(".row")).forEach(n=>{const r=n.dataset.uid;if(!r)return;const s=i[r];if(!s)return;const o=n.getBoundingClientRect(),a=s.left-o.left,l=s.top-o.top;(a||l)&&(n.style.transition="none",n.style.transform=`translate(${a}px, ${l}px)`,requestAnimationFrame(()=>{n.style.transition="transform .25s ease",n.style.transform=""}))})}render(){this.$root.innerHTML=`<style>${tt}</style>`;const e=ot(this._schema),i=this.makeFieldContainer("array",e.description),n=document.createElement("div");n.className="group",ee(n,"field-group");const r=this._schema.inner,s=()=>Array.isArray(this._value)?this._value:[];this.ensureItemIds(s().length);const o=(c,u)=>{n.innerHTML="",s().forEach((d,h)=>{const p=[...this._path,h],f=document.createElement("div");f.className="row schema-collection-row",ee(f,"field-row","collection-row");const _=this._itemIds[h];f.dataset.uid=_,f.setAttribute("data-path",kn(p));const P=Xt(r,p,d,`${this._label??""}[${h}]`);P.addEventListener("change",v=>{v.stopPropagation();const w=s().slice();w[h]=v.detail.value,this._value=w,this.emitChange(w)});const C=document.createElement("div");C.className="actions",ee(C,"field-actions");const R=document.createElement("button");R.type="button",R.className="btn",ee(R,"field-button","field-button-secondary"),R.textContent=this._i18n.arrayMoveUp??"↑",R.onclick=()=>{if(h<=0)return;const v=this.capturePositions(n),w=s().slice();[w[h-1],w[h]]=[w[h],w[h-1]],[this._itemIds[h-1],this._itemIds[h]]=[this._itemIds[h],this._itemIds[h-1]],this._value=w,o(v),this.emitChange(w)};const y=document.createElement("button");y.type="button",y.className="btn",ee(y,"field-button","field-button-secondary"),y.textContent=this._i18n.arrayMoveDown??"↓",y.onclick=()=>{const v=s();if(h>=v.length-1)return;const w=this.capturePositions(n),S=v.slice();[S[h+1],S[h]]=[S[h],S[h+1]],[this._itemIds[h+1],this._itemIds[h]]=[this._itemIds[h],this._itemIds[h+1]],this._value=S,o(w),this.emitChange(S)};const g=document.createElement("button");g.type="button",g.className="btn danger",ee(g,"field-button","field-button-danger"),g.textContent=this._i18n.arrayRemove??"×",g.onclick=()=>{f.classList.add("leaving");const v=250;let w=!1;const S=()=>{if(w)return;w=!0,clearTimeout(k);const j=s().filter((mt,ae)=>ae!==h);this._itemIds.splice(h,1);const z=this.capturePositions(n);this._value=j,o(z),this.emitChange(j)};f.addEventListener("transitionend",S,{once:!0});const k=setTimeout(S,v+80)},C.append(R,y,g),f.appendChild(P),f.appendChild(C),n.appendChild(f),u&&u===_&&(f.classList.add("enter"),requestAnimationFrame(()=>{f.classList.add("enter-active")}),requestAnimationFrame(()=>{f.classList.remove("enter")}))}),c&&this.playFLIP(n,c)};o();const a=document.createElement("button");a.type="button",a.className="btn primary",ee(a,"field-button","field-button-primary"),a.textContent=this._i18n.arrayAdd??"+",a.onclick=()=>{const c=this.capturePositions(n),u=s().slice(),d=di(r);u.push(d);const h=this.generateItemId();this._itemIds.push(h),this._value=u,o(c,h),this.emitChange(u)};const l=document.createElement("div");l.className="actions",ee(l,"field-actions"),l.appendChild(a),i.appendChild(n),i.appendChild(l),this.$root.appendChild(i)}};Gr._idCounter=0;let Lr=Gr;me("schema-form-array",Lr);class Au extends ht{render(){this.$root.innerHTML=`<style>${tt}</style>`;const e=ot(this._schema),i=this.makeFieldContainer("dict",e.description),n=document.createElement("div");n.className="group",ee(n,"field-group");const r=this._schema.inner,s=this._value??{},o=h=>`d_${h}`,a=()=>{const h={};return n.querySelectorAll(".kv").forEach(p=>{const f=p.dataset.uid;f&&(h[f]=p.getBoundingClientRect())}),h},l=h=>{n.querySelectorAll(".kv").forEach(p=>{const f=p.dataset.uid;if(!f)return;const _=h[f];if(!_)return;const P=p.getBoundingClientRect(),C=_.left-P.left,R=_.top-P.top;(C||R)&&(p.style.transition="none",p.style.transform=`translate(${C}px, ${R}px)`,requestAnimationFrame(()=>{p.style.transition="transform .25s ease",p.style.transform=""}))})},c=(h,p)=>{n.innerHTML="",Object.keys(s).forEach(f=>{const _=[...this._path,f],P=document.createElement("div");P.className="kv schema-collection-row",ee(P,"field-row","collection-row"),P.dataset.uid=o(f),P.setAttribute("data-path",kn(_));const C=document.createElement("input");C.className="input",ee(C,"field-input","field-input-text"),C.value=f,C.name=fi(_)+".__key",C.id=Jt(_)+"__key";const R=Xt(r,_,s[f],`${this._label??""}[${f}]`),y=document.createElement("button");y.type="button",y.className="btn danger",ee(y,"field-button","field-button-danger"),y.textContent=this._i18n.dictRemove??"×",y.onclick=()=>{const g=a();delete s[f];const v={...this._value??{}};delete v[f],this._value=v,c(g),this.emitChange(v)},C.onchange=()=>{const g=C.value.trim();if(!g||g===f||s[g]!==void 0)return;const v=a();s[g]=s[f],delete s[f];const w={...this._value??{}};w[g]=w[f],delete w[f],this._value=w,c(v),this.emitChange(w)},R.addEventListener("change",g=>{g.stopPropagation();const v={...this._value??{}};v[f]=g.detail.value,this._value=v,this.emitChange(v)}),P.append(C,R,y),n.appendChild(P),p===f&&(P.classList.add("enter"),requestAnimationFrame(()=>P.classList.add("enter-active")),requestAnimationFrame(()=>P.classList.remove("enter")))}),h&&l(h)};c();const u=document.createElement("button");u.type="button",u.className="btn primary",ee(u,"field-button","field-button-primary"),u.textContent=this._i18n.dictAdd??"+",u.onclick=()=>{let h=Object.keys(s).length+1,p=`k${h}`;for(;s[p]!==void 0;)p=`k${++h}`;const f=a();s[p]=di(r);const _={...this._value??{},[p]:s[p]};this._value=_,c(f,p),this.emitChange(_)};const d=document.createElement("div");d.className="actions",ee(d,"field-actions"),d.appendChild(u),i.appendChild(n),i.appendChild(d),this.$root.appendChild(i)}}me("schema-form-dict",Au);class Iu extends HTMLElement{constructor(){super(),this._i18n={...vu},this._i18nCommitted=!1,this.$root=this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=tt,this.$root.appendChild(e);const i=document.createElement("div");i.className="wrapper",ee(i,"wrapper");const n=document.createElement("form");n.className="form",ee(n,"form"),i.appendChild(n),this.$root.appendChild(i),this.addEventListener("change",r=>{if(!r?.detail)return;const{path:s,value:o}=r.detail;Array.isArray(s)&&s.length===0?this._state=o:hy(this._state??(this._state={}),s,o),this.dispatchEvent(new CustomEvent("form-change",{detail:{path:s,value:o,state:this._state}}))})}set schema(e){this._schema=_u(e);try{this._state=this._schema(null,{autofix:!0})}catch{this._state=di(this._schema)}this.render()}get schema(){return this._schema}set schemaJSON(e){this.schema=e}get schemaJSON(){return this._schema?.toJSON?.()}setData(e,i={validate:!0,autofix:!0}){if(!this._schema)throw new Error("请先设置 schema");const n=i.validate?this._schema(e??null,{autofix:i.autofix}):e;this._state=n,this.render()}getData(e={validate:!0,autofix:!0}){if(!this._schema)throw new Error("请先设置 schema");const i=this._state;return e.validate?this._schema(i??null,{autofix:e.autofix}):i}reset(){try{this._state=this._schema(null,{autofix:!0})}catch{this._state=di(this._schema)}this.render()}refresh(){this.render()}set i18n(e){this._i18nCommitted||(this._i18n={...this._i18n,...e},this._i18nCommitted=!0,this.render())}get i18n(){return this._i18n}render(){if(!this._schema)return;const e=this.$root.querySelector("form");e.innerHTML="";const i=Xt(this._schema,[],this._state,this._i18n.rootLabel,this._i18n);e.appendChild(i)}}me("schema-form",Iu);function by(){me("schema-form",Iu),me("schema-form-string",xu),me("schema-form-number",Su),me("schema-form-boolean",ku),me("schema-form-date",Eu),me("schema-form-const",Uo),me("schema-form-union",Pu),me("schema-form-tuple",Cu),me("schema-form-object",Ru),me("schema-form-array",Lr),me("schema-form-dict",Au),me("schema-form-intersect",$u)}const vy=ci({__name:"SchemasteryFormVue",props:dc({schema:{},value:{},validateOnChange:{type:Boolean,default:!1}},{schema:{required:!0},schemaModifiers:{},value:{required:!1,default:{}},valueModifiers:{}}),emits:dc(["change"],["update:schema","update:value"]),setup(t,{expose:e,emit:i}){const n=Tc(t,"schema"),r=Tc(t,"value"),s=i,o=oc("elRef");let a=!1,l=!1;const c=u=>{if(l)return;const d=o.value,h=t.validateOnChange?d.getData({validate:!0}):u.detail.state;a=!0,r.value=h,fn(()=>{a=!1}),s("change",u.detail)};return uc(()=>{by()}),mn(()=>{const u=o.value;n.value&&(u.schema=n.value),r.value!==void 0&&u.setData(r.value,{validate:!1,autofix:!0}),u.addEventListener("form-change",c)}),fo(()=>{o.value?.removeEventListener("form-change",c)}),Ti(n,u=>{a||o.value&&u&&o.value.schema!==u&&(l=!0,o.value.schema=u,fn(()=>{l=!1}))},{deep:!0,immediate:!0}),Ti(r,u=>{if(a||!o.value||u===void 0)return;const d=o.value.getData({validate:!1});JSON.stringify(d)!==JSON.stringify(u)&&(l=!0,o.value.setData(u,{validate:!1}),fn(()=>{l=!1}))},{deep:!0,immediate:!0}),e({setData(u,d){const h=o.value;h.setData(u,{validate:!!d?.validate}),d?.emit&&(r.value=h.getData({validate:!!d?.validate}))},getData(u){return o.value.getData(u)},setSchema(u,d=!0){o.value.schema=u,d&&(n.value=u)},refresh(){o.value.refresh()},reset(){o.value.reset()},el:o}),(u,d)=>(oe(),ue("schema-form",qc({ref_key:"elRef",ref:o},u.$attrs),null,16))}});function hi(t,e=new WeakMap){if(Ce(t))return hi(t.value,e);if(t===null||typeof t!="object")return t;if(e.has(t))return e.get(t);if(t instanceof Date)return new Date(t);if(t instanceof RegExp)return new RegExp(t);if(t instanceof Map){const r=new Map;return e.set(t,r),Array.from(t.entries()).forEach(([s,o])=>{r.set(s,hi(o,e))}),r}if(t instanceof Set){const r=new Set;return e.set(t,r),Array.from(t).forEach(s=>{r.add(hi(s,e))}),r}if(Array.isArray(t)){const r=[];e.set(t,r);for(const s of t)r.push(hi(s,e));return r}const i=ie(t),n={};e.set(t,n);for(const r of Object.keys(i))n[r]=hi(i[r],e);for(const r of Object.getOwnPropertySymbols(i))n[r]=hi(i[r],e);return n}const Fo=()=>{},wy={id:"preferences-ui-app"},_y={class:"tabbar"},xy={class:"tabbar-tabs"},Sy=["onClick","data-value"],ky={class:"tabbar-content"},Ey={key:0},$y={style:{"max-height":"20em",overflow:"auto"}},Py=ci({__name:"PreferencesApp",setup(t,{expose:e}){const i=Lo(),n=!1,r=Yl([]),s=Me([]),o=Me(""),a=qt(()=>s.value.find(f=>f.name===o.value)||null),l=qt(()=>{const f=r.value.filter(_=>_.category===o.value).map(_=>_.schema);return f.length===0?null:L.intersect(f)}),c=qt(()=>a.value&&typeof a.value.autoGenerateForm=="boolean"?a.value.autoGenerateForm:!0),u=Me({});e({getValue(){return hi(u)},mergeValue(f){u.value={...u.value,...f}},selectTab(f){o.value=f}}),mn(async()=>{i.inject(["preferences"],async f=>{const _=await f.preferences.getAll();u.value=_,s.value=f.preferences.getConfigCategories(),r.value=f.preferences.getConfigRegistries(),o.value=s.value[0].name})});const d=(f,_)=>{f.preventDefault(),o.value=_;const P=f.currentTarget;P&&P.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},h=oc("customRenderContainerRef"),p=Me([]);return ho(()=>{p.value.forEach(f=>f()),p.value=[]}),Ti(a,async f=>{p.value.forEach(P=>P()),p.value=[],await fn();const _=h.value;if(_&&(_.innerText="",f&&typeof f.customRenderer=="function")){let P=Fo;const C=g=>{P=g},R=g=>{p.value.push(g)},y=await f.customRenderer({ctx:i,onMounted:C,onUnmount:R});y&&(_.appendChild(y),P?.(_))}},{immediate:!0,deep:!1}),(f,_)=>(oe(),ue("div",wy,[Q("div",_y,[Q("div",xy,[(oe(!0),ue(Ue,null,po(s.value,P=>(oe(),ue("a",{class:ft(["tab",{active:o.value===P.name}]),key:P.name,onClick:C=>d(C,P.name),"data-value":P.name},ke(P.label),11,Sy))),128))]),Q("div",ky,[a.value&&a.value.customRenderer?(oe(),ue("div",{class:"custom-render-container",ref_key:"customRenderContainerRef",ref:h,key:o.value})):Yt("",!0),c.value&&l.value?(oe(),Er(so(vy),{class:"auto-schema-form",key:o.value,"data-category":o.value,schema:l.value,value:u.value,"onUpdate:value":_[0]||(_[0]=P=>u.value={...u.value,...P}),"validate-on-change":!1,i18n:{rootLabel:""}},null,8,["data-category","schema","value"])):Yt("",!0)])]),so(n)?(oe(),ue("details",Ey,[Q("pre",$y,ke(u.value),1)])):Yt("",!0)]))}}),Nr=(t,e)=>{const i=t.__vccOpts||t;for(const[n,r]of e)i[n]=r;return i},Cy=Nr(Py,[["__scopeId","data-v-7f07706b"]]);var Ry=Object.create,Bo=Object.defineProperty,Ay=Object.getOwnPropertyDescriptor,Ou=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Tu=t=>{throw TypeError(t)},Iy=(t,e,i)=>e in t?Bo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Oy=(t,e)=>Bo(t,"name",{value:e,configurable:!0}),Ty=t=>[,,,Ry(t?.[Ou("metadata")]??null)],Ly=["class","method","getter","setter","accessor","field","value","get","set"],Lu=t=>t!==void 0&&typeof t!="function"?Tu("Function expected"):t,Ny=(t,e,i,n,r)=>({kind:Ly[t],name:e,metadata:n,addInitializer:s=>i._?Tu("Already initialized"):r.push(Lu(s||null))}),My=(t,e)=>Iy(e,Ou("metadata"),t[3]),Dy=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},jy=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,h=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&Ay(r,i));Oy(r,i);for(var f=n.length-1;f>=0;f--)l=Ny(c,i,a={},t[3],h),o=(0,n[f])(r,l),a._=1,Lu(o)&&(r=o);return My(t,r),p&&Bo(r,i,p),u?c^4?s:p:r},Nu,qo,Mu;Nu=[$e(["preferences","modal"])];class Mr extends(Mu=Xe){constructor(e){super(e,{},"preferences-ui"),this.ctx=e,this._modal=null,this._form=null,e.set("preferencesUI",this),e.preferences.defineCategory({name:"about",label:"About",description:"About InPageEdit",index:99,customRenderer:()=>m("section",{className:"theme-ipe-prose",children:[m("h2",{children:"✏️ InPageEdit NEXT"}),m("p",{children:"🚀 Modular, Extensible Supercharged Plugin for MediaWiki."}),m("h3",{children:"Portals"}),m("ul",{children:[m("li",{children:m("a",{href:this.ctx.Endpoints.HOME_URL,target:"_blank",children:"Official Website & Help Center"})}),m("li",{children:m("a",{href:`${this.ctx.Endpoints.UPDATE_LOGS_URL}#${this.ctx.version.split("-")[0]}`,target:"_blank",children:"Update Logs"})})]}),m("h3",{children:"Join us"}),m("ul",{children:[m("li",{children:[m("strong",{children:"GitHub"}),":"," ",m("a",{href:this.ctx.Endpoints.GITHUB_URL,target:"_blank",children:"inpageedit/inpageedit-next"})]}),m("li",{children:[m("strong",{children:"QQ Group"}),": 1026023666"]})]}),m("hr",{}),m("p",{style:{textAlign:"center"},children:["InPageEdit-NEXT Copyright © 2025-",new Date().getFullYear()," dragon-fish"]}),m("hr",{})]})}),e.inject(["toolbox"],i=>{i.toolbox.addButton({id:"preferences",icon:m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-settings",children:[m("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),m("path",{d:"M14.647 4.081a.724 .724 0 0 0 1.08 .448c2.439 -1.485 5.23 1.305 3.745 3.744a.724 .724 0 0 0 .447 1.08c2.775 .673 2.775 4.62 0 5.294a.724 .724 0 0 0 -.448 1.08c1.485 2.439 -1.305 5.23 -3.744 3.745a.724 .724 0 0 0 -1.08 .447c-.673 2.775 -4.62 2.775 -5.294 0a.724 .724 0 0 0 -1.08 -.448c-2.439 1.485 -5.23 -1.305 -3.745 -3.744a.724 .724 0 0 0 -.447 -1.08c-2.775 -.673 -2.775 -4.62 0 -5.294a.724 .724 0 0 0 .448 -1.08c-1.485 -2.439 1.305 -5.23 3.744 -3.745a.722 .722 0 0 0 1.08 -.447c.673 -2.775 4.62 -2.775 5.294 0zm-2.647 4.919a3 3 0 1 0 0 6a3 3 0 0 0 0 -6z"})]}),tooltip:"Configure Preferences",group:"group2",index:99,onClick:()=>this.showModal()}),this.addDisposeHandler(n=>{n.toolbox.removeButton("preferences")})})}async start(){Promise.resolve().then(()=>Wv).then(({PluginPrefSync:e})=>{this.ctx.plugin(e)}).catch(this.ctx.logger.warn),this.ctx.on("preferences/changed",e=>{this._form?.mergeValue?.(e.input)})}stop(){}showModal(){if(this._modal&&!this._modal.isDestroyed)return this._modal;const e=this.ctx.modal.show({className:"ipe-preference compact-buttons",sizeClass:"small",outSideClose:!1,center:!0,title:`InPageEdit Preferences (${this.ctx.version})`,content:m(vi,{children:m(ri,{})})});e.get$window().classList.add("dialog");const i=m("div",{id:"ipe-preferences-app",style:{minHeight:"calc(85dvh - var(--ipe-modal-spacing) * 2)"}});e.setContent(i),this.ctx.emit("preferences-ui/modal-shown",{ctx:this.ctx,modal:e});const n=this.createPreferencesUIApp(),r=n.mount(i);return this._form=r,this.ctx.emit("preferences-ui/vue-app-mounted",{ctx:this.ctx,app:n,form:r}),e.setButtons([{label:"Close",className:"is-ghost",method:()=>{e.close()}},{label:"Save",className:"is-primary is-ghost",method:async()=>{const s=r.getValue();try{const o=await this.ctx.preferences.setMany(s);this.logger.info("preferences saved",s,o)}catch(o){this.logger.error("failed to save preferences",o)}e.close(),this.ctx.modal.notify("success",{title:"Preferences Saved",content:m("p",{children:"Some settings may take effect after reloading the page."})})}}]),this._modal=e,e.on(e.Event.Close,()=>{this.logger.debug("preferences modal closed, vue app unmounting"),n.unmount(),this._modal=null,this._form=null,this.ctx.emit("preferences-ui/modal-closed",{ctx:this.ctx,modal:e})}),e}getCurrentModal(){return this._modal}closeCurrentModal(){return this._modal?.close()}async dispatchFormSave(e){e=e||this._form||void 0;const i=e?.getValue();return i?(this.ctx.preferences.setMany(i),!0):!1}getCurrentFormValue(){return this._form?.getValue()}mergeFormValue(e){return this._form?.mergeValue?.(e),!!this._form?.mergeValue}createPreferencesUIApp(){return fu(this.ctx,Cy)}}qo=Ty(Mu),Mr=jy(qo,0,"PluginPreferencesUI",Nu,Mr),Dy(qo,1,Mr);const Uy=Object.freeze(Object.defineProperty({__proto__:null,get PluginPreferencesUI(){return Mr}},Symbol.toStringTag,{value:"Module"})),Fy=Symbol("@@apply"),By=Symbol("@@ctor");function Du(t,e){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError("instance is not an object");const i=(...s)=>{const o=t[e];if(typeof o!="function")throw new TypeError(`Property "${String(e)}" is not a function`);return o.apply(t,s)};i[Fy]=i,i[By]=t;const n=t?.constructor?.name;return n&&(i[Symbol.toStringTag]=n),new Proxy(i,{get(s,o,a){return o==="prototype"?Reflect.get(i,o,a):Reflect.get(t,o,t)},set(s,o,a){return Reflect.set(t,o,a)},has(s,o){return Reflect.has(t,o)},deleteProperty(s,o){return Reflect.deleteProperty(t,o)},ownKeys(){return Reflect.ownKeys(t)},getOwnPropertyDescriptor(s,o){return Object.getOwnPropertyDescriptor(t,o)},defineProperty(s,o,a){return Object.defineProperty(t,o,a)}})}const Dr={mbox:"_mbox_5x43w_1",title:"_title_5x43w_12",content:"_content_5x43w_19",close:"_close_5x43w_27"},Ho=t=>{const{type:e="default",title:i,content:n,closeable:r=!0,titleProps:s,contentProps:o,children:a,...l}=t;let c=i;typeof i>"u"&&e!=="default"&&(c=e[0].toUpperCase()+e.slice(1).toLowerCase());const u=async()=>{if(!d)return Promise.resolve();const{promise:h,resolve:p}=Promise.withResolvers();return d.animate([{opacity:"1",height:d.clientHeight+"px"},{opacity:"0",height:"0px",margin:"0px"}],{duration:300,easing:"ease"}).addEventListener("finish",()=>{d.remove(),p()}),h},d=m("div",{className:`theme-ipe ipe-mbox mbox-type-${e||"default"} ${Dr.mbox}`,...l,children:[c&&m("div",{className:`ipe-mbox-title ${Dr.title}`,...s,children:c}),m("div",{className:`ipe-mbox-content ${Dr.content}`,...o,children:a||n}),r&&m("a",{onClick:u,className:`ipe-mbox-close ${Dr.close}`,children:"×"})]});return d.close=u,d},jr=t=>{const{label:e,id:i,name:n,value:r,disabled:s,labelProps:o,inputProps:a,...l}=t;return m("div",{className:"theme-ipe ipe-input-box",...l,children:[m("label",{htmlFor:i,style:{display:"block"},...o,children:e}),m("input",{id:i,name:n,value:r,disabled:s,style:{width:"100%"},...a})]})},qy=t=>{const{id:e,name:i,value:n,label:r,inputProps:s,labelProps:o,children:a,...l}=t;return m("label",{className:"theme-ipe ipe-radio-box",...l,children:[m("input",{type:"radio",id:e,name:i,value:n,...s}),m("span",{className:"ipe-checkbox-box"}),m("span",{...o,children:r||a})]})},Di=t=>{const{id:e,name:i,label:n,checked:r,inputProps:s,labelProps:o,children:a,...l}=t;return m("label",{className:"theme-ipe ipe-checkbox",...l,children:[m("input",{type:"checkbox",id:e,name:i,checked:r,...s}),m("span",{className:"ipe-checkbox-box"}),m("span",{...o,children:n||a})]})},Hy=(t=0)=>new Promise(e=>setTimeout(e,t));var zy=Object.create,zo=Object.defineProperty,Ky=Object.getOwnPropertyDescriptor,ju=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Uu=t=>{throw TypeError(t)},Wy=(t,e,i)=>e in t?zo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Vy=(t,e)=>zo(t,"name",{value:e,configurable:!0}),Gy=t=>[,,,zy(t?.[ju("metadata")]??null)],Yy=["class","method","getter","setter","accessor","field","value","get","set"],Fu=t=>t!==void 0&&typeof t!="function"?Uu("Function expected"):t,Qy=(t,e,i,n,r)=>({kind:Yy[t],name:e,metadata:n,addInitializer:s=>i._?Uu("Already initialized"):r.push(Fu(s||null))}),Jy=(t,e)=>Wy(e,ju("metadata"),t[3]),Xy=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Zy=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,h=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&Ky(r,i));Vy(r,i);for(var f=n.length-1;f>=0;f--)l=Qy(c,i,a={},t[3],h),o=(0,n[f])(r,l),a._=1,Fu(o)&&(r=o);return Jy(t,r),p&&zo(r,i,p),u?c^4?s:p:r},Bu,Ko,qu;Bu=[$e(["api","wikiPage","wikiTitle","currentPage","wiki","modal","preferences"]),si(L.object({"quickEdit.editSummary":L.string().description("Default edit summary for quick edits").default("[IPE-NEXT] Quick edit"),"quickEdit.editMinor":L.boolean().description('Default to checking "minor edit" option').default(!1),"quickEdit.outSideClose":L.boolean().description("Close editor modal by clicking outside").default(!0),"quickEdit.watchList":L.union([L.const(rt.preferences).description("Follow MW preferences"),L.const(rt.nochange).description("Keep the current watchlist status"),L.const(rt.watch).description("Add the page to watchlist"),L.const(rt.unwatch).description("Remove the page from watchlist")]).description("Watchlist options").default(rt.preferences),"quickEdit.keyshortcut.save":L.string().default("ctrl-s").description("save button key shortcut (blank to disable)"),"quickEdit.editFont":L.union([L.const("preferences").description("Follow MW preferences"),L.const("monospace").description("Monospace"),L.const("sans-serif").description("Sans-serif"),L.const("serif").description("Serif"),L.string().description("Custom font (same as CSS `font-family` property)").default("")]).description("Font to use in quick edit's textarea").default("preferences")}).description("Quick edit options").extra("category","editor"))];let Ur=(mi=class extends(qu=Xe){constructor(e){super(e,{},"quick-edit"),this.ctx=e,this.DEFAULT_OPTIONS={title:"",pageId:0,revision:0,section:void 0,editMinor:!1,editSummary:"",createOnly:!1,reloadAfterSave:!0},this.ctx.root.set("quickEdit",Du(this,"showModal"))}start(){this.ctx.inject(["toolbox"],e=>{this.injectToolbox(e),e.on("dispose",()=>{this.removeToolbox(e)})})}async showModal(e){if(typeof e>"u"?e={}:typeof e=="string"&&(e={title:e}),e?.page&&(e.title=e.page,delete e.page),!e.title&&!e.pageId&&!e.revision){this.logger.warn("None of the title, pageId or revision provided. Using defaults.");const R=new URLSearchParams(window.location.search),y=this.ctx.currentPage.wikiTitle;e={...e,title:y?.getPrefixedDBKey(),revision:R.has("oldid")?Number(R.get("oldid")):void 0,pageId:R.has("curid")?Number(R.get("curid")):void 0}}if(!e.revision&&!e.pageId&&e.title){const R=this.ctx.wikiTitle.resolveSpecialPageTarget(e.title);R&&R.title.getNamespaceId()>=0&&(e.title=R.title.getPrefixedDBKey(),e.section??(e.section=R.section))}const i=await this.ctx.preferences.get("quickEdit.outSideClose"),n=await this.ctx.preferences.get("quickEdit.watchList"),r=typeof e.editSummary=="string"?e.editSummary:await this.ctx.preferences.get("quickEdit.editSummary"),s=typeof e.editMinor=="boolean"?e.editMinor:await this.ctx.preferences.get("quickEdit.editMinor"),o=await this.getEditFontOptions(),a={...this.DEFAULT_OPTIONS,editSummary:r,editMinor:s,...e};a.editSummary||(a.editSummary=await this.ctx.preferences.get("quickEdit.editSummary")||""),this.ctx.emit("quick-edit/init-options",{ctx:this.ctx,options:a});const l=this.ctx.modal.createObject({className:"ipe-quickEdit",sizeClass:"large",center:!1,outSideClose:i}).init();l.setTitle(m(vi,{children:["Loading: ",m("u",{children:a.title})]})),l.setContent(m("section",{className:"ipe-quickEdit-loading",style:{height:"70vh",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:m(ri,{})})),l.addButton({side:"right",type:"button",className:"is-danger is-ghost",label:"Cancel",method(){l.close()}}),l.show(),this.ctx.emit("quick-edit/show-modal",{ctx:this.ctx,modal:l,options:a});let c;try{if(c=await this.getWikiPageFromPayload(a),c.pageInfo.special)throw new Error("Special page is not editable")}catch(R){l.off(l.Event.Close),l.close(),this.ctx.modal.notify("error",{content:R instanceof Error?R.message:String(R)});return}const u=a.section==="new"?"":c.revisions[0]?.content||"",d=c.revisions[0]?.revid,h=d&&d!==c.lastrevid,p=a.section==="new",f=c.pageid===0;l.setTitle(m(vi,{children:[p?"New section":`Quick ${f?"Create":"Edit"}`,":"," ",m("u",{children:c.pageInfo.title}),h?` (Revision ${d})`:""]}));const _=[];f&&_.push(m(Ho,{title:"Attention",type:"important",children:m("p",{children:"This page does not exist."})})),h&&_.push(m(Ho,{title:"Attention",type:"warning",children:m("p",{children:["You are editing a ",m("em",{children:"historical version"}),"; the content is not the latest!"]})})),this.ctx.emit("quick-edit/edit-notice",{ctx:this.ctx,options:a,modal:l,wikiPage:c,editNotices:_});const P=m("form",{className:"ipe-quickEdit__form",children:[m("div",{className:"ipe-quickEdit__notices",children:_}),m("div",{className:"ipe-quickEdit__content",style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[a.section==="new"&&m(vi,{children:m(jr,{label:"Section title",id:"summary",name:"summary",value:"",inputProps:{placeholder:"Topic for new section, this will be the h2 heading"}})}),m("textarea",{className:`ipe-quickEdit__textarea ${o.className}`,style:{fontFamily:o.fontFamily},name:"text",id:"wpTextbox1",children:u})]}),m("div",{class:"ipe-quickEdit__options",style:{display:"flex",flexDirection:"column",gap:"1rem",marginTop:"1rem"},children:[!p&&m(jr,{label:"Summary",id:"summary",name:"summary",value:a.editSummary}),m("div",{className:"ipe-input-box",children:[m("label",{htmlFor:"watchlist",style:{display:"block"},children:"Watchlist"}),m("div",{style:{display:"flex",gap:"1rem"},children:[rt.preferences,rt.nochange,rt.watch,rt.unwatch].map(R=>m(qy,{name:"watchlist",value:R,inputProps:{checked:n===R},children:R},R))})]}),m("div",{style:{display:"flex",gap:"1rem"},children:[m(Di,{name:"minor",id:"minor",checked:a.editMinor,children:"Minor edit"}),m(Di,{name:"reloadAfterSave",id:"reloadAfterSave",checked:a.reloadAfterSave,children:"Reload after save"})]})]}),!1]});l.setContent(P),l.addButton({side:"left",className:"is-primary submit-btn",label:"Submit",keyPress:await this.ctx.preferences.get("quickEdit.keyshortcut.save")||void 0,method:()=>{const R=new FormData(P);l.setLoadingState(!0),this.handleSubmit({wikiPage:c,text:R.get("text"),summary:R.get("summary"),minor:R.get("minor")==="on",section:a.section,createonly:c.pageid===0,watchlist:n}).then(async()=>{l.setOptions({beforeClose:Fo}),l.close(),this.ctx.modal.notify("success",{title:"Submission Successful",content:"Your changes have been saved."}),R.get("reloadAfterSave")&&(await Hy(500),location.reload())}).catch(y=>{this.ctx.modal.notify("error",{title:"Submission Error",content:y instanceof Error?y.message:String(y)}),l.setLoadingState(!1)})}},0),l.setOptions({beforeClose:()=>{const R=c.revisions[0]?.content||"";return(P.querySelector("textarea")?.value||"")===R?!0:(this.ctx.modal.confirm({className:"is-primary",title:"Unsaved Changes",content:"All edit contents will be lost after closing the modal. Are you sure you want to close?",center:!0,okBtn:{label:"Give Up",className:"is-danger is-ghost"},cancelBtn:{label:"Continue Editing",className:"is-primary is-ghost"}},g=>(g&&(l.setOptions({beforeClose:Fo}),l.close()),!0)),!1)}}),this.ctx.emit("quick-edit/wiki-page",{ctx:this.ctx,options:a,modal:l,wikiPage:c});const C=R=>P.querySelector("textarea")?.value===u?!0:(R.preventDefault(),"You have unsaved changes. Are you sure you want to leave?");window.addEventListener("beforeunload",C),l.on(l.Event.Close,()=>{window.removeEventListener("beforeunload",C)})}async handleSubmit(e){const i=e.wikiPage,n=e.summary||"",r=e.text||"",s=e.minor,o=e.createonly,a=e.watchlist,l=e.section;return this.ctx.emit("quick-edit/submit",{ctx:this.ctx,wikiPage:i,summary:n,text:r,minor:s,createonly:o,watchlist:a}),i.edit({summary:n,text:r,watchlist:a,section:l},{minor:s,createonly:o})}async getEditFontOptions(){const e=await this.ctx.preferences.get("quickEdit.editFont");return mi.BUILT_IN_FONT_OPTIONS.includes(e)?{className:`mw-editfont-${e==="preferences"?this.ctx.wiki.userOptions?.editfont||"monospace":e}`,fontFamily:""}:{className:"mw-editfont-custom",fontFamily:e}}async getWikiPageFromPayload(e){if(e.revision)return this.ctx.wikiPage.newFromRevision(e.revision,e.section);if(e.pageId)return this.ctx.wikiPage.newFromPageId(e.pageId,e.section);if(e.title)return this.ctx.wikiPage.newFromTitle(e.title,!1,e.section);throw new Error("Invalid payload")}async injectToolbox(e){const i=this.ctx.currentPage.wikiTitle,n=this.ctx.wiki.hasRight("edit")&&i&&i.getNamespaceId()>=0;e.toolbox.addButton({id:"quick-edit",group:"group1",index:0,icon:m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-edit",children:[m("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),m("path",{d:"M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1"}),m("path",{d:"M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z"}),m("path",{d:"M16 5l3 3"})]}),buttonProps:{disabled:!n},tooltip:n?"Quick Edit":"Not editable",onClick:()=>{const r=new URLSearchParams(window.location.search).get("oldid");this.showModal({title:i?.getPrefixedText(),revision:r?Number(r):void 0})}})}removeToolbox(e){e.toolbox.removeButton("quick-edit")}},mi.BUILT_IN_FONT_OPTIONS=["preferences","monospace","sans-serif","serif"],mi);Ko=Gy(qu),Ur=Zy(Ko,0,"PluginQuickEdit",Bu,Ur),Xy(Ko,1,Ur);const eb=Object.freeze(Object.defineProperty({__proto__:null,PluginQuickEdit:Ur},Symbol.toStringTag,{value:"Module"})),$n={twinSwapInput:"_twinSwapInput_1gdgl_9",inputWrapper:"_inputWrapper_1gdgl_23",inputLeft:"_inputLeft_1gdgl_27",inputRight:"_inputRight_1gdgl_30",swapButton:"_swapButton_1gdgl_46"},Hu=t=>{const{inputs:e,enableSwap:i=!0,...n}=t,r=e?.length===2?e:[e?.[0]??{},e?.[1]??{}],s=[null,null];let o=0,a=null,l=null;const c=()=>s.some(f=>f&&f.disabled),u=()=>{if(!s[0]||!s[1]||c())return;const f=s[0],_=s[1],P=f.value,C=_.value;f.value=C,_.value=P,f.dispatchEvent(new Event("change")),_.dispatchEvent(new Event("change")),o++,l&&(l.style.transform=`rotateY(${o*-180}deg)`,l.style.transition="transform 200ms ease")},d=f=>{if(!a)return;const _=f??!a.disabled;a.disabled=!_,_&&s.forEach(P=>{P&&(P.disabled=!1)})},h=m("button",{type:"button","aria-label":"Swap values",onClick:u,disabled:c()||!i,ref:f=>a=f,children:m("svg",{ref:f=>l=f,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon-tabler icons-tabler-outline icon-tabler-transfer",children:[m("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),m("path",{d:"M20 10h-16l5.5 -6"}),m("path",{d:"M4 14h16l-5.5 6"})]})}),p=m("div",{className:`twin-swap-input ${$n.twinSwapInput}`,...n,children:[r.map((f,_)=>{const{label:P,id:C,name:R,value:y,disabled:g,required:v,inputProps:w}=f,S=_===0,k=C||R;return m("div",{className:`${$n.inputWrapper} ${S?$n.inputLeft:$n.inputRight}`,children:[P&&m("label",{htmlFor:k,children:P}),m("input",{ref:j=>s[_]=j,type:"text",id:k,name:R,value:y,disabled:g,required:v,...w})]})}),m("div",{className:$n.swapButton,children:h})]});return p.swap=u,p.toggleEnableSwap=d,p};var tb=Object.create,Wo=Object.defineProperty,ib=Object.getOwnPropertyDescriptor,zu=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Ku=t=>{throw TypeError(t)},nb=(t,e,i)=>e in t?Wo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,rb=(t,e)=>Wo(t,"name",{value:e,configurable:!0}),sb=t=>[,,,tb(t?.[zu("metadata")]??null)],ob=["class","method","getter","setter","accessor","field","value","get","set"],Wu=t=>t!==void 0&&typeof t!="function"?Ku("Function expected"):t,ab=(t,e,i,n,r)=>({kind:ob[t],name:e,metadata:n,addInitializer:s=>i._?Ku("Already initialized"):r.push(Wu(s||null))}),lb=(t,e)=>nb(e,zu("metadata"),t[3]),cb=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},ub=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,h=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&ib(r,i));rb(r,i);for(var f=n.length-1;f>=0;f--)l=ab(c,i,a={},t[3],h),o=(0,n[f])(r,l),a._=1,Wu(o)&&(r=o);return lb(t,r),p&&Wo(r,i,p),u?c^4?s:p:r},Vu,Vo,Gu;Vu=[si(L.object({"quickMove.reason":L.string().default("[IPE-NEXT] Quick move")}).description("Quick move options").extra("category","editor")),$e(["modal","wiki"])];class Fr extends(Gu=Xe){constructor(e){super(e,{},"quick-move"),this.ctx=e,e.set("quickMove",this)}start(){this.ctx.inject(["toolbox"],e=>{this.injectToolbox(e)})}injectToolbox(e){const i=window.mw?.config.get("wgPageName")||"",n=window.mw?.config.get("wgIsProbablyEditable");e.toolbox.addButton({id:"quick-move",icon:m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-forms",children:[m("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),m("path",{d:"M12 3a3 3 0 0 0 -3 3v12a3 3 0 0 0 3 3"}),m("path",{d:"M6 3a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3"}),m("path",{d:"M13 7h7a1 1 0 0 1 1 1v8a1 1 0 0 1 -1 1h-7"}),m("path",{d:"M5 7h-1a1 1 0 0 0 -1 1v8a1 1 0 0 0 1 1h1"}),m("path",{d:"M17 12h.01"}),m("path",{d:"M13 12h.01"})]}),tooltip:"Quick Move",group:"group1",index:1,onClick:()=>{this.showModal(n?{lockFromField:!0,from:i}:{})}})}async showModal(e){const i=await this.ctx.preferences.get("quickMove.reason"),n=this.ctx.modal.createObject({title:"Quick Move",content:m(ri,{}),className:"quick-move compact-buttons",sizeClass:"smallToMedium",center:!0}).init();let r=null;return n.setContent(m("form",{ref:s=>r=s,style:{display:"flex",flexDirection:"column",gap:"1rem"},onSubmit:s=>{if(s.preventDefault(),r?.checkValidity(),!r?.reportValidity())return;const o=new FormData(r),a={from:o.get("from")?.toString().trim(),to:o.get("to")?.toString().trim(),reason:o.get("reason")||"",movetalk:o.get("movetalk")==="on",movesubpages:o.get("movesubpages")==="on",noredirect:o.get("noredirect")==="on"};if(!a.from||!a.to){this.ctx.modal.notify("error",{title:"Failed to move",content:"From and to are required."});return}this.ctx.emit("quick-move/submit",{ctx:this.ctx,modal:n,payload:a}),n.setLoadingState(!0),this.movePage(a).then(()=>{location.reload()}).catch(l=>{n.setLoadingState(!1),this.ctx.modal.notify("error",{title:"Failed to move",content:l instanceof Error?l.message:String(l)})})},children:[m(Hu,{inputs:[{label:"Move from",name:"from",value:e?.from,required:!0},{label:"Move to",name:"to",value:e?.to,required:!0}]}),m("div",{children:m(Di,{name:"movetalk",id:"movetalk",checked:e?.movetalk,children:"Move talk page"})}),m("div",{children:m(Di,{name:"movesubpages",id:"movesubpages",checked:e?.movesubpages,children:"Move subpage(s) (up to 100)"})}),this.ctx.wiki.hasRight("suppressredirect")&&m("div",{children:m(Di,{name:"noredirect",id:"noredirect",checked:e?.noredirect,children:"Move without leaving a redirect"})}),m(jr,{label:"Reason",id:"reason",name:"reason",value:e?.reason??i??""})]})),n.setButtons([{label:"Move",className:"is-primary is-ghost",method:()=>{r?.dispatchEvent(new Event("submit"))}}]),n.show()}async movePage(e){const{from:i,to:n,reason:r="",...s}=e;if(!i||!n)throw new Error("From and to titles are required.");if(i===n)throw new Error("From and to titles cannot be the same.");return(await this.ctx.wikiPage.newFromTitle(i)).moveTo(n,r,s)}}Vo=sb(Gu),Fr=ub(Vo,0,"PluginQuickMove",Vu,Fr),cb(Vo,1,Fr);const fb=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickMove(){return Fr}},Symbol.toStringTag,{value:"Module"}));var db=Object.create,Go=Object.defineProperty,hb=Object.getOwnPropertyDescriptor,Yu=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Qu=t=>{throw TypeError(t)},pb=(t,e,i)=>e in t?Go(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,mb=(t,e)=>Go(t,"name",{value:e,configurable:!0}),gb=t=>[,,,db(t?.[Yu("metadata")]??null)],yb=["class","method","getter","setter","accessor","field","value","get","set"],Ju=t=>t!==void 0&&typeof t!="function"?Qu("Function expected"):t,bb=(t,e,i,n,r)=>({kind:yb[t],name:e,metadata:n,addInitializer:s=>i._?Qu("Already initialized"):r.push(Ju(s||null))}),vb=(t,e)=>pb(e,Yu("metadata"),t[3]),wb=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},_b=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,h=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&hb(r,i));mb(r,i);for(var f=n.length-1;f>=0;f--)l=bb(c,i,a={},t[3],h),o=(0,n[f])(r,l),a._=1,Ju(o)&&(r=o);return vb(t,r),p&&Go(r,i,p),u?c^4?s:p:r},Xu,Yo,Zu;Xu=[$e(["api","wikiPage","modal","preferences"]),si(L.object({"quickPreview.keyshortcut":L.string().default("ctrl-p").description("Key shortcut to open quick preview in quick edit modal")}).extra("category","editor").description("Quick preview options"))];class Br extends(Zu=Xe){constructor(e){super(e,{},"quickPreview"),this.ctx=e,this.ctx.set("quickPreview",Du(this,"previewWikitext"))}start(){this.ctx.on("quick-edit/wiki-page",this.injectQuickEdit.bind(this))}stop(){}previewWikitext(e,i,n,r,s){return n||(n=this.ctx.wikiPage.newBlankPage({title:"API"})),(!r||r.isDestroyed)&&(r=this.ctx.modal.createObject({className:"in-page-edit ipe-quickPreview",sizeClass:"large",center:!1,...s}).init()),r.show(),r.setTitle("Preview - Loading..."),r.setContent(m(ri,{})),r.bringToFront(),this.ctx.emit("quick-preview/show-modal",{ctx:this.ctx,text:e,modal:r,wikiPage:n}),n.preview(e,i).then(o=>{const{data:{parse:a}}=o;r.setTitle(`Preview - ${a.title}`);let l=null;r.setContent(m("section",{children:m("div",{ref:c=>l=c,className:"mw-parser-output",innerHTML:a.text})})),window.mw?.hook("wikipage.content").fire($(l)),this.ctx.emit("quick-preview/loaded",{ctx:this.ctx,modal:r,wikiPage:n,text:e,parseData:a})}).catch(o=>{r.setTitle("Preview - Failed"),r.setContent(m(vi,{children:[m("p",{children:"Failed to preview"}),m("p",{children:o instanceof Error?o.message:String(o)})]}))}),r}async injectQuickEdit({options:e,modal:i,wikiPage:n}){let r;i.addButton({label:"Preview",side:"left",className:"btn btn-secondary",keyPress:await this.ctx.preferences.get("quickPreview.keyshortcut.quickEdit")||void 0,method:()=>{let s=i.get$content().querySelector('textarea[name="text"]')?.value||"";if(e.section==="new"){const o=i.get$content().querySelector('input[name="summary"]')?.value;o&&(s=`==${o}==
17
- ${s}`)}r=this.previewWikitext(s,void 0,n,r,{backdrop:!1,draggable:!0})}},1),i.on(i.Event.Close,()=>{r?.destroy(),r=void 0})}}Yo=gb(Zu),Br=_b(Yo,0,"PluginQuickPreview",Xu,Br),wb(Yo,1,Br);const xb=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickPreview(){return Br}},Symbol.toStringTag,{value:"Module"})),Sb=t=>{let{user:e,target:i,ctx:n}=t;const r=n.getUrl.bind(n);return m("span",{className:"mw-userlinks",children:[m("a",{href:r(`User:${e}`),className:"mw-userlink",target:i,children:e})," ",m("span",{className:"mw-usertoollinks",children:["(",m("a",{href:r(`User_talk:${e}`),className:"mw-usertoollinks-talk",target:i,children:"talk"})," | ",m("a",{href:r(`Special:Contributions/${e}`),className:"mw-usertoollinks-contribs",target:i,children:"contribs"})," | ",m("a",{href:r(`Special:Block/${e}`),className:"mw-usertoollinks-block",target:i,children:"block"}),")"]})]})};var qr=(t=>(t.update="ipe:diff-table/update",t.edit="ipe:diff-table/edit",t))(qr||{});const kb=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"medium"}).format,ef=t=>{let e=["diff-title"];if(t.type==="from"?e.push("diff-otitle"):t.type==="to"&&e.push("diff-ntitle"),!t.pageid||!t.userid)return m("td",{colSpan:2,className:e,children:m("div",{className:"mw-diff-title--title",children:t.type==="from"?"Original content":t.type==="to"?"Your content":""})});const i=n=>{n.preventDefault(),n.target.dispatchEvent(new CustomEvent("ipe:diff-table/edit",{detail:{revid:t.revid},bubbles:!0}))};return m("td",{colSpan:2,className:e,children:[m("div",{className:"mw-diff-title--title",children:[t.pagetitle||t.timestamp,t.revid?` (rev#${t.revid})`:""]}),m("div",{className:"mw-diff-title--actions",children:m("a",{href:t.ctx.getUrl("",{action:"edit",oldid:t.revid}),onClick:i,children:[m(pl,{style:"width: 1em; height: 1em"}),"Quick edit"]})}),m("div",{className:"mw-diff-title--user",children:t.username&&m(Sb,{ctx:t.ctx,user:t.username,target:"_blank"})}),m("div",{className:"mw-diff-title--timestamp",children:t.timestamp&&kb(new Date(t.timestamp))}),m("div",{className:"mw-diff-title--comment",children:t.parsedcomment&&m(vi,{children:["(",m("i",{innerHTML:t.parsedcomment}),")"]})})]})},Eb=t=>{const e=t.data;if(!e.prev&&!e.next)return null;const i=(n,r,s)=>{n.preventDefault(),n.target.dispatchEvent(new CustomEvent("ipe:diff-table/update",{detail:{fromrev:r,torev:s},bubbles:!0}))};return m("tr",{className:"mw-diff-title--navigation",children:[m("td",{colSpan:2,children:e.prev?m("a",{href:t.ctx.getUrl("",{diff:e.prev,oldid:e.fromrevid}),onClick:n=>i(n,e.prev,e.fromrevid),children:"← Previous"}):m("i",{children:"Oldest version"})}),m("td",{colSpan:2,children:e.next?m("a",{href:t.ctx.getUrl("",{diff:e.next,oldid:e.torevid}),onClick:n=>i(n,e.torevid,e.next),children:"Next →"}):m("i",{children:"Newest version"})})]})},$b=t=>{const{data:e,...i}=t,n=m("table",{className:"theme-ipe diff diff-type-table","data-mw":"interface",...i,children:[m("colgroup",{children:[m("col",{className:"diff-marker"}),m("col",{className:"diff-content"}),m("col",{className:"diff-marker"}),m("col",{className:"diff-content"})]}),m("tbody",{children:[m("tr",{children:[m(ef,{ctx:t.ctx,type:"from",pageid:e.fromid,pagetitle:e.fromtitle,revid:e.fromrevid,size:e.fromsize,timestamp:e.fromtimestamp,username:e.fromuser,userid:e.fromuserid,comment:e.fromcomment,parsedcomment:e.fromparsedcomment}),m(ef,{ctx:t.ctx,type:"to",pageid:e.toid,pagetitle:e.totitle,revid:e.torevid,size:e.tosize,timestamp:e.totimestamp,username:e.touser,userid:e.touserid,comment:e.tocomment,parsedcomment:e.toparsedcomment})]}),m(Eb,{data:e,ctx:t.ctx}),m("div",{id:"diffbody"}),m("tr",{className:"diff-size",style:{textAlign:"center"},children:[m("td",{colSpan:2,className:"diff-size-old",children:e.fromsize!==void 0&&`${e.fromsize} bytes`}),m("td",{colSpan:2,className:"diff-size-new",children:e.tosize!==void 0&&`${e.tosize} bytes`})]})]})]});return n.querySelector("#diffbody").outerHTML=e.body||m("tr",{children:m("td",{colSpan:4,children:m("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"5rem"},children:m("i",{children:"No changes"})})})}).outerHTML,n},Pb=(t,e=document)=>e.querySelector(t),Cb=(t,e=document)=>e.querySelectorAll(t);var Rb=Object.create,Qo=Object.defineProperty,Ab=Object.getOwnPropertyDescriptor,tf=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),nf=t=>{throw TypeError(t)},Ib=(t,e,i)=>e in t?Qo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ob=(t,e)=>Qo(t,"name",{value:e,configurable:!0}),Tb=t=>[,,,Rb(t?.[tf("metadata")]??null)],Lb=["class","method","getter","setter","accessor","field","value","get","set"],rf=t=>t!==void 0&&typeof t!="function"?nf("Function expected"):t,Nb=(t,e,i,n,r)=>({kind:Lb[t],name:e,metadata:n,addInitializer:s=>i._?nf("Already initialized"):r.push(rf(s||null))}),Mb=(t,e)=>Ib(e,tf("metadata"),t[3]),Db=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},jb=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,h=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&Ab(r,i));Ob(r,i);for(var f=n.length-1;f>=0;f--)l=Nb(c,i,a={},t[3],h),o=(0,n[f])(r,l),a._=1,rf(o)&&(r=o);return Mb(t,r),p&&Qo(r,i,p),u?c^4?s:p:r},sf,Jo,of;sf=[$e(["wiki","getUrl","preferences"]),si(L.object({"quickDiff.keyshortcut":L.string().default("ctrl-d").description("Key shortcut to open quick diff in quick edit modal")}).description("Quick diff options").extra("category","editor"))];class Hr extends(of=Xe){constructor(e){super(e,{},"quick-diff"),this.ctx=e,this.COMPARE_API_DEFAULT_OPTIONS={prop:["comment","diff","diffsize","ids","parsedcomment","size","timestamp","title","user","rel"].join("|"),difftype:"table"}}start(){this.ctx.set("quickDiff",this),this.ctx.on("quick-edit/wiki-page",this.injectQuickEdit.bind(this)),window.RLQ.push(this.injectHistoryPage.bind(this))}stop(){}injectHistoryPage(){const e=Pb("#mw-history-compare");if(!e)return;Cb(".mw-history-compareselectedversions-button",e).forEach(n=>{n.after(m("button",{className:"cdx-button",onClick:r=>{r.preventDefault();const s=new FormData(e),o=Number(s.get("oldid"))||0,a=Number(s.get("diff"))||0;if(!s.get("title")||!o||!a)return this.logger.warn("Missing title or revision IDs");this.comparePages({fromrev:o,torev:a})},children:"Quick Diff"}))})}async injectQuickEdit({modal:e,wikiPage:i,options:n}){if(i.pageid===0||n.section==="new")return;let r;e.addButton({label:"Diff",side:"left",keyPress:await this.ctx.preferences.get("quickDiff.keyshortcut")||void 0,className:"btn btn-secondary",method:()=>{const s=i.title,o=i.revisions?.[0]?.content||"",a=e.get$content().querySelector('textarea[name="text"]')?.value||"";return o===a?this.ctx.modal.notify("info",{title:"Quick Diff",content:"No changes"}):(this.ctx.emit("quick-diff/quick-edit-modal",{ctx:this.ctx,modal:e,wikiPage:i}),r=this.comparePages({fromtitle:s,fromtext:o,totitle:s,totext:a,topst:!0},r,{backdrop:!1,draggable:!0}),r)}},2),e.on(e.Event.Close,()=>{r?.destroy(),r=void 0})}comparePages(e,i,n){return!i||i.isDestroyed?i=this.ctx.modal.createObject({title:"Loading diff...",content:"",className:"quick-diff",center:!1,...n}).init():i.removeButton("*"),this.ctx.emit("quick-diff/init-options",{ctx:this.ctx,options:e}),i.setContent(m("section",{style:{height:"70vh",display:"flex",justifyContent:"center",alignItems:"center"},children:m(ri,{})})),i.bringToFront(),window.mw&&mw.loader.getState("mediawiki.diff.styles")!=="ready"&&mw.loader.load(["mediawiki.diff.styles"]),this.ctx.api.post({...this.COMPARE_API_DEFAULT_OPTIONS,...e,action:"compare",format:"json",formatversion:2}).then(r=>{if(!r.data.compare)throw new Error("No compare data received",{cause:r});const{data:{compare:s}}=r;i.setTitle(s.fromtitle&&s.totitle?`${s.fromtitle}${s.fromrevid?` (${s.fromrevid})`:""} ⇔ ${s.totitle}${s.torevid?` (${s.torevid})`:""}`:"Differences");let o;i.setContent(m("section",{style:{minHeight:"70vh"},children:m($b,{ref:a=>o=a,data:s,ctx:this.ctx})})),o.addEventListener(qr.update,a=>{a.stopPropagation(),this.comparePages({fromrev:a.detail.fromrev,torev:a.detail.torev},i,n)},{once:!0}),this.ctx.inject(["quickEdit"],a=>{const l=c=>{c.stopPropagation(),a.quickEdit({revision:c.detail.revid})};o.addEventListener(qr.edit,l),i.on(i.Event.Close,()=>{o.removeEventListener(qr.edit,l)})}),s.fromrevid&&s.torevid&&i.addButton({label:"Original Compare Page",side:"right",className:"btn btn-secondary",method:()=>{window.location.href=this.ctx.getUrl("",{oldid:s.fromrevid,diff:s.torevid})}}),this.ctx.emit("quick-diff/loaded",{ctx:this.ctx,modal:i,compare:s})}).catch(r=>{i.setContent(m(Ho,{title:"Failed to load diff",type:"error",children:m("pre",{children:r instanceof Error?r.message:String(r)})}))}),i.show()}}Jo=Tb(of),Hr=jb(Jo,0,"PluginQuickDiff",sf,Hr),Db(Jo,1,Hr);const Ub=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickDiff(){return Hr}},Symbol.toStringTag,{value:"Module"})),Yr=class Yr extends Xe{constructor(e){super(e,{},"quick-redirect"),this.ctx=e}start(){this.ctx.set("quickRedirect",this);const e=window.mw?.config.get("wgPageName")||"",i=window.mw?.config.get("wgIsProbablyEditable");this.ctx.inject(["toolbox"],n=>{this.ctx=n,n.toolbox.addButton({id:"quick-redirect",icon:m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-file-symlink",children:[m("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),m("path",{d:"M4 21v-4a3 3 0 0 1 3 -3h5"}),m("path",{d:"M9 17l3 -3l-3 -3"}),m("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),m("path",{d:"M5 11v-6a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2h-9.5"})]}),tooltip:"Quick Redirect",group:"group1",index:2,onClick:()=>{this.showModal(i?{to:e}:{})}}),this.addDisposeHandler(r=>{r.toolbox.removeButton("quick-redirect")})})}stop(){}async showModal(e){const i=await this.ctx.preferences.get("quickRedirect.reason");e||(e={}),this.ctx.emit("quick-redirect/init-options",{ctx:this.ctx,options:e});const n=this.ctx.modal.createObject({title:"Quick Redirect",content:m(ri,{}),className:"quick-redirect compact-buttons",sizeClass:"smallToMedium",center:!0}).init();let r=null;return n.setContent(m("form",{ref:s=>r=s,style:{display:"flex",flexDirection:"column",gap:"1rem"},onSubmit:s=>{if(s.preventDefault(),r?.checkValidity(),!r?.reportValidity())return;const o=new FormData(r),a={from:o.get("from")?.toString().trim(),to:o.get("to")?.toString().trim(),reason:o.get("reason")||"",overwrite:o.get("overwrite")==="on"};if(!a.from||!a.to){this.ctx.modal.notify("error",{title:"Failed to redirect",content:"From and to are required."});return}this.ctx.emit("quick-redirect/submit",{ctx:this.ctx,payload:a}),n.setLoadingState(!0),this.redirectPage(a).then(l=>{n.close(),this.ctx.modal.notify("success",{title:"Redirect successful",content:"The redirect has been created."})}).catch(l=>{n.setLoadingState(!1),this.ctx.modal.notify("error",{title:"Failed to redirect",content:l instanceof Error?l.message:String(l)})})},children:[m(Hu,{inputs:[{label:"From",name:"from",value:e?.from,required:!0},{label:"To",name:"to",value:e?.to,required:!0}]}),m(jr,{label:"Reason",id:"reason",name:"reason",value:e?.reason??i??""}),m("div",{children:m(Di,{name:"overwrite",id:"overwrite",checked:e?.overwrite,children:"Force create redirect even if the from page already exists"})})]})),n.setButtons([{label:"Create Redirect",className:"is-primary is-ghost",method:()=>{r?.dispatchEvent(new Event("submit"))}}]),this.ctx.emit("quick-redirect/show-modal",{ctx:this.ctx,modal:n}),n.show()}async redirectPage(e){const{from:i,to:n,reason:r="",overwrite:s=!1}=e,o=await this.ctx.wikiPage.newBlankPage({title:i}),a=`#REDIRECT [[:${n}]]`;return o.edit({text:a,summary:r},{createonly:!s})}};Yr.inject=["api","wikiPage","modal"],Yr.PreferencesSchema=L.object({"quickRedirect.reason":L.string().default("[IPE-NEXT] Quick redirect")}).description("Quick redirect options").extra("category","editor");let Xo=Yr;const Fb=Object.freeze(Object.defineProperty({__proto__:null,PluginQuickRedirect:Xo},Symbol.toStringTag,{value:"Module"}));var Bb=Object.create,Zo=Object.defineProperty,qb=Object.getOwnPropertyDescriptor,af=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),lf=t=>{throw TypeError(t)},Hb=(t,e,i)=>e in t?Zo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,zb=(t,e)=>Zo(t,"name",{value:e,configurable:!0}),Kb=t=>[,,,Bb(t?.[af("metadata")]??null)],Wb=["class","method","getter","setter","accessor","field","value","get","set"],cf=t=>t!==void 0&&typeof t!="function"?lf("Function expected"):t,Vb=(t,e,i,n,r)=>({kind:Wb[t],name:e,metadata:n,addInitializer:s=>i._?lf("Already initialized"):r.push(cf(s||null))}),Gb=(t,e)=>Hb(e,af("metadata"),t[3]),Yb=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Qb=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,h=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&qb(r,i));zb(r,i);for(var f=n.length-1;f>=0;f--)l=Vb(c,i,a={},t[3],h),o=(0,n[f])(r,l),a._=1,cf(o)&&(r=o);return Gb(t,r),p&&Zo(r,i,p),u?c^4?s:p:r},uf,ea,ff;uf=[si(L.object({toolboxAlwaysShow:L.boolean().description("Make the toolbox opened by default").default(!1)}).description("Toolbox preferences")),$e(["preferences"])];class zr extends(ff=Ot){constructor(e){super(e,"toolbox",!1),this.ctx=e,this.container=void 0}async start(){this.container=this.createToolbox(),this.ctx.preferences.get("toolboxAlwaysShow").then(e=>{e&&this.container.classList.add("is-persistent")}),this.setupHoverLogic(),document.body.appendChild(this.container),this.updateButtonDelays()}stop(){this.container?.remove()}get isPersistent(){return this.container.classList.contains("is-persistent")}setupHoverLogic(){let e=null;this.container.addEventListener("mouseenter",()=>{e&&(clearTimeout(e),e=null),this.isPersistent||this.container.classList.add("is-hovered")}),this.container.addEventListener("mouseleave",()=>{this.isPersistent||(e=window.setTimeout(()=>{this.container.classList.remove("is-hovered")},150))})}calculateButtonDelay(e,i){if(i<=1)return 0;const n=.15,r=e/(i-1),s=n*Math.sqrt(r);return Math.round(s*1e3)/1e3}updateButtonDelays(){this.container.querySelectorAll(".btn-group").forEach(i=>{const n=i.querySelectorAll(".btn-tip-group"),r=n.length;n.forEach((s,o)=>{const a=this.calculateButtonDelay(o,r);s.style.setProperty("--transition-delay",`${a}s`),s.style.setProperty("--max-transition-delay","0.15s")})})}createToolbox(){return m("div",{id:"ipe-edit-toolbox",children:[m("ul",{className:"btn-group group1",style:{display:"flex",flexDirection:"column"}}),m("ul",{className:"btn-group group2",style:{display:"flex",flexDirection:"row"}}),m("button",{className:"ipe-toolbox-btn",id:"toolbox-toggler",onClick:()=>{this.toggle()},children:m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"448",height:"512",viewBox:"0 0 448 512",children:[m("rect",{width:"448",height:"512",fill:"none"}),m("path",{fill:"currentColor",d:"M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32"})]})})]})}normalizeButtonId(e){return e||(e=Math.random().toString(36).substring(2,8)),`ipe-toolbox__${e.trim()}`.replace(/\s\.#/g,"-")}addButton(e){let{id:i,group:n,icon:r,tooltip:s,itemProps:o,buttonProps:a,onClick:l,index:c}=e;i=this.normalizeButtonId(i);const u=this.container.querySelector(`#${i}`);u&&(this.ctx.logger("toolbox").warn(`Button with id ${i} already exists, replacing it.`),u.remove());let d=null;if(typeof n>"u"||n==="auto"){const p=this.container.querySelector(".btn-group.group1"),f=this.container.querySelector(".btn-group.group2"),_=p?.children.length||0,P=f?.children.length||0;d=_<=P?p:f}else d=this.container.querySelector(`.btn-group.${n}`);if(!d)throw new Error(`Button group ${n} not found`);const h=m("li",{class:"btn-tip-group",id:i,onClick:l,...o,children:[m("div",{class:"btn-tip",children:s}),m("button",{id:`${i}-btn`,"data-id":e.id,class:"ipe-toolbox-btn",...a,children:r})]});return h.addEventListener("click",p=>{this.ctx.emit("toolbox/button-clicked",{ctx:this.ctx,button:p.target,id:e.id})}),typeof c=="number"?c<=0?d.prepend(h):c>=d.children.length?d.appendChild(h):d.children[c]?.before(h):d.appendChild(h),this.ctx.emit("toolbox/button-added",{ctx:this.ctx,button:h}),this.updateButtonDelays(),h}removeButton(e){const i=this.normalizeButtonId(e);this.container.querySelector(`#${i}`)?.remove(),this.ctx.emit("toolbox/button-removed",{ctx:this.ctx,id:e}),this.updateButtonDelays()}getContainer(){return this.container}get isOpened(){return this.container.classList.contains("is-persistent")||this.container.classList.contains("is-hovered")}toggle(e){const i=this.isPersistent,n=typeof e=="boolean"?e:!i;this.container.classList.toggle("is-persistent",n),this.container.classList.remove("is-hovered"),this.ctx.preferences.set("toolboxAlwaysShow",n),this.ctx.emit("toolbox/toggle",{ctx:this.ctx,opened:this.isOpened})}}ea=Kb(ff),zr=Qb(ea,0,"PluginToolbox",uf,zr),Yb(ea,1,zr);const Jb=Object.freeze(Object.defineProperty({__proto__:null,get PluginToolbox(){return zr}},Symbol.toStringTag,{value:"Module"})),Kr=ci({__name:"UIBaseButton",props:{variant:{default:"neutral"},active:{type:Boolean,default:!1}},setup(t){const e=t,i=qt(()=>({"is-active":e.active,"is-danger":e.variant==="danger","is-primary":e.variant==="primary","is-ghost":e.variant==="ghost","is-accent":e.variant==="accent"}));return(n,r)=>(oe(),ue("button",{class:ft(["ipeps-button",i.value])},[jm(n.$slots,"default")],2))}}),Xb={id:"ipe-registry-manager"},Zb={class:"ipeps-header"},ev={class:"ipeps-input-wrapper"},tv=["disabled"],iv={key:0,class:"ipeps-list"},nv={class:"registry-info"},rv={class:"item-name"},sv={class:"item-desc"},ov={class:"homepage"},av=["href"],lv={class:"url"},cv={class:"item-meta"},uv={class:"ipeps-actions"},fv={key:1,class:"ipeps-empty"},dv={class:"description"},hv=Nr(ci({__name:"RegistryManager",setup(t){const e=Lo(),i=Me([]),n=Me(""),r=Me(!1),s=h=>{try{return new URL(h).hostname}catch{return h}};async function o(){const h=await e.preferences.get("pluginStore.registries")||[],p=await Promise.allSettled(h.map(async f=>{const _=await e.store.getRegistryInfo(f);return{registryUrl:f,label:s(f),..._}}));i.value=p.filter(f=>f.status==="fulfilled").map(f=>f.value)}async function a(){const h=n.value.trim();if(h){if(i.value.some(p=>p.registryUrl===h)){e.modal.notify("info",{content:"Registry already exists."});return}r.value=!0;try{const p=await e.store.getRegistryInfo(h,"online_manifest",!0);if(!p)throw new Error("Invalid registry or unreachable");const f=await e.preferences.get("pluginStore.registries")||[];f.push(h),await e.preferences.set("pluginStore.registries",f),i.value.push({registryUrl:h,label:s(h),...p}),n.value="",e.modal.notify("success",{content:"Registry added."})}catch(p){e.modal.notify("error",{content:p instanceof Error?p.message:String(p)})}finally{r.value=!1}}}async function l(h){const f=(await e.preferences.get("pluginStore.registries")||[]).filter(_=>_!==h);await e.preferences.set("pluginStore.registries",f),i.value=i.value.filter(_=>_.registryUrl!==h)}async function c(h){const f=(await e.preferences.get("pluginStore.plugins")||[]).filter(_=>_.registry===h);if(f.length===0){e.modal.confirm({title:"Remove registry",content:`Remove registry:
18
- ${h}`,cancelBtn:{label:"Cancel",className:"is-ghost"},okBtn:{label:"Remove",className:"is-danger"}},async _=>{_&&(await l(h),e.modal.notify("success",{content:"Registry removed."}))});return}e.modal.dialog({title:"Remove registry",content:Zi("div",{class:"theme-ipe-prose"},[Zi("p",{},`There ${f.length===1?"is":"are"} ${f.length} installed plugin${f.length===1?"":"s"} from this registry:`),Zi("ul",{},f.map(_=>Zi("li",{},_.id)))]),buttons:[{label:"Remove only",className:"is-danger is-ghost",method:async(_,P)=>{await l(h),e.modal.notify("success",{content:"Registry removed."}),P.close()}},{label:"Remove and uninstall plugins",className:"is-danger",method:async(_,P)=>{await l(h);for(const C of f)try{await e.store.uninstallAndRemovePreference(C.registry,C.id)}catch(R){e.modal.notify("error",{content:R instanceof Error?`Failed to uninstall ${C.id}: ${R.message}`:`Failed to uninstall ${C.id}`})}e.modal.notify("success",{content:`Registry removed and ${f.length} ${f.length===1?"plugin":"plugins"} uninstalled.`}),P.close()}}]},()=>{})}function u(h){const p=h.changes["pluginStore.registries"];Array.isArray(p)&&o()}function d(){const h=Lt.PLUGIN_REGISTRY_URL;n.value=h,a()}return mn(()=>{o(),e.on("preferences/changed",u)}),(h,p)=>(oe(),ue("div",Xb,[Q("div",Zb,[p[2]||(p[2]=Q("div",{class:"ipeps-header-title"},"Registries",-1)),Q("div",ev,[sc(Q("input",{class:"ipeps-input with-icon","onUpdate:modelValue":p[0]||(p[0]=f=>n.value=f),type:"url",placeholder:"Add registry URL (https://...)",disabled:r.value},null,8,tv),[[cu,n.value,void 0,{trim:!0}]]),p[1]||(p[1]=Q("div",{class:"ipeps-input-icon"},"📦",-1))]),Ee(Kr,{onClick:a,disabled:r.value||!n.value,variant:"primary"},{default:hn(()=>[xn(ke(r.value?"Adding...":"Add"),1)]),_:1},8,["disabled"])]),i.value.length?(oe(),ue("div",iv,[(oe(!0),ue(Ue,null,po(i.value,f=>(oe(),ue("div",{class:"ipeps-item",key:f.registryUrl},[Q("div",nv,[Q("div",rv,ke(f.label),1),Q("div",sv,[Q("div",ov,[f.homepage?(oe(),ue("a",{key:0,href:f.homepage,target:"_blank"},ke(f.homepage),9,av)):Yt("",!0)]),Q("div",lv,ke(f.registryUrl),1)]),Q("div",cv,ke(f.packages.length)+" packages",1)]),Q("div",uv,[Ee(Kr,{onClick:_=>c(f.registryUrl),variant:"danger"},{default:hn(()=>[...p[3]||(p[3]=[xn("Remove",-1)])]),_:1},8,["onClick"])])]))),128))])):(oe(),ue("div",fv,[p[5]||(p[5]=Q("div",{class:"icon"},"🗂️",-1)),p[6]||(p[6]=Q("div",{class:"text"},"No registries configured",-1)),Q("div",dv,[Ee(Kr,{onClick:d,variant:"primary",style:{padding:"0.25rem 0.5rem"}},{default:hn(()=>[...p[4]||(p[4]=[xn("setup default registry",-1)])]),_:1})])]))]))}}),[["__scopeId","data-v-132e6dc8"]]),pv={id:"ipe-plugin-install-manager"},mv={class:"ipeps-header"},gv={class:"ipeps-input-wrapper"},yv=["disabled"],bv=["disabled"],vv={key:0,class:"ipeps-loading"},wv={key:1,class:"ipeps-list"},_v={class:"plugin-info"},xv={class:"plugin-header"},Sv={class:"item-name"},kv={class:"ipeps-tags"},Ev=["href","title"],$v=["title"],Pv={class:"plugin-meta"},Cv={key:0,class:"version"},Rv={key:1,class:"author"},Av={key:2,class:"license"},Iv={key:2,class:"ipeps-empty"},Ov=Nr(ci({__name:"PluginInstallManager",setup(t){const e=Lo(),i=Me([]),n=Me([]),r=Me(""),s=Me(!1),o=(w,S)=>`${w}
19
- ${S}`,a=qt(()=>new Set(n.value.map(w=>o(w.registry,w.id)))),l=w=>a.value.has(w),c=w=>{try{return new URL(w).hostname}catch{return w}},u=Me(!1),d=qt(()=>i.value.length>0),h=qt(()=>{const w=r.value.trim().toLowerCase(),S=i.value.flatMap(ae=>(ae.packages||[]).map(xe=>({...xe,_key:o(ae.registryUrl,xe.id),registry:ae.registryUrl,registryHomepage:ae.homepage,registryLabel:c(ae.registryUrl),isBroken:!1,isRegistryMissing:!1}))),k=new Set(S.map(ae=>ae._key)),j=new Set(i.value.map(ae=>ae.registryUrl)),z=n.value.filter(ae=>!k.has(o(ae.registry,ae.id))).map(ae=>{const xe=i.value.find(On=>On.registryUrl===ae.registry);return{id:ae.id,name:void 0,description:void 0,version:void 0,author:void 0,license:void 0,_key:o(ae.registry,ae.id),registry:ae.registry,registryHomepage:xe?.homepage,registryLabel:c(ae.registry),isBroken:!0,isRegistryMissing:!j.has(ae.registry)}}),mt=ae=>w?ae.filter(xe=>xe.name&&xe.name.toLowerCase().includes(w)||xe.id&&xe.id.toLowerCase().includes(w)||xe.description&&xe.description.toLowerCase().includes(w)||xe.author&&xe.author.toLowerCase().includes(w)||xe.registry&&xe.registry.toLowerCase().includes(w)):ae;return[...mt(z),...mt(S)]}),p=qt(()=>h.value),f=w=>w.description?w.description:w.isBroken?w.isRegistryMissing?"[Recommend to uninstall] The registry is unavailable. Try refreshing or re-adding the registry to fix this issue.":"[Recommend to uninstall] This plugin was removed from the registry. Try refreshing the registry to confirm.":"",_=async(w,S)=>{e.store.installAndSetPreference(w,S)},P=async(w,S)=>{e.store.uninstallAndRemovePreference(w,S)},C=(w,S)=>l(o(w,S))?P(w,S):_(w,S),R=w=>C(w.registry,w.id),y=async()=>{if(s.value)return;if(i.value.length===0){e.modal.notify("info",{content:"No registry configured. Please add a registry first."});return}s.value=!0;const w=await e.store.refreshAllRegistryCaches(),S=Object.entries(w).filter(([j,z])=>z!==null);i.value=S.map(([j,z])=>({...z,registryUrl:j}));const k=Object.entries(w).filter(([j,z])=>z===null).map(([j])=>j);s.value=!1,S.length===0?e.modal.notify("error",{content:"All registries failed to refresh"}):(e.modal.notify("success",{content:`${S.length} ${S.length===1?"registry":"registries"} refreshed successfully.`}),k.length>0&&e.modal.notify("warning",{content:`${k.length} ${k.length===1?"registry":"registries"} failed to refresh:
20
- ${k.join(`
21
- `)}`}))},g=async()=>{u.value=!1;const w=await e.store.ctx.preferences.get("pluginStore.registries")||[],S=await Promise.allSettled(w.map(async k=>({...await e.store.getRegistryInfo(k),registryUrl:k})));i.value=S.filter(k=>k.status==="fulfilled").map(k=>k.value),n.value=await e.preferences.get("pluginStore.plugins")||[],u.value=!0};function v(w){const S=w.changes["pluginStore.registries"],k=w.changes["pluginStore.plugins"];Array.isArray(k)&&(n.value=k),Array.isArray(S)&&g()}return mn(()=>{g(),e.on("preferences/changed",v)}),fo(()=>{}),(w,S)=>(oe(),ue("div",pv,[Q("div",mv,[S[2]||(S[2]=Q("div",{class:"ipeps-header-title"},"Plugins",-1)),Q("div",gv,[sc(Q("input",{class:"ipeps-input with-icon","onUpdate:modelValue":S[0]||(S[0]=k=>r.value=k),type:"text",placeholder:"Search plugins...",disabled:!p.value.length},null,8,yv),[[cu,r.value,void 0,{trim:!0}]]),S[1]||(S[1]=Q("div",{class:"ipeps-input-icon"},"🔍",-1))]),Q("button",{class:ft(["ipeps-button",{refreshing:s.value}]),onClick:y,disabled:s.value||!d.value,variant:"primary"},ke(s.value?"Refreshing...":"Refresh"),11,bv)]),!d.value&&!u.value?(oe(),ue("div",vv,[...S[3]||(S[3]=[Q("div",{class:"loading-spinner"},null,-1),Q("div",{class:"loading-text"},"Loading...",-1)])])):p.value.length?(oe(),ue("div",wv,[(oe(!0),ue(Ue,null,po(p.value,k=>(oe(),ue("div",{class:ft(["ipeps-item",{installed:l(k._key),broken:k.isBroken}]),key:k._key},[Q("div",_v,[Q("div",xv,[Q("div",Sv,ke(k.name||k.id),1),l(k._key)||k.isBroken?(oe(),ue("span",{key:0,class:ft(["ipeps-badge",{"is-installed":l(k._key),"is-broken":k.isBroken}])},ke(k.isBroken?"⚠️ broken":"✓"),3)):Yt("",!0)]),Q("div",kv,[k.registryHomepage&&!k.isRegistryMissing?(oe(),ue("a",{key:0,class:"ipeps-tag registry-tag",href:k.registryHomepage,target:"_blank",title:k.registryLabel},ke(k.registryLabel),9,Ev)):(oe(),ue("span",{key:1,class:ft(["ipeps-tag registry-tag",{broken:k.isRegistryMissing}]),title:k.registryLabel},ke(k.registryLabel),11,$v)),Q("div",{class:ft(["plugin-id ipeps-tag",{broken:k.isBroken&&!k.isRegistryMissing}])},ke(k.id),3)]),Q("div",{class:ft(["plugin-desc",{"broken-desc":k.isBroken}])},ke(f(k)),3),Q("div",Pv,[k.version?(oe(),ue("span",Cv,"v"+ke(k.version),1)):Yt("",!0),k.author?(oe(),ue("span",Rv,"👤 "+ke(k.author),1)):Yt("",!0),k.license?(oe(),ue("span",Av,"📜 "+ke(k.license),1)):Yt("",!0)])]),Ee(Kr,{active:l(k._key),variant:l(k._key)?"danger":"primary",onClick:j=>R(k)},{default:hn(()=>[xn(ke(l(k._key)?"Remove":"Install"),1)]),_:2},1032,["active","variant","onClick"])],2))),128))])):(oe(),ue("div",Iv,[...S[4]||(S[4]=[Q("div",{class:"plugin-empty-icon"},"📦",-1),Q("div",{class:"plugin-empty-text"},"No matching plugins found",-1)])]))]))}}),[["__scopeId","data-v-d61d6310"]]),Tv={id:"ipe-plugin-store-app"},Lv=Object.freeze(Object.defineProperty({__proto__:null,default:Nr(ci({__name:"PluginStoreApp",setup(t){return(e,i)=>(oe(),ue("div",Tv,[Ee(Ov),i[0]||(i[0]=Q("div",{class:"divider-wrapper"},[Q("hr",{class:"divider"})],-1)),Ee(hv)]))}}),[["__scopeId","data-v-1b3d0d80"]])},Symbol.toStringTag,{value:"Module"})),Nv=window?.location?.origin,Pn=({type:t,tag:e,href:i,target:n,children:r,...s})=>(e=e||(i?"a":"button"),typeof n>"u"&&i&&i.startsWith("http")&&!i.startsWith(Nv)&&(n="_blank"),Zi(e,{className:`theme-ipe ipe-action-button ipe-modal-btn is-${t||"default"}`,href:e==="a"?i:void 0,target:e==="a"?n:void 0,"data-href":e!=="a"?i:void 0,...s},r));var Mv=Object.create,ta=Object.defineProperty,Dv=Object.getOwnPropertyDescriptor,df=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),hf=t=>{throw TypeError(t)},jv=(t,e,i)=>e in t?ta(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Uv=(t,e)=>ta(t,"name",{value:e,configurable:!0}),Fv=t=>[,,,Mv(t?.[df("metadata")]??null)],Bv=["class","method","getter","setter","accessor","field","value","get","set"],pf=t=>t!==void 0&&typeof t!="function"?hf("Function expected"):t,qv=(t,e,i,n,r)=>({kind:Bv[t],name:e,metadata:n,addInitializer:s=>i._?hf("Already initialized"):r.push(pf(s||null))}),Hv=(t,e)=>jv(e,df("metadata"),t[3]),zv=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Kv=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,h=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&Dv(r,i));Uv(r,i);for(var f=n.length-1;f>=0;f--)l=qv(c,i,a={},t[3],h),o=(0,n[f])(r,l),a._=1,pf(o)&&(r=o);return Hv(t,r),p&&ta(r,i,p),u?c^4?s:p:r},mf,ia,gf;mf=[$e(["preferences","wikiPage","wikiTitle","modal","preferencesUI"])];class Wr extends(gf=Xe){constructor(e){super(e,{},"pref-sync"),this.ctx=e,e.set("prefSync",this)}start(){const e=this.ctx;e.preferences.defineCategory({name:"pref-sync",label:"Sync",description:"Import and export preferences",index:98,customRenderer:()=>{const i=this.getUserPrefsPageTitle();return m("div",{className:"theme-ipe-prose",children:[i&&m("section",{children:[m("h3",{children:"Backup your preferences via user page"}),m("p",{children:m("a",{href:i?.getURL().toString(),target:"_blank",children:[i?.getPrefixedText()," →"]})}),m("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[m(Pn,{type:"primary",onClick:n=>{n.preventDefault();const r=n.target;r.disabled=!0;const s=e.preferencesUI.getCurrentModal();s?.setLoadingState(!0),this.exportToUserPage().then(o=>{e.modal.notify("success",{title:"Preferences Exported",content:m("p",{children:["Your preferences have been exported to"," ",m("a",{href:o.getURL().toString(),target:"_blank",children:o.getPrefixedText()}),"."]})})}).finally(()=>{r.disabled=!1,s?.setLoadingState(!1)})},children:[m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-cloud-up",children:[m("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),m("path",{d:"M12 18.004h-5.343c-2.572 -.004 -4.657 -2.011 -4.657 -4.487c0 -2.475 2.085 -4.482 4.657 -4.482c.393 -1.762 1.794 -3.2 3.675 -3.773c1.88 -.572 3.956 -.193 5.444 1c1.488 1.19 2.162 3.007 1.77 4.769h.99c1.38 0 2.57 .811 3.128 1.986"}),m("path",{d:"M19 22v-6"}),m("path",{d:"M22 19l-3 -3l-3 3"})]})," ","Backup"]}),m(Pn,{onClick:n=>{n.preventDefault();const r=e.preferencesUI.getCurrentModal(),s=n.target;s.disabled=!0,r?.setLoadingState(!0),this.importFromUserPage().then(o=>{this.notifyImportSuccess(o)}).finally(()=>{s.disabled=!1,r?.setLoadingState(!1)})},children:[m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-cloud-down",children:[m("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),m("path",{d:"M12 18.004h-5.343c-2.572 -.004 -4.657 -2.011 -4.657 -4.487c0 -2.475 2.085 -4.482 4.657 -4.482c.393 -1.762 1.794 -3.2 3.675 -3.773c1.88 -.572 3.956 -.193 5.444 1c1.488 1.19 2.162 3.007 1.77 4.769h.99c1.38 0 2.573 .813 3.13 1.99"}),m("path",{d:"M19 16v6"}),m("path",{d:"M22 19l-3 3l-3 -3"})]})," ","Restore"]})]})]}),m("section",{children:[m("h3",{children:"Import and export preferences"}),m("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[m(Pn,{onClick:n=>{n.preventDefault();const r=e.preferencesUI.getCurrentModal();r?.setLoadingState(!0);const s=document.createElement("input");s.type="file",s.accept="application/json";let o=!1;const a=()=>{o||r?.setLoadingState(!1),window.removeEventListener("focus",a)};window.addEventListener("focus",a,{once:!0}),s.addEventListener("change",async l=>{o=!0;try{const c=l.target.files?.[0];if(!c)return;const u=await this.importFromFile(c);this.notifyImportSuccess(u)}catch(c){e.modal.notify("error",{title:"Import failed",content:c instanceof Error?c.message:String(c)})}finally{r?.setLoadingState(!1)}}),s.click()},children:"Import from file"}),m(Pn,{onClick:n=>{n.preventDefault();const r=m("input",{type:"url"}),s=e.preferencesUI.getCurrentModal();e.modal.confirm({title:"Import Preferences from URL",content:m("div",{children:[m("label",{htmlFor:"url-input",children:"Enter the URL of the preferences JSON file:"}),r]})},async o=>{const a=r.value.trim();if(!(!o||!a))try{s?.setLoadingState(!0);const l=await this.importFromUrl(a);this.notifyImportSuccess(l)}catch(l){e.modal.notify("error",{title:"Import failed",content:l instanceof Error?l.message:String(l)})}finally{s?.setLoadingState(!1)}})},children:"Import from URL"}),m(Pn,{onClick:async n=>{n.preventDefault(),await e.preferencesUI.dispatchFormSave();const r=await e.preferences.getExportableRecord(),s=JSON.stringify(r,null,2);e.modal.dialog({title:"Save to file",content:m("div",{children:[m("label",{htmlFor:"data",children:"Your InPageEdit preferences:"}),m("textarea",{name:"data",id:"data",rows:10,value:s,readOnly:!0,style:{width:"100%"}})]}),buttons:[{label:"Copy",method:(o,a)=>{navigator.clipboard.writeText(s),e.modal.notify("success",{content:"Copied to clipboard"}),a.close()}},{label:"Download",method:(o,a)=>{const l=document.createElement("a");l.href=`data:text/json;charset=utf-8,${encodeURIComponent(s)}`,l.download=`ipe-prefs-${new Date().toISOString()}.json`,l.click(),a.close()}}]},()=>{})},children:"Save as file"})]})]})]})}})}stop(){}getUserPrefsPageTitle(){try{const e=this.ctx.wiki?.userInfo?.name;return e?this.ctx.wikiTitle.newTitle(`User:${e}/ipe-prefs.json`,2):null}catch{return null}}async importFromUserPage(){const e=this.getUserPrefsPageTitle();if(!e)return this.logger.debug("Cannot get user page title, skipping load"),{};try{const i=e.getURL({action:"raw",ctype:"application/json"}),n=await this.importFromUrl(i.toString());return this.logger.info("Loaded preferences from user page:",e),n}catch(i){return this.logger.error("Failed to load preferences from user page:",i),{}}}async exportToUserPage(){const e=this.ctx,i=this.getUserPrefsPageTitle();if(!i)throw new Error("Cannot get user page title");await e.preferencesUI.dispatchFormSave();const n=await e.preferences.getExportableRecord(),r=JSON.stringify(n,null,2);try{return await this.ctx.wikiPage.newBlankPage({title:i.toString(),ns:2}).edit({text:r,summary:"Update InPageEdit preferences",watchlist:rt.nochange}),this.logger.info("Exported preferences to user page:",i),i}catch(s){throw this.logger.error("Failed to export preferences to user page:",s),s}}async importFromUrl(e){const i=await fetch(e);if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);const n=await i.blob();return await this.importFromFile(n)}async importFromFile(e){const i=await e.text(),n=JSON.parse(i);return await this.ctx.preferences.setMany(n)}notifyImportSuccess(e){const i=Object.keys(e??{}),n=i.length;return this.ctx.modal.notify("success",{title:"Preferences Imported",content:m("section",{children:[m("p",{children:["Successfully imported ",n||""," ",n!==1?"settings":"setting",":"]}),m("ol",{style:{listStyle:"auto",paddingLeft:"1em"},children:i.map(r=>m("li",{children:r},r))})]})})}}ia=Fv(gf),Wr=Kv(ia,0,"PluginPrefSync",mf,Wr),zv(ia,1,Wr);const Wv=Object.freeze(Object.defineProperty({__proto__:null,get PluginPrefSync(){return Wr}},Symbol.toStringTag,{value:"Module"}));J.BasePlugin=Xe,J.Endpoints=Lt,J.InPageEdit=Si,J.Inject=$e,J.Logger=wa,J.LoggerLevel=ls,J.RegisterPreferences=si,J.Schema=L,J.Service=Ot,J.createLogger=Sa,Object.defineProperty(J,Symbol.toStringTag,{value:"Module"})}));
23
+ `,...Qg(r))}$t(),po=!1}function Yg(){let t=pn[pn.length-1];if(!t)return[];const e=[];for(;t;){const i=e[0];i&&i.vnode===t?i.recurseCount++:e.push({vnode:t,recurseCount:0});const n=t.component&&t.component.parent;t=n&&n.vnode}return e}function Qg(t){const e=[];return t.forEach((i,n)=>{e.push(...n===0?[]:[`
24
+ `],...Xg(i))}),e}function Xg({vnode:t,recurseCount:e}){const i=e>0?`... (${e} recursive calls)`:"",n=t.component?t.component.parent==null:!1,r=` at <${uu(t.component,t.type,n)}`,s=">"+i;return t.props?[r,...Jg(t.props),s]:[r+s]}function Jg(t){const e=[],i=Object.keys(t);return i.slice(0,3).forEach(n=>{e.push(...gc(n,t[n]))}),i.length>3&&e.push(" ..."),e}function gc(t,e,i){return _e(e)?(e=JSON.stringify(e),i?e:[`${t}=${e}`]):typeof e=="number"||typeof e=="boolean"||e==null?i?e:[`${t}=${e}`]:Ie(e)?(e=gc(t,ie(e.value),!0),i?e:[`${t}=Ref<`,e,">"]):Q(e)?[`${t}=fn${e.name?`<${e.name}>`:""}`]:(e=ie(e),i?e:[`${t}=`,e])}function Ii(t,e,i,n){try{return n?t(...n):t()}catch(r){gn(r,e,i)}}function Et(t,e,i,n){if(Q(t)){const r=Ii(t,e,i,n);return r&&Ul(r)&&r.catch(s=>{gn(s,e,i)}),r}if(Y(t)){const r=[];for(let s=0;s<t.length;s++)r.push(Et(t[s],e,i,n));return r}}function gn(t,e,i,n=!0){const r=e?e.vnode:null,{errorHandler:s,throwUnhandledErrorInProduction:o}=e&&e.appContext.config||ne;if(e){let a=e.parent;const l=e.proxy,c=`https://vuejs.org/error-reference/#runtime-${i}`;for(;a;){const u=a.ec;if(u){for(let f=0;f<u.length;f++)if(u[f](t,l,c)===!1)return}a=a.parent}if(s){kt(),Ii(s,null,10,[t,l,c]),$t();return}}Zg(t,i,r,n,o)}function Zg(t,e,i,n=!0,r=!1){if(r)throw t}const Fe=[];let Pt=-1;const Ai=[];let Xt=null,Oi=0;const mc=Promise.resolve();let _r=null;function mn(t){const e=_r||mc;return t?e.then(this?t.bind(this):t):e}function em(t){let e=Pt+1,i=Fe.length;for(;e<i;){const n=e+i>>>1,r=Fe[n],s=yn(r);s<t||s===t&&r.flags&2?e=n+1:i=n}return e}function go(t){if(!(t.flags&1)){const e=yn(t),i=Fe[Fe.length-1];!i||!(t.flags&2)&&e>=yn(i)?Fe.push(t):Fe.splice(em(e),0,t),t.flags|=1,yc()}}function yc(){_r||(_r=mc.then(wc))}function tm(t){Y(t)?Ai.push(...t):Xt&&t.id===-1?Xt.splice(Oi+1,0,t):t.flags&1||(Ai.push(t),t.flags|=1),yc()}function bc(t,e,i=Pt+1){for(;i<Fe.length;i++){const n=Fe[i];if(n&&n.flags&2){if(t&&n.id!==t.uid)continue;Fe.splice(i,1),i--,n.flags&4&&(n.flags&=-2),n(),n.flags&4||(n.flags&=-2)}}}function vc(t){if(Ai.length){const e=[...new Set(Ai)].sort((i,n)=>yn(i)-yn(n));if(Ai.length=0,Xt){Xt.push(...e);return}for(Xt=e,Oi=0;Oi<Xt.length;Oi++){const i=Xt[Oi];i.flags&4&&(i.flags&=-2),i.flags&8||i(),i.flags&=-2}Xt=null,Oi=0}}const yn=t=>t.id==null?t.flags&2?-1:1/0:t.id;function wc(t){try{for(Pt=0;Pt<Fe.length;Pt++){const e=Fe[Pt];e&&!(e.flags&8)&&(e.flags&4&&(e.flags&=-2),Ii(e,e.i,e.i?15:14),e.flags&4||(e.flags&=-2))}}finally{for(;Pt<Fe.length;Pt++){const e=Fe[Pt];e&&(e.flags&=-2)}Pt=-1,Fe.length=0,vc(),_r=null,(Fe.length||Ai.length)&&wc()}}let Ne=null,_c=null;function xr(t){const e=Ne;return Ne=t,_c=t&&t.type.__scopeId||null,e}function bn(t,e=Ne,i){if(!e||t._n)return t;const n=(...r)=>{n._d&&iu(-1);const s=xr(e);let o;try{o=t(...r)}finally{xr(s),n._d&&iu(1)}return o};return n._n=!0,n._c=!0,n._d=!0,n}function xc(t,e){if(Ne===null)return t;const i=Tr(Ne),n=t.dirs||(t.dirs=[]);for(let r=0;r<e.length;r++){let[s,o,a,l=ne]=e[r];s&&(Q(s)&&(s={mounted:s,updated:s}),s.deep&&Bt(o),n.push({dir:s,instance:i,value:o,oldValue:void 0,arg:a,modifiers:l}))}return t}function ui(t,e,i,n){const r=t.dirs,s=e&&e.dirs;for(let o=0;o<r.length;o++){const a=r[o];s&&(a.oldValue=s[o].value);let l=a.dir[n];l&&(kt(),Et(l,i,8,[t.el,a,t,e]),$t())}}const im=Symbol("_vte"),nm=t=>t.__isTeleport,rm=Symbol("_leaveCb");function mo(t,e){t.shapeFlag&6&&t.component?(t.transition=e,mo(t.component.subTree,e)):t.shapeFlag&128?(t.ssContent.transition=e.clone(t.ssContent),t.ssFallback.transition=e.clone(t.ssFallback)):t.transition=e}function fi(t,e){return Q(t)?Ae({name:t.name},e,{setup:t}):t}function yo(t){t.ids=[t.ids[0]+t.ids[2]+++"-",0,0]}function Sc(t){const e=Lo(),i=dc(null);if(e){const r=e.refs===ne?e.refs={}:e.refs;Object.defineProperty(r,t,{enumerable:!0,get:()=>i.value,set:s=>i.value=s})}return i}const Sr=new WeakMap;function vn(t,e,i,n,r=!1){if(Y(t)){t.forEach((d,w)=>vn(d,e&&(Y(e)?e[w]:e),i,n,r));return}if(Ti(n)&&!r){n.shapeFlag&512&&n.type.__asyncResolved&&n.component.subTree.component&&vn(t,e,i,n.component.subTree);return}const s=n.shapeFlag&4?Tr(n.component):n.el,o=r?null:s,{i:a,r:l}=t,c=e&&e.r,u=a.refs===ne?a.refs={}:a.refs,f=a.setupState,h=ie(f),p=f===ne?Dl:d=>se(h,d);if(c!=null&&c!==l){if(kc(e),_e(c))u[c]=null,p(c)&&(f[c]=null);else if(Ie(c)){c.value=null;const d=e;d.k&&(u[d.k]=null)}}if(Q(l))Ii(l,a,12,[o,u]);else{const d=_e(l),w=Ie(l);if(d||w){const S=()=>{if(t.f){const E=d?p(l)?f[l]:u[l]:l.value;if(r)Y(E)&&Vs(E,s);else if(Y(E))E.includes(s)||E.push(s);else if(d)u[l]=[s],p(l)&&(f[l]=u[l]);else{const M=[s];l.value=M,t.k&&(u[t.k]=M)}}else d?(u[l]=o,p(l)&&(f[l]=o)):w&&(l.value=o,t.k&&(u[t.k]=o))};if(o){const E=()=>{S(),Sr.delete(t)};E.id=-1,Sr.set(t,E),tt(E,i)}else kc(t),S()}}}function kc(t){const e=Sr.get(t);e&&(e.flags|=8,Sr.delete(t))}const $c=t=>t.nodeType===8;fr().requestIdleCallback,fr().cancelIdleCallback;function sm(t,e){if($c(t)&&t.data==="["){let i=1,n=t.nextSibling;for(;n;){if(n.nodeType===1){if(e(n)===!1)break}else if($c(n))if(n.data==="]"){if(--i===0)break}else n.data==="["&&i++;n=n.nextSibling}}else e(t)}const Ti=t=>!!t.type.__asyncLoader;function om(t){Q(t)&&(t={loader:t});const{loader:e,loadingComponent:i,errorComponent:n,delay:r=200,hydrate:s,timeout:o,suspensible:a=!0,onError:l}=t;let c=null,u,f=0;const h=()=>(f++,c=null,p()),p=()=>{let d;return c||(d=c=e().catch(w=>{if(w=w instanceof Error?w:new Error(String(w)),l)return new Promise((S,E)=>{l(w,()=>S(h()),()=>E(w),f+1)});throw w}).then(w=>d!==c&&c?c:(w&&(w.__esModule||w[Symbol.toStringTag]==="Module")&&(w=w.default),u=w,w)))};return fi({name:"AsyncComponentWrapper",__asyncLoader:p,__asyncHydrate(d,w,S){let E=!1;(w.bu||(w.bu=[])).push(()=>E=!0);const M=()=>{E||S()},g=s?()=>{const y=s(M,v=>sm(d,v));y&&(w.bum||(w.bum=[])).push(y)}:M;u?g():p().then(()=>!w.isUnmounted&&g())},get __asyncResolved(){return u},setup(){const d=De;if(yo(d),u)return()=>kr(u,d);const w=g=>{c=null,gn(g,d,13,!n)};if(a&&d.suspense||Di)return p().then(g=>()=>kr(g,d)).catch(g=>(w(g),()=>n?Ce(n,{error:g}):null));const S=Ue(!1),E=Ue(),M=Ue(!!r);return r&&setTimeout(()=>{M.value=!1},r),o!=null&&setTimeout(()=>{if(!S.value&&!E.value){const g=new Error(`Async component timed out after ${o}ms.`);w(g),E.value=g}},o),p().then(()=>{S.value=!0,d.parent&&bo(d.parent.vnode)&&d.parent.update()}).catch(g=>{w(g),E.value=g}),()=>{if(S.value&&u)return kr(u,d);if(E.value&&n)return Ce(n,{error:E.value});if(i&&!M.value)return kr(i,d)}}})}function kr(t,e){const{ref:i,props:n,children:r,ce:s}=e.vnode,o=Ce(t,n,r);return o.ref=i,o.ce=s,delete e.vnode.ce,o}const bo=t=>t.type.__isKeepAlive;function am(t,e){Ec(t,"a",e)}function lm(t,e){Ec(t,"da",e)}function Ec(t,e,i=De){const n=t.__wdc||(t.__wdc=()=>{let r=i;for(;r;){if(r.isDeactivated)return;r=r.parent}return t()});if($r(e,n,i),i){let r=i.parent;for(;r&&r.parent;)bo(r.parent.vnode)&&cm(n,e,i,r),r=r.parent}}function cm(t,e,i,n){const r=$r(e,t,n,!0);wo(()=>{Vs(n[e],r)},i)}function $r(t,e,i=De,n=!1){if(i){const r=i[t]||(i[t]=[]),s=e.__weh||(e.__weh=(...o)=>{kt();const a=Cn(i),l=Et(e,i,t,o);return a(),$t(),l});return n?r.unshift(s):r.push(s),s}}const qt=t=>(e,i=De)=>{(!Di||t==="sp")&&$r(t,(...n)=>e(...n),i)},Pc=qt("bm"),wn=qt("m"),um=qt("bu"),fm=qt("u"),vo=qt("bum"),wo=qt("um"),dm=qt("sp"),hm=qt("rtg"),pm=qt("rtc");function gm(t,e=De){$r("ec",t,e)}const mm=Symbol.for("v-ndc");function _o(t,e,i,n){let r;const s=i,o=Y(t);if(o||_e(t)){const a=o&&Ri(t);let l=!1,c=!1;a&&(l=!lt(t),c=Qt(t),t=hr(t)),r=new Array(t.length);for(let u=0,f=t.length;u<f;u++)r[u]=e(l?c?br(Oe(t[u])):Oe(t[u]):t[u],u,void 0,s)}else if(typeof t=="number"){r=new Array(t);for(let a=0;a<t;a++)r[a]=e(a+1,a,void 0,s)}else if(ye(t))if(t[Symbol.iterator])r=Array.from(t,(a,l)=>e(a,l,void 0,s));else{const a=Object.keys(t);r=new Array(a.length);for(let l=0,c=a.length;l<c;l++){const u=a[l];r[l]=e(t[u],u,l,s)}}else r=[];return r}function ym(t,e,i={},n,r){if(Ne.ce||Ne.parent&&Ti(Ne.parent)&&Ne.parent.ce){const c=Object.keys(i).length>0;return oe(),Ir(qe,null,[Ce("slot",i,n)],c?-2:64)}let s=t[e];s&&s._c&&(s._d=!1),oe();const o=s&&Cc(s(i)),a=i.key||o&&o.key,l=Ir(qe,{key:(a&&!Dt(a)?a:`_${e}`)+(!o&&n?"_fb":"")},o||[],o&&t._===1?64:-2);return l.scopeId&&(l.slotScopeIds=[l.scopeId+"-s"]),s&&s._c&&(s._d=!0),l}function Cc(t){return t.some(e=>Oo(e)?!(e.type===Ht||e.type===qe&&!Cc(e.children)):!0)?t:null}const xo=t=>t?au(t)?Tr(t):xo(t.parent):null,_n=Ae(Object.create(null),{$:t=>t,$el:t=>t.vnode.el,$data:t=>t.data,$props:t=>t.props,$attrs:t=>t.attrs,$slots:t=>t.slots,$refs:t=>t.refs,$parent:t=>xo(t.parent),$root:t=>xo(t.root),$host:t=>t.ce,$emit:t=>t.emit,$options:t=>Oc(t),$forceUpdate:t=>t.f||(t.f=()=>{go(t.update)}),$nextTick:t=>t.n||(t.n=mn.bind(t.proxy)),$watch:t=>Um.bind(t)}),So=(t,e)=>t!==ne&&!t.__isScriptSetup&&se(t,e),bm={get({_:t},e){if(e==="__v_skip")return!0;const{ctx:i,setupState:n,data:r,props:s,accessCache:o,type:a,appContext:l}=t;let c;if(e[0]!=="$"){const p=o[e];if(p!==void 0)switch(p){case 1:return n[e];case 2:return r[e];case 4:return i[e];case 3:return s[e]}else{if(So(n,e))return o[e]=1,n[e];if(r!==ne&&se(r,e))return o[e]=2,r[e];if((c=t.propsOptions[0])&&se(c,e))return o[e]=3,s[e];if(i!==ne&&se(i,e))return o[e]=4,i[e];ko&&(o[e]=0)}}const u=_n[e];let f,h;if(u)return e==="$attrs"&&Me(t.attrs,"get",""),u(t);if((f=a.__cssModules)&&(f=f[e]))return f;if(i!==ne&&se(i,e))return o[e]=4,i[e];if(h=l.config.globalProperties,se(h,e))return h[e]},set({_:t},e,i){const{data:n,setupState:r,ctx:s}=t;return So(r,e)?(r[e]=i,!0):n!==ne&&se(n,e)?(n[e]=i,!0):se(t.props,e)||e[0]==="$"&&e.slice(1)in t?!1:(s[e]=i,!0)},has({_:{data:t,setupState:e,accessCache:i,ctx:n,appContext:r,propsOptions:s,type:o}},a){let l,c;return!!(i[a]||t!==ne&&a[0]!=="$"&&se(t,a)||So(e,a)||(l=s[0])&&se(l,a)||se(n,a)||se(_n,a)||se(r.config.globalProperties,a)||(c=o.__cssModules)&&c[a])},defineProperty(t,e,i){return i.get!=null?t._.accessCache[e]=0:se(i,"value")&&this.set(t,e,i.value,null),Reflect.defineProperty(t,e,i)}};function Er(t){return Y(t)?t.reduce((e,i)=>(e[i]=null,e),{}):t}function Rc(t,e){return!t||!e?t||e:Y(t)&&Y(e)?t.concat(e):Ae({},Er(t),Er(e))}let ko=!0;function vm(t){const e=Oc(t),i=t.proxy,n=t.ctx;ko=!1,e.beforeCreate&&Ic(e.beforeCreate,t,"bc");const{data:r,computed:s,methods:o,watch:a,provide:l,inject:c,created:u,beforeMount:f,mounted:h,beforeUpdate:p,updated:d,activated:w,deactivated:S,beforeDestroy:E,beforeUnmount:M,destroyed:g,unmounted:y,render:v,renderTracked:x,renderTriggered:P,errorCaptured:L,serverPrefetch:C,expose:U,inheritAttrs:H,components:He,directives:dt,filters:Ki}=e;if(c&&wm(c,n,null),o)for(const me in o){const pe=o[me];Q(pe)&&(n[me]=pe.bind(i))}if(r){const me=r.call(i,i);ye(me)&&(t.data=uo(me))}if(ko=!0,s)for(const me in s){const pe=s[me],bi=Q(pe)?pe.bind(i,i):Q(pe.get)?pe.get.bind(i,i):St,ts=!Q(pe)&&Q(pe.set)?pe.set.bind(i):St,vi=It({get:bi,set:ts});Object.defineProperty(n,me,{enumerable:!0,configurable:!0,get:()=>vi.value,set:At=>vi.value=At})}if(a)for(const me in a)Ac(a[me],n,i,me);if(l){const me=Q(l)?l.call(i):l;Reflect.ownKeys(me).forEach(pe=>{Nc(pe,me[pe])})}u&&Ic(u,t,"c");function ce(me,pe){Y(pe)?pe.forEach(bi=>me(bi.bind(i))):pe&&me(pe.bind(i))}if(ce(Pc,f),ce(wn,h),ce(um,p),ce(fm,d),ce(am,w),ce(lm,S),ce(gm,L),ce(pm,x),ce(hm,P),ce(vo,M),ce(wo,y),ce(dm,C),Y(U))if(U.length){const me=t.exposed||(t.exposed={});U.forEach(pe=>{Object.defineProperty(me,pe,{get:()=>i[pe],set:bi=>i[pe]=bi,enumerable:!0})})}else t.exposed||(t.exposed={});v&&t.render===St&&(t.render=v),H!=null&&(t.inheritAttrs=H),He&&(t.components=He),dt&&(t.directives=dt),C&&yo(t)}function wm(t,e,i=St){Y(t)&&(t=$o(t));for(const n in t){const r=t[n];let s;ye(r)?"default"in r?s=Sn(r.from||n,r.default,!0):s=Sn(r.from||n):s=Sn(r),Ie(s)?Object.defineProperty(e,n,{enumerable:!0,configurable:!0,get:()=>s.value,set:o=>s.value=o}):e[n]=s}}function Ic(t,e,i){Et(Y(t)?t.map(n=>n.bind(e.proxy)):t.bind(e.proxy),e,i)}function Ac(t,e,i,n){let r=n.includes(".")?Yc(i,n):()=>i[n];if(_e(t)){const s=e[t];Q(s)&&Mi(r,s)}else if(Q(t))Mi(r,t.bind(i));else if(ye(t))if(Y(t))t.forEach(s=>Ac(s,e,i,n));else{const s=Q(t.handler)?t.handler.bind(i):e[t.handler];Q(s)&&Mi(r,s,t)}}function Oc(t){const e=t.type,{mixins:i,extends:n}=e,{mixins:r,optionsCache:s,config:{optionMergeStrategies:o}}=t.appContext,a=s.get(e);let l;return a?l=a:!r.length&&!i&&!n?l=e:(l={},r.length&&r.forEach(c=>Pr(l,c,o,!0)),Pr(l,e,o)),ye(e)&&s.set(e,l),l}function Pr(t,e,i,n=!1){const{mixins:r,extends:s}=e;s&&Pr(t,s,i,!0),r&&r.forEach(o=>Pr(t,o,i,!0));for(const o in e)if(!(n&&o==="expose")){const a=_m[o]||i&&i[o];t[o]=a?a(t[o],e[o]):e[o]}return t}const _m={data:Tc,props:Lc,emits:Lc,methods:xn,computed:xn,beforeCreate:Be,created:Be,beforeMount:Be,mounted:Be,beforeUpdate:Be,updated:Be,beforeDestroy:Be,beforeUnmount:Be,destroyed:Be,unmounted:Be,activated:Be,deactivated:Be,errorCaptured:Be,serverPrefetch:Be,components:xn,directives:xn,watch:Sm,provide:Tc,inject:xm};function Tc(t,e){return e?t?function(){return Ae(Q(t)?t.call(this,this):t,Q(e)?e.call(this,this):e)}:e:t}function xm(t,e){return xn($o(t),$o(e))}function $o(t){if(Y(t)){const e={};for(let i=0;i<t.length;i++)e[t[i]]=t[i];return e}return t}function Be(t,e){return t?[...new Set([].concat(t,e))]:e}function xn(t,e){return t?Ae(Object.create(null),t,e):e}function Lc(t,e){return t?Y(t)&&Y(e)?[...new Set([...t,...e])]:Ae(Object.create(null),Er(t),Er(e??{})):e}function Sm(t,e){if(!t)return e;if(!e)return t;const i=Ae(Object.create(null),t);for(const n in e)i[n]=Be(t[n],e[n]);return i}function Mc(){return{app:null,config:{isNativeTag:Dl,performance:!1,globalProperties:{},optionMergeStrategies:{},errorHandler:void 0,warnHandler:void 0,compilerOptions:{}},mixins:[],components:{},directives:{},provides:Object.create(null),optionsCache:new WeakMap,propsCache:new WeakMap,emitsCache:new WeakMap}}let km=0;function $m(t,e){return function(n,r=null){Q(n)||(n=Ae({},n)),r!=null&&!ye(r)&&(r=null);const s=Mc(),o=new WeakSet,a=[];let l=!1;const c=s.app={_uid:km++,_component:n,_props:r,_container:null,_context:s,_instance:null,version:ay,get config(){return s.config},set config(u){},use(u,...f){return o.has(u)||(u&&Q(u.install)?(o.add(u),u.install(c,...f)):Q(u)&&(o.add(u),u(c,...f))),c},mixin(u){return s.mixins.includes(u)||s.mixins.push(u),c},component(u,f){return f?(s.components[u]=f,c):s.components[u]},directive(u,f){return f?(s.directives[u]=f,c):s.directives[u]},mount(u,f,h){if(!l){const p=c._ceVNode||Ce(n,r);return p.appContext=s,h===!0?h="svg":h===!1&&(h=void 0),t(p,u,h),l=!0,c._container=u,u.__vue_app__=c,Tr(p.component)}},onUnmount(u){a.push(u)},unmount(){l&&(Et(a,c._instance,16),t(null,c._container),delete c._container.__vue_app__)},provide(u,f){return s.provides[u]=f,c},runWithContext(u){const f=Li;Li=c;try{return u()}finally{Li=f}}};return c}}let Li=null;function Nc(t,e){if(De){let i=De.provides;const n=De.parent&&De.parent.provides;n===i&&(i=De.provides=Object.create(n)),i[t]=e}}function Sn(t,e,i=!1){const n=Lo();if(n||Li){let r=Li?Li._context.provides:n?n.parent==null||n.ce?n.vnode.appContext&&n.vnode.appContext.provides:n.parent.provides:void 0;if(r&&t in r)return r[t];if(arguments.length>1)return i&&Q(e)?e.call(n&&n.proxy):e}}const Dc={},jc=()=>Object.create(Dc),Uc=t=>Object.getPrototypeOf(t)===Dc;function Em(t,e,i,n=!1){const r={},s=jc();t.propsDefaults=Object.create(null),Fc(t,e,r,s);for(const o in t.propsOptions[0])o in r||(r[o]=void 0);i?t.props=n?r:Ug(r):t.type.props?t.props=r:t.props=s,t.attrs=s}function Pm(t,e,i,n){const{props:r,attrs:s,vnode:{patchFlag:o}}=t,a=ie(r),[l]=t.propsOptions;let c=!1;if((n||o>0)&&!(o&16)){if(o&8){const u=t.vnode.dynamicProps;for(let f=0;f<u.length;f++){let h=u[f];if(Cr(t.emitsOptions,h))continue;const p=e[h];if(l)if(se(s,h))p!==s[h]&&(s[h]=p,c=!0);else{const d=jt(h);r[d]=Eo(l,a,d,p,t,!1)}else p!==s[h]&&(s[h]=p,c=!0)}}}else{Fc(t,e,r,s)&&(c=!0);let u;for(const f in a)(!e||!se(e,f)&&((u=Yt(f))===f||!se(e,u)))&&(l?i&&(i[f]!==void 0||i[u]!==void 0)&&(r[f]=Eo(l,a,f,void 0,t,!0)):delete r[f]);if(s!==a)for(const f in s)(!e||!se(e,f))&&(delete s[f],c=!0)}c&&Ut(t.attrs,"set","")}function Fc(t,e,i,n){const[r,s]=t.propsOptions;let o=!1,a;if(e)for(let l in e){if(ln(l))continue;const c=e[l];let u;r&&se(r,u=jt(l))?!s||!s.includes(u)?i[u]=c:(a||(a={}))[u]=c:Cr(t.emitsOptions,l)||(!(l in n)||c!==n[l])&&(n[l]=c,o=!0)}if(s){const l=ie(i),c=a||ne;for(let u=0;u<s.length;u++){const f=s[u];i[f]=Eo(r,l,f,c[f],t,!se(c,f))}}return o}function Eo(t,e,i,n,r,s){const o=t[i];if(o!=null){const a=se(o,"default");if(a&&n===void 0){const l=o.default;if(o.type!==Function&&!o.skipFactory&&Q(l)){const{propsDefaults:c}=r;if(i in c)n=c[i];else{const u=Cn(r);n=c[i]=l.call(null,e),u()}}else n=l;r.ce&&r.ce._setProp(i,n)}o[0]&&(s&&!a?n=!1:o[1]&&(n===""||n===Yt(i))&&(n=!0))}return n}const Cm=new WeakMap;function Bc(t,e,i=!1){const n=i?Cm:e.propsCache,r=n.get(t);if(r)return r;const s=t.props,o={},a=[];let l=!1;if(!Q(t)){const u=f=>{l=!0;const[h,p]=Bc(f,e,!0);Ae(o,h),p&&a.push(...p)};!i&&e.mixins.length&&e.mixins.forEach(u),t.extends&&u(t.extends),t.mixins&&t.mixins.forEach(u)}if(!s&&!l)return ye(t)&&n.set(t,Ei),Ei;if(Y(s))for(let u=0;u<s.length;u++){const f=jt(s[u]);qc(f)&&(o[f]=ne)}else if(s)for(const u in s){const f=jt(u);if(qc(f)){const h=s[u],p=o[f]=Y(h)||Q(h)?{type:h}:Ae({},h),d=p.type;let w=!1,S=!0;if(Y(d))for(let E=0;E<d.length;++E){const M=d[E],g=Q(M)&&M.name;if(g==="Boolean"){w=!0;break}else g==="String"&&(S=!1)}else w=Q(d)&&d.name==="Boolean";p[0]=w,p[1]=S,(w||se(p,"default"))&&a.push(f)}}const c=[o,a];return ye(t)&&n.set(t,c),c}function qc(t){return t[0]!=="$"&&!ln(t)}const Po=t=>t==="_"||t==="_ctx"||t==="$stable",Co=t=>Y(t)?t.map(Ct):[Ct(t)],Rm=(t,e,i)=>{if(e._n)return e;const n=bn((...r)=>Co(e(...r)),i);return n._c=!1,n},Hc=(t,e,i)=>{const n=t._ctx;for(const r in t){if(Po(r))continue;const s=t[r];if(Q(s))e[r]=Rm(r,s,n);else if(s!=null){const o=Co(s);e[r]=()=>o}}},zc=(t,e)=>{const i=Co(e);t.slots.default=()=>i},Kc=(t,e,i)=>{for(const n in e)(i||!Po(n))&&(t[n]=e[n])},Im=(t,e,i)=>{const n=t.slots=jc();if(t.vnode.shapeFlag&32){const r=e._;r?(Kc(n,e,i),i&&Hl(n,"_",r,!0)):Hc(e,n)}else e&&zc(t,e)},Am=(t,e,i)=>{const{vnode:n,slots:r}=t;let s=!0,o=ne;if(n.shapeFlag&32){const a=e._;a?i&&a===1?s=!1:Kc(r,e,i):(s=!e.$stable,Hc(e,r)),o=e}else e&&(zc(t,e),o={default:1});if(s)for(const a in r)!Po(a)&&o[a]==null&&delete r[a]},tt=Wm;function Om(t){return Tm(t)}function Tm(t,e){const i=fr();i.__VUE__=!0;const{insert:n,remove:r,patchProp:s,createElement:o,createText:a,createComment:l,setText:c,setElementText:u,parentNode:f,nextSibling:h,setScopeId:p=St,insertStaticContent:d}=t,w=(b,_,k,T=null,I=null,A=null,F=void 0,j=null,N=!!_.dynamicChildren)=>{if(b===_)return;b&&!En(b,_)&&(T=is(b),At(b,I,A,!0),b=null),_.patchFlag===-2&&(N=!1,_.dynamicChildren=null);const{type:O,ref:K,shapeFlag:q}=_;switch(O){case Rr:S(b,_,k,T);break;case Ht:E(b,_,k,T);break;case Ao:b==null&&M(_,k,T,F);break;case qe:He(b,_,k,T,I,A,F,j,N);break;default:q&1?v(b,_,k,T,I,A,F,j,N):q&6?dt(b,_,k,T,I,A,F,j,N):(q&64||q&128)&&O.process(b,_,k,T,I,A,F,j,N,jn)}K!=null&&I?vn(K,b&&b.ref,A,_||b,!_):K==null&&b&&b.ref!=null&&vn(b.ref,null,A,b,!0)},S=(b,_,k,T)=>{if(b==null)n(_.el=a(_.children),k,T);else{const I=_.el=b.el;_.children!==b.children&&c(I,_.children)}},E=(b,_,k,T)=>{b==null?n(_.el=l(_.children||""),k,T):_.el=b.el},M=(b,_,k,T)=>{[b.el,b.anchor]=d(b.children,_,k,T,b.el,b.anchor)},g=({el:b,anchor:_},k,T)=>{let I;for(;b&&b!==_;)I=h(b),n(b,k,T),b=I;n(_,k,T)},y=({el:b,anchor:_})=>{let k;for(;b&&b!==_;)k=h(b),r(b),b=k;r(_)},v=(b,_,k,T,I,A,F,j,N)=>{if(_.type==="svg"?F="svg":_.type==="math"&&(F="mathml"),b==null)x(_,k,T,I,A,F,j,N);else{const O=b.el&&b.el._isVueCE?b.el:null;try{O&&O._beginPatch(),C(b,_,I,A,F,j,N)}finally{O&&O._endPatch()}}},x=(b,_,k,T,I,A,F,j)=>{let N,O;const{props:K,shapeFlag:q,transition:z,dirs:X}=b;if(N=b.el=o(b.type,A,K&&K.is,K),q&8?u(N,b.children):q&16&&L(b.children,N,null,T,I,Ro(b,A),F,j),X&&ui(b,null,T,"created"),P(N,b,b.scopeId,F,T),K){for(const ge in K)ge!=="value"&&!ln(ge)&&s(N,ge,null,K[ge],A,T);"value"in K&&s(N,"value",null,K.value,A),(O=K.onVnodeBeforeMount)&&Rt(O,T,b)}X&&ui(b,null,T,"beforeMount");const te=Lm(I,z);te&&z.beforeEnter(N),n(N,_,k),((O=K&&K.onVnodeMounted)||te||X)&&tt(()=>{O&&Rt(O,T,b),te&&z.enter(N),X&&ui(b,null,T,"mounted")},I)},P=(b,_,k,T,I)=>{if(k&&p(b,k),T)for(let A=0;A<T.length;A++)p(b,T[A]);if(I){let A=I.subTree;if(_===A||tu(A.type)&&(A.ssContent===_||A.ssFallback===_)){const F=I.vnode;P(b,F,F.scopeId,F.slotScopeIds,I.parent)}}},L=(b,_,k,T,I,A,F,j,N=0)=>{for(let O=N;O<b.length;O++){const K=b[O]=j?Zt(b[O]):Ct(b[O]);w(null,K,_,k,T,I,A,F,j)}},C=(b,_,k,T,I,A,F)=>{const j=_.el=b.el;let{patchFlag:N,dynamicChildren:O,dirs:K}=_;N|=b.patchFlag&16;const q=b.props||ne,z=_.props||ne;let X;if(k&&di(k,!1),(X=z.onVnodeBeforeUpdate)&&Rt(X,k,_,b),K&&ui(_,b,k,"beforeUpdate"),k&&di(k,!0),(q.innerHTML&&z.innerHTML==null||q.textContent&&z.textContent==null)&&u(j,""),O?U(b.dynamicChildren,O,j,k,T,Ro(_,I),A):F||pe(b,_,j,null,k,T,Ro(_,I),A,!1),N>0){if(N&16)H(j,q,z,k,I);else if(N&2&&q.class!==z.class&&s(j,"class",null,z.class,I),N&4&&s(j,"style",q.style,z.style,I),N&8){const te=_.dynamicProps;for(let ge=0;ge<te.length;ge++){const le=te[ge],Xe=q[le],Je=z[le];(Je!==Xe||le==="value")&&s(j,le,Xe,Je,I,k)}}N&1&&b.children!==_.children&&u(j,_.children)}else!F&&O==null&&H(j,q,z,k,I);((X=z.onVnodeUpdated)||K)&&tt(()=>{X&&Rt(X,k,_,b),K&&ui(_,b,k,"updated")},T)},U=(b,_,k,T,I,A,F)=>{for(let j=0;j<_.length;j++){const N=b[j],O=_[j],K=N.el&&(N.type===qe||!En(N,O)||N.shapeFlag&198)?f(N.el):k;w(N,O,K,null,T,I,A,F,!0)}},H=(b,_,k,T,I)=>{if(_!==k){if(_!==ne)for(const A in _)!ln(A)&&!(A in k)&&s(b,A,_[A],null,I,T);for(const A in k){if(ln(A))continue;const F=k[A],j=_[A];F!==j&&A!=="value"&&s(b,A,j,F,I,T)}"value"in k&&s(b,"value",_.value,k.value,I)}},He=(b,_,k,T,I,A,F,j,N)=>{const O=_.el=b?b.el:a(""),K=_.anchor=b?b.anchor:a("");let{patchFlag:q,dynamicChildren:z,slotScopeIds:X}=_;X&&(j=j?j.concat(X):X),b==null?(n(O,k,T),n(K,k,T),L(_.children||[],k,K,I,A,F,j,N)):q>0&&q&64&&z&&b.dynamicChildren?(U(b.dynamicChildren,z,k,I,A,F,j),(_.key!=null||I&&_===I.subTree)&&Wc(b,_,!0)):pe(b,_,k,K,I,A,F,j,N)},dt=(b,_,k,T,I,A,F,j,N)=>{_.slotScopeIds=j,b==null?_.shapeFlag&512?I.ctx.activate(_,k,T,F,N):Ki(_,k,T,I,A,F,N):ke(b,_,N)},Ki=(b,_,k,T,I,A,F)=>{const j=b.component=Jm(b,T,I);if(bo(b)&&(j.ctx.renderer=jn),Zm(j,!1,F),j.asyncDep){if(I&&I.registerDep(j,ce,F),!b.el){const N=j.subTree=Ce(Ht);E(null,N,_,k),b.placeholder=N.el}}else ce(j,b,_,k,I,A,F)},ke=(b,_,k)=>{const T=_.component=b.component;if(zm(b,_,k))if(T.asyncDep&&!T.asyncResolved){me(T,_,k);return}else T.next=_,T.update();else _.el=b.el,T.vnode=_},ce=(b,_,k,T,I,A,F)=>{const j=()=>{if(b.isMounted){let{next:q,bu:z,u:X,parent:te,vnode:ge}=b;{const Tt=Gc(b);if(Tt){q&&(q.el=ge.el,me(b,q,F)),Tt.asyncDep.then(()=>{b.isUnmounted||j()});return}}let le=q,Xe;di(b,!1),q?(q.el=ge.el,me(b,q,F)):q=ge,z&&ur(z),(Xe=q.props&&q.props.onVnodeBeforeUpdate)&&Rt(Xe,te,q,ge),di(b,!0);const Je=Zc(b),Ot=b.subTree;b.subTree=Je,w(Ot,Je,f(Ot.el),is(Ot),b,I,A),q.el=Je.el,le===null&&Km(b,Je.el),X&&tt(X,I),(Xe=q.props&&q.props.onVnodeUpdated)&&tt(()=>Rt(Xe,te,q,ge),I)}else{let q;const{el:z,props:X}=_,{bm:te,m:ge,parent:le,root:Xe,type:Je}=b,Ot=Ti(_);di(b,!1),te&&ur(te),!Ot&&(q=X&&X.onVnodeBeforeMount)&&Rt(q,le,_),di(b,!0);{Xe.ce&&Xe.ce._def.shadowRoot!==!1&&Xe.ce._injectChildStyle(Je);const Tt=b.subTree=Zc(b);w(null,Tt,k,T,b,I,A),_.el=Tt.el}if(ge&&tt(ge,I),!Ot&&(q=X&&X.onVnodeMounted)){const Tt=_;tt(()=>Rt(q,le,Tt),I)}(_.shapeFlag&256||le&&Ti(le.vnode)&&le.vnode.shapeFlag&256)&&b.a&&tt(b.a,I),b.isMounted=!0,_=k=T=null}};b.scope.on();const N=b.effect=new Vl(j);b.scope.off();const O=b.update=N.run.bind(N),K=b.job=N.runIfDirty.bind(N);K.i=b,K.id=b.uid,N.scheduler=()=>go(K),di(b,!0),O()},me=(b,_,k)=>{_.component=b;const T=b.vnode.props;b.vnode=_,b.next=null,Pm(b,_.props,T,k),Am(b,_.children,k),kt(),bc(b),$t()},pe=(b,_,k,T,I,A,F,j,N=!1)=>{const O=b&&b.children,K=b?b.shapeFlag:0,q=_.children,{patchFlag:z,shapeFlag:X}=_;if(z>0){if(z&128){ts(O,q,k,T,I,A,F,j,N);return}else if(z&256){bi(O,q,k,T,I,A,F,j,N);return}}X&8?(K&16&&Dn(O,I,A),q!==O&&u(k,q)):K&16?X&16?ts(O,q,k,T,I,A,F,j,N):Dn(O,I,A,!0):(K&8&&u(k,""),X&16&&L(q,k,T,I,A,F,j,N))},bi=(b,_,k,T,I,A,F,j,N)=>{b=b||Ei,_=_||Ei;const O=b.length,K=_.length,q=Math.min(O,K);let z;for(z=0;z<q;z++){const X=_[z]=N?Zt(_[z]):Ct(_[z]);w(b[z],X,k,null,I,A,F,j,N)}O>K?Dn(b,I,A,!0,!1,q):L(_,k,T,I,A,F,j,N,q)},ts=(b,_,k,T,I,A,F,j,N)=>{let O=0;const K=_.length;let q=b.length-1,z=K-1;for(;O<=q&&O<=z;){const X=b[O],te=_[O]=N?Zt(_[O]):Ct(_[O]);if(En(X,te))w(X,te,k,null,I,A,F,j,N);else break;O++}for(;O<=q&&O<=z;){const X=b[q],te=_[z]=N?Zt(_[z]):Ct(_[z]);if(En(X,te))w(X,te,k,null,I,A,F,j,N);else break;q--,z--}if(O>q){if(O<=z){const X=z+1,te=X<K?_[X].el:T;for(;O<=z;)w(null,_[O]=N?Zt(_[O]):Ct(_[O]),k,te,I,A,F,j,N),O++}}else if(O>z)for(;O<=q;)At(b[O],I,A,!0),O++;else{const X=O,te=O,ge=new Map;for(O=te;O<=z;O++){const st=_[O]=N?Zt(_[O]):Ct(_[O]);st.key!=null&&ge.set(st.key,O)}let le,Xe=0;const Je=z-te+1;let Ot=!1,Tt=0;const Un=new Array(Je);for(O=0;O<Je;O++)Un[O]=0;for(O=X;O<=q;O++){const st=b[O];if(Xe>=Je){At(st,I,A,!0);continue}let Lt;if(st.key!=null)Lt=ge.get(st.key);else for(le=te;le<=z;le++)if(Un[le-te]===0&&En(st,_[le])){Lt=le;break}Lt===void 0?At(st,I,A,!0):(Un[Lt-te]=O+1,Lt>=Tt?Tt=Lt:Ot=!0,w(st,_[Lt],k,null,I,A,F,j,N),Xe++)}const Nf=Ot?Mm(Un):Ei;for(le=Nf.length-1,O=Je-1;O>=0;O--){const st=te+O,Lt=_[st],Df=_[st+1],jf=st+1<K?Df.el||Df.placeholder:T;Un[O]===0?w(null,Lt,k,jf,I,A,F,j,N):Ot&&(le<0||O!==Nf[le]?vi(Lt,k,jf,2):le--)}}},vi=(b,_,k,T,I=null)=>{const{el:A,type:F,transition:j,children:N,shapeFlag:O}=b;if(O&6){vi(b.component.subTree,_,k,T);return}if(O&128){b.suspense.move(_,k,T);return}if(O&64){F.move(b,_,k,jn);return}if(F===qe){n(A,_,k);for(let q=0;q<N.length;q++)vi(N[q],_,k,T);n(b.anchor,_,k);return}if(F===Ao){g(b,_,k);return}if(T!==2&&O&1&&j)if(T===0)j.beforeEnter(A),n(A,_,k),tt(()=>j.enter(A),I);else{const{leave:q,delayLeave:z,afterLeave:X}=j,te=()=>{b.ctx.isUnmounted?r(A):n(A,_,k)},ge=()=>{A._isLeaving&&A[rm](!0),q(A,()=>{te(),X&&X()})};z?z(A,te,ge):ge()}else n(A,_,k)},At=(b,_,k,T=!1,I=!1)=>{const{type:A,props:F,ref:j,children:N,dynamicChildren:O,shapeFlag:K,patchFlag:q,dirs:z,cacheIndex:X}=b;if(q===-2&&(I=!1),j!=null&&(kt(),vn(j,null,k,b,!0),$t()),X!=null&&(_.renderCache[X]=void 0),K&256){_.ctx.deactivate(b);return}const te=K&1&&z,ge=!Ti(b);let le;if(ge&&(le=F&&F.onVnodeBeforeUnmount)&&Rt(le,_,b),K&6)Tw(b.component,k,T);else{if(K&128){b.suspense.unmount(k,T);return}te&&ui(b,null,_,"beforeUnmount"),K&64?b.type.remove(b,_,k,jn,T):O&&!O.hasOnce&&(A!==qe||q>0&&q&64)?Dn(O,_,k,!1,!0):(A===qe&&q&384||!I&&K&16)&&Dn(N,_,k),T&&Lf(b)}(ge&&(le=F&&F.onVnodeUnmounted)||te)&&tt(()=>{le&&Rt(le,_,b),te&&ui(b,null,_,"unmounted")},k)},Lf=b=>{const{type:_,el:k,anchor:T,transition:I}=b;if(_===qe){Ow(k,T);return}if(_===Ao){y(b);return}const A=()=>{r(k),I&&!I.persisted&&I.afterLeave&&I.afterLeave()};if(b.shapeFlag&1&&I&&!I.persisted){const{leave:F,delayLeave:j}=I,N=()=>F(k,A);j?j(b.el,A,N):N()}else A()},Ow=(b,_)=>{let k;for(;b!==_;)k=h(b),r(b),b=k;r(_)},Tw=(b,_,k)=>{const{bum:T,scope:I,job:A,subTree:F,um:j,m:N,a:O}=b;Vc(N),Vc(O),T&&ur(T),I.stop(),A&&(A.flags|=8,At(F,b,_,k)),j&&tt(j,_),tt(()=>{b.isUnmounted=!0},_)},Dn=(b,_,k,T=!1,I=!1,A=0)=>{for(let F=A;F<b.length;F++)At(b[F],_,k,T,I)},is=b=>{if(b.shapeFlag&6)return is(b.component.subTree);if(b.shapeFlag&128)return b.suspense.next();const _=h(b.anchor||b.el),k=_&&_[im];return k?h(k):_};let fa=!1;const Mf=(b,_,k)=>{b==null?_._vnode&&At(_._vnode,null,null,!0):w(_._vnode||null,b,_,null,null,null,k),_._vnode=b,fa||(fa=!0,bc(),vc(),fa=!1)},jn={p:w,um:At,m:vi,r:Lf,mt:Ki,mc:L,pc:pe,pbc:U,n:is,o:t};return{render:Mf,hydrate:void 0,createApp:$m(Mf)}}function Ro({type:t,props:e},i){return i==="svg"&&t==="foreignObject"||i==="mathml"&&t==="annotation-xml"&&e&&e.encoding&&e.encoding.includes("html")?void 0:i}function di({effect:t,job:e},i){i?(t.flags|=32,e.flags|=4):(t.flags&=-33,e.flags&=-5)}function Lm(t,e){return(!t||t&&!t.pendingBranch)&&e&&!e.persisted}function Wc(t,e,i=!1){const n=t.children,r=e.children;if(Y(n)&&Y(r))for(let s=0;s<n.length;s++){const o=n[s];let a=r[s];a.shapeFlag&1&&!a.dynamicChildren&&((a.patchFlag<=0||a.patchFlag===32)&&(a=r[s]=Zt(r[s]),a.el=o.el),!i&&a.patchFlag!==-2&&Wc(o,a)),a.type===Rr&&a.patchFlag!==-1&&(a.el=o.el),a.type===Ht&&!a.el&&(a.el=o.el)}}function Mm(t){const e=t.slice(),i=[0];let n,r,s,o,a;const l=t.length;for(n=0;n<l;n++){const c=t[n];if(c!==0){if(r=i[i.length-1],t[r]<c){e[n]=r,i.push(n);continue}for(s=0,o=i.length-1;s<o;)a=s+o>>1,t[i[a]]<c?s=a+1:o=a;c<t[i[s]]&&(s>0&&(e[n]=i[s-1]),i[s]=n)}}for(s=i.length,o=i[s-1];s-- >0;)i[s]=o,o=e[o];return i}function Gc(t){const e=t.subTree.component;if(e)return e.asyncDep&&!e.asyncResolved?e:Gc(e)}function Vc(t){if(t)for(let e=0;e<t.length;e++)t[e].flags|=8}const Nm=Symbol.for("v-scx"),Dm=()=>Sn(Nm);function jm(t,e){return Io(t,null,{flush:"sync"})}function Mi(t,e,i){return Io(t,e,i)}function Io(t,e,i=ne){const{immediate:n,deep:r,flush:s,once:o}=i,a=Ae({},i),l=e&&n||!e&&s!=="post";let c;if(Di){if(s==="sync"){const p=Dm();c=p.__watcherHandles||(p.__watcherHandles=[])}else if(!l){const p=()=>{};return p.stop=St,p.resume=St,p.pause=St,p}}const u=De;a.call=(p,d,w)=>Et(p,u,d,w);let f=!1;s==="post"?a.scheduler=p=>{tt(p,u&&u.suspense)}:s!=="sync"&&(f=!0,a.scheduler=(p,d)=>{d?p():go(p)}),a.augmentJob=p=>{e&&(p.flags|=4),f&&(p.flags|=2,u&&(p.id=u.uid,p.i=u))};const h=Vg(t,e,a);return Di&&(c?c.push(h):l&&h()),h}function Um(t,e,i){const n=this.proxy,r=_e(t)?t.includes(".")?Yc(n,t):()=>n[t]:t.bind(n,n);let s;Q(e)?s=e:(s=e.handler,i=e);const o=Cn(this),a=Io(r,s.bind(n),i);return o(),a}function Yc(t,e){const i=e.split(".");return()=>{let n=t;for(let r=0;r<i.length&&n;r++)n=n[i[r]];return n}}function Qc(t,e,i=ne){const n=Lo(),r=jt(e),s=Yt(e),o=Xc(t,r),a=zg((l,c)=>{let u,f=ne,h;return jm(()=>{const p=t[r];Ve(u,p)&&(u=p,c())}),{get(){return l(),i.get?i.get(u):u},set(p){const d=i.set?i.set(p):p;if(!Ve(d,u)&&!(f!==ne&&Ve(p,f)))return;const w=n.vnode.props;w&&(e in w||r in w||s in w)&&(`onUpdate:${e}`in w||`onUpdate:${r}`in w||`onUpdate:${s}`in w)||(u=p,c()),n.emit(`update:${e}`,d),Ve(p,d)&&Ve(p,f)&&!Ve(d,h)&&c(),f=p,h=d}}});return a[Symbol.iterator]=()=>{let l=0;return{next(){return l<2?{value:l++?o||ne:a,done:!1}:{done:!0}}}},a}const Xc=(t,e)=>e==="modelValue"||e==="model-value"?t.modelModifiers:t[`${e}Modifiers`]||t[`${jt(e)}Modifiers`]||t[`${Yt(e)}Modifiers`];function Fm(t,e,...i){if(t.isUnmounted)return;const n=t.vnode.props||ne;let r=i;const s=e.startsWith("update:"),o=s&&Xc(n,e.slice(7));o&&(o.trim&&(r=i.map(u=>_e(u)?u.trim():u)),o.number&&(r=i.map(Xs)));let a,l=n[a=Qs(e)]||n[a=Qs(jt(e))];!l&&s&&(l=n[a=Qs(Yt(e))]),l&&Et(l,t,6,r);const c=n[a+"Once"];if(c){if(!t.emitted)t.emitted={};else if(t.emitted[a])return;t.emitted[a]=!0,Et(c,t,6,r)}}const Bm=new WeakMap;function Jc(t,e,i=!1){const n=i?Bm:e.emitsCache,r=n.get(t);if(r!==void 0)return r;const s=t.emits;let o={},a=!1;if(!Q(t)){const l=c=>{const u=Jc(c,e,!0);u&&(a=!0,Ae(o,u))};!i&&e.mixins.length&&e.mixins.forEach(l),t.extends&&l(t.extends),t.mixins&&t.mixins.forEach(l)}return!s&&!a?(ye(t)&&n.set(t,null),null):(Y(s)?s.forEach(l=>o[l]=null):Ae(o,s),ye(t)&&n.set(t,o),o)}function Cr(t,e){return!t||!ar(e)?!1:(e=e.slice(2).replace(/Once$/,""),se(t,e[0].toLowerCase()+e.slice(1))||se(t,Yt(e))||se(t,e))}function Fw(){}function Zc(t){const{type:e,vnode:i,proxy:n,withProxy:r,propsOptions:[s],slots:o,attrs:a,emit:l,render:c,renderCache:u,props:f,data:h,setupState:p,ctx:d,inheritAttrs:w}=t,S=xr(t);let E,M;try{if(i.shapeFlag&4){const y=r||n,v=y;E=Ct(c.call(v,y,u,f,p,h,d)),M=a}else{const y=e;E=Ct(y.length>1?y(f,{attrs:a,slots:o,emit:l}):y(f,null)),M=e.props?a:qm(a)}}catch(y){kn.length=0,gn(y,t,1),E=Ce(Ht)}let g=E;if(M&&w!==!1){const y=Object.keys(M),{shapeFlag:v}=g;y.length&&v&7&&(s&&y.some(Gs)&&(M=Hm(M,s)),g=Ni(g,M,!1,!0))}return i.dirs&&(g=Ni(g,null,!1,!0),g.dirs=g.dirs?g.dirs.concat(i.dirs):i.dirs),i.transition&&mo(g,i.transition),E=g,xr(S),E}const qm=t=>{let e;for(const i in t)(i==="class"||i==="style"||ar(i))&&((e||(e={}))[i]=t[i]);return e},Hm=(t,e)=>{const i={};for(const n in t)(!Gs(n)||!(n.slice(9)in e))&&(i[n]=t[n]);return i};function zm(t,e,i){const{props:n,children:r,component:s}=t,{props:o,children:a,patchFlag:l}=e,c=s.emitsOptions;if(e.dirs||e.transition)return!0;if(i&&l>=0){if(l&1024)return!0;if(l&16)return n?eu(n,o,c):!!o;if(l&8){const u=e.dynamicProps;for(let f=0;f<u.length;f++){const h=u[f];if(o[h]!==n[h]&&!Cr(c,h))return!0}}}else return(r||a)&&(!a||!a.$stable)?!0:n===o?!1:n?o?eu(n,o,c):!0:!!o;return!1}function eu(t,e,i){const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!0;for(let r=0;r<n.length;r++){const s=n[r];if(e[s]!==t[s]&&!Cr(i,s))return!0}return!1}function Km({vnode:t,parent:e},i){for(;e;){const n=e.subTree;if(n.suspense&&n.suspense.activeBranch===t&&(n.el=t.el),n===t)(t=e.vnode).el=i,e=e.parent;else break}}const tu=t=>t.__isSuspense;function Wm(t,e){e&&e.pendingBranch?Y(t)?e.effects.push(...t):e.effects.push(t):tm(t)}const qe=Symbol.for("v-fgt"),Rr=Symbol.for("v-txt"),Ht=Symbol.for("v-cmt"),Ao=Symbol.for("v-stc"),kn=[];let it=null;function oe(t=!1){kn.push(it=t?null:[])}function Gm(){kn.pop(),it=kn[kn.length-1]||null}let $n=1;function iu(t,e=!1){$n+=t,t<0&&it&&e&&(it.hasOnce=!0)}function nu(t){return t.dynamicChildren=$n>0?it||Ei:null,Gm(),$n>0&&it&&it.push(t),t}function de(t,e,i,n,r,s){return nu(J(t,e,i,n,r,s,!0))}function Ir(t,e,i,n,r){return nu(Ce(t,e,i,n,r,!0))}function Oo(t){return t?t.__v_isVNode===!0:!1}function En(t,e){return t.type===e.type&&t.key===e.key}const ru=({key:t})=>t??null,Ar=({ref:t,ref_key:e,ref_for:i})=>(typeof t=="number"&&(t=""+t),t!=null?_e(t)||Ie(t)||Q(t)?{i:Ne,r:t,k:e,f:!!i}:t:null);function J(t,e=null,i=null,n=0,r=null,s=t===qe?0:1,o=!1,a=!1){const l={__v_isVNode:!0,__v_skip:!0,type:t,props:e,key:e&&ru(e),ref:e&&Ar(e),scopeId:_c,slotScopeIds:null,children:i,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:s,patchFlag:n,dynamicProps:r,dynamicChildren:null,appContext:null,ctx:Ne};return a?(To(l,i),s&128&&t.normalize(l)):i&&(l.shapeFlag|=_e(i)?8:16),$n>0&&!o&&it&&(l.patchFlag>0||s&6)&&l.patchFlag!==32&&it.push(l),l}const Ce=Vm;function Vm(t,e=null,i=null,n=0,r=null,s=!1){if((!t||t===mm)&&(t=Ht),Oo(t)){const a=Ni(t,e,!0);return i&&To(a,i),$n>0&&!s&&it&&(a.shapeFlag&6?it[it.indexOf(t)]=a:it.push(a)),a.patchFlag=-2,a}if(oy(t)&&(t=t.__vccOpts),e){e=Ym(e);let{class:a,style:l}=e;a&&!_e(a)&&(e.class=pt(a)),ye(l)&&(ho(l)&&!Y(l)&&(l=Ae({},l)),e.style=Js(l))}const o=_e(t)?1:tu(t)?128:nm(t)?64:ye(t)?4:Q(t)?2:0;return J(t,e,i,n,r,o,s,!0)}function Ym(t){return t?ho(t)||Uc(t)?Ae({},t):t:null}function Ni(t,e,i=!1,n=!1){const{props:r,ref:s,patchFlag:o,children:a,transition:l}=t,c=e?su(r||{},e):r,u={__v_isVNode:!0,__v_skip:!0,type:t.type,props:c,key:c&&ru(c),ref:e&&e.ref?i&&s?Y(s)?s.concat(Ar(e)):[s,Ar(e)]:Ar(e):s,scopeId:t.scopeId,slotScopeIds:t.slotScopeIds,children:a,target:t.target,targetStart:t.targetStart,targetAnchor:t.targetAnchor,staticCount:t.staticCount,shapeFlag:t.shapeFlag,patchFlag:e&&t.type!==qe?o===-1?16:o|16:o,dynamicProps:t.dynamicProps,dynamicChildren:t.dynamicChildren,appContext:t.appContext,dirs:t.dirs,transition:l,component:t.component,suspense:t.suspense,ssContent:t.ssContent&&Ni(t.ssContent),ssFallback:t.ssFallback&&Ni(t.ssFallback),placeholder:t.placeholder,el:t.el,anchor:t.anchor,ctx:t.ctx,ce:t.ce};return l&&n&&mo(u,l.clone(u)),u}function Pn(t=" ",e=0){return Ce(Rr,null,t,e)}function Jt(t="",e=!1){return e?(oe(),Ir(Ht,null,t)):Ce(Ht,null,t)}function Ct(t){return t==null||typeof t=="boolean"?Ce(Ht):Y(t)?Ce(qe,null,t.slice()):Oo(t)?Zt(t):Ce(Rr,null,String(t))}function Zt(t){return t.el===null&&t.patchFlag!==-1||t.memo?t:Ni(t)}function To(t,e){let i=0;const{shapeFlag:n}=t;if(e==null)e=null;else if(Y(e))i=16;else if(typeof e=="object")if(n&65){const r=e.default;r&&(r._c&&(r._d=!1),To(t,r()),r._c&&(r._d=!0));return}else{i=32;const r=e._;!r&&!Uc(e)?e._ctx=Ne:r===3&&Ne&&(Ne.slots._===1?e._=1:(e._=2,t.patchFlag|=1024))}else Q(e)?(e={default:e,_ctx:Ne},i=32):(e=String(e),n&64?(i=16,e=[Pn(e)]):i=8);t.children=e,t.shapeFlag|=i}function su(...t){const e={};for(let i=0;i<t.length;i++){const n=t[i];for(const r in n)if(r==="class")e.class!==n.class&&(e.class=pt([e.class,n.class]));else if(r==="style")e.style=Js([e.style,n.style]);else if(ar(r)){const s=e[r],o=n[r];o&&s!==o&&!(Y(s)&&s.includes(o))&&(e[r]=s?[].concat(s,o):o)}else r!==""&&(e[r]=n[r])}return e}function Rt(t,e,i,n=null){Et(t,e,7,[i,n])}const Qm=Mc();let Xm=0;function Jm(t,e,i){const n=t.type,r=(e?e.appContext:t.appContext)||Qm,s={uid:Xm++,vnode:t,type:n,parent:e,appContext:r,root:null,next:null,subTree:null,effect:null,update:null,job:null,scope:new vg(!0),render:null,proxy:null,exposed:null,exposeProxy:null,withProxy:null,provides:e?e.provides:Object.create(r.provides),ids:e?e.ids:["",0,0],accessCache:null,renderCache:[],components:null,directives:null,propsOptions:Bc(n,r),emitsOptions:Jc(n,r),emit:null,emitted:null,propsDefaults:ne,inheritAttrs:n.inheritAttrs,ctx:ne,data:ne,props:ne,attrs:ne,slots:ne,refs:ne,setupState:ne,setupContext:null,suspense:i,suspenseId:i?i.pendingId:0,asyncDep:null,asyncResolved:!1,isMounted:!1,isUnmounted:!1,isDeactivated:!1,bc:null,c:null,bm:null,m:null,bu:null,u:null,um:null,bum:null,da:null,a:null,rtg:null,rtc:null,ec:null,sp:null};return s.ctx={_:s},s.root=e?e.root:s,s.emit=Fm.bind(null,s),t.ce&&t.ce(s),s}let De=null;const Lo=()=>De||Ne;let Or,Mo;{const t=fr(),e=(i,n)=>{let r;return(r=t[i])||(r=t[i]=[]),r.push(n),s=>{r.length>1?r.forEach(o=>o(s)):r[0](s)}};Or=e("__VUE_INSTANCE_SETTERS__",i=>De=i),Mo=e("__VUE_SSR_SETTERS__",i=>Di=i)}const Cn=t=>{const e=De;return Or(t),t.scope.on(),()=>{t.scope.off(),Or(e)}},ou=()=>{De&&De.scope.off(),Or(null)};function au(t){return t.vnode.shapeFlag&4}let Di=!1;function Zm(t,e=!1,i=!1){e&&Mo(e);const{props:n,children:r}=t.vnode,s=au(t);Em(t,n,s,e),Im(t,r,i||e);const o=s?ey(t,e):void 0;return e&&Mo(!1),o}function ey(t,e){const i=t.type;t.accessCache=Object.create(null),t.proxy=new Proxy(t.ctx,bm);const{setup:n}=i;if(n){kt();const r=t.setupContext=n.length>1?iy(t):null,s=Cn(t),o=Ii(n,t,0,[t.props,r]),a=Ul(o);if($t(),s(),(a||t.sp)&&!Ti(t)&&yo(t),a){if(o.then(ou,ou),e)return o.then(l=>{lu(t,l)}).catch(l=>{gn(l,t,0)});t.asyncDep=o}else lu(t,o)}else cu(t)}function lu(t,e,i){Q(e)?t.type.__ssrInlineRender?t.ssrRender=e:t.render=e:ye(e)&&(t.setupState=pc(e)),cu(t)}function cu(t,e,i){const n=t.type;t.render||(t.render=n.render||St);{const r=Cn(t);kt();try{vm(t)}finally{$t(),r()}}}const ty={get(t,e){return Me(t,"get",""),t[e]}};function iy(t){const e=i=>{t.exposed=i||{}};return{attrs:new Proxy(t.attrs,ty),slots:t.slots,emit:t.emit,expose:e}}function Tr(t){return t.exposed?t.exposeProxy||(t.exposeProxy=new Proxy(pc(Fg(t.exposed)),{get(e,i){if(i in e)return e[i];if(i in _n)return _n[i](t)},has(e,i){return i in e||i in _n}})):t.proxy}const ny=/(?:^|[-_])\w/g,ry=t=>t.replace(ny,e=>e.toUpperCase()).replace(/[-_]/g,"");function sy(t,e=!0){return Q(t)?t.displayName||t.name:t.name||e&&t.__name}function uu(t,e,i=!1){let n=sy(e);if(!n&&e.__file){const r=e.__file.match(/([^/\\]+)\.\w+$/);r&&(n=r[1])}if(!n&&t&&t.parent){const r=s=>{for(const o in s)if(s[o]===e)return o};n=r(t.components||t.parent.type.components)||r(t.appContext.components)}return n?ry(n):i?"App":"Anonymous"}function oy(t){return Q(t)&&"__vccOpts"in t}const It=(t,e)=>Wg(t,e,Di),ay="3.5.24";let No;const fu=typeof window<"u"&&window.trustedTypes;if(fu)try{No=fu.createPolicy("vue",{createHTML:t=>t})}catch{}const du=No?t=>No.createHTML(t):t=>t,ly="http://www.w3.org/2000/svg",cy="http://www.w3.org/1998/Math/MathML",zt=typeof document<"u"?document:null,hu=zt&&zt.createElement("template"),uy={insert:(t,e,i)=>{e.insertBefore(t,i||null)},remove:t=>{const e=t.parentNode;e&&e.removeChild(t)},createElement:(t,e,i,n)=>{const r=e==="svg"?zt.createElementNS(ly,t):e==="mathml"?zt.createElementNS(cy,t):i?zt.createElement(t,{is:i}):zt.createElement(t);return t==="select"&&n&&n.multiple!=null&&r.setAttribute("multiple",n.multiple),r},createText:t=>zt.createTextNode(t),createComment:t=>zt.createComment(t),setText:(t,e)=>{t.nodeValue=e},setElementText:(t,e)=>{t.textContent=e},parentNode:t=>t.parentNode,nextSibling:t=>t.nextSibling,querySelector:t=>zt.querySelector(t),setScopeId(t,e){t.setAttribute(e,"")},insertStaticContent(t,e,i,n,r,s){const o=i?i.previousSibling:e.lastChild;if(r&&(r===s||r.nextSibling))for(;e.insertBefore(r.cloneNode(!0),i),!(r===s||!(r=r.nextSibling)););else{hu.innerHTML=du(n==="svg"?`<svg>${t}</svg>`:n==="mathml"?`<math>${t}</math>`:t);const a=hu.content;if(n==="svg"||n==="mathml"){const l=a.firstChild;for(;l.firstChild;)a.appendChild(l.firstChild);a.removeChild(l)}e.insertBefore(a,i)}return[o?o.nextSibling:e.firstChild,i?i.previousSibling:e.lastChild]}},fy=Symbol("_vtc");function dy(t,e,i){const n=t[fy];n&&(e=(e?[e,...n]:[...n]).join(" ")),e==null?t.removeAttribute("class"):i?t.setAttribute("class",e):t.className=e}const pu=Symbol("_vod"),hy=Symbol("_vsh"),py=Symbol(""),gy=/(?:^|;)\s*display\s*:/;function my(t,e,i){const n=t.style,r=_e(i);let s=!1;if(i&&!r){if(e)if(_e(e))for(const o of e.split(";")){const a=o.slice(0,o.indexOf(":")).trim();i[a]==null&&Lr(n,a,"")}else for(const o in e)i[o]==null&&Lr(n,o,"");for(const o in i)o==="display"&&(s=!0),Lr(n,o,i[o])}else if(r){if(e!==i){const o=n[py];o&&(i+=";"+o),n.cssText=i,s=gy.test(i)}}else e&&t.removeAttribute("style");pu in t&&(t[pu]=s?n.display:"",t[hy]&&(n.display="none"))}const gu=/\s*!important$/;function Lr(t,e,i){if(Y(i))i.forEach(n=>Lr(t,e,n));else if(i==null&&(i=""),e.startsWith("--"))t.setProperty(e,i);else{const n=yy(t,e);gu.test(i)?t.setProperty(Yt(n),i.replace(gu,""),"important"):t[n]=i}}const mu=["Webkit","Moz","ms"],Do={};function yy(t,e){const i=Do[e];if(i)return i;let n=jt(e);if(n!=="filter"&&n in t)return Do[e]=n;n=ql(n);for(let r=0;r<mu.length;r++){const s=mu[r]+n;if(s in t)return Do[e]=s}return e}const yu="http://www.w3.org/1999/xlink";function bu(t,e,i,n,r,s=bg(e)){n&&e.startsWith("xlink:")?i==null?t.removeAttributeNS(yu,e.slice(6,e.length)):t.setAttributeNS(yu,e,i):i==null||s&&!Kl(i)?t.removeAttribute(e):t.setAttribute(e,s?"":Dt(i)?String(i):i)}function vu(t,e,i,n,r){if(e==="innerHTML"||e==="textContent"){i!=null&&(t[e]=e==="innerHTML"?du(i):i);return}const s=t.tagName;if(e==="value"&&s!=="PROGRESS"&&!s.includes("-")){const a=s==="OPTION"?t.getAttribute("value")||"":t.value,l=i==null?t.type==="checkbox"?"on":"":String(i);(a!==l||!("_value"in t))&&(t.value=l),i==null&&t.removeAttribute(e),t._value=i;return}let o=!1;if(i===""||i==null){const a=typeof t[e];a==="boolean"?i=Kl(i):i==null&&a==="string"?(i="",o=!0):a==="number"&&(i=0,o=!0)}try{t[e]=i}catch{}o&&t.removeAttribute(r||e)}function ji(t,e,i,n){t.addEventListener(e,i,n)}function by(t,e,i,n){t.removeEventListener(e,i,n)}const wu=Symbol("_vei");function vy(t,e,i,n,r=null){const s=t[wu]||(t[wu]={}),o=s[e];if(n&&o)o.value=n;else{const[a,l]=wy(e);if(n){const c=s[e]=Sy(n,r);ji(t,a,c,l)}else o&&(by(t,a,o,l),s[e]=void 0)}}const _u=/(?:Once|Passive|Capture)$/;function wy(t){let e;if(_u.test(t)){e={};let n;for(;n=t.match(_u);)t=t.slice(0,t.length-n[0].length),e[n[0].toLowerCase()]=!0}return[t[2]===":"?t.slice(3):Yt(t.slice(2)),e]}let jo=0;const _y=Promise.resolve(),xy=()=>jo||(_y.then(()=>jo=0),jo=Date.now());function Sy(t,e){const i=n=>{if(!n._vts)n._vts=Date.now();else if(n._vts<=i.attached)return;Et(ky(n,i.value),e,5,[n])};return i.value=t,i.attached=xy(),i}function ky(t,e){if(Y(e)){const i=t.stopImmediatePropagation;return t.stopImmediatePropagation=()=>{i.call(t),t._stopped=!0},e.map(n=>r=>!r._stopped&&n&&n(r))}else return e}const xu=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)>96&&t.charCodeAt(2)<123,$y=(t,e,i,n,r,s)=>{const o=r==="svg";e==="class"?dy(t,n,o):e==="style"?my(t,i,n):ar(e)?Gs(e)||vy(t,e,i,n,s):(e[0]==="."?(e=e.slice(1),!0):e[0]==="^"?(e=e.slice(1),!1):Ey(t,e,n,o))?(vu(t,e,n),!t.tagName.includes("-")&&(e==="value"||e==="checked"||e==="selected")&&bu(t,e,n,o,s,e!=="value")):t._isVueCE&&(/[A-Z]/.test(e)||!_e(n))?vu(t,jt(e),n,s,e):(e==="true-value"?t._trueValue=n:e==="false-value"&&(t._falseValue=n),bu(t,e,n,o))};function Ey(t,e,i,n){if(n)return!!(e==="innerHTML"||e==="textContent"||e in t&&xu(e)&&Q(i));if(e==="spellcheck"||e==="draggable"||e==="translate"||e==="autocorrect"||e==="sandbox"&&t.tagName==="IFRAME"||e==="form"||e==="list"&&t.tagName==="INPUT"||e==="type"&&t.tagName==="TEXTAREA")return!1;if(e==="width"||e==="height"){const r=t.tagName;if(r==="IMG"||r==="VIDEO"||r==="CANVAS"||r==="SOURCE")return!1}return xu(e)&&_e(i)?!1:e in t}const Su=t=>{const e=t.props["onUpdate:modelValue"]||!1;return Y(e)?i=>ur(e,i):e};function Py(t){t.target.composing=!0}function ku(t){const e=t.target;e.composing&&(e.composing=!1,e.dispatchEvent(new Event("input")))}const Uo=Symbol("_assign");function $u(t,e,i){return e&&(t=t.trim()),i&&(t=Xs(t)),t}const Eu={created(t,{modifiers:{lazy:e,trim:i,number:n}},r){t[Uo]=Su(r);const s=n||r.props&&r.props.type==="number";ji(t,e?"change":"input",o=>{o.target.composing||t[Uo]($u(t.value,i,s))}),(i||s)&&ji(t,"change",()=>{t.value=$u(t.value,i,s)}),e||(ji(t,"compositionstart",Py),ji(t,"compositionend",ku),ji(t,"change",ku))},mounted(t,{value:e}){t.value=e??""},beforeUpdate(t,{value:e,oldValue:i,modifiers:{lazy:n,trim:r,number:s}},o){if(t[Uo]=Su(o),t.composing)return;const a=(s||t.type==="number")&&!/^0\d/.test(t.value)?Xs(t.value):t.value,l=e??"";a!==l&&(document.activeElement===t&&t.type!=="range"&&(n&&e===i||r&&t.value.trim()===l)||(t.value=l))}},Cy=Ae({patchProp:$y},uy);let Pu;function Ry(){return Pu||(Pu=Om(Cy))}const Iy=((...t)=>{const e=Ry().createApp(...t),{mount:i}=e;return e.mount=n=>{const r=Oy(n);if(!r)return;const s=e._component;!Q(s)&&!s.render&&!s.template&&(s.template=r.innerHTML),r.nodeType===1&&(r.textContent="");const o=i(r,!1,Ay(r));return r instanceof Element&&(r.removeAttribute("v-cloak"),r.setAttribute("data-v-app","")),o},e});function Ay(t){if(t instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&t instanceof MathMLElement)return"mathml"}function Oy(t){return _e(t)?document.querySelector(t):t}const Ty=1;var Mr;(t=>{t.PackageLoader=new R(R.object({kind:R.union(["autoload","module","umd","styles"]).required().default("autoload"),entry:R.string(),styles:R.array(R.string()),main_export:R.string()})),t.Package=new R(R.object({id:R.string().required(),name:R.string().required(),version:R.string().required(),description:R.string(),author:R.string(),license:R.string(),loader:t.PackageLoader.required()})),t.RegistryMaintainer=new R(R.object({name:R.string().required(),email:R.string()})),t.RegistryRepository=new R(R.object({type:R.union(["git"]).required().default("git"),url:R.string().required()})),t.Registry=new R(R.object({manifest_version:R.number().min(Ty).required(),name:R.string().required(),base_url:R.string().required(),homepage:R.string(),maintainers:R.array(t.RegistryMaintainer),repository:t.RegistryRepository,packages:R.array(t.Package).required()}))})(Mr||(Mr={}));const Fo=Symbol("IPEInjectKey"),Ly=(t,e)=>(e?e.provide(Fo,t):Nc(Fo,t),t),Bo=()=>{const t=Sn(Fo);if(!t)throw new Error("InPageEdit instance is not provided");return t},Cu=(t,...e)=>{const i=Iy(...e);return Ly(t,i),i};var My=Object.create,qo=Object.defineProperty,Ny=Object.getOwnPropertyDescriptor,Ru=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Iu=t=>{throw TypeError(t)},Dy=(t,e,i)=>e in t?qo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,jy=(t,e)=>qo(t,"name",{value:e,configurable:!0}),Uy=t=>[,,,My(t?.[Ru("metadata")]??null)],Fy=["class","method","getter","setter","accessor","field","value","get","set"],Au=t=>t!==void 0&&typeof t!="function"?Iu("Function expected"):t,By=(t,e,i,n,r)=>({kind:Fy[t],name:e,metadata:n,addInitializer:s=>i._?Iu("Already initialized"):r.push(Au(s||null))}),qy=(t,e)=>Dy(e,Ru("metadata"),t[3]),Hy=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},zy=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&Ny(r,i));jy(r,i);for(var d=n.length-1;d>=0;d--)l=By(c,i,a={},t[3],h),o=(0,n[d])(r,l),a._=1,Au(o)&&(r=o);return qy(t,r),p&&qo(r,i,p),u?c^4?s:p:r},Ou,Ho,Tu;const Lu=t=>{if(!t)return null;try{return t.split(".").reduce((e,i)=>e==null?e:e[i],globalThis)}catch{return null}},Mu=(t,e,i)=>{if(/^https?:\/\//i.test(t))return t;const n=o=>o.endsWith("/")?o:o+"/";if(/^https?:\/\//i.test(e)){const o=n(e);return new URL(t,o).href}const r=(()=>{try{return new URL(i).href}catch{return new URL(i,location.origin).href}})(),s=new URL(n(e),r).href;return new URL(t,s).href};Ou=[Ee(["storage","preferences","resourceLoader","$"])];let Nr=(yt=class extends(Tu=et){constructor(e){super(e,{},"plugin-store"),this.ctx=e,this.regInfoDB=void 0,this._installedPlugins=new Map,this._onlineRegistryQueries=new Map,e.set("store",this),this.regInfoDB=e.storage.createDatabase(yt.REGISTRY_INFO_STORAGE_NAME,yt.REGISTRY_INFO_CACHE_TTL,1,"indexedDB")}async start(){this._installUserPlugins(),this._injectPreferenceUI()}async _installUserPlugins(){const e=await this.ctx.preferences.get("pluginStore.plugins",[]);if(e?.length)for(const i of e)this.install(i.registry,i.id,i.source)}async _createManagementApp(){const e=await this.ctx.withInject(["store"]);return Cu(e,om(()=>Promise.resolve().then(()=>vw)))}async _injectPreferenceUI(){const e=this.ctx,i=e.$;e.preferences.defineCategory({name:"plugin-store",label:i`Plugin Store`,description:i`Plugin Store`,index:90,autoGenerateForm:!1,customRenderer:async({onUnmount:n})=>{const r=m("div",{id:"ipe-plugin-store-preferences-vue"}),s=await this._createManagementApp();return s.mount(r),n(()=>{s.unmount(),this.ctx.logger.debug("Plugin Store preferences app unmounted")}),m("section",{children:r})}}),e.preferences.registerCustomConfig("plugin-store",R.object({"pluginStore.registries":R.array(R.string()).default([xt.PLUGIN_REGISTRY_URL]).description(i`Registry URLs`).hidden(),"pluginStore.cdnForNpm":R.string().description(i`CDN to install packages from npm`).default('https://cdn.jsdelivr.net/npm/{{ package }}{{ version ? "@" + version : "" }}').hidden(),"pluginStore.plugins":R.array(R.object({source:R.union(["online_manifest","npm"]).default("online_manifest"),registry:R.string().required(),id:R.string().required()})).description(i`Installed plugins`).default([]).hidden()}),"plugin-store")}async showModal(){const e=this.ctx.modal.show({title:$`Plugin Store`,sizeClass:"small"}),i=m("section",{id:"ipe-plugin-store-vue"});e.setContent(i);const n=await this._createManagementApp();return n.mount(i),e.on(e.Event.Close,()=>{n.unmount()}),e}async install(e,i,n="online_manifest"){const r=await this.getRegistryInfo(e,n);if(!r)return this.ctx.logger.warn(`Registry ${e} not found`),null;const s=`${e}#${i}`;if(this._installedPlugins.has(s))return await this._installedPlugins.get(s)??null;const o=this._installOneByRegistryInfo(e,r,i);return this._installedPlugins.set(s,o),await o}async uninstall(e,i){const n=this._installedPlugins.get(`${e}#${i}`);if(n===void 0)return!0;this._installedPlugins.delete(`${e}#${i}`);const r=await n;return r?r.dispose?.()??!0:!0}async addToPreferences(e,i){let n=await this.ctx.preferences.get("pluginStore.plugins")||[];return n.some(s=>s.registry===e&&s.id===i)||(n.push({registry:e,id:i}),await this.ctx.preferences.set("pluginStore.plugins",n)),!0}async removeFromPreferences(e,i){let n=await this.ctx.preferences.get("pluginStore.plugins")||[];return n=n.filter(r=>r.registry!==e||r.id!==i),await this.ctx.preferences.set("pluginStore.plugins",n),!0}async installAndSetPreference(e,i){return await this.addToPreferences(e,i),this.install(e,i)}async uninstallAndRemovePreference(e,i){return await this.removeFromPreferences(e,i),this.uninstall(e,i)}async _installOneByRegistryInfo(e,i,n){const r=i.base_url,s=i.packages.find(d=>d.id===n);if(!s)return this.ctx.logger.warn(`Package ${n} not found in registry ${e}`),null;const o=s.loader,{kind:a,entry:l="index.js",styles:c=[],main_export:u=null}=o;let f=null;if(a!=="styles"){if(!l)return this.ctx.logger.warn(`Entry url missing for ${n}`,o),null;try{f=Mu(l,r,e)}catch(d){return this.ctx.logger.warn(`Failed to resolve entry "${l}" with base "${r}" and registry "${e}"`,d),null}}const h={"data-plugin-registry":e,"data-plugin-id":n};let p=null;switch(a){case"autoload":{p=this.ctx.plugin({inject:["resourceLoader"],name:`plugin-store-${e}-${n}`,apply:d=>{f&&d.resourceLoader.loadScript(f,{...h})}});break}case"module":{if(!f)return this.ctx.logger.warn(`Entry url missing for module kind, package ${n}`),null;const d=await import(f).then(w=>(u?w[u]:w.default)??w);if(!d)return this.ctx.logger.warn(`Main export ${u} not found in module ${f}`),null;p=this.ctx.plugin(d);break}case"umd":{let d=Lu(u);if(!d){if(!f)return this.ctx.logger.warn(`Entry url missing for umd kind, package ${n}`),null;await this.ctx.resourceLoader.loadScript(f,{...h}),d=Lu(u)}if(!d)return this.ctx.logger.warn(`Main export ${u} not found on globalThis after loading ${f}`),null;p=this.ctx.plugin(d);break}}if(c&&c.length>0){let d=[];try{d=c.map(w=>Mu(w,r,e)).filter(Boolean)}catch(w){this.ctx.logger.warn(`Failed to resolve styles for ${n}`,c,w)}p||(p=this.ctx.plugin({name:`plugin-store-${e}-${n}`,apply(){}})),p.ctx.plugin({inject:["resourceLoader"],name:`plugin-store-${e}-${n}-styles`,apply:w=>{d.forEach(S=>w.resourceLoader.loadStyle(S,{...h})),w.on("dispose",()=>{try{d.forEach(S=>w.resourceLoader.removeStyle(S))}catch{}})}})}return p}validateRegistry(e){return Mr.Registry(e)}async getRegistryInfo(e,i="online_manifest",n=!1){try{let s;switch(i){case"online_manifest":{s=await this._fetchOnlineRegistryInfo(e,n),this.logger.debug("Fetched registry info from online manifest",s),this.setRegistryCache(e,s);break}default:throw new Error(`Unsupported registry source: ${i}`)}return s}catch(s){this.ctx.logger.warn("Failed to fetch registry info",s)}const r=await this.getRegistryCache(e);if(!r)throw new Error(`Failed to fetch registry info: ${e}`);return r}async _fetchOnlineRegistryInfo(e,i=!1){if(!i&&this._onlineRegistryQueries.has(e))return await this._onlineRegistryQueries.get(e);const r=(async()=>{const s={method:"GET"};i&&(s.cache="no-store");const a=await(await fetch(e,s)).json();return this.validateRegistry(a)})();return this._onlineRegistryQueries.set(e,r),await r}async getRegistryCache(e){const i=await this.regInfoDB.get(e);if(i)try{return this.validateRegistry(i)}catch(n){this.ctx.logger.warn("Invalid cached registry",n,i),this.regInfoDB.delete(e)}return null}async setRegistryCache(e,i){return this.regInfoDB.set(e,i)}async deleteRegistryCache(e){await this.regInfoDB.delete(e)}async clearAllRegistryCaches(){await this.regInfoDB.clear(),this.ctx.logger.debug("All registry caches cleared")}async refreshRegistryCache(e){const i=await this.getRegistryInfo(e,"online_manifest",!0);if(!i)throw new Error(`Failed to refresh registry cache: ${e}`);return this.ctx.logger.debug("Registry cache refreshed:",e),i}async refreshAllRegistryCaches(){const e=await this.ctx.preferences.get("pluginStore.registries")||[],i=await Promise.allSettled(e.map(r=>this.refreshRegistryCache(r))),n={};for(const[r,s]of i.entries())s.status==="fulfilled"?n[e[r]]=s.value:n[e[r]]=null;return n}},yt.PluginStoreSchemas=Mr,yt.REGISTRY_INFO_CACHE_TTL=1e3*60*60*24,yt.REGISTRY_INFO_STORAGE_NAME="plugin-store-registry",yt.REGISTRY_ETAG_STORAGE_NAME="psreg-etag",yt);Ho=Uy(Tu),Nr=zy(Ho,0,"PluginPluginStore",Ou,Nr),Hy(Ho,1,Nr);const Ky=Object.freeze(Object.defineProperty({__proto__:null,PluginPluginStore:Nr},Symbol.toStringTag,{value:"Module"})),nt='@charset "UTF-8";:host{display:block;font-family:var(--schema-font-family, ui-sans-serif, system-ui, -apple-system);color:var(--schema-color-fg, #111827)}*,*:before,*:after{box-sizing:border-box}.wrapper{display:block;background:var(--schema-color-bg, #ffffff)}.form{display:grid;gap:12px}.field{display:grid;gap:6px;padding:8px 10px;border:1px solid var(--schema-color-muted, #e5e7eb);border-radius:var(--schema-radius, 10px);background:var(--schema-surface, #fff)}.label{font-size:12px;color:var(--schema-color-muted-text, #6b7280)}.input,select,textarea{width:100%;padding:8px 10px;border-radius:8px;border:1px solid var(--schema-color-muted, #e5e7eb);background:var(--schema-input-bg, #fff);color:inherit}.checkbox{display:inline-flex;align-items:center;gap:8px}.helper{font-size:12px;color:var(--schema-color-muted-text, #6b7280)}.row{display:grid;gap:8px}.actions{display:flex;gap:8px}.btn{padding:6px 10px;border:1px solid var(--schema-color-muted, #e5e7eb);background:var(--schema-btn-bg, #f8fafc);border-radius:8px;cursor:pointer}.btn.primary{background:var(--schema-color-primary, #2563eb);color:#fff;border-color:transparent}.btn:disabled{opacity:.5;cursor:not-allowed}.btn.danger{background:var(--schema-color-danger, #dc2626);color:#fff;border-color:transparent}.group{display:grid;gap:10px}.kv{display:grid;grid-template-columns:1fr 1fr auto;gap:8px;align-items:center}.badge{display:inline-flex;padding:2px 6px;border-radius:999px;font-size:11px;background:var(--schema-badge-bg, #eef2ff);color:var(--schema-badge-fg, #4f46e5)}.hidden{display:none!important}.toolbar{display:flex;gap:6px}.schema-collection-row{position:relative;transition:transform var(--schema-collection-transition-duration, .25s) var(--schema-collection-transition-ease, ease),opacity var(--schema-collection-transition-duration, .25s) var(--schema-collection-transition-ease, ease)}.schema-collection-row.enter{opacity:0}.schema-collection-row.enter.enter-active{opacity:1}.schema-collection-row.leaving{opacity:0}.field.schema-type-array .group,.field.schema-type-array .group .row{position:relative}',Nu={arrayAdd:"+",arrayMoveUp:"↑",arrayMoveDown:"↓",arrayRemove:"×",dictAdd:"+",dictRemove:"×",rootLabel:"root"},be=(t,e)=>{customElements.get(t)||customElements.define(t,e)},Wy=(t,e,i)=>{if(!e.length)return;let n=t,r=null,s=null;for(let a=0;a<e.length-1;a++){const l=e[a];let c=n?.[l];c==null?(c=typeof e[a+1]=="number"?[]:{},n[l]=c):typeof c!="object"&&(c=typeof e[a+1]=="number"?[]:{},n[l]=c),r=n,s=l,n=c}const o=e[e.length-1];if(n==null||typeof n!="object"){const a=typeof o=="number"?[]:{};if(r)r[s]=a,n=a;else return}try{n[o]=i}catch{try{const a=Array.isArray(n)?n.slice():{...n};a[o]=i,r&&(r[s]=a)}catch{}}},Rn=t=>t.map(String).join("."),Gy=t=>t.replace(/[^a-zA-Z0-9_-]/g,"_"),ei=t=>`schema_${Gy(Rn(t)||"root")}`,hi=t=>Rn(t),ee=(t,...e)=>{const i=new Set(e);i.size&&t.setAttribute("part",Array.from(i).join(" "))},Vy=["wrapper","form","field","field-intersect","field-string","field-number","field-boolean","field-date","field-const","field-array","field-object","field-tuple","field-union","field-dict","field-label","field-helper","field-group","field-row","field-actions","field-button","field-button-primary","field-button-danger","field-button-secondary","field-toolbar","field-badge","field-input","field-input-text","field-input-number","field-input-date","field-input-select","field-input-textarea","field-input-checkbox","field-const-value","collection-row","field-checkbox","field-checkbox-text","field-toolbar-select"].join(" ");function zo(t,e){if(e==null)return e;switch(t){case"number":case"natural":case"percent":{if(e==="")return;const i=Number(e);return Number.isNaN(i)?void 0:i}case"boolean":return!!e;case"date":{if(!e)return;const i=new Date(e);return Number.isNaN(+i)?void 0:i}case"const":case"string":default:return e}}function Du(t){return typeof t=="function"&&!!t?.type}function ju(t){if(!t)throw new Error("schema is required");if(Du(t))return t;try{const e=Schema.from(t);if(Du(e))return e}catch{}if(t?.type){const e=t.type;if(Schema[e])return Schema[e](t.inner??t.list??t.dict)}throw new Error("无法从传入对象生成 Schemastery 实例,请传入 schema 或 schema.toJSON() 的结果。")}function ct(t){return t?.meta??{}}function Yy(t){return t.length>0&&t.every(e=>e?.type==="const")}function pi(t){if(!t)return;const e=t,i=e.meta||{};if(Object.prototype.hasOwnProperty.call(i,"default"))return i.default;const n=e.type;try{const r=t();if(r!==void 0)return r}catch{}switch(n){case"string":return"";case"number":case"natural":case"percent":return 0;case"boolean":return!1;case"array":return[];case"tuple":return[];case"object":return{};case"dict":return{};case"union":{const r=e.list||[];return r.length?pi(r[0]):void 0}case"const":return e.value;case"date":return;case"intersect":{const r=e.list||[],s=(a,l)=>{if(Array.isArray(a)&&Array.isArray(l))return l.slice();if(a&&l&&typeof a=="object"&&typeof l=="object"){const c={...a};for(const u of Object.keys(l))c[u]=u in c?s(c[u],l[u]):l[u];return c}return l??a};let o={};for(const a of r)o=s(o,pi(a));return o}default:return}}class mt extends HTMLElement{constructor(){super(),this._path=[],this._i18n=Nu,this.$root=this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=nt,this.$root.appendChild(e)}makeFieldContainer(e,i){const n=document.createElement("div");if(n.className=`field schema-form-item schema-type-${e}`,n.setAttribute("data-path",Rn(this._path)),ee(n,"field",`field-${e}`),this._label){const r=document.createElement("label");r.className="label",r.textContent=this._label,ee(r,"field-label"),n.appendChild(r)}if(i&&i!==this._label){const r=document.createElement("div");r.className="helper",r.textContent=i,ee(r,"field-helper"),n.appendChild(r)}return n}set schema(e){this._schema=ju(e),this.render()}get schema(){return this._schema}set path(e){this._path=e??[],this.render()}get path(){return this._path}set label(e){this._label=e,this.render()}get label(){return this._label}set i18n(e){e&&(this._i18n={...this._i18n,...e}),this.render()}get i18n(){return this._i18n}setValue(e){this._value=e,this.render()}getValue(){return this._value}emitChange(e){this._value=e,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{path:this._path,value:e}}))}}class Uu extends mt{render(){if(this.$input&&this.$root.contains(this.$input)){const s=!!this.$root.querySelector("label.label");if(!(this._label&&!s)){const o=this._value??"";this.$input.value!==o&&document.activeElement!==this.$input&&(this.$input.value=o);return}}this.$root.innerHTML=`<style>${nt}</style>`;const e=ct(this._schema),i=this.makeFieldContainer("string",e.description),n=document.createElement("input");this.$input=n,n.className="input",ee(n,"field-input","field-input-text"),n.type="text",n.name=hi(this._path),n.id=ei(this._path),e?.pattern?.source&&(n.pattern=e.pattern.source),e?.max!=null&&(n.maxLength=e.max),n.value=this._value??"",n.oninput=()=>this.emitChange(zo("string",n.value));const r=i.querySelector("label.label");r&&(r.htmlFor=n.id),i.appendChild(n),this.$root.appendChild(i)}}be("schema-form-string",Uu);class Fu extends mt{render(){if(this.$input&&this.$root.contains(this.$input)){const o=!!this.$root.querySelector("label.label");if(!(this._label&&!o)){const a=this._value??"";this.$input.value!==String(a)&&document.activeElement!==this.$input&&(this.$input.value=a);return}}this.$root.innerHTML=`<style>${nt}</style>`;const e=this._schema?.type??"number",i=ct(this._schema),n=this.makeFieldContainer("number",i.description),r=document.createElement("input");this.$input=r,r.className="input",ee(r,"field-input","field-input-number"),r.name=hi(this._path),r.id=ei(this._path),i?.min!=null&&(r.min=String(i.min)),i?.max!=null&&(r.max=String(i.max)),i?.step!=null&&(r.step=String(i.step)),e==="percent"&&!r.step&&(r.step="0.01"),r.value=this._value??"",r.oninput=()=>this.emitChange(zo(e,r.value));const s=n.querySelector("label.label");s&&(s.htmlFor=r.id),i.role==="slider"?r.type="range":r.type="number",n.appendChild(r),this.$root.appendChild(n)}}be("schema-form-number",Fu);class Bu extends mt{render(){this.$root.innerHTML=`<style>${nt}</style>`;const e=ct(this._schema),i=this.makeFieldContainer("boolean",e.description),n=document.createElement("label");n.className="checkbox",ee(n,"field-checkbox");const r=document.createElement("input");r.type="checkbox",r.checked=!!this._value,r.name=hi(this._path),r.id=ei(this._path),ee(r,"field-input","field-input-checkbox");const s=document.createElement("span");s.textContent=e.description??this._label??"",ee(s,"field-checkbox-text"),r.onchange=()=>this.emitChange(r.checked);const o=i.querySelector("label.label");o&&(o.htmlFor=r.id),n.append(r,s),i.appendChild(n),this.$root.appendChild(i)}}be("schema-form-boolean",Bu);function Dr(t){return String(t).padStart(2,"0")}function In(t){return`${t.getFullYear()}-${Dr(t.getMonth()+1)}-${Dr(t.getDate())}`}function Ko(t){return`${Dr(t.getHours())}:${Dr(t.getMinutes())}`}function jr(t){return`${In(t)}T${Ko(t)}`}class qu extends mt{render(){if(this.$input&&this.$root.contains(this.$input)){const o=!!this.$root.querySelector("label.label");if(!(this._label&&!o)){const a=ct(this._schema).role||"date";if(document.activeElement!==this.$input)if(this._value instanceof Date)a==="date"?this.$input.value=In(this._value):a==="time"?this.$input.value=Ko(this._value):a==="datetime"&&(this.$input.value=jr(this._value));else if(typeof this._value=="string"&&a!=="time"){const l=new Date(this._value);isNaN(+l)||(a==="date"?this.$input.value=In(l):a==="datetime"&&(this.$input.value=jr(l)))}else this._value||(this.$input.value="");return}}this.$root.innerHTML=`<style>${nt}</style>`;const e=ct(this._schema),i=this.makeFieldContainer("date",e.description),n=document.createElement("input");this.$input=n,n.className="input",ee(n,"field-input","field-input-date");const r=e.role||"date";if(r==="datetime"?n.type="datetime-local":r==="time"?n.type="time":n.type="date",n.name=hi(this._path),n.id=ei(this._path),this._value instanceof Date)r==="date"?n.value=In(this._value):r==="time"?n.value=Ko(this._value):r==="datetime"&&(n.value=jr(this._value));else if(typeof this._value=="string"&&r!=="time"){const o=new Date(this._value);isNaN(+o)||(r==="date"?n.value=In(o):r==="datetime"&&(n.value=jr(o)))}n.oninput=()=>{e.role;let o;if(!n.value)o=void 0;else{const a=new Date(n.value);o=Number.isNaN(+a)?void 0:a}this.emitChange(o)};const s=i.querySelector("label.label");s&&(s.htmlFor=n.id),i.appendChild(n),this.$root.appendChild(i)}}be("schema-form-date",qu);class Wo extends mt{render(){this.$root.innerHTML=`<style>${nt}</style>`;const e=ct(this._schema),i=this._schema.value;if(e.role==="raw-html"){if(i instanceof Node){this.$root.append(i);return}else if(typeof i=="function"){this.$root.append(i());return}else if(typeof i=="string"){const o=document.createElement("div");o.innerHTML=String(i),ee(o,"field-const-value"),this.$root.appendChild(o);return}}const n=this.makeFieldContainer("const",e.description),r=document.createElement("section");r.className="const content",r.textContent=String(i),r.id=ei(this._path),ee(r,"field-const-value");const s=n.querySelector("label.label");s&&(s.htmlFor=r.id),n.appendChild(r),this.$root.appendChild(n)}}be("schema-form-const",Wo);class Hu extends mt{render(){this.$root.innerHTML=`<style>${nt}</style>`;const e=ct(this._schema),i=this.makeFieldContainer("intersect",e.description);i.classList.remove("field");const n=document.createElement("div");n.classList.add("group"),ee(n,"field-group");const r=this._schema.list||[],s=r.length>0&&r.every(a=>a?.type==="object"),o=(a,l)=>{if(Array.isArray(a)&&Array.isArray(l))return l.slice();if(a&&l&&typeof a=="object"&&typeof l=="object"){const c={...a};for(const u of Object.keys(l))c[u]=u in c?o(c[u],l[u]):l[u];return c}return l??a};if(s){const a=this._value&&typeof this._value=="object"?this._value:{};r.forEach((l,c)=>{const u=l?.meta?.description??"",f=ti(l,this._path,a,u,this._i18n);f.addEventListener("change",h=>{h.stopPropagation();const p=o(this._value??{},h.detail.value);this.emitChange(p)}),n.appendChild(f)})}else{const a=r[r.length-1],l=ti(a,this._path,this._value,this._label,this._i18n);l.addEventListener("change",c=>{c.stopPropagation(),this.emitChange(c.detail.value)}),n.appendChild(l)}i.appendChild(n),this.$root.appendChild(i)}}be("schema-form-intersect",Hu);function Qy(t){switch(t.type){case"intersect":return"schema-form-intersect";case"string":return"schema-form-string";case"number":case"natural":case"percent":return"schema-form-number";case"boolean":return"schema-form-boolean";case"date":return"schema-form-date";case"const":return"schema-form-const";case"array":return"schema-form-array";case"object":return"schema-form-object";case"tuple":return"schema-form-tuple";case"dict":return"schema-form-dict";case"union":{const e=t.list||[];return e.length===2&&e[0]?.type==="is"&&e[0]?.constructor===Date&&e[1]?.type==="transform"&&(e[1]?.inner?.meta?.role==="datetime"||e[1]?.inner?.meta?.role==="date"||e[1]?.inner?.meta?.role==="time")?"schema-form-date":"schema-form-union"}default:return"schema-form-string"}}function ti(t,e,i,n,r){const s=Qy(t),o=document.createElement(s);return o.schema=t,o.path=e,o.label=n,r&&(o.i18n=r),o.setValue?.(i),o.setAttribute("exportparts",Vy),o}class zu extends mt{render(){this.$root.innerHTML=`<style>${nt}</style>`;const e=ct(this._schema),i=this.makeFieldContainer("union",e.description),n=this._schema.list||[];if(Yy(n)){const r=document.createElement("select");r.className="input",ee(r,"field-input","field-input-select"),r.name=hi(this._path),r.id=ei(this._path),n.forEach(o=>{const a=document.createElement("option");a.value=String(o.value),a.textContent=String(o.meta?.description||o.value||o.type),this._value===o.value&&(a.selected=!0),r.appendChild(a)}),r.onchange=()=>this.emitChange(zo("string",r.value));const s=i.querySelector("label.label");s&&(s.htmlFor=r.id),i.appendChild(r)}else{const r=document.createElement("div");r.className="toolbar",ee(r,"field-toolbar");const s=document.createElement("select");s.className="input",ee(s,"field-input","field-input-select","field-toolbar-select"),s.name=hi(this._path)+".__type",s.id=ei(this._path)+"__type";let o=0;n.forEach((u,f)=>{const h=document.createElement("option");h.value=String(f),h.textContent=String(u.meta?.description||u.value||u.type),s.appendChild(h)}),s.onchange=()=>{o=Number(s.value);const u=n[o],f=pi(u);this.emitChange(f),c()};const a=i.querySelector("label.label");a&&(a.htmlFor=s.id),r.appendChild(s),i.appendChild(r);const l=document.createElement("div");l.className="group",ee(l,"field-group");const c=()=>{l.innerHTML="";const u=n[o],f=ti(u,this._path,this._value,this._label);f instanceof Wo||(f.addEventListener("change",h=>{h.stopPropagation(),this.emitChange(h.detail.value)}),l.appendChild(f))};c(),i.appendChild(l)}this.$root.appendChild(i)}}be("schema-form-union",zu);class Ku extends mt{render(){this.$root.innerHTML=`<style>${nt}</style>`;const e=ct(this._schema),i=this.makeFieldContainer("tuple",e.description),n=document.createElement("div");n.className="group",ee(n,"field-group");const r=Array.isArray(this._value)?this._value:[];(this._schema.list||[]).forEach((s,o)=>{const a=ti(s,[...this._path,o],r[o],`${this._label??""}[${o}]`);a.addEventListener("change",l=>{l.stopPropagation();const c=Array.isArray(this._value)?this._value.slice():[];c[o]=l.detail.value,this.emitChange(c)}),n.appendChild(a)}),i.appendChild(n),this.$root.appendChild(i)}}be("schema-form-tuple",Ku);class Wu extends mt{render(){this.$root.innerHTML=`<style>${nt}</style>`;const e=ct(this._schema),i=this.makeFieldContainer("object",e.description),n=document.createElement("div");n.className="group",ee(n,"field-group");const r=this._schema.dict||{};Object.keys(r).forEach(s=>{if(r[s]?.meta?.hidden)return;const o=(this._value??{})[s],a=ti(r[s],[...this._path,s],o,s);a.addEventListener("change",l=>{l.stopPropagation();const c={...this._value??{}};c[s]=l.detail.value,this.emitChange(c)}),n.appendChild(a)}),i.appendChild(n),this.$root.appendChild(i)}}be("schema-form-object",Wu);const Zr=class Zr extends mt{constructor(){super(...arguments),this._itemIds=[]}generateItemId(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return"i"+Zr._idCounter++}ensureItemIds(e){for(;this._itemIds.length<e;)this._itemIds.push(this.generateItemId());this._itemIds.length>e&&(this._itemIds.length=e)}capturePositions(e){const i={};return e.querySelectorAll(".row").forEach(n=>{const r=n.dataset.uid;r&&(i[r]=n.getBoundingClientRect())}),i}playFLIP(e,i){Array.from(e.querySelectorAll(".row")).forEach(n=>{const r=n.dataset.uid;if(!r)return;const s=i[r];if(!s)return;const o=n.getBoundingClientRect(),a=s.left-o.left,l=s.top-o.top;(a||l)&&(n.style.transition="none",n.style.transform=`translate(${a}px, ${l}px)`,requestAnimationFrame(()=>{n.style.transition="transform .25s ease",n.style.transform=""}))})}render(){this.$root.innerHTML=`<style>${nt}</style>`;const e=ct(this._schema),i=this.makeFieldContainer("array",e.description),n=document.createElement("div");n.className="group",ee(n,"field-group");const r=this._schema.inner,s=()=>Array.isArray(this._value)?this._value:[];this.ensureItemIds(s().length);const o=(c,u)=>{n.innerHTML="",s().forEach((f,h)=>{const p=[...this._path,h],d=document.createElement("div");d.className="row schema-collection-row",ee(d,"field-row","collection-row");const w=this._itemIds[h];d.dataset.uid=w,d.setAttribute("data-path",Rn(p));const S=ti(r,p,f,`${this._label??""}[${h}]`);S.addEventListener("change",v=>{v.stopPropagation();const x=s().slice();x[h]=v.detail.value,this._value=x,this.emitChange(x)});const E=document.createElement("div");E.className="actions",ee(E,"field-actions");const M=document.createElement("button");M.type="button",M.className="btn",ee(M,"field-button","field-button-secondary"),M.textContent=this._i18n.arrayMoveUp??"↑",M.onclick=()=>{if(h<=0)return;const v=this.capturePositions(n),x=s().slice();[x[h-1],x[h]]=[x[h],x[h-1]],[this._itemIds[h-1],this._itemIds[h]]=[this._itemIds[h],this._itemIds[h-1]],this._value=x,o(v),this.emitChange(x)};const g=document.createElement("button");g.type="button",g.className="btn",ee(g,"field-button","field-button-secondary"),g.textContent=this._i18n.arrayMoveDown??"↓",g.onclick=()=>{const v=s();if(h>=v.length-1)return;const x=this.capturePositions(n),P=v.slice();[P[h+1],P[h]]=[P[h],P[h+1]],[this._itemIds[h+1],this._itemIds[h]]=[this._itemIds[h],this._itemIds[h+1]],this._value=P,o(x),this.emitChange(P)};const y=document.createElement("button");y.type="button",y.className="btn danger",ee(y,"field-button","field-button-danger"),y.textContent=this._i18n.arrayRemove??"×",y.onclick=()=>{d.classList.add("leaving");const v=250;let x=!1;const P=()=>{if(x)return;x=!0,clearTimeout(L);const C=s().filter((H,He)=>He!==h);this._itemIds.splice(h,1);const U=this.capturePositions(n);this._value=C,o(U),this.emitChange(C)};d.addEventListener("transitionend",P,{once:!0});const L=setTimeout(P,v+80)},E.append(M,g,y),d.appendChild(S),d.appendChild(E),n.appendChild(d),u&&u===w&&(d.classList.add("enter"),requestAnimationFrame(()=>{d.classList.add("enter-active")}),requestAnimationFrame(()=>{d.classList.remove("enter")}))}),c&&this.playFLIP(n,c)};o();const a=document.createElement("button");a.type="button",a.className="btn primary",ee(a,"field-button","field-button-primary"),a.textContent=this._i18n.arrayAdd??"+",a.onclick=()=>{const c=this.capturePositions(n),u=s().slice(),f=pi(r);u.push(f);const h=this.generateItemId();this._itemIds.push(h),this._value=u,o(c,h),this.emitChange(u)};const l=document.createElement("div");l.className="actions",ee(l,"field-actions"),l.appendChild(a),i.appendChild(n),i.appendChild(l),this.$root.appendChild(i)}};Zr._idCounter=0;let Ur=Zr;be("schema-form-array",Ur);class Gu extends mt{render(){this.$root.innerHTML=`<style>${nt}</style>`;const e=ct(this._schema),i=this.makeFieldContainer("dict",e.description),n=document.createElement("div");n.className="group",ee(n,"field-group");const r=this._schema.inner,s=this._value??{},o=h=>`d_${h}`,a=()=>{const h={};return n.querySelectorAll(".kv").forEach(p=>{const d=p.dataset.uid;d&&(h[d]=p.getBoundingClientRect())}),h},l=h=>{n.querySelectorAll(".kv").forEach(p=>{const d=p.dataset.uid;if(!d)return;const w=h[d];if(!w)return;const S=p.getBoundingClientRect(),E=w.left-S.left,M=w.top-S.top;(E||M)&&(p.style.transition="none",p.style.transform=`translate(${E}px, ${M}px)`,requestAnimationFrame(()=>{p.style.transition="transform .25s ease",p.style.transform=""}))})},c=(h,p)=>{n.innerHTML="",Object.keys(s).forEach(d=>{const w=[...this._path,d],S=document.createElement("div");S.className="kv schema-collection-row",ee(S,"field-row","collection-row"),S.dataset.uid=o(d),S.setAttribute("data-path",Rn(w));const E=document.createElement("input");E.className="input",ee(E,"field-input","field-input-text"),E.value=d,E.name=hi(w)+".__key",E.id=ei(w)+"__key";const M=ti(r,w,s[d],`${this._label??""}[${d}]`),g=document.createElement("button");g.type="button",g.className="btn danger",ee(g,"field-button","field-button-danger"),g.textContent=this._i18n.dictRemove??"×",g.onclick=()=>{const y=a();delete s[d];const v={...this._value??{}};delete v[d],this._value=v,c(y),this.emitChange(v)},E.onchange=()=>{const y=E.value.trim();if(!y||y===d||s[y]!==void 0)return;const v=a();s[y]=s[d],delete s[d];const x={...this._value??{}};x[y]=x[d],delete x[d],this._value=x,c(v),this.emitChange(x)},M.addEventListener("change",y=>{y.stopPropagation();const v={...this._value??{}};v[d]=y.detail.value,this._value=v,this.emitChange(v)}),S.append(E,M,g),n.appendChild(S),p===d&&(S.classList.add("enter"),requestAnimationFrame(()=>S.classList.add("enter-active")),requestAnimationFrame(()=>S.classList.remove("enter")))}),h&&l(h)};c();const u=document.createElement("button");u.type="button",u.className="btn primary",ee(u,"field-button","field-button-primary"),u.textContent=this._i18n.dictAdd??"+",u.onclick=()=>{let h=Object.keys(s).length+1,p=`k${h}`;for(;s[p]!==void 0;)p=`k${++h}`;const d=a();s[p]=pi(r);const w={...this._value??{},[p]:s[p]};this._value=w,c(d,p),this.emitChange(w)};const f=document.createElement("div");f.className="actions",ee(f,"field-actions"),f.appendChild(u),i.appendChild(n),i.appendChild(f),this.$root.appendChild(i)}}be("schema-form-dict",Gu);class Vu extends HTMLElement{constructor(){super(),this._i18n={...Nu},this._i18nCommitted=!1,this.$root=this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=nt,this.$root.appendChild(e);const i=document.createElement("div");i.className="wrapper",ee(i,"wrapper");const n=document.createElement("form");n.className="form",ee(n,"form"),i.appendChild(n),this.$root.appendChild(i),this.addEventListener("change",r=>{if(!r?.detail)return;const{path:s,value:o}=r.detail;Array.isArray(s)&&s.length===0?this._state=o:Wy(this._state??(this._state={}),s,o),this.dispatchEvent(new CustomEvent("form-change",{detail:{path:s,value:o,state:this._state}}))})}set schema(e){this._schema=ju(e);try{this._state=this._schema(null,{autofix:!0})}catch{this._state=pi(this._schema)}this.render()}get schema(){return this._schema}set schemaJSON(e){this.schema=e}get schemaJSON(){return this._schema?.toJSON?.()}setData(e,i={validate:!0,autofix:!0}){if(!this._schema)throw new Error("请先设置 schema");const n=i.validate?this._schema(e??null,{autofix:i.autofix}):e;this._state=n,this.render()}getData(e={validate:!0,autofix:!0}){if(!this._schema)throw new Error("请先设置 schema");const i=this._state;return e.validate?this._schema(i??null,{autofix:e.autofix}):i}reset(){try{this._state=this._schema(null,{autofix:!0})}catch{this._state=pi(this._schema)}this.render()}refresh(){this.render()}set i18n(e){this._i18nCommitted||(this._i18n={...this._i18n,...e},this._i18nCommitted=!0,this.render())}get i18n(){return this._i18n}render(){if(!this._schema)return;const e=this.$root.querySelector("form");e.innerHTML="";const i=ti(this._schema,[],this._state,this._i18n.rootLabel,this._i18n);e.appendChild(i)}}be("schema-form",Vu);function Xy(){be("schema-form",Vu),be("schema-form-string",Uu),be("schema-form-number",Fu),be("schema-form-boolean",Bu),be("schema-form-date",qu),be("schema-form-const",Wo),be("schema-form-union",zu),be("schema-form-tuple",Ku),be("schema-form-object",Wu),be("schema-form-array",Ur),be("schema-form-dict",Gu),be("schema-form-intersect",Hu)}const Jy=fi({__name:"SchemasteryFormVue",props:Rc({schema:{},value:{},validateOnChange:{type:Boolean,default:!1}},{schema:{required:!0},schemaModifiers:{},value:{required:!1,default:{}},valueModifiers:{}}),emits:Rc(["change"],["update:schema","update:value"]),setup(t,{expose:e,emit:i}){const n=Qc(t,"schema"),r=Qc(t,"value"),s=i,o=Sc("elRef");let a=!1,l=!1;const c=u=>{if(l)return;const f=o.value,h=t.validateOnChange?f.getData({validate:!0}):u.detail.state;a=!0,r.value=h,mn(()=>{a=!1}),s("change",u.detail)};return Pc(()=>{Xy()}),wn(()=>{const u=o.value;n.value&&(u.schema=n.value),r.value!==void 0&&u.setData(r.value,{validate:!1,autofix:!0}),u.addEventListener("form-change",c)}),vo(()=>{o.value?.removeEventListener("form-change",c)}),Mi(n,u=>{a||o.value&&u&&o.value.schema!==u&&(l=!0,o.value.schema=u,mn(()=>{l=!1}))},{deep:!0,immediate:!0}),Mi(r,u=>{if(a||!o.value||u===void 0)return;const f=o.value.getData({validate:!1});JSON.stringify(f)!==JSON.stringify(u)&&(l=!0,o.value.setData(u,{validate:!1}),mn(()=>{l=!1}))},{deep:!0,immediate:!0}),e({setData(u,f){const h=o.value;h.setData(u,{validate:!!f?.validate}),f?.emit&&(r.value=h.getData({validate:!!f?.validate}))},getData(u){return o.value.getData(u)},setSchema(u,f=!0){o.value.schema=u,f&&(n.value=u)},refresh(){o.value.refresh()},reset(){o.value.reset()},el:o}),(u,f)=>(oe(),de("schema-form",su({ref_key:"elRef",ref:o},u.$attrs),null,16))}});function gi(t,e=new WeakMap){if(Ie(t))return gi(t.value,e);if(t===null||typeof t!="object")return t;if(e.has(t))return e.get(t);if(t instanceof Date)return new Date(t);if(t instanceof RegExp)return new RegExp(t);if(t instanceof Map){const r=new Map;return e.set(t,r),Array.from(t.entries()).forEach(([s,o])=>{r.set(s,gi(o,e))}),r}if(t instanceof Set){const r=new Set;return e.set(t,r),Array.from(t).forEach(s=>{r.add(gi(s,e))}),r}if(Array.isArray(t)){const r=[];e.set(t,r);for(const s of t)r.push(gi(s,e));return r}const i=ie(t),n={};e.set(t,n);for(const r of Object.keys(i))n[r]=gi(i[r],e);for(const r of Object.getOwnPropertySymbols(i))n[r]=gi(i[r],e);return n}const Go=()=>{},Zy={id:"preferences-ui-app"},eb={class:"tabbar"},tb={class:"tabbar-tabs"},ib=["onClick","data-value"],nb={class:"tabbar-content"},rb={key:0},sb={style:{"max-height":"20em",overflow:"auto"}},ob=fi({__name:"PreferencesApp",setup(t,{expose:e}){const i=Bo(),n=!1,r=dc([]),s=Ue([]),o=Ue(""),a=It(()=>s.value.find(d=>d.name===o.value)||null),l=It(()=>{const d=r.value.filter(w=>w.category===o.value).map(w=>w.schema);return d.length===0?null:R.intersect(d)}),c=It(()=>a.value&&typeof a.value.autoGenerateForm=="boolean"?a.value.autoGenerateForm:!0),u=Ue({});e({getValue(){return gi(u)},mergeValue(d){u.value={...u.value,...d}},selectTab(d){o.value=d}}),wn(async()=>{i.inject(["preferences"],async d=>{const w=await d.preferences.getAll();u.value=w,s.value=d.preferences.getConfigCategories(),r.value=d.preferences.getConfigRegistries(),o.value=s.value[0].name})});const f=(d,w)=>{d.preventDefault(),o.value=w;const S=d.currentTarget;S&&S.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},h=Sc("customRenderContainerRef"),p=Ue([]);return wo(()=>{p.value.forEach(d=>d()),p.value=[]}),Mi(a,async d=>{p.value.forEach(S=>S()),p.value=[],await mn();const w=h.value;if(w&&(w.innerText="",d&&typeof d.customRenderer=="function")){let S=Go;const E=y=>{S=y},M=y=>{p.value.push(y)},g=await d.customRenderer({ctx:i,onMounted:E,onUnmount:M});g&&(w.appendChild(g),S?.(w))}},{immediate:!0,deep:!1}),(d,w)=>(oe(),de("div",Zy,[J("div",eb,[J("div",tb,[(oe(!0),de(qe,null,_o(s.value,S=>(oe(),de("a",{class:pt(["tab",{active:o.value===S.name}]),key:S.name,onClick:E=>f(E,S.name),"data-value":S.name},ue(S.label),11,ib))),128))]),J("div",nb,[a.value&&a.value.customRenderer?(oe(),de("div",{class:"custom-render-container",ref_key:"customRenderContainerRef",ref:h,key:o.value})):Jt("",!0),c.value&&l.value?(oe(),Ir(Pe(Jy),{class:"auto-schema-form",key:o.value,"data-category":o.value,schema:l.value,value:u.value,"onUpdate:value":w[0]||(w[0]=S=>u.value={...u.value,...S}),"validate-on-change":!1,i18n:{rootLabel:""}},null,8,["data-category","schema","value"])):Jt("",!0)])]),Pe(n)?(oe(),de("details",rb,[J("pre",sb,ue(u.value),1)])):Jt("",!0)]))}}),Fr=(t,e)=>{const i=t.__vccOpts||t;for(const[n,r]of e)i[n]=r;return i},ab=Fr(ob,[["__scopeId","data-v-7f07706b"]]);var lb=Object.create,Vo=Object.defineProperty,cb=Object.getOwnPropertyDescriptor,Yu=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Qu=t=>{throw TypeError(t)},ub=(t,e,i)=>e in t?Vo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,fb=(t,e)=>Vo(t,"name",{value:e,configurable:!0}),db=t=>[,,,lb(t?.[Yu("metadata")]??null)],hb=["class","method","getter","setter","accessor","field","value","get","set"],Xu=t=>t!==void 0&&typeof t!="function"?Qu("Function expected"):t,pb=(t,e,i,n,r)=>({kind:hb[t],name:e,metadata:n,addInitializer:s=>i._?Qu("Already initialized"):r.push(Xu(s||null))}),gb=(t,e)=>ub(e,Yu("metadata"),t[3]),mb=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},yb=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&cb(r,i));fb(r,i);for(var d=n.length-1;d>=0;d--)l=pb(c,i,a={},t[3],h),o=(0,n[d])(r,l),a._=1,Xu(o)&&(r=o);return gb(t,r),p&&Vo(r,i,p),u?c^4?s:p:r},Ju,Yo,Zu;Ju=[Ee(["preferences","modal","$","$$"])];class Br extends(Zu=et){constructor(e){super(e,{},"preferences-ui"),this.ctx=e,this._modal=null,this._form=null,e.set("preferencesUI",this);const i=e.$,n=e.$$;e.preferences.defineCategory({name:"general",label:i`prefs.general.label`,description:i`prefs.general.description`,autoGenerateForm:!0}),e.preferences.defineCategory({name:"editor",label:i`prefs.editor.label`,description:i`prefs.editor.description`,autoGenerateForm:!0}),e.preferences.defineCategory({name:"about",label:n`prefs.about.label`,description:n`prefs.about.description`,index:99,customRenderer:()=>m("section",{className:"theme-ipe-prose",children:[m("h2",{children:"✏️ InPageEdit NEXT"}),m("p",{children:n`prefs.about.intro`}),m("h3",{children:n`prefs.about.portals.header`}),m("ul",{children:[m("li",{children:m("a",{href:this.ctx.Endpoints.HOME_URL,target:"_blank",children:n`prefs.about.portals.officialwebsite`})}),m("li",{children:m("a",{href:`${this.ctx.Endpoints.UPDATE_LOGS_URL}#${this.ctx.version.split("-")[0]}`,target:"_blank",children:n`prefs.about.portals.updatelogs`})})]}),m("h3",{children:n`prefs.about.joinus.header`}),m("ul",{children:[m("li",{children:[m("strong",{children:n`prefs.about.joinus.github`}),":"," ",m("a",{href:this.ctx.Endpoints.GITHUB_URL,target:"_blank",children:`${this.ctx.Endpoints.GITHUB_OWNER}/${this.ctx.Endpoints.GITHUB_REPO}`})]}),m("li",{children:[m("strong",{children:n`prefs.about.joinus.qqgroup`}),": ",this.ctx.Endpoints.QQ_GROUP_ID]})]}),m("hr",{}),m("p",{style:{textAlign:"center"},children:n`prefs.about.copyright`}),m("hr",{})]})}),e.inject(["toolbox"],r=>{r.toolbox.addButton({id:"preferences",icon:m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-settings",children:[m("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),m("path",{d:"M14.647 4.081a.724 .724 0 0 0 1.08 .448c2.439 -1.485 5.23 1.305 3.745 3.744a.724 .724 0 0 0 .447 1.08c2.775 .673 2.775 4.62 0 5.294a.724 .724 0 0 0 -.448 1.08c1.485 2.439 -1.305 5.23 -3.744 3.745a.724 .724 0 0 0 -1.08 .447c-.673 2.775 -4.62 2.775 -5.294 0a.724 .724 0 0 0 -1.08 -.448c-2.439 1.485 -5.23 -1.305 -3.745 -3.744a.724 .724 0 0 0 -.447 -1.08c-2.775 -.673 -2.775 -4.62 0 -5.294a.724 .724 0 0 0 .448 -1.08c-1.485 -2.439 1.305 -5.23 3.744 -3.745a.722 .722 0 0 0 1.08 -.447c.673 -2.775 4.62 -2.775 5.294 0zm-2.647 4.919a3 3 0 1 0 0 6a3 3 0 0 0 0 -6z"})]}),tooltip:i`Configure Preferences`,group:"group2",index:99,onClick:()=>this.showModal()}),this.addDisposeHandler(s=>{s.toolbox.removeButton("preferences")})})}async start(){Promise.resolve().then(()=>Aw).then(({PluginPrefSync:e})=>{this.ctx.plugin(e)}).catch(this.ctx.logger.warn),this.ctx.on("preferences/changed",e=>{this._form?.mergeValue?.(e.input)})}stop(){}showModal(){const e=this.ctx.$;if(this._modal&&!this._modal.isDestroyed)return this._modal;const i=this.ctx.modal.show({className:"ipe-preference compact-buttons",sizeClass:"small",outSideClose:!1,center:!0,title:`${e`InPageEdit Preferences`} (${this.ctx.version})`,content:m(_i,{children:m(ai,{})})});i.get$window().classList.add("dialog");const n=m("div",{id:"ipe-preferences-app",style:{minHeight:"calc(85dvh - var(--ipe-modal-spacing) * 2)"}});i.setContent(n),this.ctx.emit("preferences-ui/modal-shown",{ctx:this.ctx,modal:i});const r=this.createPreferencesUIApp(),s=r.mount(n);return this._form=s,this.ctx.emit("preferences-ui/vue-app-mounted",{ctx:this.ctx,app:r,form:s}),i.setButtons([{label:e`Close`,className:"is-ghost",method:()=>{i.close()}},{label:e`Save`,className:"is-primary is-ghost",method:async()=>{const o=s.getValue();try{const a=await this.ctx.preferences.setMany(o);this.logger.info("preferences saved",o,a)}catch(a){this.logger.error("failed to save preferences",a)}i.close(),this.ctx.modal.notify("success",{title:e`Preferences Saved`,content:m("p",{children:e`Some settings may take effect after reloading the page.`})})}}]),this._modal=i,i.on(i.Event.Close,()=>{this.logger.debug("preferences modal closed, vue app unmounting"),r.unmount(),this._modal=null,this._form=null,this.ctx.emit("preferences-ui/modal-closed",{ctx:this.ctx,modal:i})}),i}getCurrentModal(){return this._modal}closeCurrentModal(){return this._modal?.close()}async dispatchFormSave(e){e=e||this._form||void 0;const i=e?.getValue();return i?(this.ctx.preferences.setMany(i),!0):!1}getCurrentFormValue(){return this._form?.getValue()}mergeFormValue(e){return this._form?.mergeValue?.(e),!!this._form?.mergeValue}createPreferencesUIApp(){return Cu(this.ctx,ab)}}Yo=db(Zu),Br=yb(Yo,0,"PluginPreferencesUI",Ju,Br),mb(Yo,1,Br);const bb=Object.freeze(Object.defineProperty({__proto__:null,get PluginPreferencesUI(){return Br}},Symbol.toStringTag,{value:"Module"})),vb=Symbol("@@apply"),wb=Symbol("@@ctor");function ef(t,e){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError("instance is not an object");const i=(...s)=>{const o=t[e];if(typeof o!="function")throw new TypeError(`Property "${String(e)}" is not a function`);return o.apply(t,s)};i[vb]=i,i[wb]=t;const n=t?.constructor?.name;return n&&(i[Symbol.toStringTag]=n),new Proxy(i,{get(s,o,a){return o==="prototype"?Reflect.get(i,o,a):Reflect.get(t,o,t)},set(s,o,a){return Reflect.set(t,o,a)},has(s,o){return Reflect.has(t,o)},deleteProperty(s,o){return Reflect.deleteProperty(t,o)},ownKeys(){return Reflect.ownKeys(t)},getOwnPropertyDescriptor(s,o){return Object.getOwnPropertyDescriptor(t,o)},defineProperty(s,o,a){return Object.defineProperty(t,o,a)}})}const qr={mbox:"_mbox_5x43w_1",title:"_title_5x43w_12",content:"_content_5x43w_19",close:"_close_5x43w_27"},Qo=t=>{const{type:e="default",title:i,content:n,closeable:r=!0,titleProps:s,contentProps:o,children:a,...l}=t;let c=i;typeof i>"u"&&e!=="default"&&(c=e[0].toUpperCase()+e.slice(1).toLowerCase());const u=async()=>{if(!f)return Promise.resolve();const{promise:h,resolve:p}=Promise.withResolvers();return f.animate([{opacity:"1",height:f.clientHeight+"px"},{opacity:"0",height:"0px",margin:"0px"}],{duration:300,easing:"ease"}).addEventListener("finish",()=>{f.remove(),p()}),h},f=m("div",{className:`theme-ipe ipe-mbox mbox-type-${e||"default"} ${qr.mbox}`,...l,children:[c&&m("div",{className:`ipe-mbox-title ${qr.title}`,...s,children:c}),m("div",{className:`ipe-mbox-content ${qr.content}`,...o,children:a||n}),r&&m("a",{onClick:u,className:`ipe-mbox-close ${qr.close}`,children:"×"})]});return f.close=u,f},Hr=t=>{const{label:e,id:i,name:n,value:r,disabled:s,labelProps:o,inputProps:a,...l}=t;return m("div",{className:"theme-ipe ipe-input-box",...l,children:[m("label",{htmlFor:i,style:{display:"block"},...o,children:e}),m("input",{id:i,name:n,value:r,disabled:s,style:{width:"100%"},...a})]})},_b=t=>{const{id:e,name:i,value:n,label:r,inputProps:s,labelProps:o,children:a,...l}=t;return m("label",{className:"theme-ipe ipe-radio-box",...l,children:[m("input",{type:"radio",id:e,name:i,value:n,...s}),m("span",{className:"ipe-checkbox-box"}),m("span",{...o,children:r||a})]})},Ui=t=>{const{id:e,name:i,label:n,checked:r,inputProps:s,labelProps:o,children:a,...l}=t;return m("label",{className:"theme-ipe ipe-checkbox",...l,children:[m("input",{type:"checkbox",id:e,name:i,checked:r,...s}),m("span",{className:"ipe-checkbox-box"}),m("span",{...o,children:n||a})]})},xb=(t=0)=>new Promise(e=>setTimeout(e,t));var Sb=Object.create,Xo=Object.defineProperty,kb=Object.getOwnPropertyDescriptor,tf=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),nf=t=>{throw TypeError(t)},$b=(t,e,i)=>e in t?Xo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Eb=(t,e)=>Xo(t,"name",{value:e,configurable:!0}),Pb=t=>[,,,Sb(t?.[tf("metadata")]??null)],Cb=["class","method","getter","setter","accessor","field","value","get","set"],rf=t=>t!==void 0&&typeof t!="function"?nf("Function expected"):t,Rb=(t,e,i,n,r)=>({kind:Cb[t],name:e,metadata:n,addInitializer:s=>i._?nf("Already initialized"):r.push(rf(s||null))}),Ib=(t,e)=>$b(e,tf("metadata"),t[3]),Ab=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Ob=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&kb(r,i));Eb(r,i);for(var d=n.length-1;d>=0;d--)l=Rb(c,i,a={},t[3],h),o=(0,n[d])(r,l),a._=1,rf(o)&&(r=o);return Ib(t,r),p&&Xo(r,i,p),u?c^4?s:p:r},sf,Jo,of;sf=[Ee(["api","wikiPage","wikiTitle","currentPage","wiki","modal","preferences","$"]),Vt(R.object({"quickEdit.editSummary":R.string().description("Default edit summary for quick edits").default("[IPE-NEXT] Quick edit"),"quickEdit.editMinor":R.boolean().description('Default to checking "minor edit" option').default(!1),"quickEdit.outSideClose":R.boolean().description("Close editor modal by clicking outside").default(!0),"quickEdit.watchList":R.union([R.const(at.preferences).description("Follow MW preferences"),R.const(at.nochange).description("Keep the current watchlist status"),R.const(at.watch).description("Add the page to watchlist"),R.const(at.unwatch).description("Remove the page from watchlist")]).description("Watchlist options").default(at.preferences),"quickEdit.keyshortcut.save":R.string().default("ctrl-s").description("save button key shortcut (blank to disable)"),"quickEdit.editFont":R.union([R.const("preferences").description("Follow MW preferences"),R.const("monospace").description("Monospace"),R.const("sans-serif").description("Sans-serif"),R.const("serif").description("Serif"),R.string().description("Custom font (same as CSS `font-family` property)").default("")]).description("Font to use in quick edit's textarea").default("preferences")}).description("Quick edit options").extra("category","editor"))];let zr=(yi=class extends(of=et){constructor(e){super(e,{},"quick-edit"),this.ctx=e,this.DEFAULT_OPTIONS={title:"",pageId:0,revision:0,section:void 0,editMinor:!1,editSummary:"",createOnly:!1,reloadAfterSave:!0},this.ctx.root.set("quickEdit",ef(this,"showModal"))}start(){this.ctx.inject(["toolbox"],e=>{this.injectToolbox(e),e.on("dispose",()=>{this.removeToolbox(e)})})}async showModal(e){const i=this.ctx.$;if(typeof e>"u"?e={}:typeof e=="string"&&(e={title:e}),e?.page&&(e.title=e.page,delete e.page),!e.title&&!e.pageId&&!e.revision){this.logger.warn("None of the title, pageId or revision provided. Using defaults.");const g=new URLSearchParams(window.location.search),y=this.ctx.currentPage.wikiTitle;e={...e,title:y?.getPrefixedDBKey(),revision:g.has("oldid")?Number(g.get("oldid")):void 0,pageId:g.has("curid")?Number(g.get("curid")):void 0}}if(!e.revision&&!e.pageId&&e.title){const g=this.ctx.wikiTitle.resolveSpecialPageTarget(e.title);g&&g.title.getNamespaceId()>=0&&(e.title=g.title.getPrefixedDBKey(),e.section??(e.section=g.section))}const n=await this.ctx.preferences.get("quickEdit.outSideClose"),r=await this.ctx.preferences.get("quickEdit.watchList"),s=typeof e.editSummary=="string"?e.editSummary:await this.ctx.preferences.get("quickEdit.editSummary"),o=typeof e.editMinor=="boolean"?e.editMinor:await this.ctx.preferences.get("quickEdit.editMinor"),a=await this.getEditFontOptions(),l={...this.DEFAULT_OPTIONS,editSummary:s,editMinor:o,...e};l.editSummary||(l.editSummary=await this.ctx.preferences.get("quickEdit.editSummary")||""),this.ctx.emit("quick-edit/init-options",{ctx:this.ctx,options:l});const c=this.ctx.modal.createObject({className:"ipe-quickEdit",sizeClass:"large",center:!1,outSideClose:n}).init();c.setTitle(m(_i,{children:["Loading: ",m("u",{children:l.title})]})),c.setContent(m("section",{className:"ipe-quickEdit-loading",style:{height:"70vh",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:m(ai,{})})),c.addButton({side:"right",type:"button",className:"is-danger is-ghost",label:i`Cancel`,method(){c.close()}}),c.show(),this.ctx.emit("quick-edit/show-modal",{ctx:this.ctx,modal:c,options:l});let u;try{if(u=await this.getWikiPageFromPayload(l),u.pageInfo.special)throw new Error(i`Special page is not editable.`)}catch(g){c.off(c.Event.Close),c.close(),this.ctx.modal.notify("error",{content:g instanceof Error?g.message:String(g)});return}const f=l.section==="new"?"":u.revisions[0]?.content||"",h=u.revisions[0]?.revid,p=h&&h!==u.lastrevid,d=l.section==="new",w=u.pageid===0;c.setTitle(m(_i,{children:[d?i`New Section`:i`Quick ${w?"Create":"Edit"}`,": ",m("u",{children:u.pageInfo.title}),p?` (${i`Revision`} ${h})`:""]}));const S=[];w&&S.push(m(Qo,{title:i`Attention`,type:"important",children:m("p",{children:i`This page does not exist.`})})),p&&S.push(m(Qo,{title:i`Attention`,type:"warning",children:m("p",{innerHTML:i`You are editing a <em>historical version</em>; the content is not the latest!`})})),this.ctx.emit("quick-edit/edit-notice",{ctx:this.ctx,options:l,modal:c,wikiPage:u,editNotices:S});const E=m("form",{className:"ipe-quickEdit__form",children:[m("div",{className:"ipe-quickEdit__notices",children:S}),m("div",{className:"ipe-quickEdit__content",style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[l.section==="new"&&m(_i,{children:m(Hr,{label:i`Section title`,id:"summary",name:"summary",value:"",inputProps:{placeholder:i`Topic for new section, this will be the h2 heading`}})}),m("textarea",{className:`ipe-quickEdit__textarea ${a.className}`,style:{fontFamily:a.fontFamily},name:"text",id:"wpTextbox1",children:f})]}),m("div",{class:"ipe-quickEdit__options",style:{display:"flex",flexDirection:"column",gap:"1rem",marginTop:"1rem"},children:[!d&&m(Hr,{label:i`Summary`,id:"summary",name:"summary",value:l.editSummary}),m("div",{className:"ipe-input-box",children:[m("label",{htmlFor:"watchlist",style:{display:"block"},children:i`Watchlist`}),m("div",{style:{display:"flex",gap:"1rem"},children:[at.preferences,at.nochange,at.watch,at.unwatch].map(g=>m(_b,{name:"watchlist",value:g,inputProps:{checked:r===g},children:i`watchlist.${g}`},g))})]}),m("div",{style:{display:"flex",gap:"1rem"},children:[m(Ui,{name:"minor",id:"minor",checked:l.editMinor,children:i`Minor edit`}),m(Ui,{name:"reloadAfterSave",id:"reloadAfterSave",checked:l.reloadAfterSave,children:i`Reload after save`})]})]}),!1]});c.setContent(E),c.addButton({side:"left",className:"is-primary submit-btn",label:i`Submit`,keyPress:await this.ctx.preferences.get("quickEdit.keyshortcut.save")||void 0,method:()=>{const g=new FormData(E);c.setLoadingState(!0),this.handleSubmit({wikiPage:u,text:g.get("text"),summary:g.get("summary"),minor:g.get("minor")==="on",section:l.section,createonly:u.pageid===0,watchlist:r}).then(async()=>{c.setOptions({beforeClose:Go}),c.close(),this.ctx.modal.notify("success",{title:i`Submission Successful`,content:i`Your changes have been saved.`}),g.get("reloadAfterSave")&&(await xb(500),location.reload())}).catch(y=>{this.ctx.modal.notify("error",{title:i`Submission Error`,content:y instanceof Error?y.message:String(y)}),c.setLoadingState(!1)})}},0),c.setOptions({beforeClose:()=>{const g=u.revisions[0]?.content||"";return(E.querySelector("textarea")?.value||"")===g?!0:(this.ctx.modal.confirm({className:"is-primary",title:i`Unsaved Changes`,content:i`All edit contents will be lost after closing the modal. Are you sure you want to close?`,center:!0,okBtn:{label:i`Give Up`,className:"is-danger is-ghost"},cancelBtn:{label:i`Continue Editing`,className:"is-primary is-ghost"}},v=>(v&&(c.setOptions({beforeClose:Go}),c.close()),!0)),!1)}}),this.ctx.emit("quick-edit/wiki-page",{ctx:this.ctx,options:l,modal:c,wikiPage:u});const M=g=>E.querySelector("textarea")?.value===f?!0:(g.preventDefault(),i`You have unsaved changes. Are you sure you want to leave?`);window.addEventListener("beforeunload",M),c.on(c.Event.Close,()=>{window.removeEventListener("beforeunload",M)})}async handleSubmit(e){const i=e.wikiPage,n=e.summary||"",r=e.text||"",s=e.minor,o=e.createonly,a=e.watchlist,l=e.section;return this.ctx.emit("quick-edit/submit",{ctx:this.ctx,wikiPage:i,summary:n,text:r,minor:s,createonly:o,watchlist:a}),i.edit({summary:n,text:r,watchlist:a,section:l},{minor:s,createonly:o})}async getEditFontOptions(){const e=await this.ctx.preferences.get("quickEdit.editFont");return yi.BUILT_IN_FONT_OPTIONS.includes(e)?{className:`mw-editfont-${e==="preferences"?this.ctx.wiki.userOptions?.editfont||"monospace":e}`,fontFamily:""}:{className:"mw-editfont-custom",fontFamily:e}}async getWikiPageFromPayload(e){if(e.revision)return this.ctx.wikiPage.newFromRevision(e.revision,e.section);if(e.pageId)return this.ctx.wikiPage.newFromPageId(e.pageId,e.section);if(e.title)return this.ctx.wikiPage.newFromTitle(e.title,!1,e.section);throw new Error("Invalid payload")}async injectToolbox(e){const i=this.ctx.$,n=this.ctx.currentPage.wikiTitle,r=n&&n.getNamespaceId()>=0;e.toolbox.addButton({id:"quick-edit",group:"group1",index:0,icon:m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-edit",children:[m("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),m("path",{d:"M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1"}),m("path",{d:"M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z"}),m("path",{d:"M16 5l3 3"})]}),buttonProps:{disabled:!r},tooltip:r?i`Quick Edit`:i`Not editable`,onClick:()=>{const s=new URLSearchParams(window.location.search).get("oldid");this.showModal({title:n?.getPrefixedText(),revision:s?Number(s):void 0})}})}removeToolbox(e){e.toolbox.removeButton("quick-edit")}},yi.BUILT_IN_FONT_OPTIONS=["preferences","monospace","sans-serif","serif"],yi);Jo=Pb(of),zr=Ob(Jo,0,"PluginQuickEdit",sf,zr),Ab(Jo,1,zr);const Tb=Object.freeze(Object.defineProperty({__proto__:null,PluginQuickEdit:zr},Symbol.toStringTag,{value:"Module"})),An={twinSwapInput:"_twinSwapInput_1gdgl_9",inputWrapper:"_inputWrapper_1gdgl_23",inputLeft:"_inputLeft_1gdgl_27",inputRight:"_inputRight_1gdgl_30",swapButton:"_swapButton_1gdgl_46"},af=t=>{const{inputs:e,enableSwap:i=!0,...n}=t,r=e?.length===2?e:[e?.[0]??{},e?.[1]??{}],s=[null,null];let o=0,a=null,l=null;const c=()=>s.some(d=>d&&d.disabled),u=()=>{if(!s[0]||!s[1]||c())return;const d=s[0],w=s[1],S=d.value,E=w.value;d.value=E,w.value=S,d.dispatchEvent(new Event("change")),w.dispatchEvent(new Event("change")),o++,l&&(l.style.transform=`rotateY(${o*-180}deg)`,l.style.transition="transform 200ms ease")},f=d=>{if(!a)return;const w=d??!a.disabled;a.disabled=!w,w&&s.forEach(S=>{S&&(S.disabled=!1)})},h=m("button",{type:"button","aria-label":"Swap values",onClick:u,disabled:c()||!i,ref:d=>a=d,children:m("svg",{ref:d=>l=d,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon-tabler icons-tabler-outline icon-tabler-transfer",children:[m("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),m("path",{d:"M20 10h-16l5.5 -6"}),m("path",{d:"M4 14h16l-5.5 6"})]})}),p=m("div",{className:`twin-swap-input ${An.twinSwapInput}`,...n,children:[r.map((d,w)=>{const{label:S,id:E,name:M,value:g,disabled:y,required:v,inputProps:x}=d,P=w===0,L=E||M;return m("div",{className:`${An.inputWrapper} ${P?An.inputLeft:An.inputRight}`,children:[S&&m("label",{htmlFor:L,children:S}),m("input",{ref:C=>s[w]=C,type:"text",id:L,name:M,value:g,disabled:y,required:v,...x})]})}),m("div",{className:An.swapButton,children:h})]});return p.swap=u,p.toggleEnableSwap=f,p};var Lb=Object.create,Zo=Object.defineProperty,Mb=Object.getOwnPropertyDescriptor,lf=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),cf=t=>{throw TypeError(t)},Nb=(t,e,i)=>e in t?Zo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Db=(t,e)=>Zo(t,"name",{value:e,configurable:!0}),jb=t=>[,,,Lb(t?.[lf("metadata")]??null)],Ub=["class","method","getter","setter","accessor","field","value","get","set"],uf=t=>t!==void 0&&typeof t!="function"?cf("Function expected"):t,Fb=(t,e,i,n,r)=>({kind:Ub[t],name:e,metadata:n,addInitializer:s=>i._?cf("Already initialized"):r.push(uf(s||null))}),Bb=(t,e)=>Nb(e,lf("metadata"),t[3]),qb=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Hb=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&Mb(r,i));Db(r,i);for(var d=n.length-1;d>=0;d--)l=Fb(c,i,a={},t[3],h),o=(0,n[d])(r,l),a._=1,uf(o)&&(r=o);return Bb(t,r),p&&Zo(r,i,p),u?c^4?s:p:r},ff,ea,df;ff=[Vt(R.object({"quickMove.reason":R.string().default("[IPE-NEXT] Quick move")}).description("Quick move options").extra("category","editor")),Ee(["modal","wiki","$"])];class Kr extends(df=et){constructor(e){super(e,{},"quick-move"),this.ctx=e,e.set("quickMove",this)}start(){this.ctx.inject(["toolbox"],e=>{this.injectToolbox(e)})}injectToolbox(e){const i=e.$,n=window.mw?.config.get("wgPageName")||"",r=window.mw?.config.get("wgIsProbablyEditable");e.toolbox.addButton({id:"quick-move",icon:m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-forms",children:[m("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),m("path",{d:"M12 3a3 3 0 0 0 -3 3v12a3 3 0 0 0 3 3"}),m("path",{d:"M6 3a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3"}),m("path",{d:"M13 7h7a1 1 0 0 1 1 1v8a1 1 0 0 1 -1 1h-7"}),m("path",{d:"M5 7h-1a1 1 0 0 0 -1 1v8a1 1 0 0 0 1 1h1"}),m("path",{d:"M17 12h.01"}),m("path",{d:"M13 12h.01"})]}),tooltip:i`Quick Move`,group:"group1",index:1,onClick:()=>{this.showModal(r?{lockFromField:!0,from:n}:{})}})}async showModal(e){const i=this.ctx.$,n=await this.ctx.preferences.get("quickMove.reason"),r=this.ctx.modal.createObject({title:i`Quick Move`,content:m(ai,{}),className:"quick-move compact-buttons",sizeClass:"smallToMedium",center:!0}).init();let s=null;return r.setContent(m("form",{ref:o=>s=o,style:{display:"flex",flexDirection:"column",gap:"1rem"},onSubmit:o=>{if(o.preventDefault(),s?.checkValidity(),!s?.reportValidity())return;const a=new FormData(s),l={from:a.get("from")?.toString().trim(),to:a.get("to")?.toString().trim(),reason:a.get("reason")||"",movetalk:a.get("movetalk")==="on",movesubpages:a.get("movesubpages")==="on",noredirect:a.get("noredirect")==="on"};if(!l.from||!l.to){this.ctx.modal.notify("error",{title:i`Failed to move`,content:"From and to are required."});return}this.ctx.emit("quick-move/submit",{ctx:this.ctx,modal:r,payload:l}),r.setLoadingState(!0),this.movePage(l).then(()=>{location.reload()}).catch(c=>{r.setLoadingState(!1),this.ctx.modal.notify("error",{title:i`Failed to move`,content:c instanceof Error?c.message:String(c)})})},children:[m(af,{inputs:[{label:i`Move from`,name:"from",value:e?.from,required:!0},{label:i`Move to`,name:"to",value:e?.to,required:!0}]}),m("div",{children:m(Ui,{name:"movetalk",id:"movetalk",checked:e?.movetalk,children:i`Move talk page`})}),m("div",{children:m(Ui,{name:"movesubpages",id:"movesubpages",checked:e?.movesubpages,children:i`Move subpages (up to 100)`})}),this.ctx.wiki.hasRight("suppressredirect")&&m("div",{children:m(Ui,{name:"noredirect",id:"noredirect",checked:e?.noredirect,children:i`Move without leaving a redirect`})}),m(Hr,{label:i`Reason`,id:"reason",name:"reason",value:e?.reason??n??""})]})),r.setButtons([{label:i`Move`,className:"is-primary is-ghost",method:()=>{s?.dispatchEvent(new Event("submit"))}}]),r.show()}async movePage(e){const{from:i,to:n,reason:r="",...s}=e;if(!i||!n)throw new Error("From and to titles are required.");if(i===n)throw new Error("From and to titles cannot be the same.");return(await this.ctx.wikiPage.newFromTitle(i)).moveTo(n,r,s)}}ea=jb(df),Kr=Hb(ea,0,"PluginQuickMove",ff,Kr),qb(ea,1,Kr);const zb=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickMove(){return Kr}},Symbol.toStringTag,{value:"Module"}));var Kb=Object.create,ta=Object.defineProperty,Wb=Object.getOwnPropertyDescriptor,hf=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),pf=t=>{throw TypeError(t)},Gb=(t,e,i)=>e in t?ta(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Vb=(t,e)=>ta(t,"name",{value:e,configurable:!0}),Yb=t=>[,,,Kb(t?.[hf("metadata")]??null)],Qb=["class","method","getter","setter","accessor","field","value","get","set"],gf=t=>t!==void 0&&typeof t!="function"?pf("Function expected"):t,Xb=(t,e,i,n,r)=>({kind:Qb[t],name:e,metadata:n,addInitializer:s=>i._?pf("Already initialized"):r.push(gf(s||null))}),Jb=(t,e)=>Gb(e,hf("metadata"),t[3]),Zb=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},ev=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&Wb(r,i));Vb(r,i);for(var d=n.length-1;d>=0;d--)l=Xb(c,i,a={},t[3],h),o=(0,n[d])(r,l),a._=1,gf(o)&&(r=o);return Jb(t,r),p&&ta(r,i,p),u?c^4?s:p:r},mf,ia,yf;mf=[Ee(["api","wikiPage","modal","preferences","$"]),Vt(R.object({"quickPreview.keyshortcut":R.string().default("ctrl-p").description("Key shortcut to open quick preview in quick edit modal")}).extra("category","editor").description("Quick preview options"))];class Wr extends(yf=et){constructor(e){super(e,{},"quickPreview"),this.ctx=e,this.ctx.set("quickPreview",ef(this,"previewWikitext"))}start(){this.ctx.on("quick-edit/wiki-page",this.injectQuickEdit.bind(this))}stop(){}previewWikitext(e,i,n,r,s){const o=this.ctx.$;return n||(n=this.ctx.wikiPage.newBlankPage({title:"API"})),(!r||r.isDestroyed)&&(r=this.ctx.modal.createObject({className:"in-page-edit ipe-quickPreview",sizeClass:"large",center:!1,...s}).init()),r.show(),r.setTitle(o`Preview - Loading...`),r.setContent(m(ai,{})),r.bringToFront(),this.ctx.emit("quick-preview/show-modal",{ctx:this.ctx,text:e,modal:r,wikiPage:n}),n.preview(e,i).then(a=>{const{data:{parse:l}}=a;r.setTitle(o(l.title)`Preview - {{ $1 }}`);let c=null;r.setContent(m("section",{children:m("div",{ref:u=>c=u,className:"mw-parser-output",innerHTML:l.text})})),window.mw?.hook&&typeof jQuery=="function"&&window.mw.hook("wikipage.content").fire(jQuery(c)),this.ctx.emit("quick-preview/loaded",{ctx:this.ctx,modal:r,wikiPage:n,text:e,parseData:l})}).catch(a=>{r.setTitle(o`Preview - Failed`),r.setContent(m(_i,{children:[m("p",{children:o`Failed to preview`}),m("p",{children:a instanceof Error?a.message:String(a)})]}))}),r}async injectQuickEdit({options:e,modal:i,wikiPage:n}){const r=this.ctx.$;let s;i.addButton({label:r`Preview`,side:"left",className:"btn btn-secondary",keyPress:await this.ctx.preferences.get("quickPreview.keyshortcut.quickEdit")||void 0,method:()=>{let o=i.get$content().querySelector('textarea[name="text"]')?.value||"";if(e.section==="new"){const a=i.get$content().querySelector('input[name="summary"]')?.value;a&&(o=`==${a}==
25
+ ${o}`)}s=this.previewWikitext(o,void 0,n,s,{backdrop:!1,draggable:!0})}},1),i.on(i.Event.Close,()=>{s?.destroy(),s=void 0})}}ia=Yb(yf),Wr=ev(ia,0,"PluginQuickPreview",mf,Wr),Zb(ia,1,Wr);const tv=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickPreview(){return Wr}},Symbol.toStringTag,{value:"Module"})),iv=t=>{let{user:e,target:i,ctx:n}=t;const r=n.getUrl.bind(n);return m("span",{className:"mw-userlinks",children:[m("a",{href:r(`User:${e}`),className:"mw-userlink",target:i,children:e})," ",m("span",{className:"mw-usertoollinks",children:["(",m("a",{href:r(`User_talk:${e}`),className:"mw-usertoollinks-talk",target:i,children:"talk"})," | ",m("a",{href:r(`Special:Contributions/${e}`),className:"mw-usertoollinks-contribs",target:i,children:"contribs"})," | ",m("a",{href:r(`Special:Block/${e}`),className:"mw-usertoollinks-block",target:i,children:"block"}),")"]})]})};var Gr=(t=>(t.update="ipe:diff-table/update",t.edit="ipe:diff-table/edit",t))(Gr||{});const nv=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"medium"}).format,bf=t=>{let e=["diff-title"];if(t.type==="from"?e.push("diff-otitle"):t.type==="to"&&e.push("diff-ntitle"),!t.pageid||!t.userid)return m("td",{colSpan:2,className:e,children:m("div",{className:"mw-diff-title--title",children:t.type==="from"?"Original content":t.type==="to"?"Your content":""})});const i=n=>{n.preventDefault(),n.target.dispatchEvent(new CustomEvent("ipe:diff-table/edit",{detail:{revid:t.revid},bubbles:!0}))};return m("td",{colSpan:2,className:e,children:[m("div",{className:"mw-diff-title--title",children:[t.pagetitle||t.timestamp,t.revid?` (rev#${t.revid})`:""]}),m("div",{className:"mw-diff-title--actions",children:m("a",{href:t.ctx.getUrl("",{action:"edit",oldid:t.revid}),onClick:i,children:[m(Al,{style:"width: 1em; height: 1em"}),"Quick edit"]})}),m("div",{className:"mw-diff-title--user",children:t.username&&m(iv,{ctx:t.ctx,user:t.username,target:"_blank"})}),m("div",{className:"mw-diff-title--timestamp",children:t.timestamp&&nv(new Date(t.timestamp))}),m("div",{className:"mw-diff-title--comment",children:t.parsedcomment&&m(_i,{children:["(",m("i",{innerHTML:t.parsedcomment}),")"]})})]})},rv=t=>{const e=t.data;if(!e.prev&&!e.next)return null;const i=(n,r,s)=>{n.preventDefault(),n.target.dispatchEvent(new CustomEvent("ipe:diff-table/update",{detail:{fromrev:r,torev:s},bubbles:!0}))};return m("tr",{className:"mw-diff-title--navigation",children:[m("td",{colSpan:2,children:e.prev?m("a",{href:t.ctx.getUrl("",{diff:e.prev,oldid:e.fromrevid}),onClick:n=>i(n,e.prev,e.fromrevid),children:"← Previous"}):m("i",{children:"Oldest version"})}),m("td",{colSpan:2,children:e.next?m("a",{href:t.ctx.getUrl("",{diff:e.next,oldid:e.torevid}),onClick:n=>i(n,e.torevid,e.next),children:"Next →"}):m("i",{children:"Newest version"})})]})},sv=t=>{const{data:e,...i}=t,n=m("table",{className:"theme-ipe diff diff-type-table","data-mw":"interface",...i,children:[m("colgroup",{children:[m("col",{className:"diff-marker"}),m("col",{className:"diff-content"}),m("col",{className:"diff-marker"}),m("col",{className:"diff-content"})]}),m("tbody",{children:[m("tr",{children:[m(bf,{ctx:t.ctx,type:"from",pageid:e.fromid,pagetitle:e.fromtitle,revid:e.fromrevid,size:e.fromsize,timestamp:e.fromtimestamp,username:e.fromuser,userid:e.fromuserid,comment:e.fromcomment,parsedcomment:e.fromparsedcomment}),m(bf,{ctx:t.ctx,type:"to",pageid:e.toid,pagetitle:e.totitle,revid:e.torevid,size:e.tosize,timestamp:e.totimestamp,username:e.touser,userid:e.touserid,comment:e.tocomment,parsedcomment:e.toparsedcomment})]}),m(rv,{data:e,ctx:t.ctx}),m("div",{id:"diffbody"}),m("tr",{className:"diff-size",style:{textAlign:"center"},children:[m("td",{colSpan:2,className:"diff-size-old",children:e.fromsize!==void 0&&`${e.fromsize} bytes`}),m("td",{colSpan:2,className:"diff-size-new",children:e.tosize!==void 0&&`${e.tosize} bytes`})]})]})]});return n.querySelector("#diffbody").outerHTML=e.body||m("tr",{children:m("td",{colSpan:4,children:m("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"5rem"},children:m("i",{children:"No changes"})})})}).outerHTML,n},ov=(t,e=document)=>e.querySelector(t),av=(t,e=document)=>e.querySelectorAll(t);var lv=Object.create,na=Object.defineProperty,cv=Object.getOwnPropertyDescriptor,vf=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),wf=t=>{throw TypeError(t)},uv=(t,e,i)=>e in t?na(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,fv=(t,e)=>na(t,"name",{value:e,configurable:!0}),dv=t=>[,,,lv(t?.[vf("metadata")]??null)],hv=["class","method","getter","setter","accessor","field","value","get","set"],_f=t=>t!==void 0&&typeof t!="function"?wf("Function expected"):t,pv=(t,e,i,n,r)=>({kind:hv[t],name:e,metadata:n,addInitializer:s=>i._?wf("Already initialized"):r.push(_f(s||null))}),gv=(t,e)=>uv(e,vf("metadata"),t[3]),mv=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},yv=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&cv(r,i));fv(r,i);for(var d=n.length-1;d>=0;d--)l=pv(c,i,a={},t[3],h),o=(0,n[d])(r,l),a._=1,_f(o)&&(r=o);return gv(t,r),p&&na(r,i,p),u?c^4?s:p:r},xf,ra,Sf;xf=[Ee(["wiki","getUrl","preferences","$"]),Vt(R.object({"quickDiff.keyshortcut":R.string().default("ctrl-d").description("Key shortcut to open quick diff in quick edit modal")}).description("Quick diff options").extra("category","editor"))];class Vr extends(Sf=et){constructor(e){super(e,{},"quick-diff"),this.ctx=e,this.COMPARE_API_DEFAULT_OPTIONS={prop:["comment","diff","diffsize","ids","parsedcomment","size","timestamp","title","user","rel"].join("|"),difftype:"table"}}start(){this.ctx.set("quickDiff",this),this.ctx.on("quick-edit/wiki-page",this.injectQuickEdit.bind(this)),window.RLQ.push(this.injectHistoryPage.bind(this))}stop(){}injectHistoryPage(){const e=this.ctx.$,i=ov("#mw-history-compare");if(!i)return;av(".mw-history-compareselectedversions-button",i).forEach(r=>{r.after(m("button",{className:"cdx-button",onClick:s=>{s.preventDefault();const o=new FormData(i),a=Number(o.get("oldid"))||0,l=Number(o.get("diff"))||0;if(!o.get("title")||!a||!l)return this.logger.warn("Missing title or revision IDs");this.comparePages({fromrev:a,torev:l})},children:e`Quick Diff`}))})}async injectQuickEdit({modal:e,wikiPage:i,options:n}){if(i.pageid===0||n.section==="new")return;const r=this.ctx.$;let s;e.addButton({label:r`Diff`,side:"left",keyPress:await this.ctx.preferences.get("quickDiff.keyshortcut")||void 0,className:"btn btn-secondary",method:()=>{const o=i.title,a=i.revisions?.[0]?.content||"",l=e.get$content().querySelector('textarea[name="text"]')?.value||"";return a===l?this.ctx.modal.notify("info",{title:r`Quick Diff`,content:r`No changes`}):(this.ctx.emit("quick-diff/quick-edit-modal",{ctx:this.ctx,modal:e,wikiPage:i}),s=this.comparePages({fromtitle:o,fromtext:a,totitle:o,totext:l,topst:!0},s,{backdrop:!1,draggable:!0}),s)}},2),e.on(e.Event.Close,()=>{s?.destroy(),s=void 0})}comparePages(e,i,n){const r=this.ctx.$;return!i||i.isDestroyed?i=this.ctx.modal.createObject({title:r`Loading diff...`,content:"",className:"quick-diff",center:!1,...n}).init():i.removeButton("*"),this.ctx.emit("quick-diff/init-options",{ctx:this.ctx,options:e}),i.setContent(m("section",{style:{height:"70vh",display:"flex",justifyContent:"center",alignItems:"center"},children:m(ai,{})})),i.bringToFront(),window.mw&&mw.loader.getState("mediawiki.diff.styles")!=="ready"&&mw.loader.load(["mediawiki.diff.styles"]),this.ctx.api.post({...this.COMPARE_API_DEFAULT_OPTIONS,...e,action:"compare",format:"json",formatversion:2}).then(s=>{if(!s.data.compare)throw new Error("No compare data received",{cause:s});const{data:{compare:o}}=s;i.setTitle(o.fromtitle&&o.totitle?`${o.fromtitle}${o.fromrevid?` (${o.fromrevid})`:""} ⇔ ${o.totitle}${o.torevid?` (${o.torevid})`:""}`:r`Differences`);let a;i.setContent(m("section",{style:{minHeight:"70vh"},children:m(sv,{ref:l=>a=l,data:o,ctx:this.ctx})})),a.addEventListener(Gr.update,l=>{l.stopPropagation(),this.comparePages({fromrev:l.detail.fromrev,torev:l.detail.torev},i,n)},{once:!0}),this.ctx.inject(["quickEdit"],l=>{const c=u=>{u.stopPropagation(),l.quickEdit({revision:u.detail.revid})};a.addEventListener(Gr.edit,c),i.on(i.Event.Close,()=>{a.removeEventListener(Gr.edit,c)})}),o.fromrevid&&o.torevid&&i.addButton({label:r`Original Compare Page`,side:"right",className:"btn btn-secondary",method:()=>{window.location.href=this.ctx.getUrl("",{oldid:o.fromrevid,diff:o.torevid})}}),this.ctx.emit("quick-diff/loaded",{ctx:this.ctx,modal:i,compare:o})}).catch(s=>{i.setContent(m(Qo,{title:r`Failed to load diff`,type:"error",children:m("pre",{children:s instanceof Error?s.message:String(s)})}))}),i.show()}}ra=dv(Sf),Vr=yv(ra,0,"PluginQuickDiff",xf,Vr),mv(ra,1,Vr);const bv=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickDiff(){return Vr}},Symbol.toStringTag,{value:"Module"})),es=class es extends et{constructor(e){super(e,{},"quick-redirect"),this.ctx=e}start(){this.ctx.set("quickRedirect",this);const e=this.ctx.$,i=window.mw?.config.get("wgPageName")||"",n=window.mw?.config.get("wgIsProbablyEditable");this.ctx.inject(["toolbox"],r=>{this.ctx=r,r.toolbox.addButton({id:"quick-redirect",icon:m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-file-symlink",children:[m("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),m("path",{d:"M4 21v-4a3 3 0 0 1 3 -3h5"}),m("path",{d:"M9 17l3 -3l-3 -3"}),m("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),m("path",{d:"M5 11v-6a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2h-9.5"})]}),tooltip:e`Quick Redirect`,group:"group1",index:2,onClick:()=>{this.showModal(n?{to:i}:{})}}),this.addDisposeHandler(s=>{s.toolbox.removeButton("quick-redirect")})})}stop(){}async showModal(e){const i=this.ctx.$,n=await this.ctx.preferences.get("quickRedirect.reason");e||(e={}),this.ctx.emit("quick-redirect/init-options",{ctx:this.ctx,options:e});const r=this.ctx.modal.createObject({title:i`Quick Redirect`,content:m(ai,{}),className:"quick-redirect compact-buttons",sizeClass:"smallToMedium",center:!0}).init();let s=null;return r.setContent(m("form",{ref:o=>s=o,style:{display:"flex",flexDirection:"column",gap:"1rem"},onSubmit:o=>{if(o.preventDefault(),s?.checkValidity(),!s?.reportValidity())return;const a=new FormData(s),l={from:a.get("from")?.toString().trim(),to:a.get("to")?.toString().trim(),reason:a.get("reason")||"",overwrite:a.get("overwrite")==="on"};if(!l.from||!l.to){this.ctx.modal.notify("error",{title:i`Failed to redirect`,content:i`From and to are required.`});return}this.ctx.emit("quick-redirect/submit",{ctx:this.ctx,payload:l}),r.setLoadingState(!0),this.redirectPage(l).then(c=>{r.close(),this.ctx.modal.notify("success",{title:i`Redirect successful`,content:i`The redirect has been created.`})}).catch(c=>{r.setLoadingState(!1),this.ctx.modal.notify("error",{title:i`Failed to redirect`,content:c instanceof Error?c.message:String(c)})})},children:[m(af,{inputs:[{label:i`Redirect from`,name:"from",value:e?.from,required:!0},{label:i`Redirect to`,name:"to",value:e?.to,required:!0}]}),m(Hr,{label:i`Reason`,id:"reason",name:"reason",value:e?.reason??n??""}),m("div",{children:m(Ui,{name:"overwrite",id:"overwrite",checked:e?.overwrite,children:i`Force create redirect even if the from page already exists`})})]})),r.setButtons([{label:i`Create Redirect`,className:"is-primary is-ghost",method:()=>{s?.dispatchEvent(new Event("submit"))}}]),this.ctx.emit("quick-redirect/show-modal",{ctx:this.ctx,modal:r}),r.show()}async redirectPage(e){const{from:i,to:n,reason:r="",overwrite:s=!1}=e,o=await this.ctx.wikiPage.newBlankPage({title:i}),a=`#REDIRECT [[:${n}]]`;return o.edit({text:a,summary:r},{createonly:!s})}};es.inject=["api","wikiPage","modal","$"],es.PreferencesSchema=R.object({"quickRedirect.reason":R.string().default("[IPE-NEXT] Quick redirect")}).description("Quick redirect options").extra("category","editor");let sa=es;const vv=Object.freeze(Object.defineProperty({__proto__:null,PluginQuickRedirect:sa},Symbol.toStringTag,{value:"Module"}));var wv=Object.create,oa=Object.defineProperty,_v=Object.getOwnPropertyDescriptor,kf=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),$f=t=>{throw TypeError(t)},xv=(t,e,i)=>e in t?oa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Sv=(t,e)=>oa(t,"name",{value:e,configurable:!0}),kv=t=>[,,,wv(t?.[kf("metadata")]??null)],$v=["class","method","getter","setter","accessor","field","value","get","set"],Ef=t=>t!==void 0&&typeof t!="function"?$f("Function expected"):t,Ev=(t,e,i,n,r)=>({kind:$v[t],name:e,metadata:n,addInitializer:s=>i._?$f("Already initialized"):r.push(Ef(s||null))}),Pv=(t,e)=>xv(e,kf("metadata"),t[3]),Cv=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Rv=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&_v(r,i));Sv(r,i);for(var d=n.length-1;d>=0;d--)l=Ev(c,i,a={},t[3],h),o=(0,n[d])(r,l),a._=1,Ef(o)&&(r=o);return Pv(t,r),p&&oa(r,i,p),u?c^4?s:p:r},Pf,aa,Cf;Pf=[Vt(R.object({toolboxAlwaysShow:R.boolean().description("Make the toolbox opened by default").default(!1)}).description("Toolbox preferences")),Ee(["preferences"])];class Yr extends(Cf=wt){constructor(e){super(e,"toolbox",!1),this.ctx=e,this.container=void 0}async start(){this.container=this.createToolbox(),this.ctx.preferences.get("toolboxAlwaysShow").then(e=>{e&&this.container.classList.add("is-persistent")}),this.setupHoverLogic(),document.body.appendChild(this.container),this.updateButtonDelays()}stop(){this.container?.remove()}get isPersistent(){return this.container.classList.contains("is-persistent")}setupHoverLogic(){let e=null;this.container.addEventListener("mouseenter",()=>{e&&(clearTimeout(e),e=null),this.isPersistent||this.container.classList.add("is-hovered")}),this.container.addEventListener("mouseleave",()=>{this.isPersistent||(e=window.setTimeout(()=>{this.container.classList.remove("is-hovered")},150))})}calculateButtonDelay(e,i){if(i<=1)return 0;const n=.15,r=e/(i-1),s=n*Math.sqrt(r);return Math.round(s*1e3)/1e3}updateButtonDelays(){this.container.querySelectorAll(".btn-group").forEach(i=>{const n=i.querySelectorAll(".btn-tip-group"),r=n.length;n.forEach((s,o)=>{const a=this.calculateButtonDelay(o,r);s.style.setProperty("--transition-delay",`${a}s`),s.style.setProperty("--max-transition-delay","0.15s")})})}createToolbox(){return m("div",{id:"ipe-edit-toolbox",children:[m("ul",{className:"btn-group group1",style:{display:"flex",flexDirection:"column"}}),m("ul",{className:"btn-group group2",style:{display:"flex",flexDirection:"row"}}),m("button",{className:"ipe-toolbox-btn",id:"toolbox-toggler",onClick:()=>{this.toggle()},children:m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"448",height:"512",viewBox:"0 0 448 512",children:[m("rect",{width:"448",height:"512",fill:"none"}),m("path",{fill:"currentColor",d:"M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32"})]})})]})}normalizeButtonId(e){return e||(e=Math.random().toString(36).substring(2,8)),`ipe-toolbox__${e.trim()}`.replace(/\s\.#/g,"-")}addButton(e){let{id:i,group:n,icon:r,tooltip:s,itemProps:o,buttonProps:a,onClick:l,index:c}=e;i=this.normalizeButtonId(i);const u=this.container.querySelector(`#${i}`);u&&(this.ctx.logger("toolbox").warn(`Button with id ${i} already exists, replacing it.`),u.remove());let f=null;if(typeof n>"u"||n==="auto"){const p=this.container.querySelector(".btn-group.group1"),d=this.container.querySelector(".btn-group.group2"),w=p?.children.length||0,S=d?.children.length||0;f=w<=S?p:d}else f=this.container.querySelector(`.btn-group.${n}`);if(!f)throw new Error(`Button group ${n} not found`);const h=m("li",{class:"btn-tip-group",id:i,onClick:l,...o,children:[m("div",{class:"btn-tip",children:s}),m("button",{id:`${i}-btn`,"data-id":e.id,class:"ipe-toolbox-btn",...a,children:r})]});return h.addEventListener("click",p=>{this.ctx.emit("toolbox/button-clicked",{ctx:this.ctx,button:p.target,id:e.id})}),typeof c=="number"?c<=0?f.prepend(h):c>=f.children.length?f.appendChild(h):f.children[c]?.before(h):f.appendChild(h),this.ctx.emit("toolbox/button-added",{ctx:this.ctx,button:h}),this.updateButtonDelays(),h}removeButton(e){const i=this.normalizeButtonId(e);this.container.querySelector(`#${i}`)?.remove(),this.ctx.emit("toolbox/button-removed",{ctx:this.ctx,id:e}),this.updateButtonDelays()}getContainer(){return this.container}get isOpened(){return this.container.classList.contains("is-persistent")||this.container.classList.contains("is-hovered")}toggle(e){const i=this.isPersistent,n=typeof e=="boolean"?e:!i;this.container.classList.toggle("is-persistent",n),this.container.classList.remove("is-hovered"),this.ctx.preferences.set("toolboxAlwaysShow",n),this.ctx.emit("toolbox/toggle",{ctx:this.ctx,opened:this.isOpened})}}aa=kv(Cf),Yr=Rv(aa,0,"PluginToolbox",Pf,Yr),Cv(aa,1,Yr);const Iv=Object.freeze(Object.defineProperty({__proto__:null,get PluginToolbox(){return Yr}},Symbol.toStringTag,{value:"Module"})),Qr=fi({__name:"UIBaseButton",props:{variant:{default:"neutral"},active:{type:Boolean,default:!1}},setup(t){const e=t,i=It(()=>({"is-active":e.active,"is-danger":e.variant==="danger","is-primary":e.variant==="primary","is-ghost":e.variant==="ghost","is-accent":e.variant==="accent"}));return(n,r)=>(oe(),de("button",{class:pt(["ipeps-button",i.value])},[ym(n.$slots,"default")],2))}}),Av={id:"ipe-registry-manager"},Ov={class:"ipeps-header"},Tv={class:"ipeps-header-title"},Lv={class:"ipeps-input-wrapper"},Mv=["placeholder","disabled"],Nv={key:0,class:"ipeps-list"},Dv={class:"registry-info"},jv={class:"item-name"},Uv={class:"item-desc"},Fv={class:"homepage"},Bv=["href"],qv={class:"url"},Hv={class:"item-meta"},zv={class:"ipeps-actions"},Kv={key:1,class:"ipeps-empty"},Wv={class:"text"},Gv={class:"description"},Vv=Fr(fi({__name:"RegistryManager",setup(t){const e=Bo(),i=e.$,n=e.$$,r=Ue([]),s=Ue(""),o=Ue(!1),a=d=>{try{return new URL(d).hostname}catch{return d}};async function l(){const d=await e.preferences.get("pluginStore.registries")||[],w=await Promise.allSettled(d.map(async S=>{const E=await e.store.getRegistryInfo(S);return{registryUrl:S,label:a(S),...E}}));r.value=w.filter(S=>S.status==="fulfilled").map(S=>S.value)}async function c(){const d=s.value.trim();if(d){if(r.value.some(w=>w.registryUrl===d)){e.modal.notify("info",{content:"Registry already exists."});return}o.value=!0;try{const w=await e.store.getRegistryInfo(d,"online_manifest",!0);if(!w)throw new Error("Invalid registry or unreachable");const S=await e.preferences.get("pluginStore.registries")||[];S.push(d),await e.preferences.set("pluginStore.registries",S),r.value.push({registryUrl:d,label:a(d),...w}),s.value="",e.modal.notify("success",{content:"Registry added."})}catch(w){e.modal.notify("error",{content:w instanceof Error?w.message:String(w)})}finally{o.value=!1}}}async function u(d){const S=(await e.preferences.get("pluginStore.registries")||[]).filter(E=>E!==d);await e.preferences.set("pluginStore.registries",S),r.value=r.value.filter(E=>E.registryUrl!==d)}async function f(d){const S=(await e.preferences.get("pluginStore.plugins")||[]).filter(E=>E.registry===d);if(S.length===0){e.modal.confirm({title:n`plugin-store.remove-registry.title`,content:n`plugin-store.remove-registry.tip-content`+`
26
+ ${d}`,cancelBtn:{label:i`Cancel`,className:"is-ghost"},okBtn:{label:i`Remove`,className:"is-danger"}},async E=>{E&&(await u(d),e.modal.notify("success",{content:n`plugin-store.remove-registry.remove-success`}))});return}e.modal.dialog({title:n`plugin-store.remove-registry.title`,content:nn("div",{class:"theme-ipe-prose"},[nn("p",{},n({$1:S.length})`plugin-store.remove-registry.confirm-content`),nn("ul",{},S.map(E=>nn("li",{},E.id)))]),buttons:[{label:n`plugin-store.remove-registry.buttons.remove-only`,className:"is-danger is-ghost",method:async(E,M)=>{await u(d),e.modal.notify("success",{content:n`plugin-store.remove-registry.remove-success`}),M.close()}},{label:n`plugin-store.remove-registry.buttons.remove-and-uninstall`,className:"is-danger",method:async(E,M)=>{await u(d);for(const g of S)try{await e.store.uninstallAndRemovePreference(g.registry,g.id)}catch(y){e.modal.notify("error",{content:y instanceof Error?`Failed to uninstall ${g.id}: ${y.message}`:`Failed to uninstall ${g.id}`})}e.modal.notify("success",{content:n({$1:S.length})`plugin-store.remove-registry.remove-with-plugins-success`}),M.close()}}]},()=>{})}function h(d){const w=d.changes["pluginStore.registries"];Array.isArray(w)&&l()}function p(){const d=xt.PLUGIN_REGISTRY_URL;s.value=d,c()}return wn(()=>{l(),e.on("preferences/changed",h)}),(d,w)=>(oe(),de("div",Av,[J("div",Ov,[J("div",Tv,ue(Pe(i)`Registries`),1),J("div",Lv,[xc(J("input",{class:"ipeps-input with-icon","onUpdate:modelValue":w[0]||(w[0]=S=>s.value=S),type:"url",placeholder:Pe(i)`Add registry URL`+" (https://...)",disabled:o.value},null,8,Mv),[[Eu,s.value,void 0,{trim:!0}]]),w[1]||(w[1]=J("div",{class:"ipeps-input-icon"},"📦",-1))]),Ce(Qr,{onClick:c,disabled:o.value||!s.value,variant:"primary"},{default:bn(()=>[Pn(ue(o.value?Pe(i)`Adding...`:Pe(i)`Add`),1)]),_:1},8,["disabled"])]),r.value.length?(oe(),de("div",Nv,[(oe(!0),de(qe,null,_o(r.value,S=>(oe(),de("div",{class:"ipeps-item",key:S.registryUrl},[J("div",Dv,[J("div",jv,ue(S.label),1),J("div",Uv,[J("div",Fv,[S.homepage?(oe(),de("a",{key:0,href:S.homepage,target:"_blank"},ue(S.homepage),9,Bv)):Jt("",!0)]),J("div",qv,ue(S.registryUrl),1)]),J("div",Hv,ue(S.packages.length)+" packages",1)]),J("div",zv,[Ce(Qr,{onClick:E=>f(S.registryUrl),variant:"danger"},{default:bn(()=>[Pn(ue(Pe(i)`Remove`),1)]),_:1},8,["onClick"])])]))),128))])):(oe(),de("div",Kv,[w[2]||(w[2]=J("div",{class:"icon"},"🗂️",-1)),J("div",Wv,ue(Pe(i)`No registries configured`),1),J("div",Gv,[Ce(Qr,{onClick:p,variant:"primary",style:{padding:"0.25rem 0.5rem"}},{default:bn(()=>[Pn(ue(Pe(i)`Setup default registry`),1)]),_:1})])]))]))}}),[["__scopeId","data-v-971ee6d5"]]),Yv={id:"ipe-plugin-install-manager"},Qv={class:"ipeps-header"},Xv={class:"ipeps-header-title"},Jv={class:"ipeps-input-wrapper"},Zv=["disabled"],ew=["disabled"],tw={key:0,class:"ipeps-loading"},iw={class:"loading-text"},nw={key:1,class:"ipeps-list"},rw={class:"plugin-info"},sw={class:"plugin-header"},ow={class:"item-name"},aw={class:"ipeps-tags"},lw=["href","title"],cw=["title"],uw={class:"plugin-meta"},fw={key:0,class:"version"},dw={key:1,class:"author"},hw={key:2,class:"license"},pw={key:2,class:"ipeps-empty"},gw={class:"plugin-empty-text"},yw=Fr(fi({__name:"PluginInstallManager",setup(t){const e=Bo(),i=e.$,n=e.$$,r=Ue([]),s=Ue([]),o=Ue(""),a=Ue(!1),l=(C,U)=>`${C}
27
+ ${U}`,c=It(()=>new Set(s.value.map(C=>l(C.registry,C.id)))),u=C=>c.value.has(C),f=C=>{try{return new URL(C).hostname}catch{return C}},h=Ue(!1),p=It(()=>r.value.length>0),d=It(()=>r.value.flatMap(C=>(C.packages||[]).map(U=>({...U,_key:l(C.registryUrl,U.id),registry:C.registryUrl,registryHomepage:C.homepage,registryLabel:f(C.registryUrl),isBroken:!1,isRegistryMissing:!1})))),w=It(()=>{const C=o.value.trim().toLowerCase(),U=d.value,H=new Set(U.map(ke=>ke._key)),He=new Set(r.value.map(ke=>ke.registryUrl)),dt=s.value.filter(ke=>!H.has(l(ke.registry,ke.id))).map(ke=>{const ce=r.value.find(me=>me.registryUrl===ke.registry);return{id:ke.id,name:void 0,description:void 0,version:void 0,author:void 0,license:void 0,_key:l(ke.registry,ke.id),registry:ke.registry,registryHomepage:ce?.homepage,registryLabel:f(ke.registry),isBroken:!0,isRegistryMissing:!He.has(ke.registry)}}),Ki=ke=>C?ke.filter(ce=>ce.name&&ce.name.toLowerCase().includes(C)||ce.id&&ce.id.toLowerCase().includes(C)||ce.description&&ce.description.toLowerCase().includes(C)||ce.author&&ce.author.toLowerCase().includes(C)||ce.registry&&ce.registry.toLowerCase().includes(C)):ke;return[...Ki(dt),...Ki(U)]}),S=It(()=>w.value),E=C=>C.description?C.description:C.isBroken?C.isRegistryMissing?n`plugin-store.broken.registry-unavailable`:n`plugin-store.broken.plugin-removed`:"",M=async(C,U)=>{e.store.installAndSetPreference(C,U)},g=async(C,U)=>{e.store.uninstallAndRemovePreference(C,U)},y=(C,U)=>u(l(C,U))?g(C,U):M(C,U),v=C=>y(C.registry,C.id),x=async()=>{if(a.value)return;if(r.value.length===0){e.modal.notify("info",{content:"No registry configured. Please add a registry first."});return}a.value=!0;const C=await e.store.refreshAllRegistryCaches(),U=Object.entries(C).filter(([He,dt])=>dt!==null);r.value=U.map(([He,dt])=>({...dt,registryUrl:He}));const H=Object.entries(C).filter(([He,dt])=>dt===null).map(([He])=>He);a.value=!1,U.length===0?e.modal.notify("error",{content:"All registries failed to refresh"}):(e.modal.notify("success",{content:`${U.length} ${U.length===1?"registry":"registries"} refreshed successfully.`}),H.length>0&&e.modal.notify("warning",{content:`${H.length} ${H.length===1?"registry":"registries"} failed to refresh:
28
+ ${H.join(`
29
+ `)}`}))},P=async()=>{h.value=!1;const C=await e.store.ctx.preferences.get("pluginStore.registries")||[],U=await Promise.allSettled(C.map(async H=>({...await e.store.getRegistryInfo(H),registryUrl:H})));r.value=U.filter(H=>H.status==="fulfilled").map(H=>H.value),s.value=await e.preferences.get("pluginStore.plugins")||[],h.value=!0};function L(C){const U=C.changes["pluginStore.registries"],H=C.changes["pluginStore.plugins"];Array.isArray(H)&&(s.value=H),Array.isArray(U)&&P()}return wn(()=>{P(),e.on("preferences/changed",L)}),vo(()=>{}),(C,U)=>(oe(),de("div",Yv,[J("div",Qv,[J("div",Xv,ue(Pe(i)`Plugins`),1),J("div",Jv,[xc(J("input",{class:"ipeps-input with-icon","onUpdate:modelValue":U[0]||(U[0]=H=>o.value=H),type:"text",placeholder:"{{ $`Search plugins...` }}",disabled:!d.value.length},null,8,Zv),[[Eu,o.value,void 0,{trim:!0}]]),U[1]||(U[1]=J("div",{class:"ipeps-input-icon"},"🔍",-1))]),J("button",{class:pt(["ipeps-button",{refreshing:a.value}]),onClick:x,disabled:a.value||!p.value,variant:"primary"},ue(a.value?Pe(i)`Refreshing...`:Pe(i)`Refresh`),11,ew)]),!p.value&&!h.value?(oe(),de("div",tw,[U[2]||(U[2]=J("div",{class:"loading-spinner"},null,-1)),J("div",iw,ue(Pe(i)`Loading...`),1)])):S.value.length?(oe(),de("div",nw,[(oe(!0),de(qe,null,_o(S.value,H=>(oe(),de("div",{class:pt(["ipeps-item",{installed:u(H._key),broken:H.isBroken}]),key:H._key},[J("div",rw,[J("div",sw,[J("div",ow,ue(H.name||H.id),1),u(H._key)||H.isBroken?(oe(),de("span",{key:0,class:pt(["ipeps-badge",{"is-installed":u(H._key),"is-broken":H.isBroken}])},ue(H.isBroken?Pe(n)`plugin-store.tags.broken`:Pe(n)`plugin-store.tags.installed`),3)):Jt("",!0)]),J("div",aw,[H.registryHomepage&&!H.isRegistryMissing?(oe(),de("a",{key:0,class:"ipeps-tag registry-tag",href:H.registryHomepage,target:"_blank",title:H.registryLabel},ue(H.registryLabel),9,lw)):(oe(),de("span",{key:1,class:pt(["ipeps-tag registry-tag",{broken:H.isRegistryMissing}]),title:H.registryLabel},ue(H.registryLabel),11,cw)),J("div",{class:pt(["plugin-id ipeps-tag",{broken:H.isBroken&&!H.isRegistryMissing}])},ue(H.id),3)]),J("div",{class:pt(["plugin-desc",{"broken-desc":H.isBroken}])},ue(E(H)),3),J("div",uw,[H.version?(oe(),de("span",fw,"v"+ue(H.version),1)):Jt("",!0),H.author?(oe(),de("span",dw,"👤 "+ue(H.author),1)):Jt("",!0),H.license?(oe(),de("span",hw,"📜 "+ue(H.license),1)):Jt("",!0)])]),Ce(Qr,{active:u(H._key),variant:u(H._key)?"danger":"primary",onClick:He=>v(H)},{default:bn(()=>[Pn(ue(u(H._key)?Pe(i)`Remove`:Pe(i)`Install`),1)]),_:2},1032,["active","variant","onClick"])],2))),128))])):(oe(),de("div",pw,[U[3]||(U[3]=J("div",{class:"plugin-empty-icon"},"📦",-1)),J("div",gw,ue(Pe(i)`No matching plugins found`),1)]))]))}}),[["__scopeId","data-v-f11a3331"]]),bw={id:"ipe-plugin-store-app"},vw=Object.freeze(Object.defineProperty({__proto__:null,default:Fr(fi({__name:"PluginStoreApp",setup(t){return(e,i)=>(oe(),de("div",bw,[Ce(yw),i[0]||(i[0]=J("div",{class:"divider-wrapper"},[J("hr",{class:"divider"})],-1)),Ce(Vv)]))}}),[["__scopeId","data-v-1b3d0d80"]])},Symbol.toStringTag,{value:"Module"})),ww=window?.location?.origin,On=({type:t,tag:e,href:i,target:n,children:r,...s})=>(e=e||(i?"a":"button"),typeof n>"u"&&i&&i.startsWith("http")&&!i.startsWith(ww)&&(n="_blank"),nn(e,{className:`theme-ipe ipe-action-button ipe-modal-btn is-${t||"default"}`,href:e==="a"?i:void 0,target:e==="a"?n:void 0,"data-href":e!=="a"?i:void 0,...s},r));var _w=Object.create,la=Object.defineProperty,xw=Object.getOwnPropertyDescriptor,Rf=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),If=t=>{throw TypeError(t)},Sw=(t,e,i)=>e in t?la(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,kw=(t,e)=>la(t,"name",{value:e,configurable:!0}),$w=t=>[,,,_w(t?.[Rf("metadata")]??null)],Ew=["class","method","getter","setter","accessor","field","value","get","set"],Af=t=>t!==void 0&&typeof t!="function"?If("Function expected"):t,Pw=(t,e,i,n,r)=>({kind:Ew[t],name:e,metadata:n,addInitializer:s=>i._?If("Already initialized"):r.push(Af(s||null))}),Cw=(t,e)=>Sw(e,Rf("metadata"),t[3]),Rw=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Iw=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&xw(r,i));kw(r,i);for(var d=n.length-1;d>=0;d--)l=Pw(c,i,a={},t[3],h),o=(0,n[d])(r,l),a._=1,Af(o)&&(r=o);return Cw(t,r),p&&la(r,i,p),u?c^4?s:p:r},Of,ca,Tf;Of=[Ee(["preferences","wiki","wikiPage","wikiTitle","modal","preferencesUI","$"])];class Xr extends(Tf=et){constructor(e){super(e,{},"pref-sync"),this.ctx=e,e.set("prefSync",this)}start(){const e=this.ctx,i=e.$;e.preferences.defineCategory({name:"pref-sync",label:i`Sync`,description:i`Import and export preferences`,index:98,customRenderer:()=>{const n=this.getUserPrefsPageTitle();return m("div",{className:"theme-ipe-prose",children:[n&&m("section",{children:[m("h3",{children:i`Backup your preferences via user page`}),m("p",{children:m("a",{href:n?.getURL().toString(),target:"_blank",children:[n?.getPrefixedText()," →"]})}),m("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[m(On,{type:"primary",onClick:r=>{r.preventDefault();const s=r.target;s.disabled=!0;const o=e.preferencesUI.getCurrentModal();o?.setLoadingState(!0),this.exportToUserPage().then(a=>{e.modal.notify("success",{title:i`Preferences Exported`,content:m("p",{children:["Your preferences have been exported to"," ",m("a",{href:a.getURL().toString(),target:"_blank",children:a.getPrefixedText()}),"."]})})}).finally(()=>{s.disabled=!1,o?.setLoadingState(!1)})},children:[m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-cloud-up",children:[m("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),m("path",{d:"M12 18.004h-5.343c-2.572 -.004 -4.657 -2.011 -4.657 -4.487c0 -2.475 2.085 -4.482 4.657 -4.482c.393 -1.762 1.794 -3.2 3.675 -3.773c1.88 -.572 3.956 -.193 5.444 1c1.488 1.19 2.162 3.007 1.77 4.769h.99c1.38 0 2.57 .811 3.128 1.986"}),m("path",{d:"M19 22v-6"}),m("path",{d:"M22 19l-3 -3l-3 3"})]})," ",i`Backup`]}),m(On,{onClick:r=>{r.preventDefault();const s=e.preferencesUI.getCurrentModal(),o=r.target;o.disabled=!0,s?.setLoadingState(!0),this.importFromUserPage().then(a=>{this.notifyImportSuccess(a)}).finally(()=>{o.disabled=!1,s?.setLoadingState(!1)})},children:[m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-cloud-down",children:[m("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),m("path",{d:"M12 18.004h-5.343c-2.572 -.004 -4.657 -2.011 -4.657 -4.487c0 -2.475 2.085 -4.482 4.657 -4.482c.393 -1.762 1.794 -3.2 3.675 -3.773c1.88 -.572 3.956 -.193 5.444 1c1.488 1.19 2.162 3.007 1.77 4.769h.99c1.38 0 2.573 .813 3.13 1.99"}),m("path",{d:"M19 16v6"}),m("path",{d:"M22 19l-3 3l-3 -3"})]})," ",i`Restore`]})]})]}),m("section",{children:[m("h3",{children:i`Import and export preferences`}),m("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[m(On,{onClick:r=>{r.preventDefault();const s=e.preferencesUI.getCurrentModal();s?.setLoadingState(!0);const o=document.createElement("input");o.type="file",o.accept="application/json";let a=!1;const l=()=>{a||s?.setLoadingState(!1),window.removeEventListener("focus",l)};window.addEventListener("focus",l,{once:!0}),o.addEventListener("change",async c=>{a=!0;try{const u=c.target.files?.[0];if(!u)return;const f=await this.importFromFile(u);this.notifyImportSuccess(f)}catch(u){e.modal.notify("error",{title:"Import failed",content:u instanceof Error?u.message:String(u)})}finally{s?.setLoadingState(!1)}}),o.click()},children:i`Import from file`}),m(On,{onClick:r=>{r.preventDefault();const s=m("input",{type:"url",style:{width:"100%"}}),o=e.preferencesUI.getCurrentModal();e.modal.confirm({title:i`Import from URL`,content:m("div",{className:"ipe-input-box",children:[m("label",{htmlFor:"url-input",children:i`Enter the URL of the preferences JSON file:`}),s]})},async a=>{const l=s.value.trim();if(!(!a||!l))try{o?.setLoadingState(!0);const c=await this.importFromUrl(l);this.notifyImportSuccess(c)}catch(c){e.modal.notify("error",{title:"Import failed",content:c instanceof Error?c.message:String(c)})}finally{o?.setLoadingState(!1)}})},children:i`Import from URL`}),m(On,{onClick:async r=>{r.preventDefault(),await e.preferencesUI.dispatchFormSave();const s=await e.preferences.getExportableRecord(),o=JSON.stringify(s,null,2);e.modal.dialog({title:i`Save to file`,content:m("div",{children:[m("label",{htmlFor:"data",children:i`Your InPageEdit preferences:`}),m("textarea",{name:"data",id:"data",rows:10,value:o,readOnly:!0,style:{width:"100%"}})]}),buttons:[{label:"Copy",method:(a,l)=>{navigator.clipboard.writeText(o),e.modal.notify("success",{content:i`Copied to clipboard`}),l.close()}},{label:i`Download`,method:(a,l)=>{const c=document.createElement("a");c.href=`data:text/json;charset=utf-8,${encodeURIComponent(o)}`,c.download=`ipe-prefs-${new Date().toISOString()}.json`,c.click(),l.close()}}]},()=>{})},children:i`Save as file`})]})]})]})}})}stop(){}getUserPrefsPageTitle(){try{const e=this.ctx.wiki?.userInfo?.name;return e?this.ctx.wikiTitle.newTitle(`User:${e}/ipe-prefs.json`,2):null}catch{return null}}async importFromUserPage(){const e=this.getUserPrefsPageTitle();if(!e)return this.logger.debug("Cannot get user page title, skipping load"),{};try{const i=e.getURL({action:"raw",ctype:"application/json"}),n=await this.importFromUrl(i.toString());return this.logger.info("Loaded preferences from user page:",e),n}catch(i){return this.logger.error("Failed to load preferences from user page:",i),{}}}async exportToUserPage(){const e=this.ctx,i=this.getUserPrefsPageTitle();if(!i)throw new Error("Cannot get user page title");await e.preferencesUI.dispatchFormSave();const n=await e.preferences.getExportableRecord(),r=JSON.stringify(n,null,2);try{return await this.ctx.wikiPage.newBlankPage({title:i.toString(),ns:2}).edit({text:r,summary:"Update InPageEdit preferences",watchlist:at.nochange}),this.logger.info("Exported preferences to user page:",i),i}catch(s){throw this.logger.error("Failed to export preferences to user page:",s),s}}async importFromUrl(e){const i=await fetch(e);if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);const n=await i.blob();return await this.importFromFile(n)}async importFromFile(e){const i=await e.text(),n=JSON.parse(i);return await this.ctx.preferences.setMany(n)}notifyImportSuccess(e){const i=this.ctx.$,n=Object.keys(e??{}),r=n.length;return this.ctx.modal.notify("success",{title:i`Preferences Imported`,content:m("section",{children:[m("p",{children:i({count:r})`Successfully imported {{ count }} {{ count > 1 ? "settings" : "setting" }}:`}),m("ol",{style:{listStyle:"auto",paddingLeft:"1em"},children:n.map(s=>m("li",{children:s},s))})]})})}}ca=$w(Tf),Xr=Iw(ca,0,"PluginPrefSync",Of,Xr),Rw(ca,1,Xr);const Aw=Object.freeze(Object.defineProperty({__proto__:null,get PluginPrefSync(){return Xr}},Symbol.toStringTag,{value:"Module"}));W.BasePlugin=et,W.CordisSymbols=D,W.EffectScope=ds,W.Endpoints=xt,W.ForkScope=$a,W.InPageEdit=$i,W.Inject=Ee,W.Lifecycle=Sa,W.Logger=Ca,W.LoggerLevel=ps,W.MainScope=hs,W.RegisterPreferences=Vt,W.Schema=R,W.ScopeStatus=ka,W.Service=wt,W.createLogger=Aa,Object.defineProperty(W,Symbol.toStringTag,{value:"Module"})}));
22
30
  //# sourceMappingURL=index.umd.js.map