@devvit/payments 0.12.0-next-2025-04-10-14eb9113e.0 → 0.12.0-next-2025-04-12-5721a9506.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/meta.min.json +5 -5
- package/package.json +7 -7
- package/payments.min.js +6 -6
- package/payments.min.js.map +3 -3
package/payments.min.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var Ml=Object.create;var Zo=Object.defineProperty;var Nl=Object.getOwnPropertyDescriptor;var Bl=Object.getOwnPropertyNames;var Dl=Object.getPrototypeOf,Ol=Object.prototype.hasOwnProperty;var Qo=t=>{throw TypeError(t)};var Ul=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Wt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Ll=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Bl(e))!Ol.call(t,n)&&n!==r&&Zo(t,n,{get:()=>e[n],enumerable:!(i=Nl(e,n))||i.enumerable});return t};var Xo=(t,e,r)=>(r=t!=null?Ml(Dl(t)):{},Ll(e||!t||!t.__esModule?Zo(r,"default",{value:t,enumerable:!0}):r,t));var Yo=(t,e,r)=>e.has(t)||Qo("Cannot "+r);var Ue=(t,e,r)=>(Yo(t,e,"read from private field"),r?r.call(t):e.get(t)),Cr=(t,e,r)=>e.has(t)?Qo("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Ni=(t,e,r,i)=>(Yo(t,e,"write to private field"),i?i.call(t,r):e.set(t,r),r);var ro=Wt((_y,gc)=>{var fh=Object.prototype.toString;gc.exports=function(e){if(e===void 0)return"undefined";if(e===null)return"null";var r=typeof e;if(r==="boolean")return"boolean";if(r==="string")return"string";if(r==="number")return"number";if(r==="symbol")return"symbol";if(r==="function")return yh(e)?"generatorfunction":"function";if(mh(e))return"array";if(kh(e))return"buffer";if(vh(e))return"arguments";if(gh(e))return"date";if(ph(e))return"error";if(wh(e))return"regexp";switch(pc(e)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(bh(e))return"generator";switch(r=fh.call(e),r){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return r.slice(8,-1).toLowerCase().replace(/\s/g,"")};function pc(t){return typeof t.constructor=="function"?t.constructor.name:null}function mh(t){return Array.isArray?Array.isArray(t):t instanceof Array}function ph(t){return t instanceof Error||typeof t.message=="string"&&t.constructor&&typeof t.constructor.stackTraceLimit=="number"}function gh(t){return t instanceof Date?!0:typeof t.toDateString=="function"&&typeof t.getDate=="function"&&typeof t.setDate=="function"}function wh(t){return t instanceof RegExp?!0:typeof t.flags=="string"&&typeof t.ignoreCase=="boolean"&&typeof t.multiline=="boolean"&&typeof t.global=="boolean"}function yh(t,e){return pc(t)==="GeneratorFunction"}function bh(t){return typeof t.throw=="function"&&typeof t.return=="function"&&typeof t.next=="function"}function vh(t){try{if(typeof t.length=="number"&&typeof t.callee=="function")return!0}catch(e){if(e.message.indexOf("callee")!==-1)return!0}return!1}function kh(t){return t.constructor&&typeof t.constructor.isBuffer=="function"?t.constructor.isBuffer(t):!1}});var bc=Wt((Ey,yc)=>{"use strict";var wc=Symbol.prototype.valueOf,_h=ro();function Eh(t,e){switch(_h(t)){case"array":return t.slice();case"object":return Object.assign({},t);case"date":return new t.constructor(Number(t));case"map":return new Map(t);case"set":return new Set(t);case"buffer":return Ph(t);case"symbol":return Ih(t);case"arraybuffer":return Fh(t);case"float32array":case"float64array":case"int16array":case"int32array":case"int8array":case"uint16array":case"uint32array":case"uint8clampedarray":case"uint8array":return Ah(t);case"regexp":return Ch(t);case"error":return Object.create(t);default:return t}}function Ch(t){let e=t.flags!==void 0?t.flags:/\w+$/.exec(t)||void 0,r=new t.constructor(t.source,e);return r.lastIndex=t.lastIndex,r}function Fh(t){let e=new t.constructor(t.byteLength);return new Uint8Array(e).set(new Uint8Array(t)),e}function Ah(t,e){return new t.constructor(t.buffer,t.byteOffset,t.length)}function Ph(t){let e=t.length,r=Buffer.allocUnsafe?Buffer.allocUnsafe(e):Buffer.from(e);return t.copy(r),r}function Ih(t){return wc?Object(wc.call(t)):{}}yc.exports=Eh});var kc=Wt((Cy,vc)=>{"use strict";vc.exports=function(e){return e!=null&&typeof e=="object"&&Array.isArray(e)===!1}});var Cc=Wt((Fy,Ec)=>{"use strict";var xh=kc();function _c(t){return xh(t)===!0&&Object.prototype.toString.call(t)==="[object Object]"}Ec.exports=function(e){var r,i;return!(_c(e)===!1||(r=e.constructor,typeof r!="function")||(i=r.prototype,_c(i)===!1)||i.hasOwnProperty("isPrototypeOf")===!1)}});var Ac=Wt((Ay,Fc)=>{"use strict";var Sh=bc(),Th=ro(),Rh=Cc();function io(t,e){switch(Th(t)){case"object":return Mh(t,e);case"array":return Nh(t,e);default:return Sh(t)}}function Mh(t,e){if(typeof e=="function")return e(t);if(e||Rh(t)){let r=new t.constructor;for(let i in t)r[i]=io(t[i],e);return r}return t}function Nh(t,e){let r=new t.constructor(t.length);for(let i=0;i<t.length;i++)r[i]=io(t[i],e);return r}Fc.exports=io});var yl=Wt(Wn=>{"use strict";Wn.byteLength=df;Wn.toByteArray=uf;Wn.fromByteArray=mf;var Pe=[],me=[],cf=typeof Uint8Array<"u"?Uint8Array:Array,jo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(At=0,gl=jo.length;At<gl;++At)Pe[At]=jo[At],me[jo.charCodeAt(At)]=At;var At,gl;me[45]=62;me[95]=63;function wl(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var i=r===e?0:4-r%4;return[r,i]}function df(t){var e=wl(t),r=e[0],i=e[1];return(r+i)*3/4-i}function lf(t,e,r){return(e+r)*3/4-r}function uf(t){var e,r=wl(t),i=r[0],n=r[1],s=new cf(lf(t,i,n)),o=0,d=n>0?i-4:i,l;for(l=0;l<d;l+=4)e=me[t.charCodeAt(l)]<<18|me[t.charCodeAt(l+1)]<<12|me[t.charCodeAt(l+2)]<<6|me[t.charCodeAt(l+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return n===2&&(e=me[t.charCodeAt(l)]<<2|me[t.charCodeAt(l+1)]>>4,s[o++]=e&255),n===1&&(e=me[t.charCodeAt(l)]<<10|me[t.charCodeAt(l+1)]<<4|me[t.charCodeAt(l+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function hf(t){return Pe[t>>18&63]+Pe[t>>12&63]+Pe[t>>6&63]+Pe[t&63]}function ff(t,e,r){for(var i,n=[],s=e;s<r;s+=3)i=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(t[s+2]&255),n.push(hf(i));return n.join("")}function mf(t){for(var e,r=t.length,i=r%3,n=[],s=16383,o=0,d=r-i;o<d;o+=s)n.push(ff(t,o,o+s>d?d:o+s));return i===1?(e=t[r-1],n.push(Pe[e>>2]+Pe[e<<4&63]+"==")):i===2&&(e=(t[r-2]<<8)+t[r-1],n.push(Pe[e>>10]+Pe[e>>4&63]+Pe[e<<2&63]+"=")),n.join("")}});import{OrderResultStatus as ea}from"@devvit/protos/types/devvit/ui/effects/v1alpha/create_order.js";var ta=(i=>(i[i.Cancelled=0]="Cancelled",i[i.Success=1]="Success",i[i.Error=2]="Error",i))(ta||{});function ra(t){switch(t){case ea.STATUS_SUCCESS:return 1;case ea.STATUS_ERROR:return 2;default:return 0}}var ae={APP:0,USER:1};import"@devvit/protos";var C=Object.freeze({Actor:"devvit-actor",App:"devvit-app",AppUser:"devvit-app-user",AppViewerAuthToken:"devvit-app-viewer-authorization",Caller:"devvit-caller",CallerPortID:"devvit-caller-port-id",Canary:"devvit-canary",Debug:"devvit-debug",GQLHost:"devvit-gql-host",Installation:"devvit-installation",ModPermissions:"devvit-mod-permissions",Post:"devvit-post",PostAuthor:"devvit-post-author",R2Auth:"devvit-sec-authorization",R2Host:"devvit-r2-host",RemoteHostname:"devvit-remote-hostname",SettingsUri:"devvit-sec-settings-uri",StreamID:"devvit-stream-id",Subreddit:"devvit-subreddit",SubredditName:"devvit-subreddit-name",TraceID:"devvit-trace-id",User:"devvit-user",Username:"devvit-user-name",UserAgent:"devvit-user-agent",Version:"devvit-version",Language:"devvit-accept-language",Timezone:"devvit-accept-timezone",Traceparent:"traceparent",AppDependencies:"devvit-app-dependencies"}),ia;(function(t){t.Blocks="blocks",t.EmitSnapshots="emitSnapshots",t.EmitState="emitState",t.Realtime="realtime",t.Runtime="runtime",t.Surface="surface",t.UseAsync="useAsync",t.Payments="payments",t.Bootstrap="bootstrap",t.WebView="webView"})(ia||(ia={}));function tt(t,e){if(!t)throw Error(e)}var J;(function(t){t.COMMENT="t1_",t.ACCOUNT="t2_",t.LINK="t3_",t.MESSAGE="t4_",t.SUBREDDIT="t5_",t.AWARD="t6_"})(J||(J={}));function Ht(t){return t.startsWith(J.COMMENT)}function Bi(t){return t.startsWith(J.ACCOUNT)}function Fr(t){return t.startsWith(J.LINK)}function na(t){return t.startsWith(J.MESSAGE)}function sa(t){return t.startsWith(J.SUBREDDIT)}function oa(t){return t.startsWith(J.AWARD)}function Wl(t){tt(Ht(t),`Expected comment id to start with ${J.COMMENT}, got ${t}}`)}function Hl(t){tt(Bi(t),`Expected account id to start with ${J.ACCOUNT}, got ${t}}`)}function jl(t){tt(Fr(t),`Expected link id to start with ${J.LINK}, got ${t}}`)}function Gl(t){tt(na(t),`Expected message id to start with ${J.MESSAGE}, got ${t}}`)}function Vl(t){tt(sa(t),`Expected subreddit id to start with ${J.SUBREDDIT}, got ${t}}`)}function $l(t){tt(oa(t),`Expected award id to start with ${J.AWARD}, got ${t}}`)}function jt(t){return Wl(t),t}function ie(t){return Hl(t),t}function ce(t){return jl(t),t}function zl(t){return Gl(t),t}function ge(t){return Vl(t),t}function Kl(t){return $l(t),t}function Gt(t){if(Ht(t))return jt(t);if(Bi(t))return ie(t);if(Fr(t))return ce(t);if(na(t))return zl(t);if(sa(t))return ge(t);if(oa(t))return Kl(t);throw new Error(`Expected thing id to start with ${Object.values(J).join(", ")} got ${t}}`)}function Ss(t){return Ht(t)}import*as w from"@devvit/protos";var Di=class{constructor(e){}};var rt;(function(t){t.Installation="installation",t.App="app"})(rt||(rt={}));function it(t,e=new Set){for(let r of t){if(r.type==="group"){it(r.fields,e);continue}let i=r.name;if(e.has(i))throw new Error(`Duplicate field name: ${i}`);e.add(i)}ql(t)}function ql(t){for(let e of t)if(e.type==="string"&&e.isSecret&&e.scope!==rt.App)throw`Invalid setting: only app settings can be secrets. Add "scope: SettingScope.App" to field "${e.name}"`}var Le=Object.freeze({INTERVAL:0,FORM:1,STATE:2,CHANNEL:3,WEB_VIEW:4});import{DeletionReason as gp,EventSource as wp}from"@devvit/protos";import{AppSettingsDefinition as vu,GetFieldsResponse as ku}from"@devvit/protos";import{FormFieldType as de}from"@devvit/protos";function Ie(t){return t.map(e=>{switch(e.type){case"string":return Jl(e);case"image":return Zl(e);case"paragraph":return Ql(e);case"number":return Xl(e);case"select":return Yl(e);case"boolean":return eu(e);case"group":return tu(e);default:throw new Error("Unknown field type.")}})}function Jl(t){return{defaultValue:{fieldType:de.STRING,stringValue:t.defaultValue},disabled:t.disabled,fieldConfig:{stringConfig:{placeholder:t.placeholder}},fieldId:t.name,fieldType:de.STRING,helpText:t.helpText,label:t.label,required:t.required,isSecret:t.isSecret}}function Zl(t){return{disabled:t.disabled,fieldId:t.name,fieldType:de.IMAGE,helpText:t.helpText,label:t.label,required:t.required}}function Ql(t){return{defaultValue:{fieldType:de.PARAGRAPH,stringValue:t.defaultValue},disabled:t.disabled,fieldConfig:{paragraphConfig:{lineHeight:t.lineHeight,placeholder:t.placeholder}},fieldId:t.name,fieldType:de.PARAGRAPH,helpText:t.helpText,label:t.label,required:t.required}}function Xl(t){return{defaultValue:{fieldType:de.NUMBER,numberValue:t.defaultValue},disabled:t.disabled,fieldConfig:{numberConfig:{}},fieldId:t.name,fieldType:de.NUMBER,helpText:t.helpText,label:t.label,required:t.required}}function Yl(t){return{defaultValue:{fieldType:de.SELECTION,selectionValue:{values:t.defaultValue??[]}},disabled:t.disabled,fieldConfig:{selectionConfig:{choices:t.options,multiSelect:t.multiSelect}},fieldId:t.name,fieldType:de.SELECTION,helpText:t.helpText,label:t.label,required:t.required}}function eu(t){return{defaultValue:{fieldType:de.BOOLEAN,boolValue:t.defaultValue},disabled:t.disabled,fieldId:t.name,fieldType:de.BOOLEAN,helpText:t.helpText,label:t.label}}function tu(t){return{fieldId:"",fieldType:de.GROUP,fieldConfig:{groupConfig:{fields:Ie(t.fields)}},label:t.label,helpText:t.helpText}}var Oi=function(){try{let{AsyncLocalStorage:t}=Ul("node:async_hooks");return new t}catch{}}(),Ui;function Vt(){if(Oi){let t=Oi.getStore();if(!t)throw Error("API error; metadata should never be accessed outside a request");return t}if(!Ui)throw Error("Devvit metadata can only be accessed within a request");return Ui}async function aa(t,e){if(Oi)return Oi.run(t,e);try{return Ui=t,await e()}finally{Ui=void 0}}function x(t,e){a.prototype[t]=(r,i,...n)=>{let s=i??{};return aa(s,()=>e(r,s,...n))}}import{ValidateFormResponse as bu}from"@devvit/protos";import{RealtimeSubscriptionStatus as ca}from"@devvit/protos";function m(t,e){if(t==null)throw Error(e??"Expected nonnullish value.")}var ne;(function(t){t[t.Unknown=0]="Unknown",t[t.Connecting=1]="Connecting",t[t.Connected=2]="Connected",t[t.Disconnecting=3]="Disconnecting",t[t.Disconnected=4]="Disconnected"})(ne||(ne={}));function da(t){function e(r){let n=t.currentHookIndex,s=t.getCurrentComponentState(),o=t.getPreviousComponentState(),d=t.metadata[C.App]?.values[0];m(d,"useChannel - app is missing from Context");let l=t.metadata[C.Installation]?.values[0];m(l,"useChannel - installation is missing from Context");async function u(D){let oe=s[n].channel;if(s[n].active)if(s[n].connected)await t.realtime.send(oe,D);else throw Error(`Failed to send to channel '${oe}'; it is active but not yet connected`);else throw Error(`Cannot send a message over inactive channel: ${oe}`)}function g(){if(!s[n].active){let D=s[n].channel;s[n].active=!0,t.addRealtimeChannel(D)}}function p(){if(s[n].active){let D=s[n].channel;s[n].active=!1,t.removeRealtimeChannel(D)}}function _(D){return async()=>{let oe;switch(D.status){case ca.REALTIME_SUBSCRIBED:s[n].connected=!0,oe=r.onSubscribed?.();break;case ca.REALTIME_UNSUBSCRIBED:s[n].connected=!1,oe=r.onUnsubscribed?.();break;default:oe=r.onMessage(D.event?.data?.msg);break}await oe}}let I={channel:`${d}:${l}:${r.name}`,active:!1,connected:!1,preventCallback:!1,type:Le.CHANNEL};n in s?I=s[n]:n in o&&(I=o[n]);let T=t.realtimeEvent;t.isInitialRender?I.active=!1:T&&I.active&&T.event.channel===I.channel&&(I.preventCallback||t.runHook(_(T)),t.rerenderIn(0)),s[n]=I,t.currentHookIndex++;let L=ne.Unknown;return I.active&&I.connected?L=ne.Connected:I.active&&!I.connected?L=ne.Connecting:!I.active&&I.connected?L=ne.Disconnecting:!I.active&&!I.connected&&(L=ne.Disconnected),{subscribe:g,unsubscribe:p,send:u,status:L}}return e}import{FormFieldType as $t}from"@devvit/protos";function Ts(t){switch(t.fieldType){case $t.STRING:return t.stringValue;case $t.IMAGE:return t.stringValue;case $t.PARAGRAPH:return t.stringValue;case $t.NUMBER:return t.numberValue;case $t.BOOLEAN:return t.boolValue;case $t.SELECTION:return t.selectionValue?.values??[];default:return}}function We(t){return Object.keys(t).reduce((e,r)=>{let i=Ts(t[r]);return i!==void 0&&(e[r]=i),e},{})}function la(t){function e(r,i){let n=t.currentHookIndex,s=t.getCurrentComponentKey(),o=t.getCurrentComponentState(),d=t.getPreviousComponentState(),l=`form.hook.${s}.${n}`,u={formKey:l,preventSubmit:!1,type:Le.FORM};n in o?u=o[n]:n in d&&(u=d[n]),o[n]=u,t.forms.set(l,r);let g=t.formSubmittedEvent;return g&&!u.preventSubmit&&g.formId===l&&t.runHook(async()=>{let p=i(We(g.results));p&&p instanceof Promise&&await p,t.rerenderIn(0)}),o[n].preventSubmit=!1,t.currentHookIndex++,l}return e}function ua(t){function e(r,i){let n=t.currentHookIndex,s=t.getCurrentComponentState(),o=t.getPreviousComponentState(),d=100,l=Math.max(d,i),u={lastRun:void 0,running:!1,preventCallback:!1,type:Le.INTERVAL};n in s?u=s[n]:n in o&&(u=o[n]);function g(){i<d&&console.error(`useInterval delay must be at least ${d}ms. Your interval of ${i}ms was automatically extended.`);for(let[_,I]of Object.entries(s))if(_!==n.toString()&&I?.type===Le.INTERVAL&&I?.running)throw new Error("Only one useInterval hook may be running at a time");s[n]={running:!0,lastRun:s[n]?.lastRun??Date.now(),preventCallback:!1,type:Le.INTERVAL},t.rerenderIn(l)}function p(){s[n].running=!1,s[n].lastRun=void 0,s[n].preventCallback=!1}return t.isEffectRender&&u.running&&(u.preventCallback||(u.lastRun===void 0||u.lastRun+l<Date.now())&&t.runHook(async()=>{let _=r();_&&_ instanceof Promise&&await _,u.lastRun=Date.now()}),t.rerenderIn(l)),u.preventCallback=!1,s[n]=u,t.currentHookIndex++,{start:g,stop:p}}return e}function ha(t){function e(r){let i=t.currentHookIndex,n=t.getCurrentComponentState(),s=t.getPreviousComponentState();if(i in n)return t.currentHookIndex++,[n[i],o];if(t.isInitialRender||!(i in s)){let d=r instanceof Function?r():r;if(d instanceof Promise)throw(async()=>{n[i]=await d,t.currentHookIndex=0})();n[i]=d}else n[i]=s[i];function o(d){if(t.isRendering)throw new Error("Cannot call setState while rendering.");n[i]=d instanceof Function?d(n[i]):d}return t.currentHookIndex++,[n[i],o]}return e}var Li=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},O=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},le,nt,st,we,Ar,ka,_a,fa,ma,pa,ga,Ms,Ea,Ns={now(){return new Date}};function wa(t){return`__autocache__${t}`}function ya(t){return`__lock__${t}`}var ru=300,iu=1e3,Wi=5e3,Rs=3,ba=.1,va=1e3,nu=3e4;function Ca(t){if(t.error)throw new Error(t.error);return t.value}var Hi=class{constructor(e,r,i=Ns){le.add(this),nt.set(this,void 0),st.set(this,{}),we.set(this,void 0),Ar.set(this,void 0),Li(this,nt,e,"f"),Li(this,Ar,r,"f"),Li(this,we,i,"f")}async cache(e,r){Li(this,st,O(this,Ar,"f").__cache=O(this,Ar,"f").__cache??{},"f"),O(this,le,"m",Ea).call(this,r);let i=O(this,le,"m",ka).call(this,r.key);if(i!==void 0)return i;let n=await O(this,le,"m",Ms).call(this,r.key),s=await O(this,le,"m",_a).call(this,r,n,e);return Ca(s)}};nt=new WeakMap,st=new WeakMap,we=new WeakMap,Ar=new WeakMap,le=new WeakSet,ka=function(e){let r=O(this,st,"f")[e];if(r){let i=O(this,we,"f").now().getTime(),n=r?.error&&r?.errorTime&&r.errorCount<Rs&&Math.random()<ba&&r.errorTime+va<i;if(r?.expires&&r.expires<i&&r.checkedAt+va<i||n){delete O(this,st,"f")[e];return}else return Ca(r)}},_a=async function(e,r,i){let n=r?.expires,s=n?O(this,le,"m",ga).call(this,n):1;return!r||r?.error&&r.errorCount<Rs&&ba>Math.random()||s>Math.random()?O(this,le,"m",fa).call(this,e,r,i):r},fa=async function(e,r,i){let n=ya(e.key),s=O(this,we,"f").now().getTime(),o=new Date(s+e.ttl/2);if(await O(this,nt,"f").set(n,"1",{expiration:o,nx:!0}))return O(this,le,"m",pa).call(this,e.key,r,i,e.ttl);if(r)return r;{let l=O(this,we,"f").now();return O(this,le,"m",ma).call(this,l,e.key,e.ttl)}},ma=async function t(e,r,i){let n=Math.min(i,iu),s=await O(this,le,"m",Ms).call(this,r);if(s)return s;if(O(this,we,"f").now().getTime()-e.getTime()>=n)throw new Error(`Cache request timed out trying to get data at key: ${r}`);return await new Promise(o=>setTimeout(o,ru)),O(this,le,"m",t).call(this,e,r,i)},pa=async function(e,r,i,n){let s=O(this,we,"f").now().getTime()+n;r=r??{value:null,expires:s,errorCount:0,error:null,errorTime:null,checkedAt:0};try{r.value=await i(),r.error=null,r.errorCount=0,r.errorTime=null}catch(o){r.value=null,r.error=o.message??"Unknown error",r.errorTime=O(this,we,"f").now().getTime(),r.errorCount++}return O(this,st,"f")[e]=r,await O(this,nt,"f").set(wa(e),JSON.stringify(r),{expiration:new Date(s+nu)}),r.error&&r.errorCount<Rs&&await O(this,nt,"f").del(ya(e)),r},ga=function(e){let r=O(this,we,"f").now().getTime(),i=e-r;return i<0?1:i<1e3?.1:i<2e3?.01:i<3e3?.001:0},Ms=async function(e){let r=await O(this,nt,"f").get(wa(e));if(r){let i=JSON.parse(r);return i.checkedAt=O(this,we,"f").now().getTime(),O(this,st,"f")[e]=i,i}},Ea=function(e){e.ttl<Wi&&(console.warn(`Cache TTL cannot be less than ${Wi} milliseconds! Updating ttl value of ${e.ttl} to ${Wi}.`),e.ttl=Wi)};function Fa(t,e,r=Ns){let i=new Hi(t,e,r);return i.cache.bind(i)}var Aa=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},zt=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},ji,Pr,Ir,Ia,xa;function Pa(t){new URL(t.slice(0,t.indexOf(",")))}var Kt=class{constructor(){ji.add(this),Pr.set(this,{}),Ir.set(this,{}),Aa(this,Pr,a.assets,"f"),Aa(this,Ir,a.webViewAssets,"f")}getURL(e,r){return typeof e=="string"?zt(this,ji,"m",Ia).call(this,e,r??{webView:!1}):zt(this,ji,"m",xa).call(this,e,r??{webView:!1})}};Pr=new WeakMap,Ir=new WeakMap,ji=new WeakSet,Ia=function(e,r){let i=r.webView?zt(this,Ir,"f")[e]:zt(this,Pr,"f")[e];if(i)return i;try{return Pa(e),e}catch{return""}},xa=function(e,r){let i={},n=[],s=r.webView?zt(this,Ir,"f"):zt(this,Pr,"f");if(s)for(let o of e)if(s[o])i[o]=s[o];else try{Pa(o),i[o]=o}catch{n.push(o)}else n=e;if(n.length>0)throw new Error(`The following assets were missing from the assets list: ${n.join(", ")}`);return i};var su=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},Gi=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},ot,qt=class{constructor(e){ot.set(this,void 0),su(this,ot,e,"f")}async get(e){let{messages:r}=await a.kvStorePlugin.Get({keys:[e]},Gi(this,ot,"f"));try{if(r[e])return JSON.parse(r[e])}catch{return}}async put(e,r){let i={};i[e]=JSON.stringify(r),await a.kvStorePlugin.Put({messages:i},Gi(this,ot,"f"))}async delete(e){await a.kvStorePlugin.Del({keys:[e]},Gi(this,ot,"f"))}async list(){let{keys:e}=await a.kvStorePlugin.List({filter:"*"},Gi(this,ot,"f"));return e}};ot=new WeakMap;var ou=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},au=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Vi,Jt=class{constructor(e){Vi.set(this,void 0),ou(this,Vi,e,"f")}async upload(e){let r=await a.mediaPlugin.Upload(e,au(this,Vi,"f"));if(!r.mediaId)throw new Error("unable to get mediaId via uploads");return Promise.resolve({mediaId:r.mediaId,mediaUrl:r.mediaUrl})}};Vi=new WeakMap;var cu=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},du=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},$i,Zt=class{constructor(e){$i.set(this,void 0),cu(this,$i,e,"f")}async add(e){await a.modLogPlugin.Add(e,du(this,$i,"f"))}};$i=new WeakMap;var lu=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},uu=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},zi,Qt=class{constructor(e){zi.set(this,void 0),lu(this,zi,e,"f")}async send(e,r){await a.realtimePlugin.Send({channel:e,data:{msg:r}},uu(this,zi,"f"))}};zi=new WeakMap;import{BitfieldOverflowBehavior as Bs,RedisKeyScope as Ds}from"@devvit/protos";var Tr=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},c=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},F,A,P,E,Sr;function xr(t){return t&&typeof t=="object"&&"message"in t&&t.message!==void 0&&typeof t.message=="string"?t.message.includes("redis: nil"):!1}var Os=class{constructor(e,r,i){F.set(this,void 0),A.set(this,void 0),P.set(this,void 0),Tr(this,F,e,"f"),Tr(this,A,r,"f"),Tr(this,P,i,"f")}async get(e){return await c(this,F,"f").Get({key:e,transactionId:c(this,A,"f")},c(this,P,"f")),this}async multi(){await c(this,F,"f").Multi(c(this,A,"f"),c(this,P,"f"))}async set(e,r,i){let n;return i?.expiration&&(n=Math.floor((i.expiration.getTime()-Date.now())/1e3),n<1&&(n=1)),await c(this,F,"f").Set({key:e,value:r,nx:i?.nx===!0,xx:i?.xx===!0,expiration:n||0,transactionId:c(this,A,"f")},c(this,P,"f")),this}async del(...e){return await c(this,F,"f").Del({keys:e,transactionId:c(this,A,"f")},c(this,P,"f")),this}async type(e){return await c(this,F,"f").Type({key:e,transactionId:c(this,A,"f")},c(this,P,"f")),this}async exec(){let e=await c(this,F,"f").Exec(c(this,A,"f"),c(this,P,"f")),r=[];for(let i of e.response)i.members?r.push(i.members):i.nil!==void 0?r.push(null):i.num!==void 0?r.push(i.num):i.values!==void 0?r.push(i.values.values):i.str!==void 0?r.push(i.str):i.dbl!==void 0&&r.push(i.dbl);return r}async discard(){await c(this,F,"f").Discard(c(this,A,"f"),c(this,P,"f"))}async watch(...e){return await c(this,F,"f").Watch({keys:e,transactionId:c(this,A,"f")},c(this,P,"f")),this}async unwatch(){return await c(this,F,"f").Unwatch(c(this,A,"f"),c(this,P,"f")),this}async getRange(e,r,i){return await c(this,F,"f").GetRange({key:e,start:r,end:i,transactionId:c(this,A,"f")},c(this,P,"f")),this}async setRange(e,r,i){return await c(this,F,"f").SetRange({key:e,offset:r,value:i,transactionId:c(this,A,"f")},c(this,P,"f")),this}async strlen(e){return this.strLen(e)}async strLen(e){return await c(this,F,"f").Strlen({key:e,transactionId:c(this,A,"f")},c(this,P,"f")),this}async mget(e){return this.mGet(e)}async mGet(e){return await c(this,F,"f").MGet({keys:e,transactionId:c(this,A,"f")},c(this,P,"f")),this}async mset(e){return this.mSet(e)}async mSet(e){let r=Object.entries(e).map(([i,n])=>({key:i,value:n}));return await c(this,F,"f").MSet({kv:r,transactionId:c(this,A,"f")},c(this,P,"f")),this}async incrBy(e,r){return await c(this,F,"f").IncrBy({key:e,value:r,transactionId:c(this,A,"f")},c(this,P,"f")),this}async expire(e,r){return await c(this,F,"f").Expire({key:e,seconds:r,transactionId:c(this,A,"f")},c(this,P,"f")),this}async expireTime(e){return await c(this,F,"f").ExpireTime({key:e,transactionId:c(this,A,"f")},c(this,P,"f")),this}async zAdd(e,...r){return await c(this,F,"f").ZAdd({key:e,members:r,transactionId:c(this,A,"f")},c(this,P,"f")),this}async zScore(e,r){return await c(this,F,"f").ZScore({key:{key:e,transactionId:c(this,A,"f")},member:r},c(this,P,"f")),this}async zRank(e,r){return await c(this,F,"f").ZRank({key:{key:e,transactionId:c(this,A,"f")},member:r},c(this,P,"f")),this}async zIncrBy(e,r,i){return await c(this,F,"f").ZIncrBy({key:e,member:r,value:i,transactionId:c(this,A,"f")},c(this,P,"f")),this}async zScan(e,r,i,n){let s={key:e,cursor:r,pattern:i,count:n,transactionId:c(this,A,"f")};return await c(this,F,"f").ZScan(s,c(this,P,"f")),this}async zCard(e){return await c(this,F,"f").ZCard({key:e,transactionId:c(this,A,"f")},c(this,P,"f")),this}async zRange(e,r,i,n){let s={rev:!1,byLex:!1,byScore:!1,offset:0,count:1e3};if(n?.reverse&&(s.rev=n.reverse),n?.by==="lex"?s.byLex=!0:n?.by==="score"&&(s.byScore=!0),n?.limit)if(s.byLex||s.byScore)s.offset=n.limit.offset,s.count=n.limit.count;else throw new Error("zRange parsing error: 'limit' only allowed when 'options.by' is 'lex' or 'score'");return await c(this,F,"f").ZRange({key:{key:e,transactionId:c(this,A,"f")},start:r+"",stop:i+"",...s},c(this,P,"f")),this}async zRem(e,r){return await c(this,F,"f").ZRem({key:{key:e,transactionId:c(this,A,"f")},members:r},c(this,P,"f")),this}async zRemRangeByLex(e,r,i){return await c(this,F,"f").ZRemRangeByLex({key:{key:e,transactionId:c(this,A,"f")},min:r,max:i},c(this,P,"f")),this}async zRemRangeByRank(e,r,i){return await c(this,F,"f").ZRemRangeByRank({key:{key:e,transactionId:c(this,A,"f")},start:r,stop:i},c(this,P,"f")),this}async zRemRangeByScore(e,r,i){return await c(this,F,"f").ZRemRangeByScore({key:{key:e,transactionId:c(this,A,"f")},min:r,max:i},c(this,P,"f")),this}async hgetall(e){return this.hGetAll(e)}async hGetAll(e){return await c(this,F,"f").HGetAll({key:e,transactionId:c(this,A,"f")},c(this,P,"f")),this}async hget(e,r){return this.hGet(e,r)}async hGet(e,r){return await c(this,F,"f").HGet({key:e,field:r,transactionId:c(this,A,"f")},c(this,P,"f")),this}async hMGet(e,r){return await c(this,F,"f").HMGet({key:e,fields:r,transactionId:c(this,A,"f")},c(this,P,"f")),this}async hset(e,r){return this.hSet(e,r)}async hSet(e,r){let i=Object.entries(r).map(([n,s])=>({field:n,value:s}));return await c(this,F,"f").HSet({key:e,fv:i,transactionId:c(this,A,"f")},c(this,P,"f")),this}async hincrby(e,r,i){return this.hIncrBy(e,r,i)}async hIncrBy(e,r,i){return await c(this,F,"f").HIncrBy({key:e,field:r,value:i,transactionId:c(this,A,"f")},c(this,P,"f")),this}async hdel(e,r){return this.hDel(e,r)}async hDel(e,r){return await c(this,F,"f").HDel({key:e,fields:r,transactionId:c(this,A,"f")},c(this,P,"f")),this}async hscan(e,r,i,n){return this.hScan(e,r,i,n)}async hScan(e,r,i,n){let s={key:e,cursor:r,pattern:i,count:n,transactionId:c(this,A,"f")};return await c(this,F,"f").HScan(s,c(this,P,"f")),this}async hkeys(e){return this.hKeys(e)}async hKeys(e){return await c(this,F,"f").HKeys({key:e,transactionId:c(this,A,"f")},c(this,P,"f")),this}async hlen(e){return this.hLen(e)}async hLen(e){return await c(this,F,"f").HLen({key:e,transactionId:c(this,A,"f")},c(this,P,"f")),this}};F=new WeakMap,A=new WeakMap,P=new WeakMap;var Xt=class t{constructor(e,r=void 0,i=Ds.INSTALLATION){E.set(this,void 0),Sr.set(this,void 0),Tr(this,E,e,"f"),Tr(this,Sr,r,"f"),this.scope=i,this.global=i===Ds.INSTALLATION?new t(c(this,E,"f"),c(this,Sr,"f"),Ds.GLOBAL):this}get storage(){return c(this,Sr,"f")||a.redisPlugin}async watch(...e){let r=await this.storage.Watch({keys:e},c(this,E,"f"));return new Os(this.storage,r,c(this,E,"f"))}async get(e){try{let r=await this.storage.Get({key:e,scope:this.scope},{...c(this,E,"f"),"throw-redis-nil":{values:["true"]}});return r!==null?r.value??void 0:r}catch(r){if(xr(r))return;throw r}}async getBuffer(e){try{let r=await this.storage.GetBytes({key:e,scope:this.scope},{...c(this,E,"f"),"throw-redis-nil":{values:["true"]}});return r!==null?Buffer.from(r.value):r}catch(r){if(xr(r))return;throw r}}async set(e,r,i){let n;return i?.expiration&&(n=Math.floor((i.expiration.getTime()-Date.now())/1e3),n<1&&(n=1)),(await this.storage.Set({key:e,value:r,nx:i?.nx===!0&&!i.xx,xx:i?.xx===!0&&!i.nx,expiration:n||0,scope:this.scope},c(this,E,"f"))).value}async exists(...e){return(await this.storage.Exists({keys:e,scope:this.scope},c(this,E,"f"))).existingKeys}async del(...e){await this.storage.Del({keys:e,scope:this.scope},c(this,E,"f"))}async incrBy(e,r){return(await this.storage.IncrBy({key:e,value:r,scope:this.scope},c(this,E,"f"))).value}async getRange(e,r,i){let n=await this.storage.GetRange({key:e,start:r,end:i,scope:this.scope},c(this,E,"f"));return n!==null?n.value:n}async setRange(e,r,i){return(await this.storage.SetRange({key:e,offset:r,value:i,scope:this.scope},c(this,E,"f"))).value}async strlen(e){return this.strLen(e)}async strLen(e){return(await this.storage.Strlen({key:e,scope:this.scope},c(this,E,"f"))).value}async expire(e,r){await this.storage.Expire({key:e,seconds:r,scope:this.scope},c(this,E,"f"))}async expireTime(e){return(await this.storage.ExpireTime({key:e,scope:this.scope},c(this,E,"f"))).value}async zAdd(e,...r){return(await this.storage.ZAdd({key:e,members:r,scope:this.scope},c(this,E,"f"))).value}async zRange(e,r,i,n){let s={rev:!1,byLex:!1,byScore:!1,offset:0,count:1e3};if(n?.reverse&&(s.rev=n.reverse),n?.by==="lex"?s.byLex=!0:n?.by==="score"?s.byScore=!0:(s.offset=0,s.count=0),n?.limit)if(s.byLex||s.byScore)s.offset=n.limit.offset,s.count=n.limit.count;else throw new Error("zRange parsing error: 'limit' only allowed when 'options.by' is 'lex' or 'score'");return(await this.storage.ZRange({key:{key:e},start:r+"",stop:i+"",...s,scope:this.scope},c(this,E,"f"))).members}async zRem(e,r){return(await this.storage.ZRem({key:{key:e},members:r,scope:this.scope},c(this,E,"f"))).value}async zRemRangeByLex(e,r,i){return(await this.storage.ZRemRangeByLex({key:{key:e},min:r,max:i,scope:this.scope},c(this,E,"f"))).value}async zRemRangeByRank(e,r,i){return(await this.storage.ZRemRangeByRank({key:{key:e},start:r,stop:i,scope:this.scope},c(this,E,"f"))).value}async zRemRangeByScore(e,r,i){return(await this.storage.ZRemRangeByScore({key:{key:e},min:r,max:i,scope:this.scope},c(this,E,"f"))).value}async zScore(e,r){try{let i=await this.storage.ZScore({key:{key:e},member:r,scope:this.scope},{...c(this,E,"f"),"throw-redis-nil":{values:["true"]}});return i!==null?i.value:i}catch(i){if(xr(i))return;throw i}}async zRank(e,r){try{let i=await this.storage.ZRank({key:{key:e},member:r,scope:this.scope},{...c(this,E,"f"),"throw-redis-nil":{values:["true"]}});return i!==null?i.value:i}catch(i){if(xr(i))return;throw i}}async zIncrBy(e,r,i){let n=await this.storage.ZIncrBy({key:e,member:r,value:i,scope:this.scope},c(this,E,"f"));return n!==null?n.value:n}async mget(e){return this.mGet(e)}async mGet(e){let r=await this.storage.MGet({keys:e,scope:this.scope},c(this,E,"f"));return r!==null?r.values.map(i=>i||null):r}async mset(e){return this.mSet(e)}async mSet(e){let r=Object.entries(e).map(([i,n])=>({key:i,value:n}));await this.storage.MSet({kv:r,scope:this.scope},c(this,E,"f"))}async zCard(e){let r=await this.storage.ZCard({key:e,scope:this.scope},c(this,E,"f"));return r!==null?r.value:r}async zScan(e,r,i,n){let s={key:e,cursor:r,pattern:i,count:n,scope:this.scope};return await this.storage.ZScan(s,c(this,E,"f"))}async type(e){let r=await this.storage.Type({key:e,scope:this.scope},c(this,E,"f"));return r!==null?r.value:r}async rename(e,r){return(await this.storage.Rename({key:e,newKey:r,scope:this.scope},c(this,E,"f"))).result}async hget(e,r){return this.hGet(e,r)}async hGet(e,r){try{let i=await this.storage.HGet({key:e,field:r,scope:this.scope},{...c(this,E,"f"),"throw-redis-nil":{values:["true"]}});return i!==null?i.value??void 0:i}catch(i){if(xr(i))return;throw i}}async hMGet(e,r){let i=await this.storage.HMGet({key:e,fields:r,scope:this.scope},c(this,E,"f"));return i!==null?i.values.map(n=>n||null):i}async hset(e,r){return this.hSet(e,r)}async hSet(e,r){let i=Object.entries(r).map(([s,o])=>({field:s,value:o}));return(await this.storage.HSet({key:e,fv:i,scope:this.scope},c(this,E,"f"))).value}async hSetNX(e,r,i){return(await this.storage.HSetNX({key:e,field:r,value:i,scope:this.scope},c(this,E,"f"))).success}async hgetall(e){return this.hGetAll(e)}async hGetAll(e){let r=await this.storage.HGetAll({key:e,scope:this.scope},c(this,E,"f"));return r!==null?r.fieldValues:r}async hdel(e,r){return this.hDel(e,r)}async hDel(e,r){return(await this.storage.HDel({key:e,fields:r,scope:this.scope},c(this,E,"f"))).value}async hscan(e,r,i,n){return this.hScan(e,r,i,n)}async hScan(e,r,i,n){let s={key:e,cursor:r,pattern:i,count:n,scope:this.scope};return await this.storage.HScan(s,c(this,E,"f"))}async hkeys(e){return this.hKeys(e)}async hKeys(e){let r=await this.storage.HKeys({key:e,scope:this.scope},c(this,E,"f"));return r!==null?r.keys:r}async hincrby(e,r,i){return this.hIncrBy(e,r,i)}async hIncrBy(e,r,i){return(await this.storage.HIncrBy({key:e,field:r,value:i,scope:this.scope},c(this,E,"f"))).value}async hlen(e){return this.hLen(e)}async hLen(e){return(await this.storage.HLen({key:e,scope:this.scope})).value}async bitfield(e,...r){let i=[];for(let s=0;s<r.length;){let o=r[s],d={};switch(o){case"get":{if(s+2>=r.length)throw Error("bitfield command parse failed; not enough arguments for 'get' command");d.get={encoding:r[s+1],offset:r[s+2].toString()},s+=3;break}case"set":{if(s+3>=r.length)throw Error("bitfield command parse failed; not enough arguments for 'set' command");d.set={encoding:r[s+1],offset:r[s+2].toString(),value:r[s+3].toString()},s+=4;break}case"incrBy":{if(s+3>=r.length)throw Error("bitfield command parse failed; not enough arguments for 'incrBy' command");d.incrBy={encoding:r[s+1],offset:r[s+2].toString(),increment:r[s+3].toString()},s+=4;break}case"overflow":{if(s+1>=r.length)throw Error("bitfield command parse failed; not enough arguments for 'overflow' command");let l=r[s+1].toString();d.overflow={behavior:hu(l)},s+=2;break}default:throw Error(`bitfield command parse failed; ${o} unrecognized (must be 'get', 'set', 'incrBy', or 'overflow')`)}i.push(d)}return(await this.storage.Bitfield({key:e,commands:i})).results}};E=new WeakMap,Sr=new WeakMap;function hu(t){let e=t.toLowerCase();switch(e){case"wrap":return Bs.BITFIELD_OVERFLOW_BEHAVIOR_WRAP;case"sat":return Bs.BITFIELD_OVERFLOW_BEHAVIOR_SAT;case"fail":return Bs.BITFIELD_OVERFLOW_BEHAVIOR_FAIL;default:throw Error(`unknown bitfield overflow behavior: ${e}`)}}var fu=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},Us=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Yt,er=class{constructor(e){Yt.set(this,void 0),fu(this,Yt,e,"f")}async runJob(e){return(await a.schedulerPlugin.Schedule({action:{type:e.name,data:e.data},cron:"cron"in e?e.cron:void 0,when:"runAt"in e?e.runAt:void 0},Us(this,Yt,"f"))).id}async cancelJob(e){await a.schedulerPlugin.Cancel({id:e},Us(this,Yt,"f"))}async listJobs(){return(await a.schedulerPlugin.List({after:new Date(0),before:new Date(Date.now()+31536e7)},Us(this,Yt,"f"))).actions.map(r=>(m(r.request?.action,"Scheduled job is malformed"),"when"in r.request&&r.request.when!=null?{id:r.id,name:r.request.action.type,runAt:r.request.when,data:r.request.action.data}:{id:r.id,name:r.request.action.type,cron:r.request.cron??"",data:r.request.action}))}};Yt=new WeakMap;import{FormFieldType as Ki}from"@devvit/protos";var mu=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},pu=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},qi,tr=class{constructor(e){qi.set(this,void 0),mu(this,qi,e,"f")}async get(e){return(await this.getAll())[e]}async getAll(){let r=await a.settingsPlugin.GetSettings({},pu(this,qi,"f"));if(!r.installationSettings)throw new Error("Could not get installation settings");if(!r.appSettings)throw new Error("Could not get app settings");return gu(r),{...Sa(r.installationSettings.settings,a.installationSettings),...Sa(r.appSettings.settings,a.appSettings)}}};qi=new WeakMap;function gu(t){if(!t.appSettings)throw new Error("Could not get app settings");for(let[e,r]of Object.entries(t.appSettings.settings)){let i=a.appSettings?.find(n=>n.type!=="group"&&n.name===e);i&&(i.type==="boolean"&&r.fieldType===Ki.STRING&&r.boolValue==null&&r.stringValue!=null?(r.fieldType=Ki.BOOLEAN,r.boolValue=!!r.stringValue,delete r.stringValue):i.type==="number"&&r.fieldType===Ki.STRING&&r.numberValue==null&&r.stringValue!=null&&(r.fieldType=Ki.NUMBER,r.numberValue=Number(r.stringValue),delete r.stringValue))}}function Sa(t,e){let r=Object.keys(t).reduce((i,n)=>(i[n]=Ts(t[n]),i),{});return e&&Ta(r,e),r}function Ta(t,e){for(let r of e)r.type==="group"?Ta(t,r.fields):!(r.name in t)&&"defaultValue"in r&&(t[r.name]=r.defaultValue)}import{EffectType as Ji,ToastAppearance as Ma}from"@devvit/protos";var Ra=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},xe=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},at,Rr,Zi,Ls,Qi=class{constructor(e){at.set(this,[]),Rr.set(this,void 0),Zi.set(this,void 0),Ls.set(this,(r,i)=>{let n=i!==void 0?r:"",s=i!==void 0?i:r;xe(this,at,"f").push({type:Ji.EFFECT_WEB_VIEW,webView:{postMessage:{webViewId:n,app:{message:s}}}})}),Ra(this,Rr,e,"f"),Ra(this,Zi,{postMessage:xe(this,Ls,"f")},"f")}get webView(){return xe(this,Zi,"f")}showForm(e,r){let i=a.formDefinitions.get(e);if(!i&&xe(this,Rr,"f")){let o=xe(this,Rr,"f").forms.get(e);o&&(i={form:o,onSubmit:()=>{}})}if(!i)throw new Error("Form does not exist. Make sure you have added it using Devvit.createForm at the root of your app.");let n=i.form instanceof Function?i.form(r??{}):i.form,s={fields:[],id:e,title:n.title,acceptLabel:n.acceptLabel,cancelLabel:n.cancelLabel,shortDescription:n.description};it(n.fields),s.fields=Ie(n.fields),xe(this,at,"f").push({type:Ji.EFFECT_SHOW_FORM,showForm:{form:s}})}showToast(e){let r;e instanceof Object?r={text:e.text,appearance:e.appearance==="success"?Ma.SUCCESS:Ma.NEUTRAL}:r={text:e},xe(this,at,"f").push({type:Ji.EFFECT_SHOW_TOAST,showToast:{toast:r}})}navigateTo(e){let r;typeof e=="string"?r=new URL(e).toString():r=new URL(e.permalink,"https://www.reddit.com").toString(),xe(this,at,"f").push({type:Ji.EFFECT_NAVIGATE_TO_URL,navigateToUrl:{url:r}})}get __effects(){return xe(this,at,"f")}};at=new WeakMap,Rr=new WeakMap,Zi=new WeakMap,Ls=new WeakMap;function Z({metadata:t,ui:e,hooks:r,reconciler:i}){let n=new Zt(t),s=new qt(t),o=new Xt(t),d=Fa(o,i?i.state:{}),l=new er(t),u=new tr(t),g=e?new Qi(i):void 0,p=new Jt(t),_=new Kt,I=new Qt(t),T=r&&i?ha(i):void 0,L=r&&i?ua(i):void 0,D=r&&i?la(i):void 0,oe=r&&i?da(i):void 0;return{modLog:n,kvStore:s,redis:o,scheduler:l,settings:u,media:p,assets:_,realtime:I,get useForm(){return D??(()=>{throw new Error("useForm() is unavailable")})},get cache(){return d??(()=>{throw new Error("cache() is unavailable")})},get useState(){return T??(()=>{throw new Error("useState() is unavailable")})},get useInterval(){return L??(()=>{throw new Error("useInterval() is unavailable")})},get useChannel(){return oe??(()=>{throw new Error("useChannel() is unavailable")})},get ui(){if(!g)throw new Error("ui client is not available");return g}}}var Na={name:"@devvit/public-api",version:"0.12.0-dev",license:"BSD-3-Clause",repository:{type:"git",url:"https://developers.reddit.com/"},type:"module",exports:{".":"./dist/index.js","./package.json":"./package.json","./*":"./dist/*"},main:"./dist/index.js",files:["dist/**"],scripts:{build:"yarn build:icon-types && yarn build:semantic-colors && tsc && cp -af devvit.tsconfig.json dist/ && yarn build:types && yarn build:min && yarn build:unmin","build:icon-types":"make-icons src/types/icons.ts","build:min":"esbuild --bundle --sourcemap=linked --target=es2020 --format=esm --metafile=dist/meta.min.json --outfile=dist/public-api.min.js --external:@devvit/protos --minify src/index.ts","build:semantic-colors":"node scripts/make-semantic-colors.js","build:types":"api-extractor run && sed -ne '/declare global {/,$ p' src/devvit/Devvit.ts >> dist/public-api.d.ts","build:unmin":"esbuild --bundle --sourcemap=inline --target=es2020 --format=iife --metafile=dist/meta.json --outfile=dist/public-api.iife.js --global-name=devvitPublicAPI src/index.ts",clean:"rm -rf .turbo api-extractor coverage dist src/devvit/internals/semanticColors.ts src/types/icons.ts || :",clobber:"yarn clean && rm -rf node_modules",dev:"tsc -w","dev:build":"chokidar ./src ../shared-types/dist --command 'yarn build' --ignore './src/types/icons.ts' --ignore './src/devvit/internals/semanticColors.ts'",lint:"redlint .","lint:fix":"yarn lint --fix",prepublishOnly:"publish-package-json",test:"yarn test:unit && yarn test:types && yarn test:size","test:size":"filesize","test:types":"tsc --noEmit","test:unit":"vitest run","test:unit-with-coverage":"vitest run --coverage"},types:"./dist/index.d.ts",dependencies:{"@devvit/metrics":"0.12.0-dev","@devvit/protos":"0.12.0-dev","@devvit/shared-types":"0.12.0-dev","base64-js":"1.5.1","clone-deep":"4.0.1",moderndash:"4.0.0"},devDependencies:{"@ampproject/filesize":"4.3.0","@devvit/repo-tools":"0.12.0-dev","@devvit/tsconfig":"0.12.0-dev","@microsoft/api-extractor":"7.41.0","@reddit/faceplate-ui":"18.0.1","@types/clone-deep":"4.0.1","@vitest/coverage-c8":"0.32.0","chokidar-cli":"3.0.0",esbuild:"0.23.0",eslint:"9.11.1",typescript:"5.3.2",vitest:"1.6.0"},publishConfig:{directory:"dist"},filesize:{"dist/public-api.min.js":{gzip:"62 KB",none:"218 KB"}},source:"./src/index.ts"};function z(t,e,r){let i=t[C.Subreddit]?.values[0];m(i,"subreddit is missing from Context");let n=t[C.SubredditName]?.values[0],s=t[C.AppUser]?.values[0],o=t[C.App]?.values[0],d=t[C.Version]?.values[0],l=t[C.User]?.values[0],u=yu(t);return{get appAccountId(){return m(s,"appAccountId is missing from Context"),s},subredditId:i,subredditName:n,userId:l,postId:e,commentId:r,appName:o,appVersion:d,debug:u,metadata:t,toJSON(){return{appAccountId:s,appName:o,appVersion:d,subredditId:i,subredditName:n,userId:l,postId:e,commentId:r,debug:u,metadata:t}}}}function yu(t){var e;let r={blocks:void 0,emitSnapshots:void 0,emitState:void 0,realtime:void 0,runtime:void 0,surface:void 0,useAsync:void 0,payments:void 0,bootstrap:void 0,webView:void 0},i={};for(let s in r)i[s.toLowerCase()]=s;let n={};for(let s of(t[C.Debug]?.values??[]).join().split(",")){let[o,d]=s.split("=");o&&(o=o.trim(),d=d?.trim(),o.toLowerCase()in i&&(o=i[o.toLowerCase()]),n[e=o]??(n[e]=d||"true"))}return t[C.Debug]&&console.info(`[api] @devvit/public-api v${Na.version} ${Object.entries(n).map(([s,o])=>`${s}=${o}`).join(" ")}`),{...n}}function Ba(t){return t.flatMap(e=>e.type==="group"?Ba(e.fields):e)}async function Xi(t,e,r){if(!e)throw new Error("Settings were not defined.");let i={success:!0,errors:{}},n=We(t.fieldValues),s=Ba(e);return await Promise.all(s.map(async o=>{let d=o.name;if(d&&o.onValidate){let l=n[d],u=o.onValidate,g=Object.assign(Z({metadata:r}),z(r)),p=await u({value:l,isEditing:t.editing},g);p&&(i.success=!1,i.errors[d]=p)}})),bu.fromJSON(i)}async function _u(){if(!a.appSettings)throw new Error("App settings were not defined.");return ku.fromJSON({fields:{fields:Ie(a.appSettings)}})}async function Eu(t,e){return Xi(t,a.appSettings,e)}function Da(t){t.provides(vu),x("GetAppSettingsFields",_u),x("ValidateAppForm",Eu)}import{CustomPostDefinition as Mu,RenderPostResponse as Nu}from"@devvit/protos";import{BlockRenderEventType as Ys,EffectType as Qa}from"@devvit/protos";function rr(t){return t.__effects}function Oa(){let t=new Set;return e=>{let r=e,i=1;for(;t.has(r);)r=`${e}.${i++}`;return t.add(r),r}}import{BlockActionType as Xs,BlockAvatarBackground as Ka,BlockAvatarFacing as qa,BlockAvatarSize as He,BlockBorderWidth as rn,BlockButtonAppearance as je,BlockButtonSize as Vs,BlockGap as nn,BlockHorizontalAlignment as $s,BlockIconSize as sn,BlockImageResizeMode as Mr,BlockPadding as Nr,BlockRadius as Br,BlockSpacerShape as zs,BlockSpacerSize as on,BlockStackDirection as Ks,BlockTextOutline as qs,BlockTextOverflow as Js,BlockTextSize as nr,BlockTextStyle as Zs,BlockTextWeight as Ja,BlockType as Ee,BlockVerticalAlignment as Qs}from"@devvit/protos";var Ws={"alienblue-100":"#DCE2FB","alienblue-200":"#B8C5FC","alienblue-25":"#F7F8FD","alienblue-300":"#90A9FD","alienblue-400":"#648EFC","alienblue-50":"#EEF0FB","alienblue-500":"#1870F4","alienblue-600":"#115BCA","alienblue-700":"#0A449B","alienblue-75":"#E6E9FB","alienblue-800":"#0A2F6C","alienblue-900":"#0A1A3F","alienblue-950":"#07102B","berrypurple-100":"#F3DAFB","berrypurple-200":"#EAB3FD","berrypurple-25":"#FBF6FD","berrypurple-300":"#DE8BFF","berrypurple-400":"#CF5FFF","berrypurple-50":"#F8EDFC","berrypurple-500":"#BC0EFF","berrypurple-600":"#9B00D4","berrypurple-700":"#7600A3","berrypurple-75":"#F6E4FB","berrypurple-800":"#520472","berrypurple-900":"#300643","berrypurple-950":"#20042A",black:"#000000","black-opacity-0":"#00000000","black-opacity-10":"#00000019","black-opacity-15":"#00000026","black-opacity-20":"#00000033","black-opacity-25":"#0000003F","black-opacity-33":"#00000054","black-opacity-5":"#0000000C","black-opacity-50":"#0000007F","black-opacity-60":"#00000099","black-opacity-67":"#000000AA","black-opacity-80":"#000000CC","black-opacity-90":"#000000E5","brown-100":"#F1DFCF","brown-200":"#E9BE95","brown-25":"#FBF7F4","brown-300":"#DC9D5D","brown-400":"#BA854E","brown-50":"#F7EFE9","brown-500":"#9A6D3F","brown-600":"#7B5631","brown-700":"#5D4023","brown-75":"#F4E7DC","brown-800":"#3F2C19","brown-900":"#221A11","brown-950":"#15100A","coolgray-100":"#DBE4E9","coolgray-150":"#C9D7DE","coolgray-200":"#B7CAD4","coolgray-25":"#F6F8F9","coolgray-250":"#A4BDCA","coolgray-300":"#97AFBC","coolgray-350":"#8BA2AD","coolgray-400":"#7F949F","coolgray-450":"#748791","coolgray-50":"#EEF1F3","coolgray-500":"#667780","coolgray-525":"#576F76","coolgray-550":"#5C6C74","coolgray-600":"#536168","coolgray-650":"#48545B","coolgray-700":"#3D494E","coolgray-75":"#E5EBEE","coolgray-750":"#333D42","coolgray-800":"#2A3236","coolgray-850":"#21272A","coolgray-900":"#181C1F","coolgray-950":"#0E1113","global-black":{light:"#000000",dark:"#000000"},"global-brand-orangered":{light:"#FF4500",dark:"#FF4500"},"global-white":{light:"#FFFFFF",dark:"#FFFFFF"},"kiwigreen-100":"#A8F5A0","kiwigreen-200":"#58E15B","kiwigreen-25":"#EBFDE7","kiwigreen-300":"#00C61C","kiwigreen-400":"#01A816","kiwigreen-50":"#DDF8D7","kiwigreen-500":"#008A10","kiwigreen-600":"#016E0B","kiwigreen-700":"#005306","kiwigreen-75":"#CAF5C2","kiwigreen-800":"#033902","kiwigreen-900":"#0D2005","kiwigreen-950":"#081404","lightblue-100":"#CAE7FB","lightblue-200":"#87D0FD","lightblue-25":"#F3F9FD","lightblue-300":"#02B9FB","lightblue-400":"#029DD5","lightblue-50":"#E6F3FC","lightblue-500":"#007FAE","lightblue-600":"#01668D","lightblue-700":"#014D6B","lightblue-75":"#D9EDFB","lightblue-800":"#03354B","lightblue-900":"#051E2B","lightblue-950":"#04131A","lime-100":"#B7F28E","lime-200":"#90DA58","lime-25":"#EEFDDC","lime-300":"#6DBF01","lime-400":"#5BA200","lime-50":"#E0F8C8","lime-500":"#4A8500","lime-600":"#3A6A00","lime-700":"#2A5000","lime-75":"#CEF5AD","lime-800":"#1E3702","lime-900":"#151E05","lime-950":"#0D1304","mintgreen-100":"#9BF5D9","mintgreen-200":"#00E2B7","mintgreen-25":"#E7FDF5","mintgreen-300":"#00C29D","mintgreen-400":"#01A484","mintgreen-50":"#D7F8EC","mintgreen-500":"#01876D","mintgreen-600":"#006C56","mintgreen-700":"#015140","mintgreen-75":"#C0F5E3","mintgreen-800":"#00382B","mintgreen-900":"#032019","mintgreen-950":"#03140F","orangered-100":"#FCDBCF","orangered-200":"#FDB498","orangered-25":"#FDF6F4","orangered-300":"#FF895D","orangered-400":"#FF4500","orangered-50":"#FCEEE8","orangered-500":"#D93900","orangered-600":"#AE2C00","orangered-700":"#842100","orangered-75":"#FBE5DC","orangered-800":"#591B02","orangered-900":"#2F1405","orangered-950":"#1C0D04","periwinkle-100":"#E6DFFB","periwinkle-200":"#CDBEFD","periwinkle-25":"#F9F7FD","periwinkle-300":"#B29FFF","periwinkle-400":"#9580FF","periwinkle-50":"#F2EFFC","periwinkle-500":"#6A5CFF","periwinkle-600":"#523DFF","periwinkle-700":"#4001EA","periwinkle-75":"#ECE7FB","periwinkle-800":"#250AA6","periwinkle-900":"#160E5B","periwinkle-950":"#0C083F","poopbrown-100":"#FEEEDD","poopbrown-200":"#F6DDC3","poopbrown-300":"#EECCAA","poopbrown-400":"#CAA075","poopbrown-50":"#FEF7EE","poopbrown-500":"#9A6D3F","poopbrown-600":"#6E4924","poopbrown-700":"#54371A","poopbrown-800":"#3B2510","poopbrown-900":"#29190A","poopbrown-950":"#110B04","puregray-100":"#F2F2F2","puregray-150":"#EBEBEB","puregray-200":"#E4E4E4","puregray-250":"#DDDDDD","puregray-300":"#D6D6D6","puregray-350":"#C3C3C3","puregray-400":"#ACACAC","puregray-450":"#919191","puregray-50":"#F8F8F8","puregray-500":"#767676","puregray-550":"#5C5C5C","puregray-600":"#434343","puregray-650":"#393939","puregray-700":"#303030","puregray-750":"#272727","puregray-800":"#1E1E1E","puregray-850":"#181818","puregray-900":"#131313","puregray-950":"#080808","red-100":"#FBDBD4","red-200":"#FDB3A4","red-25":"#FDF6F5","red-300":"#FF8773","red-400":"#FF4F40","red-50":"#FCEEEA","red-500":"#EB001F","red-600":"#BC0117","red-700":"#90000F","red-75":"#FBE4DF","red-800":"#650405","red-900":"#340F05","red-950":"#1F0B04","sakurapink-100":"#FBD9EB","sakurapink-200":"#FDAEDA","sakurapink-25":"#FDF6F9","sakurapink-300":"#FF7ECA","sakurapink-400":"#FF38BB","sakurapink-50":"#FCEDF4","sakurapink-500":"#DE019F","sakurapink-600":"#B2007F","sakurapink-700":"#880060","sakurapink-75":"#FBE3EF","sakurapink-800":"#5F0443","sakurapink-900":"#380626","sakurapink-950":"#250419",transparent:"transparent",white:"#ffffff","white-opacity-0":"#FFFFFF00","white-opacity-10":"#FFFFFF19","white-opacity-15":"#FFFFFF26","white-opacity-20":"#FFFFFF33","white-opacity-25":"#FFFFFF3F","white-opacity-5":"#FFFFFF0C","white-opacity-50":"#FFFFFF7F","yellow-100":"#FFE284","yellow-200":"#FFBF0B","yellow-25":"#FFF9E0","yellow-300":"#D8A100","yellow-400":"#B78800","yellow-50":"#FFF3C0","yellow-500":"#977000","yellow-600":"#785800","yellow-700":"#5B4200","yellow-75":"#FFEAA2","yellow-800":"#3F2D00","yellow-900":"#231A03","yellow-950":"#161003","yelloworange-100":"#FCDCC8","yelloworange-200":"#FDB586","yelloworange-25":"#FDF7F3","yelloworange-300":"#FF8A35","yelloworange-400":"#E46C00","yelloworange-50":"#FCEEE6","yelloworange-500":"#BD5800","yelloworange-600":"#974500","yelloworange-700":"#733300","yelloworange-75":"#FBE5D7","yelloworange-800":"#4E2402","yelloworange-900":"#2A1705","yelloworange-950":"#1A0E04","action-downvote":{light:"#6A5CFF",dark:"#6A5CFF"},"action-upvote":{light:"#D93900",dark:"#D93900"},"ai-background-weaker":{light:"#E7FDF5",dark:"#00382B"},"ai-plain":{light:"#006C56",dark:"#01A484"},"ai-plain-hover":{light:"#015140",dark:"#00C29D"},"alert-caution":{light:"#977000",dark:"#977000"},"avatar-gradient":{light:"",dark:""},"brand-background":{light:"#D93900",dark:"#D93900"},"brand-background-hover":{light:"#AE2C00",dark:"#AE2C00"},"brand-gradient-active":{light:"",dark:""},"brand-gradient-active-highlight":{light:"",dark:""},"brand-gradient-default":{light:"",dark:""},"brand-gradient-default-highlight":{light:"",dark:""},"brand-gradient-hover":{light:"",dark:""},"brand-gradient-hover-highlight":{light:"",dark:""},"brand-onBackground":{light:"#FFFFFF",dark:"#FFFFFF"},"category-live":{light:"#D93900",dark:"#D93900"},"category-nsfw":{light:"#DE019F",dark:"#DE019F"},"category-spoiler":{light:"#131313",dark:"#F2F2F2"},"caution-background":{light:"#FFBF0B",dark:"#D8A100"},"caution-background-hover":{light:"#D8A100",dark:"#FFBF0B"},"caution-onBackground":{light:"#000000",dark:"#000000"},"caution-plain":{light:"#785800",dark:"#FFBF0B"},"caution-plain-hover":{light:"#5B4200",dark:"#FFE284"},"danger-background":{light:"#EB001F",dark:"#BC0117"},"danger-background-disabled":{light:"#FDB3A4",dark:"#340F05"},"danger-background-hover":{light:"#BC0117",dark:"#EB001F"},"danger-background-weaker":{light:"#FBDBD4",dark:"#650405"},"danger-content":{light:"#BC0117",dark:"#FF4F40"},"danger-content-default":{light:"#ffffff",dark:"#ffffff"},"danger-content-hover":{light:"#90000F",dark:"#FF8773"},"danger-onBackground":{light:"#FFFFFF",dark:"#FFFFFF"},"danger-plain":{light:"#BC0117",dark:"#FF8773"},"danger-plain-hover":{light:"#90000F",dark:"#FDB3A4"},"downvote-background":{light:"#6A5CFF",dark:"#6A5CFF"},"downvote-background-disabled":{light:"#6a5cff4d",dark:"#6a5cff4d"},"downvote-background-hover":{light:"#523DFF",dark:"#523DFF"},"downvote-content":{light:"#523DFF",dark:"#9580FF"},"downvote-content-weak":{light:"#6A5CFF",dark:"#6A5CFF"},"downvote-disabled":{light:"#523DFF4c",dark:"#9580FF4c"},"downvote-onBackground":{light:"#FFFFFF",dark:"#FFFFFF"},"downvote-onStrongScrim":{light:"#B29FFF",dark:"#B29FFF"},"downvote-onStrongScrim-disabled":{light:"#b29fff4d",dark:"#b29fff4d"},"downvote-onStrongScrim-weaker":{light:"#9580FF",dark:"#9580FF"},"downvote-plain":{light:"#523DFF",dark:"#9580FF"},"downvote-plain-disabled":{light:"#523dff4d",dark:"#9580ff4d"},"downvote-plain-weaker":{light:"#6A5CFF",dark:"#6A5CFF"},"elevation-large1":{light:"#0000003F",dark:"#0000007F"},"elevation-large2":{light:"#00000026",dark:"#00000033"},"elevation-medium1":{light:"#0000003F",dark:"#0000007F"},"elevation-medium2":{light:"#00000019",dark:"#00000033"},"elevation-small":{light:"#00000026",dark:"#00000054"},"elevation-xsmall":{light:"#0000003F",dark:"#000000AA"},favorite:{light:"#977000",dark:"#B78800"},"global-admin":{light:"#D93900",dark:"#D93900"},"global-alienblue":{light:"#1870F4",dark:"#1870F4"},"global-darkblue":{light:"#2A3236",dark:"#2A3236"},"global-focus":{light:"#029DD5",dark:"#007FAE"},"global-gold":{light:"#B78800",dark:"#D8A100"},"global-moderator":{light:"#008A10",dark:"#008A10"},"global-nsfw":{light:"#DE019F",dark:"#DE019F"},"global-offline":{light:"#667780",dark:"#667780"},"global-online":{light:"#00C61C",dark:"#00C61C"},"global-orangered":{light:"#FF4500",dark:"#FF4500"},"global-stars":{light:"#977000",dark:"#D8A100"},"gradient-media":{light:"",dark:""},"gradient-media-strong":{light:"",dark:""},"identity-admin":{light:"#D93900",dark:"#D93900"},"identity-coins":{light:"#B78800",dark:"#B78800"},"identity-moderator":{light:"#008A10",dark:"#008A10"},"identity-self":{light:"#01876D",dark:"#01876D"},"interactive-background-disabled":{light:"#0000000C",dark:"#FFFFFF0C"},"interactive-content-disabled":{light:"#0000003F",dark:"#FFFFFF3F"},"interactive-focused":{light:"#007FAE",dark:"#007FAE"},"interactive-pressed":{light:"#00000026",dark:"#FFFFFF26"},"inverted-interactive-background-disabled":{light:"#FFFFFF0C",dark:"#0000000C"},"inverted-interactive-content-disabled":{light:"#FFFFFF3F",dark:"#0000003F"},"inverted-interactive-pressed":{light:"#FFFFFF26",dark:"#00000026"},"inverted-neutral-background":{light:"#0E1113",dark:"#FFFFFF"},"inverted-neutral-background-hover":{light:"#181C1F",dark:"#F6F8F9"},"inverted-neutral-border":{light:"#FFFFFF33",dark:"#00000033"},"inverted-neutral-content":{light:"#B7CAD4",dark:"#333D42"},"inverted-neutral-content-strong":{light:"#EEF1F3",dark:"#181C1F"},"inverted-secondary-background":{light:"#2A3236",dark:"#E5EBEE"},"inverted-secondary-background-hover":{light:"#333D42",dark:"#DBE4E9"},"inverted-secondary-background-selected":{light:"#3D494E",dark:"#C9D7DE"},"inverted-secondary-onBackground":{light:"#FFFFFF",dark:"#000000"},"inverted-secondary-plain":{light:"#DBE4E9",dark:"#181C1F"},"inverted-secondary-plain-hover":{light:"#FFFFFF",dark:"#000000"},"media-background":{light:"#00000099",dark:"#00000099"},"media-background-hover":{light:"#000000cc",dark:"#000000cc"},"media-background-selected":{light:"#000000cc",dark:"#000000cc"},"media-border-selected":{light:"#FFFFFF",dark:"#FFFFFF"},"media-border-weak":{light:"#FFFFFF19",dark:"#FFFFFF19"},"media-onBackground":{light:"#FFFFFF",dark:"#FFFFFF"},"media-onBackground-disabled":{light:"#FFFFFF3F",dark:"#FFFFFF3F"},"media-onBackground-weak":{light:"#E5EBEE",dark:"#E5EBEE"},"media-onbackground":{light:"#ffffff",dark:"#ffffff"},"media-onbackground-disabled":{light:"#ffffff3f",dark:"#ffffff3f"},"media-onbackground-weak":{light:"#B7CAD4",dark:"#B7CAD4"},"neutral-background":{light:"#FFFFFF",dark:"#0E1113"},"neutral-background-container":{light:"#F6F8F9",dark:"#181C1F"},"neutral-background-container-hover":{light:"#EEF1F3",dark:"#21272A"},"neutral-background-container-strong":{light:"#EEF1F3",dark:"#21272A"},"neutral-background-container-strong-hover":{light:"#E5EBEE",dark:"#2A3236"},"neutral-background-gilded":{light:"#FFF9E0",dark:"#181C1F"},"neutral-background-gilded-hover":{light:"#FFF3C0",dark:"#21272A"},"neutral-background-hover":{light:"#F6F8F9",dark:"#181C1F"},"neutral-background-medium":{light:"#F8F8F8",dark:"#131313"},"neutral-background-pinned":{light:"#FFFFFF",dark:"#0E1113"},"neutral-background-selected":{light:"#E5EBEE",dark:"#2A3236"},"neutral-background-strong":{light:"#FFFFFF",dark:"#181C1F"},"neutral-background-strong-hover":{light:"#F6F8F9",dark:"#21272A"},"neutral-background-weak":{light:"#F6F8F9",dark:"#000000"},"neutral-background-weak-hover":{light:"#EEF1F3",dark:"#0E1113"},"neutral-border":{light:"#00000033",dark:"#FFFFFF33"},"neutral-border-medium":{light:"#0000007F",dark:"#FFFFFF7F"},"neutral-border-strong":{light:"#181C1F",dark:"#F6F8F9"},"neutral-border-weak":{light:"#00000019",dark:"#FFFFFF19"},"neutral-content":{light:"#333D42",dark:"#B7CAD4"},"neutral-content-disabled":{light:"#D6D6D6",dark:"#303030"},"neutral-content-strong":{light:"#181C1F",dark:"#EEF1F3"},"neutral-content-weak":{light:"#5C6C74",dark:"#8BA2AD"},offline:{light:"#767676",dark:"#767676"},online:{light:"#01A816",dark:"#01A816"},"opacity-08":{light:"#13131314",dark:"#13131314"},"opacity-50":{light:"#0000007f",dark:"#F2F2F27f"},"opacity-highlight":{light:"",dark:""},pizzaRed:{light:"#ef5350",dark:"#c62828"},primary:{light:"#115BCA",dark:"#648EFC"},"primary-background":{light:"#0A449B",dark:"#115BCA"},"primary-background-hover":{light:"#0A2F6C",dark:"#1870F4"},"primary-background-selected":{light:"#0A1A3F",dark:"#648EFC"},"primary-border":{light:"#0A449B",dark:"#648EFC"},"primary-border-hover":{light:"#0A2F6C",dark:"#90A9FD"},"primary-hover":{light:"#0A449B",dark:"#90A9FD"},"primary-onBackground":{light:"#FFFFFF",dark:"#FFFFFF"},"primary-onBackground-selected":{light:"#FFFFFF",dark:"#000000"},"primary-plain":{light:"#0A449B",dark:"#648EFC"},"primary-plain-hover":{light:"#0A2F6C",dark:"#90A9FD"},"primary-plain-visited":{light:"#7600A3",dark:"#CF5FFF"},"primary-visited":{light:"#9B00D4",dark:"#CF5FFF"},scrim:{light:"#00000099",dark:"#00000099"},"scrim-background":{light:"#00000099",dark:"#00000099"},"scrim-background-strong":{light:"#000000CC",dark:"#000000CC"},"scrim-gradient":{light:"",dark:""},"scrim-strong":{light:"#000000cc",dark:"#000000cc"},secondary:{light:"#21272A",dark:"#DBE4E9"},"secondary-background":{light:"#E5EBEE",dark:"#2A3236"},"secondary-background-hover":{light:"#DBE4E9",dark:"#333D42"},"secondary-background-selected":{light:"#C9D7DE",dark:"#3D494E"},"secondary-hover":{light:"#000000",dark:"#ffffff"},"secondary-onBackground":{light:"#000000",dark:"#FFFFFF"},"secondary-plain":{light:"#181C1F",dark:"#DBE4E9"},"secondary-plain-hover":{light:"#000000",dark:"#FFFFFF"},"secondary-plain-weak":{light:"#5C6C74",dark:"#8BA2AD"},"secondary-weak":{light:"#576F76",dark:"#748791"},"success-background":{light:"#008A10",dark:"#016E0B"},"success-background-hover":{light:"#016E0B",dark:"#008A10"},"success-content":{light:"#016E0B",dark:"#01A816"},"success-hover":{light:"#005306",dark:"#00C61C"},"success-onBackground":{light:"#FFFFFF",dark:"#FFFFFF"},"success-plain":{light:"#016E0B",dark:"#00C61C"},"success-plain-hover":{light:"#005306",dark:"#58E15B"},"tone-1":{light:"#131313",dark:"#F2F2F2"},"tone-2":{light:"#434343",dark:"#ACACAC"},"tone-3":{light:"#ACACAC",dark:"#434343"},"tone-4":{light:"#E4E4E4",dark:"#303030"},"tone-5":{light:"#F2F2F2",dark:"#1E1E1E"},"tone-6":{light:"#F8F8F8",dark:"#131313"},"tone-7":{light:"#ffffff",dark:"#080808"},"transparent-background-hover":{light:"#74879119",dark:"#66778019"},"ui-canvas":{light:"#F2F2F2",dark:"#080808"},"ui-modalbackground":{light:"#FFFFFF",dark:"#181C1F"},"upvote-background":{light:"#D93900",dark:"#D93900"},"upvote-background-disabled":{light:"#d939004d",dark:"#d939004d"},"upvote-background-hover":{light:"#AE2C00",dark:"#AE2C00"},"upvote-content":{light:"#AE2C00",dark:"#FF4500"},"upvote-content-weak":{light:"#FF4500",dark:"#FF4500"},"upvote-disabled":{light:"#AE2C004c",dark:"#FF45004c"},"upvote-onBackground":{light:"#FFFFFF",dark:"#FFFFFF"},"upvote-onStrongScrim":{light:"#FF895D",dark:"#FF895D"},"upvote-onStrongScrim-disabled":{light:"#ff895d4d",dark:"#ff895d4d"},"upvote-onStrongScrim-weaker":{light:"#FF4500",dark:"#FF4500"},"upvote-plain":{light:"#AE2C00",dark:"#FF895D"},"upvote-plain-disabled":{light:"#ae2c004d",dark:"#ff895d4d"},"upvote-plain-weaker":{light:"#FF4500",dark:"#FF4500"},"warning-background":{light:"#B78800",dark:"#B78800"},"warning-background-hover":{light:"#977000",dark:"#D8A100"},"warning-content":{light:"#785800",dark:"#B78800"},"warning-content-hover":{light:"#5B4200",dark:"#D8A100"},"warning-onBackground":{light:"#000000",dark:"#000000"}};var Ua={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",transparent:"#FFFFFF00",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},La=t=>!!t.match(/^(#[0-9a-fA-F]{3,8}).*/),Wa=t=>t in Ws,Hs=t=>t in Ua,Ha=t=>!!t.match(/^rgba?\(.*/),ja=t=>!!t.match(/^hsla?\(.*/),Ga=(t,e="light")=>{if(Hs(t))return Yi(t);let i=Ws[t];return typeof i=="string"?i:i[e]},Yi=t=>Ua[t]??t,Va=t=>{let[e,r,i,n]=t.replace(/^rgba?\(|\s+|\)$/g,"").split(",");if(!e||!r||!i)return t;let o=[...[e,r,i].map(l=>parseFloat(l))];if(n){let l=parseFloat(n),u=Math.round(l*255);o.push(u)}return`#${o.map(l=>l.toString(16).padStart(2,"0")).join("")}`};import{BlockStackDirection as en}from"@devvit/protos";var js={stackParentLayout:{hasHeight:!0,hasWidth:!0,direction:en.UNRECOGNIZED,alignment:void 0}},_e;(function(t){t[t.NONE=0]="NONE",t[t.HORIZONTAL=1]="HORIZONTAL",t[t.VERTICAL=2]="VERTICAL"})(_e||(_e={}));function za(t,e,r){if(!e)return{hasHeight:!1,hasWidth:!1};let{growDirection:i,stretchDirection:n}=Cu(t?.grow,e.direction,e.alignment),s=r?.height?.value?.value||r?.height?.min?.value||$a(_e.VERTICAL,i,n,e.hasHeight),o=r?.width?.value?.value||r?.width?.min?.value||$a(_e.HORIZONTAL,i,n,e.hasWidth);return{hasHeight:!!s,hasWidth:!!o}}function $a(t,e,r,i){return e===t&&i||r===t&&i}function Cu(t,e,r){let i=e===en.STACK_VERTICAL||e===en.UNRECOGNIZED,n=e===en.STACK_HORIZONTAL,s=_e.NONE;n&&t?s=_e.HORIZONTAL:i&&t&&(s=_e.VERTICAL);let o=r===void 0||r.horizontal===void 0,d=r===void 0||r.vertical===void 0,l=n?!!d:i?!!o:!1,u=_e.NONE;return n&&l?u=_e.VERTICAL:i&&l&&(u=_e.HORIZONTAL),{growDirection:s,stretchDirection:u}}import{BlockSizeUnit as ct,BlockStackDirection as tn}from"@devvit/protos";function ir(t){if(t==null)return;if(typeof t=="number")return{value:t,unit:ct.SIZE_UNIT_PERCENT};let e=t.match(/^(\d+(?:\.\d+)?)(px|%)?$/);if(e==null)return;let r=ct.SIZE_UNIT_PERCENT;return e.at(2)==="px"&&(r=ct.SIZE_UNIT_PIXELS),{value:Number.parseFloat(e[1]),unit:r}}function Fu(t,e){return(t.width?.value?.unit===ct.SIZE_UNIT_PERCENT||t.width?.min?.unit===ct.SIZE_UNIT_PERCENT)&&(e.direction===tn.STACK_HORIZONTAL||e.direction===tn.STACK_DEPTH)&&(e.hasWidth||(t.width=void 0)),(t.height?.value?.unit===ct.SIZE_UNIT_PERCENT||t.height?.min?.unit===ct.SIZE_UNIT_PERCENT)&&(e.direction===tn.STACK_VERTICAL||e.direction===tn.STACK_DEPTH)&&(e.hasHeight||(t.height=void 0)),t}function Gs(t,e){if(t){let r=t.width!=null||t.minWidth!=null||t.maxWidth!=null,i=t.height!=null||t.minHeight!=null||t.maxHeight!=null;if(r||i||t.grow!=null){let n={width:r?{value:ir(t.width),min:ir(t.minWidth),max:ir(t.maxWidth)}:void 0,height:i?{value:ir(t.height),min:ir(t.minHeight),max:ir(t.maxHeight)}:void 0,grow:t.grow};return e.stackParentLayout&&(n=Fu(n,e.stackParentLayout)),n}}}var Au=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},Pu=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},an,Za="data-",Iu=new Set(["onPress","onMessage"]),xu=new Map([["onPress",Xs.ACTION_CLICK],["onMessage",Xs.ACTION_WEBVIEW]]),sr=class{constructor(e=()=>{}){an.set(this,void 0),Au(this,an,e,"f")}createBlocksElementOrThrow({type:e,props:r,children:i}){let n=this.createBlocksElement({type:e,props:r,children:i},js);if(!n)throw new Error(`Could not create block of type ${e}`);return n}createBlocksElement({type:e,props:r,children:i},n){switch(e){case"blocks":return this.makeRoot(r,...i);case"hstack":return this.makeHStack(r,n,...i);case"vstack":return this.makeVStack(r,n,...i);case"zstack":return this.makeZStack(r,n,...i);case"text":return this.makeText(r,n,...i);case"button":return this.makeButton(r,n,...i);case"image":return this.makeImage(r,n);case"spacer":return this.makeSpacer(r,n);case"icon":return this.makeIcon(r,n);case"avatar":return this.makeAvatar(r,n);case"webview":return this.makeWebView(r,n);case"__fragment":throw new Error("root fragment is not supported - use 'blocks' instead")}}makeRootHeight(e){switch(e){case"regular":return 320;case"tall":return 512}}makeBlockPadding(e){switch(e){case"none":return Nr.PADDING_NONE;case"xsmall":return Nr.PADDING_XSMALL;case"small":return Nr.PADDING_SMALL;case"medium":return Nr.PADDING_MEDIUM;case"large":return Nr.PADDING_LARGE}}makeBlockRadius(e){switch(e){case"none":return Br.RADIUS_NONE;case"small":return Br.RADIUS_SMALL;case"medium":return Br.RADIUS_MEDIUM;case"large":return Br.RADIUS_LARGE;case"full":return Br.RADIUS_FULL}}makeBlockGap(e){switch(e){case"none":return nn.GAP_NONE;case"small":return nn.GAP_SMALL;case"medium":return nn.GAP_MEDIUM;case"large":return nn.GAP_LARGE}}makeBlockAlignment(e){if(e===void 0)return;let r,i;if(e.includes("top")?r=Qs.ALIGN_TOP:e.includes("middle")?r=Qs.ALIGN_MIDDLE:e.includes("bottom")&&(r=Qs.ALIGN_BOTTOM),e.includes("start")?i=$s.ALIGN_START:e.includes("center")?i=$s.ALIGN_CENTER:e.includes("end")&&(i=$s.ALIGN_END),r!==void 0||i!==void 0)return{vertical:r,horizontal:i}}makeBlockBorder(e,r,i,n){if(!e&&!r)return;let s;switch(e){case"none":s=rn.BORDER_WIDTH_NONE;break;case"thin":s=rn.BORDER_WIDTH_THIN;break;case"thick":s=rn.BORDER_WIDTH_THICK;break;default:s=rn.BORDER_WIDTH_THIN;break}let o=r??"neutral-border-weak",d=this.getThemedColors(o,i,n);return{width:s,color:d?.light,colors:d}}makeBlockTextSize(e){switch(e){case"xsmall":return nr.TEXT_SIZE_XSMALL;case"small":return nr.TEXT_SIZE_SMALL;case"medium":return nr.TEXT_SIZE_MEDIUM;case"large":return nr.TEXT_SIZE_LARGE;case"xlarge":return nr.TEXT_SIZE_XLARGE;case"xxlarge":return nr.TEXT_SIZE_XXLARGE}}makeBlockTextStyle(e){switch(e){case"body":return Zs.TEXT_STYLE_BODY;case"metadata":return Zs.TEXT_STYLE_METADATA;case"heading":return Zs.TEXT_STYLE_HEADING}}makeBlockTextOutline(e){switch(e){case"none":return qs.TEXT_OUTLINE_NONE;case"thin":return qs.TEXT_OUTLINE_THIN;case"thick":return qs.TEXT_OUTLINE_THICK}}makeBlockTextWeight(e){switch(e){case"regular":return Ja.TEXT_WEIGHT_REGULAR;case"bold":return Ja.TEXT_WEIGHT_BOLD}}makeBlockTextOverflow(e){switch(e){case"clip":return Js.TEXT_OVERFLOW_CLIP;case"ellipsis":return Js.TEXT_OVERFLOW_ELLIPSE}return Js.TEXT_OVERFLOW_ELLIPSE}makeBlockButtonAppearance(e){switch(e){case"secondary":return je.BUTTON_APPEARANCE_SECONDARY;case"primary":return je.BUTTON_APPEARANCE_PRIMARY;case"plain":return je.BUTTON_APPEARANCE_PLAIN;case"bordered":return je.BUTTON_APPEARANCE_BORDERED;case"media":return je.BUTTON_APPEARANCE_MEDIA;case"destructive":return je.BUTTON_APPEARANCE_DESTRUCTIVE;case"caution":return je.BUTTON_APPEARANCE_CAUTION;case"success":return je.BUTTON_APPEARANCE_SUCCESS}}makeBlockButtonSize(e){switch(e){case"small":return Vs.BUTTON_SIZE_SMALL;case"medium":return Vs.BUTTON_SIZE_MEDIUM;case"large":return Vs.BUTTON_SIZE_LARGE}}makeBlockImageResizeMode(e){switch(e){case"none":return Mr.IMAGE_RESIZE_NONE;case"fit":return Mr.IMAGE_RESIZE_FIT;case"fill":return Mr.IMAGE_RESIZE_FILL;case"cover":return Mr.IMAGE_RESIZE_COVER;case"scale-down":return Mr.IMAGE_RESIZE_SCALE_DOWN}}makeBlockSpacerSize(e){switch(e){case"xsmall":return on.SPACER_XSMALL;case"small":return on.SPACER_SMALL;case"medium":return on.SPACER_MEDIUM;case"large":return on.SPACER_LARGE}}makeBlockSpacerShape(e){switch(e){case"invisible":return zs.SPACER_INVISIBLE;case"thin":return zs.SPACER_THIN;case"square":return zs.SPACER_SQUARE}}makeBlockIconSize(e){switch(e){case"xsmall":return sn.ICON_SIZE_XSMALL;case"small":return sn.ICON_SIZE_SMALL;case"medium":return sn.ICON_SIZE_MEDIUM;case"large":return sn.ICON_SIZE_LARGE}}makeBlockAvatarSize(e){switch(e){case"xxsmall":return He.AVATAR_SIZE_XXSMALL;case"xsmall":return He.AVATAR_SIZE_XSMALL;case"small":return He.AVATAR_SIZE_SMALL;case"medium":return He.AVATAR_SIZE_MEDIUM;case"large":return He.AVATAR_SIZE_LARGE;case"xlarge":return He.AVATAR_SIZE_XXLARGE;case"xxlarge":return He.AVATAR_SIZE_XXLARGE;case"xxxlarge":return He.AVATAR_SIZE_XXXLARGE}}makeBlockAvatarFacing(e){switch(e){case"left":return qa.AVATAR_FACING_LEFT;case"right":return qa.AVATAR_FACING_RIGHT}}makeBlockAvatarBackground(e){switch(e){case"dark":return Ka.AVATAR_BG_DARK;case"light":return Ka.AVATAR_BG_LIGHT}}getDataSet(e){return Object.keys(e).filter(r=>r.startsWith(Za)).reduce((r,i)=>(r[i.substring(Za.length)]=e[i],r),{})}makeActions(e,r){let i=[],n=this.getDataSet(r);return Iu.forEach(s=>{if(s in r){let o=r[s];i.push({type:xu.get(s)??Xs.UNRECOGNIZED,id:o.toString(),data:n})}}),i}blockColorToHex(e,r="light"){if(e)return e=e.toLowerCase(),La(e)?e:Wa(e)?Ga(e,r):Hs(e)?Yi(e):Ha(e)?Va(e):ja(e)?e:(console.warn(`Could not parse color: ${e}.`),Yi("red"))}childrenToBlocks(e,r){return e.flatMap(i=>(typeof i!="string"?this.createBlocksElement(i,r):void 0)??[])}getThemedColors(e,r,i){let n=this.blockColorToHex(r,"light"),s=this.blockColorToHex(i,"dark"),o=[];if(e&&(!n||!s)){let d=Array.from(e?.matchAll(/[\w#-]+(?:\([\w\t ,.#-]+\))?/g)??[]);o.push(...d.map(l=>l[0]))}return n||(n=this.blockColorToHex(o?.at(0),"light")),s||(s=this.blockColorToHex(o?.at(1)??o?.at(0),"dark")),n||s?{light:n,dark:s}:void 0}parsePixels(e){return typeof e=="string"?Number(e.slice(0,-2)):e}resolveAssetUrl(e,r){return Pu(this,an,"f").call(this)?.getURL(e,r)??e}childrenToString(e){return e.map(r=>r.toString()).join("")}makeRoot(e,...r){return this.wrapRoot(e,this.childrenToBlocks(r,js))}wrapRoot(e,r){return this.makeBlock(Ee.BLOCK_ROOT,{},{},{rootConfig:{children:r,height:this.makeRootHeight(a.customPostType?.height??e?.height??"regular")}})}makeStackBlock(e,r,i,n){let s=this.getThemedColors(r?.backgroundColor,r?.lightBackgroundColor,r?.darkBackgroundColor),o=this.makeBlockAlignment(r?.alignment),d=Gs(r,i),l=za(r,i.stackParentLayout,d);return this.makeBlock(Ee.BLOCK_STACK,r,i,{stackConfig:{alignment:o,backgroundColor:s?.light,backgroundColors:s,border:this.makeBlockBorder(r?.border,r?.borderColor,r?.lightBorderColor,r?.darkBorderColor),children:this.childrenToBlocks(n,{stackParentLayout:{...l,direction:e,alignment:o}}),cornerRadius:this.makeBlockRadius(r?.cornerRadius),direction:e,gap:this.makeBlockGap(r?.gap),padding:this.makeBlockPadding(r?.padding),reverse:r?.reverse}})}makeHStack(e,r,...i){return this.makeStackBlock(Ks.STACK_HORIZONTAL,e,r,i)}makeVStack(e,r,...i){return this.makeStackBlock(Ks.STACK_VERTICAL,e,r,i)}makeZStack(e,r,...i){return this.makeStackBlock(Ks.STACK_DEPTH,e,r,i)}makeText(e,r,...i){let n=this.getThemedColors(e?.color,e?.lightColor,e?.darkColor);return this.makeBlock(Ee.BLOCK_TEXT,e,r,{textConfig:{alignment:this.makeBlockAlignment(e?.alignment),color:n?.light,colors:n,outline:this.makeBlockTextOutline(e?.outline),size:this.makeBlockTextSize(e?.size),style:this.makeBlockTextStyle(e?.style),text:this.childrenToString(i),weight:this.makeBlockTextWeight(e?.weight),selectable:e?.selectable,wrap:e?.wrap,overflow:this.makeBlockTextOverflow(e?.overflow)}})}makeButton(e,r,...i){let n=this.getThemedColors(e?.textColor,e?.lightTextColor,e?.darkTextColor);return this.makeBlock(Ee.BLOCK_BUTTON,e,r,{buttonConfig:{buttonAppearance:this.makeBlockButtonAppearance(e?.appearance),icon:e?.icon,buttonSize:this.makeBlockButtonSize(e?.size),text:this.childrenToString(i),textColor:n?.light,textColors:n,disabled:e?.disabled}})}makeImage(e,r){return e&&this.makeBlock(Ee.BLOCK_IMAGE,e,r,{imageConfig:{description:e?.description,resizeMode:this.makeBlockImageResizeMode(e.resizeMode),url:this.resolveAssetUrl(e.url),width:this.parsePixels(e.imageWidth),height:this.parsePixels(e.imageHeight)}})}makeSpacer(e,r){return this.makeBlock(Ee.BLOCK_SPACER,e,r,{spacerConfig:{size:this.makeBlockSpacerSize(e?.size),shape:this.makeBlockSpacerShape(e?.shape)}})}makeIcon(e,r){let i=this.getThemedColors(e?.color,e?.lightColor,e?.darkColor);return e&&this.makeBlock(Ee.BLOCK_ICON,e,r,{iconConfig:{icon:e.name,color:i?.light,colors:i,size:this.makeBlockIconSize(e.size)}})}makeAvatar(e,r){return e&&this.makeBlock(Ee.BLOCK_AVATAR,e,r,{avatarConfig:{thingId:e.thingId,size:this.makeBlockAvatarSize(e.size),facing:this.makeBlockAvatarFacing(e.facing),background:this.makeBlockAvatarBackground(e.background)}})}makeWebView(e,r){return e&&this.makeBlock(Ee.BLOCK_WEBVIEW,e,r,{webviewConfig:{url:this.resolveAssetUrl(e.url,{webView:!0})}})}makeBlock(e,r,i,n){return{type:e,sizes:Gs(r,i),config:n,actions:(r&&this.makeActions(e,r))??[],id:r?.id,key:r?.key}}ensureRootBlock(e){let r;if(e.type===Ee.BLOCK_ROOT?(e.config?.rootConfig&&a.customPostType?.height&&(e.config.rootConfig.height=this.makeRootHeight(a.customPostType?.height)),r=e):r=this.wrapRoot(void 0,[e]),!r)throw new Error("Could not create root block");return r}};an=new WeakMap;var dt=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Su=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},Ge,Ya,cn,ec,dn;function Xa(t){if(typeof t=="string")throw new Error("Root element cannot be a string")}var tc=t=>{let e="",r=t.props?Object.keys(t.props).map(i=>i==="onPress"?"":`${i}="${t.props[i]}"`).join(" "):"";e+=`<${t.type}${r?" "+r:""}>`;for(let i of t.children)typeof i=="string"?e+=i:e+=tc(i);return e+=`</${t.type}>`,e};function Tu(t){return" ".repeat(t)}function Ru(t){let e="",r=0,i=t.split(/>\s*</);for(let n=0;n<i.length;n++){let s=i[n];n===0&&(s=s.trim()),n===i.length-1&&(s=s.trim());let o=s.charAt(0)==="/";o&&r--,e+=Tu(r),n!==0&&(e+="<"),e+=s,n!==i.length-1&&(e+=`>
|
|
2
|
-
`),!o&&s.indexOf("</")===-1&&s.charAt(s.length-1)!=="/"&&r++}return e}var Se=class{emitEffect(e,r){this.effects.push(r)}constructor(e,r,i,n,s){Ge.add(this),this.renderState={},this.currentComponentKey=[],this.currentHookIndex=0,this.actions=new Map,this.forms=new Map,this.realtimeChannels=[],this.realtimeUpdated=!1,this.pendingHooks=[],this.isRendering=!1,this.transformer=new sr(()=>this.assets),this.effects=[],dn.set(this,!1),this.component=e,this.event=r,this.state={__renderState:{},...i},this.metadata=n,this.state.__realtimeChannels&&(this.realtimeChannels=this.state.__realtimeChannels);let o=Z({reconciler:this,hooks:!0,ui:!0,metadata:n});this.cache=o.cache,this.modLog=o.modLog,this.kvStore=o.kvStore,this.redis=o.redis,this.settings=o.settings,this.scheduler=o.scheduler,this.media=o.media,this.assets=o.assets,this.realtime=o.realtime,this.dimensions=s,this.ui=o.ui,this.hooks={useState:o.useState,useInterval:o.useInterval,useForm:o.useForm,useChannel:o.useChannel}}async render(){await this.reconcile(),this.isRendering=!0;let e=await this.buildBlocksUI();return this.isRendering=!1,e}makeUniqueActionID(e){let r=e,i=1;for(;this.actions.has(r);)r=`${e}.${i++}`;return r}async reconcile(){let e=dt(this,Ge,"m",cn).call(this),r={type:this.component,props:e,children:[]},i=await this.processBlock(r);if(Xa(i),this.transformer.createBlocksElementOrThrow(i),this.isUserActionRender&&this.blockRenderEventId){let n=this.actions.get(this.blockRenderEventId);n&&await n(this.event.data)}for(let n of this.pendingHooks)await n();this.buildNextState(),dt(this,Ge,"m",Ya).call(this)}async buildBlocksUI(){let e=dt(this,Ge,"m",cn).call(this),r={type:this.component,props:e,children:[]},i=await this.renderElement(e,r);return this.transformer.ensureRootBlock(i)}async renderElement(e,r){let i=await this.processBlock(r);return Xa(i),(a.debug.emitSnapshots||e.debug.emitSnapshots)&&console.debug(Ru(tc(i))),(a.debug.emitState||e.debug.emitState)&&console.debug(JSON.stringify(this.state,void 0,2)),this.transformer.createBlocksElementOrThrow(i)}async processProps(e){let r=e.props??{},i=["onPress","onMessage"];for(let n of i)if(n in r){let s=r[n],o=s?.name,d=this.makeUniqueActionID(`${e.type}.${o??n}`);this.actions.set(d,s),r[n]=d}}async processBlock(e,r=Oa(),i=[]){if(typeof e=="string")return e;if(typeof e=="number")return`${e}`;let n=e;if(typeof n.type=="string"){let d=[];for(let g=0;g<n.children.length;g++){let p=n.children[g];p!=null&&d.push(await this.processBlock(p,r,[...i,`${n.type}.${g}`]))}let l=d.flat(),u=dt(this,Ge,"m",ec).call(this,l);return await this.processProps(n),{type:n.type,props:n.props,children:u}}if(typeof n.type=="function"){let d=r(`${i.length?i.join("."):"root"}.${n.type.name.length?n.type.name:"anonymous"}`);this.currentComponentKey.push(d),this.renderState[d]||(this.renderState[d]={});let l=n.children.flatMap(_=>_),u=dt(this,Ge,"m",cn).call(this),g={...u,...n.props,children:l},p;for(;p===void 0;)try{p=await n.type(g,u)}catch(_){if(_ instanceof Promise)p=await _;else throw _}if(!this.isInitialRender){let _=this.getPreviousComponentState();if(Object.keys(_).length!==this.currentHookIndex)throw new Error("Invalid hook call. Hooks can only be called at the top-level of a function component. Make sure that you are not calling hooks inside loops, conditions, or nested functions.")}if(this.currentComponentKey.pop(),this.currentHookIndex=0,typeof p=="object")return this.processBlock(p,r,[...i,n.type.name])}let s=[],o="";return Array.isArray(n)?s=n:typeof n.type>"u"&&n.children&&(s=n.children,o="fragmentChild."),{type:"__fragment",props:void 0,children:await Promise.all(s.flatMap(async(d,l)=>await this.processBlock(d,r,[...i,`${o}${l}`])))}}getCurrentComponentKey(){if(!this.currentComponentKey.at(-1))throw new Error("Current component key is missing");return this.currentComponentKey}getCurrentComponentState(){let e=this.currentComponentKey.at(-1);if(!e)throw new Error("Current component key is missing");return this.renderState[e]}getPreviousComponentState(){let e=this.currentComponentKey.at(-1);if(!e)throw new Error("Current component key is missing");return this.state.__renderState[e]||(this.state.__renderState[e]={}),this.state.__renderState[e]}get isInitialRender(){return this.event?this.event.type===Ys.RENDER_INITIAL:!1}get isUserActionRender(){return this.event?this.event.type===Ys.RENDER_USER_ACTION:!1}get isEffectRender(){return this.event?this.event.type===Ys.RENDER_EFFECT_EVENT:!1}get formSubmittedEvent(){return this.event?this.event.formSubmitted:!1}get blockRenderEventId(){return this.event?this.event.id:!1}get realtimeEvent(){if(!this.event)return!1;let e=this.event.realtimeEvent;return e?.event?.channel?e:!1}runHook(e){this.pendingHooks.push(e)}rerenderIn(e){dt(this,dn,"f")||(Su(this,dn,!0,"f"),this.effects.push({type:Qa.EFFECT_RERENDER_UI,rerenderUi:{delaySeconds:e/1e3}}))}addRealtimeChannel(e){this.realtimeChannels.push(e),this.realtimeUpdated=!0}removeRealtimeChannel(e){this.realtimeChannels=this.realtimeChannels.filter(r=>r!==e),this.realtimeUpdated=!0}get realtimeEffect(){return this.realtimeUpdated&&this.realtimeChannels.length>0?[{type:Qa.EFFECT_REALTIME_SUB,realtimeSubscriptions:{subscriptionIds:this.realtimeChannels}}]:[]}getEffects(){return[...rr(this.ui),...this.effects,...this.realtimeEffect]}buildNextState(){for(let e of Object.keys(this.renderState))this.renderState[e]=Object.values(this.renderState[e]);this.state={__postData:this.state.__postData,__renderState:this.renderState,__cache:this.state.__cache,...this.realtimeChannels.length>0?{__realtimeChannels:this.realtimeChannels}:{}}}};dn=new WeakMap,Ge=new WeakSet,Ya=function(){this.actions.clear(),this.currentComponentKey=[],this.currentHookIndex=0,this.pendingHooks=[],this.realtimeChannels=[],this.realtimeUpdated=!1},cn=function(){let e={...z(this.metadata,this.state.__postData?.thingId),modLog:this.modLog,cache:this.cache,kvStore:this.kvStore,redis:this.redis,settings:this.settings,scheduler:this.scheduler,media:this.media,assets:this.assets,realtime:this.realtime,ui:this.ui,dimensions:this.dimensions,uiEnvironment:{timezone:this.metadata[C.Timezone]?.values[0],locale:this.metadata[C.Language]?.values[0],dimensions:this.dimensions},...this.hooks};return e.debug.effects=this,e},ec=function t(e){let r=[];for(let i of e)typeof i=="string"?r.push(i):i.type==="__fragment"?r.push(...dt(this,Ge,"m",t).call(this,i.children)):r.push(i);return r};async function Bu(t,e){let r=a.customPostType;if(!r)throw new Error("Custom post type not registered");let i=new Se((s,o)=>r.render(o),t.blocks,t.state,e,t.dimensions),n=await i.render();return Nu.fromJSON({state:i.state,blocks:{ui:n},effects:i.getEffects()})}function rc(t){t.provides(Mu),x("RenderPost",Bu)}import{GetFieldsResponse as Du,InstallationSettingsDefinition as Ou}from"@devvit/protos";async function Uu(){if(!a.installationSettings)throw new Error("Installation settings were not defined.");return Du.fromJSON({fields:{fields:Ie(a.installationSettings)}})}async function Lu(t,e){return Xi(t,a.installationSettings,e)}function ic(t){t.provides(Ou),x("GetSettingsFields",Uu),x("ValidateForm",Lu)}import{ContextActionDefinition as Wu,ContextActionList as Hu,ContextActionResponse as ju}from"@devvit/protos";function eo(t){let e=t.metadata[C.User].values[0];if(!e)throw new Error("User missing from context");return e}function to(t){let e=t.metadata[C.Subreddit].values[0];if(!e)throw new Error("Subreddit missing from context");return e}async function nc(t,e){let r=eo(t),i=to(t);if(!r||!i)throw new Error("User or subreddit missing from context");let n=e.comment?.id&&`t1_${e.comment.id}`,s=e.post?.id&&`t3_${e.post.id}`,o=e.subreddit?.id&&`t5_${e.subreddit.id}`,d=n||s||o;if(!d)throw new Error("targetId is missing from ContextActionRequest");if(n){let p=await dc(n);if(!p)throw new Error(`Comment ${n} not found`);if(p.subredditId!==i)throw new Error("Comment does not belong to the subreddit")}if(s){let p=await cc(s);if(!p)throw new Error(`Post ${s} not found`);if(p.subredditId!==i)throw new Error("Post does not belong to the subreddit")}if(o&&o!==i)throw new Error(`Subreddit ${o} ${i} not found`);let l=Dr(e.actionId);if(!l)throw new Error("Action not found");let u=!!l.forUserType?.includes("moderator");if(u&&!sc(t))throw new Error("User is not a moderator");let g={needsModCheck:u};await t.redis.set(`${r}${i}${d}${e.actionId}`,JSON.stringify(g)),await t.redis.expire(`${r}${i}${d}${e.actionId}`,600)}async function sc(t){let e=eo(t),r=to(t),i=await ac(r);return!!(await lc({subredditName:i.name}).all()).find(s=>s.id===e)}async function oc(t,e){let r=eo(t),i=to(t),{actionId:n,thingId:s}=e.state?.__contextAction??{},o=await t.redis.get(`${r}${i}${s}${n}`);if(!o)throw new Error("CSRF token not found");if(JSON.parse(o).needsModCheck&&!await sc(t))throw new Error("User is not a moderator: "+r+"; "+i)}var uc=t=>`menuItem.${t}`;function Dr(t){return a.menuItems.find((e,r)=>uc(r)===t)}async function Gu(t,e){let r=a.menuItems;if(!r.length)throw new Error("No menu items registered.");let i=r.map((n,s)=>({actionId:uc(s),name:n.label,description:n.description,contexts:{subreddit:n.location.includes("subreddit"),post:n.location.includes("post"),comment:n.location.includes("comment")},users:{loggedOut:n.forUserType?.includes("loggedOut"),moderator:n.forUserType?.includes("moderator")},postFilters:n.postFilter==="currentApp"?{currentApp:!0}:void 0}));return Hu.fromJSON({actions:i})}async function Vu(t,e){let r=Dr(t.actionId);if(!r)throw new Error(`MenuItem ${t.actionId} not found`);let i=t.comment?.id&&`t1_${t.comment.id}`,n=t.post?.id&&`t3_${t.post.id}`,s=t.subreddit?.id&&`t5_${t.subreddit.id}`,o=i||n||s;m(o,"targetId is missing from ContextActionRequest");let d={targetId:o,location:t.comment?"comment":t.post?"post":"subreddit"},l=Object.assign(Z({ui:!0,metadata:e}),z(e,n,i),{uiEnvironment:{timezone:e[C.Timezone]?.values[0],locale:e[C.Language]?.values[0]}});return await nc(l,t),await r.onPress(d,l),ju.fromJSON({effects:rr(l.ui)})}function hc(t){t.provides(Wu),x("GetActions",Gu),x("OnAction",Vu)}function ue(t){return t?t===!0?!0:t.enabled:!1}import{SchedulerHandlerDefinition as $u}from"@devvit/protos";async function zu(t,e){let r=t.type,i=a.scheduledJobHandlers.get(r);if(!i)throw new Error(`Job ${r} not found`);let n={name:r,data:t.data},s=Object.assign(Z({metadata:e}),z(e));await i(n,s)}function fc(t){t.provides($u),x("HandleScheduledAction",zu)}import{OnAppInstallDefinition as Ku,OnAppUpgradeDefinition as qu,OnAutomoderatorFilterCommentDefinition as Ju,OnAutomoderatorFilterPostDefinition as Zu,OnCommentCreateDefinition as Qu,OnCommentDeleteDefinition as Xu,OnCommentReportDefinition as Yu,OnCommentSubmitDefinition as eh,OnCommentUpdateDefinition as th,OnModActionDefinition as rh,OnModMailDefinition as ih,OnPostCreateDefinition as nh,OnPostDeleteDefinition as sh,OnPostFlairUpdateDefinition as oh,OnPostNsfwUpdateDefinition as ah,OnPostReportDefinition as ch,OnPostSpoilerUpdateDefinition as dh,OnPostSubmitDefinition as lh,OnPostUpdateDefinition as uh}from"@devvit/protos";var lt;(function(t){function e(o,d){return o.length<=d?o:`${o.slice(0,d-1)}\u2026`}t.ellipsize=e;function r(o){return o[0]==null?o:`${o[0].toLocaleUpperCase()}${o.slice(1)}`}t.capitalize=r;function i(o){return o==null||/^\s*$/.test(o)}t.isBlank=i;function n(o,d="stack"){return o instanceof Error?`${o[d]||o.stack||o.message||o.name}`:String(o)}t.caughtToString=n;function s(o,d="stack"){return o instanceof Error?`${o[d]||o.stack||o.message||o.name}`:String(o)}t.caughtToStringUntyped=s})(lt||(lt={}));function G(t,e){return m(e),async(r,i)=>{let n={...r,type:t},s=Object.assign(Z({metadata:i}),z(i)),o=await Promise.allSettled(e.map(l=>l(n,s))),d=hh(o);if(d)throw d.err;return{}}}function mc(t){for(let e of a.triggerOnEventHandlers.keys())switch(e){case"PostSubmit":t.provides(lh),x("OnPostSubmit",G("PostSubmit",a.triggerOnEventHandlers.get(e)));break;case"PostCreate":t.provides(nh),x("OnPostCreate",G("PostCreate",a.triggerOnEventHandlers.get(e)));break;case"PostUpdate":t.provides(uh),x("OnPostUpdate",G("PostUpdate",a.triggerOnEventHandlers.get(e)));break;case"PostReport":t.provides(ch),x("OnPostReport",G("PostReport",a.triggerOnEventHandlers.get(e)));break;case"PostDelete":t.provides(sh),x("OnPostDelete",G("PostDelete",a.triggerOnEventHandlers.get(e)));break;case"PostFlairUpdate":t.provides(oh),x("OnPostFlairUpdate",G("PostFlairUpdate",a.triggerOnEventHandlers.get(e)));break;case"CommentSubmit":t.provides(eh),x("OnCommentSubmit",G("CommentSubmit",a.triggerOnEventHandlers.get(e)));break;case"CommentCreate":t.provides(Qu),x("OnCommentCreate",G("CommentCreate",a.triggerOnEventHandlers.get(e)));break;case"CommentUpdate":t.provides(th),x("OnCommentUpdate",G("CommentUpdate",a.triggerOnEventHandlers.get(e)));break;case"CommentReport":t.provides(Yu),x("OnCommentReport",G("CommentReport",a.triggerOnEventHandlers.get(e)));break;case"CommentDelete":t.provides(Xu),x("OnCommentDelete",G("CommentDelete",a.triggerOnEventHandlers.get(e)));break;case"AppInstall":t.provides(Ku),x("OnAppInstall",G("AppInstall",a.triggerOnEventHandlers.get(e)));break;case"AppUpgrade":t.provides(qu),x("OnAppUpgrade",G("AppUpgrade",a.triggerOnEventHandlers.get(e)));break;case"ModAction":t.provides(rh),x("OnModAction",G("ModAction",a.triggerOnEventHandlers.get(e)));break;case"ModMail":t.provides(ih),x("OnModMail",G("ModMail",a.triggerOnEventHandlers.get(e)));break;case"PostNsfwUpdate":t.provides(ah),x("OnPostNsfwUpdate",G("PostNsfwUpdate",a.triggerOnEventHandlers.get(e)));break;case"PostSpoilerUpdate":t.provides(dh),x("OnPostSpoilerUpdate",G("PostSpoilerUpdate",a.triggerOnEventHandlers.get(e)));break;case"AutomoderatorFilterPost":t.provides(Zu),x("OnAutomoderatorFilterPost",G("AutomoderatorFilterPost",a.triggerOnEventHandlers.get(e)));break;case"AutomoderatorFilterComment":t.provides(Ju),x("OnAutomoderatorFilterComment",G("AutomoderatorFilterComment",a.triggerOnEventHandlers.get(e)));break;default:throw new Error(`Unknown trigger event: ${e}`)}}function hh(t){let e=t.reduce((r,i)=>i.status==="rejected"?[...r,i.reason]:r,[]);if(e.length!==0)return e.length===1?{err:e[0]}:{err:new Error(e.map(r=>lt.caughtToString(r)).join(`
|
|
3
|
-
`))}}import{EffectType as Dh,HandleUIEventResponse as no,UIEventHandlerDefinition as Oh}from"@devvit/protos";var Tc=Xo(Ac(),1);function Pc(t){return t?.constructor===Object}function ut(t,e){return Object.is(t,e)?!0:typeof t!=typeof e?!1:Array.isArray(t)&&Array.isArray(e)?Ic(t,e):t instanceof Date&&e instanceof Date?t.getTime()===e.getTime():t instanceof RegExp&&e instanceof RegExp?t.toString()===e.toString():Pc(t)&&Pc(e)?Bh(t,e):t instanceof ArrayBuffer&&e instanceof ArrayBuffer?xc(new DataView(t),new DataView(e)):t instanceof DataView&&e instanceof DataView?xc(t,e):Sc(t)&&Sc(e)?t.byteLength!==e.byteLength?!1:Ic(t,e):!1}function Bh(t,e){let r=Object.keys(t),i=Object.keys(e);if(!ut(r,i))return!1;for(let n of r)if(!ut(t[n],e[n]))return!1;return!0}function Ic(t,e){return t.length!==e.length?!1:t.every((r,i)=>ut(r,e[i]))}function xc(t,e){if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t.getUint8(r)!==e.getUint8(r))return!1;return!0}function Sc(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}async function Uh(t,e){let r=t.state??{},i=(0,Tc.default)(r),n=Z({ui:!0,metadata:e});if(t.event?.formSubmitted&&t.event.formSubmitted.formId){let l=t.event.formSubmitted.formId;if(l.includes("form.hook.")&&a.customPostType){let I=new Se((T,L)=>a.customPostType?.render(L)??null,t.event,t.state,e,void 0);return await I.reconcile(),no.fromJSON({state:I.state,effects:I.getEffects()})}let u=a.formDefinitions.get(l);if(!u)throw new Error(`Form with key ${l} not found`);let g,p;if(i.__contextAction){let{actionId:I,thingId:T}=i.__contextAction,L=Dr(I);L?.location==="post"?g=T:L?.location==="comment"&&(p=T)}let _=Object.assign(n,z(e,g,p),{uiEnvironment:{timezone:e[C.Timezone]?.values[0],locale:e[C.Language]?.values[0]}});await oc(_,t),await u.onSubmit({values:We(t.event.formSubmitted.results)},_)}else if(t.event?.realtimeEvent){if(a.customPostType){let l=new Se((u,g)=>a.customPostType?.render(g)??null,t.event,t.state,e,void 0);return await l.reconcile(),no.fromJSON({state:l.state,effects:l.getEffects()})}}else if(t.event?.toastAction)throw new Error("Toast actions not yet implemented");let s=!ut(r,i),o=rr(n.ui),d=s?[...o,{type:Dh.EFFECT_RERENDER_UI,rerenderUi:{delaySeconds:0}}]:o;return no.fromJSON({state:i,effects:d})}function Rc(t){t.provides(Oh),x("HandleUIEvent",Uh)}import{CustomPostDefinition as Sn,UIResponse as od}from"@devvit/protos";import{UIEventScope as zh}from"@devvit/protos";var so="ServerCallRequired";function ln(t){return t?.message===so}var un=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},U=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},he,ht,ft,ye,Or,Hc,jc,Mc,Nc,Bc,Dc,ao,Gc,co={now(){return new Date}};function Oc(t){return`__autocache__${t}`}function Uc(t){return`__lock__${t}`}var Lh=300,Wh=1e3,hn=5e3,oo=3,Lc=.1,Wc=1e3,Hh=3e4;function Vc(t){if(t.error)throw new Error(t.error);return t.value}var fn=class{constructor(e,r,i=co){he.add(this),ht.set(this,void 0),ft.set(this,{}),ye.set(this,void 0),Or.set(this,void 0),un(this,ht,e,"f"),un(this,Or,r,"f"),un(this,ye,i,"f")}async cache(e,r){var i;(i=U(this,Or,"f")).__cache??(i.__cache={}),un(this,ft,U(this,Or,"f").__cache,"f"),U(this,he,"m",Gc).call(this,r);let n=U(this,he,"m",Hc).call(this,r.key);if(n!==void 0)return n;let s=await U(this,he,"m",ao).call(this,r.key),o=await U(this,he,"m",jc).call(this,r,s,e);return Vc(o)}};ht=new WeakMap,ft=new WeakMap,ye=new WeakMap,Or=new WeakMap,he=new WeakSet,Hc=function(e){let r=U(this,ft,"f")[e];if(r){let i=U(this,ye,"f").now().getTime(),n=r?.error&&r?.errorTime&&r.errorCount<oo&&Math.random()<Lc&&r.errorTime+Wc<i;if(r?.expires&&r.expires<i&&r.checkedAt+Wc<i||n){delete U(this,ft,"f")[e];return}else return Vc(r)}},jc=async function(e,r,i){let n=r?.expires,s=n?U(this,he,"m",Dc).call(this,n):1;return!r||r?.error&&r.errorCount<oo&&Lc>Math.random()||s>Math.random()?U(this,he,"m",Mc).call(this,e,r,i):r},Mc=async function(e,r,i){let n=Uc(e.key),s=U(this,ye,"f").now().getTime(),o=new Date(s+e.ttl/2);if(await U(this,ht,"f").set(n,"1",{expiration:o,nx:!0}))return U(this,he,"m",Bc).call(this,e.key,r,i,e.ttl);if(r)return r;{let l=U(this,ye,"f").now();return U(this,he,"m",Nc).call(this,l,e.key,e.ttl)}},Nc=async function t(e,r,i){let n=Math.min(i,Wh),s=await U(this,he,"m",ao).call(this,r);if(s)return s;if(U(this,ye,"f").now().getTime()-e.getTime()>=n)throw new Error(`Cache request timed out trying to get data at key: ${r}`);return await new Promise(o=>setTimeout(o,Lh)),U(this,he,"m",t).call(this,e,r,i)},Bc=async function(e,r,i,n){let s=U(this,ye,"f").now().getTime()+n;r=r??{value:null,expires:s,errorCount:0,error:null,errorTime:null,checkedAt:0};try{r.value=await i(),r.error=null,r.errorCount=0,r.errorTime=null}catch(o){r.value=null,r.error=o.message??"Unknown error",r.errorTime=U(this,ye,"f").now().getTime(),r.errorCount++}return U(this,ft,"f")[e]=r,await U(this,ht,"f").set(Oc(e),JSON.stringify(r),{expiration:new Date(s+Hh)}),r.error&&r.errorCount<oo&&await U(this,ht,"f").del(Uc(e)),r},Dc=function(e){let r=U(this,ye,"f").now().getTime(),i=e-r;return i<0?1:i<1e3?.1:i<2e3?.01:i<3e3?.001:0},ao=async function(e){let r=await U(this,ht,"f").get(Oc(e));if(r){let i=JSON.parse(r);return i.checkedAt=U(this,ye,"f").now().getTime(),U(this,ft,"f")[e]=i,i}},Gc=function(e){e.ttl<hn&&(console.warn(`Cache TTL cannot be less than ${hn} milliseconds! Updating ttl value of ${e.ttl} to ${hn}.`),e.ttl=hn)};function $c(t,e,r=co){let i=new fn(t,e,r);return i.cache.bind(i)}import{EffectType as mn,ToastAppearance as qc}from"@devvit/protos";function zc(t){let e=t.match(/form\.hook\.(.+)\.0/);if(e?.[1])return e[1]}var lo=class{constructor(e,r,i){this.state=null,this.hookId=e.hookId,this.form=r,this.onSubmit=i,this.onUIEvent=async n=>{n.formSubmitted&&await i(We(n.formSubmitted.results))}}};function uo(t,e){let r=Y({namespace:"useForm",initializer:i=>new lo(i,t,e)});return jh({id:r.hookId})}function jh(t){return`form.hook.${t.id}.0`}function Kc(t,e){let r=zc(e);return t.getHook({id:r})}var ho=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},Ve=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},$e,pn,gn,fo;var wn=class{constructor(e){$e.set(this,void 0),pn.set(this,0),gn.set(this,void 0),fo.set(this,(r,i)=>{var n,s;let o=i!==void 0?r:"",d=i!==void 0?i:r;Ve(this,$e,"f").emitEffect(`postMessage${ho(this,pn,(s=Ve(this,pn,"f"),n=s++,s),"f"),n}`,{type:mn.EFFECT_WEB_VIEW,webView:{postMessage:{webViewId:o,app:{message:d,jsonString:JSON.stringify(d)}}}})}),ho(this,$e,e,"f"),ho(this,gn,{postMessage:Ve(this,fo,"f")},"f")}get webView(){return Ve(this,gn,"f")}showForm(e,r){let i=Kc(Ve(this,$e,"f"),e);if(!i)throw new Error("Form does not exist. Make sure you have added it using useForm.");let n=i.form instanceof Function?i.form(r??{}):i.form,s={fields:[],id:e,title:n.title,acceptLabel:n.acceptLabel,cancelLabel:n.cancelLabel,shortDescription:n.description};it(n.fields),s.fields=Ie(n.fields),Ve(this,$e,"f").emitEffect(e,{type:mn.EFFECT_SHOW_FORM,showForm:{form:s}})}showToast(e){let r;e instanceof Object?r={text:e.text,appearance:e.appearance==="success"?qc.SUCCESS:qc.NEUTRAL}:r={text:e},Ve(this,$e,"f").emitEffect(e.toString(),{type:mn.EFFECT_SHOW_TOAST,showToast:{toast:r}})}navigateTo(e){let r;typeof e=="string"?r=new URL(e).toString():r=new URL(e.permalink,"https://www.reddit.com").toString(),Ve(this,$e,"f").emitEffect(r,{type:mn.EFFECT_NAVIGATE_TO_URL,navigateToUrl:{url:r}})}};$e=new WeakMap,pn=new WeakMap,gn=new WeakMap,fo=new WeakMap;import{EffectType as Gh,RealtimeSubscriptionStatus as Jc}from"@devvit/protos";var yn=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},V=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},bn,mo,pt,Te,mt,or,po,vn=class{constructor(e,r){bn.add(this),pt.set(this,void 0),Te.set(this,void 0),mt.set(this,void 0),or.set(this,void 0),yn(this,pt,r.context,"f"),yn(this,Te,!!r.context._devvitContext?.debug.realtime,"f"),yn(this,or,e,"f"),yn(this,mt,r.invalidate,"f");let i=r.context.meta[C.App]?.values[0];if(!i)throw Error("useChannel missing app ID metadata");let n=r.context.meta[C.Installation]?.values[0];if(!n)throw Error("useChannel missing install ID from metadata");let s=`${i}:${n}:${e.name}`;if(Object.values(V(this,pt,"f")._hooks).filter(d=>d instanceof mo).some(d=>d.state.channel===s))throw Error(`useChannel channel names must be unique; "${s}" duplicated`);this.state={channel:s,connected:!1,subscribed:!1}}async onUIEvent(e){let r=e.realtimeEvent;if(!(!r||!this.state.subscribed))switch(r.status){case Jc.REALTIME_SUBSCRIBED:V(this,Te,"f")&&console.debug(`[realtime] "${this.state.channel}" connected`),this.state.connected=!0,V(this,mt,"f").call(this),await V(this,or,"f").onSubscribed?.();break;case Jc.REALTIME_UNSUBSCRIBED:V(this,Te,"f")&&console.debug(`[realtime] "${this.state.channel}" disconnected`),this.state.connected=!1,V(this,mt,"f").call(this),await V(this,or,"f").onUnsubscribed?.();break;default:V(this,Te,"f")&&console.debug(`[realtime] "${this.state.channel}" received message: ${JSON.stringify(e,void 0,2)}`),V(this,or,"f").onMessage(r.event?.data?.msg);break}}async send(e){if(V(this,Te,"f")&&console.debug(`[realtime] "${this.state.channel}" send message: ${JSON.stringify(e,void 0,2)}`),!this.state.subscribed||!this.state.connected)throw console.debug(`[realtime] "${this.state.channel}" send failed; channel not connected`),Error(`useChannel send failed; "${this.state.channel}" channel not connected`);await V(this,pt,"f").devvitContext.realtime.send(this.state.channel,e)}get status(){return this.state.subscribed&&this.state.connected?ne.Connected:this.state.subscribed&&!this.state.connected?ne.Connecting:!this.state.subscribed&&this.state.connected?ne.Disconnecting:ne.Disconnected}subscribe(){this.state.subscribed||(V(this,Te,"f")&&console.debug(`[realtime] "${this.state.channel}" subscribed`),this.state.subscribed=!0,V(this,mt,"f").call(this),V(this,bn,"m",po).call(this))}unsubscribe(){this.state.subscribed&&(V(this,Te,"f")&&console.debug(`[realtime] "${this.state.channel}" unsubscribed`),this.state.subscribed=!1,V(this,mt,"f").call(this),V(this,bn,"m",po).call(this))}};mo=vn,pt=new WeakMap,Te=new WeakMap,mt=new WeakMap,or=new WeakMap,bn=new WeakSet,po=function(){let e=Object.values(V(this,pt,"f")._hooks).filter(r=>r instanceof mo&&r.state.subscribed).map(r=>r.state.channel);V(this,pt,"f").emitEffect(this.state.channel,{type:Gh.EFFECT_REALTIME_SUB,realtimeSubscriptions:{subscriptionIds:e}})};function go(t){if(!t.name||/[^a-zA-Z0-9_]/.test(t.name))throw Error(`useChannel error: The name "${t.name}" you provided for the hook is invalid. Valid names can only contain letters, numbers, and underscores (_).`);let e=`useChannel:${t.name}`;return Y({id:e,namespace:e,initializer:r=>new vn(t,r)})}import{EffectType as yo}from"@devvit/protos";var wo=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},ar=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},cr,gt;function Zc(t){return typeof t=="object"&&t!==null&&"__deleted"in t}var wt=class t{get devvitContext(){if(!this._devvitContext)throw new Error("Devvit context not available");return this._devvitContext}set devvitContext(e){this._devvitContext=e}constructor(e,r){cr.set(this,void 0),this._segments=[],gt.set(this,{}),this._prevHooks={},this._prevHookId="",this._effects={},this._changed={},this._touched={},this._requeueEvents=[],this._rootProps={},this._generated={},this._undeliveredHandlers={},this.request=e,this.meta=r,wo(this,cr,e.state??{__cache:{}},"f"),this._rootProps=e.props??{}}get _changedState(){let e={__cache:ar(this,cr,"f").__cache??{}};for(let i in this._changed)e[i]=this._state[i];let r=new Set(Object.keys(this._state));return Object.keys(ar(this,gt,"f")).forEach(i=>{i!=="__cache"&&r.delete(i)}),r.forEach(i=>{if(i==="__cache")return;let n={__deleted:!0};this._state[i]=e[i]=n}),e}get _hooks(){return ar(this,gt,"f")}set _hooks(e){this._prevHooks=ar(this,gt,"f"),wo(this,gt,e,"f")}get _state(){return ar(this,cr,"f")}set _state(e){wo(this,cr,e,"f")}push(e){this._segments.push({...e,next:0})}pop(){this._segments.pop()}addUndeliveredEventHandler(e,r){this._undeliveredHandlers[e]=r}addGlobalUndeliveredEventHandler(e,r){t.addGlobalUndeliveredEventHandler(e,r)}getHook(e){return ar(this,gt,"f")[e.id]}static addGlobalUndeliveredEventHandler(e,r){t._staticUndeliveredHandlers[e]=r}async handleUndeliveredEvent(e){let r={...t._staticUndeliveredHandlers,...this._undeliveredHandlers};for(let[i,n]of Object.entries(r))await n(e,this)}emitEffect(e,r){this._effects[e]=r}addToRequeueEvents(...e){this._devvitContext?.debug.blocks&&console.debug("[blocks] requeueing events",e);let r=e.reduce((i,n)=>(n.retry?i.retry.push(n):i.normal.push(n),i),{retry:[],normal:[]});this._requeueEvents=[...r.retry,...this._requeueEvents,...r.normal]}get effects(){return Object.values(this._effects)}nextHookId(e){e.key===void 0&&(e.key=this._segments[this._segments.length-1].next+++""),this.push(e);try{let r=[];for(let n=this._segments.length-1;n>=0;n--){let s=this._segments[n];if(s.id){r.unshift(s.id);break}let o=[];s.namespace&&o.push(s.namespace),s.key!==void 0&&s.key!==!1&&o.push(s.key),r.unshift(o.join("-"))}let i=r.join(".");if(this._generated[i]&&!e.shared)throw new Error(`Hook id ${i} already used, cannot register another hook with the same id`);return this._generated[i]=!0,this._prevHookId=i,i}finally{this.pop()}}};cr=new WeakMap,gt=new WeakMap;wt._staticUndeliveredHandlers={};var kn=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},Re=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},yt,Ur,_n,Lr,ze={};wt.addGlobalUndeliveredEventHandler("intervals",async(t,e)=>{t.timer&&t.hook&&(delete ze[t.hook],e.emitEffect("timers",{type:yo.EFFECT_SET_INTERVALS,interval:{intervals:ze}}))});var bo=class{constructor(e,r,i){yt.set(this,void 0),Ur.set(this,void 0),_n.set(this,void 0),Lr.set(this,void 0),this.state={duration:{seconds:0,nanos:0},running:!1},kn(this,Ur,i.invalidate,"f"),kn(this,yt,i.hookId,"f"),kn(this,_n,e,"f"),kn(this,Lr,i.context,"f");let n=Math.floor(r/1e3),s=r%1e3*1e6;this.state.duration={seconds:n,nanos:s}}onStateLoaded(){this.state.running?ze[Re(this,yt,"f")]={duration:this.state.duration}:delete ze[Re(this,yt,"f")]}async onUIEvent(e){await Re(this,_n,"f").call(this)}start(){ze[Re(this,yt,"f")]={duration:this.state.duration},this.state.running=!0,Re(this,Ur,"f").call(this),Re(this,Lr,"f").emitEffect("timers",{type:yo.EFFECT_SET_INTERVALS,interval:{intervals:ze}})}stop(){delete ze[Re(this,yt,"f")],this.state.running=!1,Re(this,Ur,"f").call(this),Re(this,Lr,"f").emitEffect("timers",{type:yo.EFFECT_SET_INTERVALS,interval:{intervals:ze}})}};yt=new WeakMap,Ur=new WeakMap,_n=new WeakMap,Lr=new WeakMap;function vo(t,e){let r=Y({namespace:"useInterval",initializer:i=>new bo(t,e,i)});return{start:()=>r.start(),stop:()=>r.stop()}}import{UIEventScope as Vh}from"@devvit/protos";var bt=class extends Error{};import{UIEventScope as Qc}from"@devvit/protos";var Wr=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},$=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Ce,Me,Hr,En,jr;function _o(t){if(t instanceof Error){if(t.message===so)throw t;return console.error(t),{message:t.message,details:t.stack??""}}else return console.error(t),{message:"Unknown error",details:lt.caughtToString(t)}}var ko=class{constructor(e,r,i){Ce.set(this,void 0),Me.set(this,void 0),Hr.set(this,void 0),En.set(this,void 0),jr.set(this,void 0),Wr(this,Ce,!!i.context.devvitContext.debug.useAsync,"f"),$(this,Ce,"f")&&console.debug("[useAsync] v1",r),this.state={data:null,load_state:"initial",error:null,depends:null},Wr(this,Me,i.hookId,"f"),this.initializer=e,Wr(this,Hr,i.invalidate,"f"),Wr(this,En,i.context,"f"),this.localDepends=r.depends??null,Wr(this,jr,r,"f")}onStateLoaded(){if($(this,Ce,"f")&&console.debug("[useAsync] async onLoad ",$(this,Me,"f"),this.state),$(this,Ce,"f")&&console.debug("[useAsync] async onLoad have ",this.localDepends,"and",this.state.depends),!ut(this.localDepends,this.state.depends)||this.state.load_state==="initial"){$(this,Ce,"f")&&console.debug("[useAsync] attempting to resolve for hookId",$(this,Me,"f")),this.state.load_state="loading",this.state.depends=this.localDepends,$(this,Hr,"f").call(this);let e={scope:Qc.ALL,hook:$(this,Me,"f"),async:!0,asyncRequest:{requestId:$(this,Me,"f")+"-"+JSON.stringify(this.state.depends)}};$(this,Ce,"f")&&console.debug("[useAsync] onLoad requeue"),$(this,En,"f").addToRequeueEvents(e)}}async onUIEvent(e,r){if(e.asyncRequest){let i={requestId:e.asyncRequest.requestId};try{i.data={value:await this.initializer()}}catch(s){i.error=_o(s)}let n={scope:Qc.ALL,asyncResponse:i,hook:$(this,Me,"f")};$(this,Ce,"f")&&console.debug("[useAsync] onReq requeue"),r.addToRequeueEvents(n)}else if(e.asyncResponse){let i=$(this,Me,"f")+"-"+JSON.stringify(this.state.depends);e.asyncResponse.requestId===i?(this.state={...this.state,data:e.asyncResponse.data?.value??null,error:e.asyncResponse.error??null,load_state:e.asyncResponse.error?"error":"loaded"},$(this,jr,"f").finally&&await $(this,jr,"f").finally(this.state.data,this.state.error?new Error(this.state.error?.message??"Unknown error"):null),$(this,Hr,"f").call(this)):$(this,Ce,"f")&&console.debug("[useAsync] onResp skip, stale event",e.asyncResponse.requestId," !== ",i)}else throw new Error("Unknown event type")}};Ce=new WeakMap,Me=new WeakMap,Hr=new WeakMap,En=new WeakMap,jr=new WeakMap;function Gr(t,e={}){let r=Y({namespace:"useAsync",initializer:i=>new ko(t,e,i)});return{data:r.state.data,error:r.state.error,loading:r.state.load_state==="loading"}}var Cn=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},ee=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Ke,Vr,dr,vt,Eo=class{constructor(e,r){this.state={value:null,load_state:"initial",error:null},Ke.set(this,void 0),Vr.set(this,void 0),dr.set(this,void 0),vt.set(this,void 0),Cn(this,dr,e,"f"),Cn(this,vt,r.hookId,"f"),Cn(this,Ke,r.invalidate,"f"),Cn(this,Vr,r.context,"f")}async onUIEvent(){if(this.state.load_state==="loading"&&this._promise){try{this.state.value=await this._promise,this.state.load_state="loaded"}catch(e){this.state.load_state="error",this.state.error=_o(e)}ee(this,Ke,"f").call(this)}else console.warn(`Invalid state for hook (${ee(this,vt,"f")}):`,this.state.load_state,this._promise)}setter(e){this.state.value=e instanceof Function?e(this.state.value):e,this.state.load_state="loaded",ee(this,Ke,"f").call(this)}onStateLoaded(){if(this._promise=ee(this,Vr,"f")._prevHooks[ee(this,vt,"f")]?._promise,this.state.load_state==="loading")throw new bt;if(this.state.load_state==="error")throw new Error(this.state.error?.message??"Unknown error");if(this.state.load_state==="initial"){let e;try{e=ee(this,dr,"f")instanceof Function?ee(this,dr,"f").call(this):ee(this,dr,"f")}catch(r){console.log("error in loading async",r),this.state.load_state="error",ee(this,Ke,"f").call(this);return}if(e instanceof Promise){this._promise=e,this.state.load_state="loading";let r={scope:Vh.ALL,asyncRequest:{requestId:ee(this,vt,"f")},hook:ee(this,vt,"f")};throw ee(this,Vr,"f").addToRequeueEvents(r),ee(this,Ke,"f").call(this),new bt}else this.state.value=e,this.state.load_state="loaded";ee(this,Ke,"f").call(this)}}};Ke=new WeakMap,Vr=new WeakMap,dr=new WeakMap,vt=new WeakMap;function kt(t){let e=Y({namespace:"useState",initializer:r=>new Eo(t,r)});return[e.state.value,e.setter.bind(e)]}var Fn=class{buildContext(e,r,i){let n=new Zt(i),s=new qt(i),o=new Xt(i),d=new er(i),l=new tr(i),u=new wn(e),g=new Jt(i),p=new Kt,_=new Qt(i),I=$c(o,e._state),T={modLog:n,kvStore:s,redis:o,scheduler:d,settings:l,media:g,assets:p,realtime:_,ui:u,useState:kt,useChannel:go,useInterval:vo,useForm:uo,cache:I,dimensions:r.env?.dimensions,uiEnvironment:{timezone:i[C.Timezone]?.values[0],locale:i[C.Language]?.values[0],dimensions:r.env?.dimensions,colorScheme:r.env?.colorScheme}},L=z(i,r.props?.postId);return L.debug.effects=e,{...L,...T}}};var R=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},$h=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},M,$r,Po,xn,te,An,ed,Co,td,Io,Fo,Pn,Ao,Xc,se=null;function Yc(t){return JSON.parse(JSON.stringify(t))}function Kh(t){if(!(t!==""&&!/[-.]/.test(t)))throw new Error(`Hook with namespace '${t}' is invalid. Hook namespaces cannot be empty string or contain dashes/dots because they are used as delimiters internally. Please update the hook namespace and try again.`)}function Y({initializer:t,...e}){if(!se)throw new Error("Hooks can only be declared at the top of a component. You cannot declare hooks outside of components or inside of event handlers. It's almost always a mistake to declare hooks inside of loops or conditionals.");Kh(e.namespace);let r=se.nextHookId(e),i=se,n={hookId:r,invalidate:()=>{i._changed[r]=!0,i._state[r]=i?._hooks[r]?.state},context:se},s=se._state[r]===void 0||Zc(se._state[r]);se._hooks[r]=se._hooks[r]??t(n);let o=se._hooks[r];return s||(o.state=se._state[r]),o.onStateLoaded?.(),s&&o.state!==void 0&&o.state!==null&&n.invalidate(),o}var qh=null,In=128,_t=class{constructor(e){M.add(this),$r.set(this,void 0),Po.set(this,new Fn),xn.set(this,new sr(()=>this._latestRenderContext?.devvitContext?.assets)),this._latestRenderContext=null,R(this,M,"a",te)&&console.debug("[blocks] BlocksHandler v1"),$h(this,$r,e,"f"),qh=this}async handle(e,r){let i=new wt(e,r);i.devvitContext=R(this,Po,"f").buildContext(i,e,r);let n,s=e.events.length-In,o=e.events;if(s>0){o=[];{let T=0;for(let L of e.events)T<s&&L.realtimeEvent?T++:o.push(L)}for(;o.length>In;)o.shift();console.warn(`dropped ${s} events`)}let l=!o.length||o.some(T=>!T.async),u=o.some(T=>T.blocking),g,p,_=[...o];o.length===0&&o.push({scope:zh.ALL}),R(this,M,"a",te)&&console.debug("[blocks] starting processing events");let I=0;for(;o.length>0;){if(I++>In)throw new Error(`Exceeded maximum iterations of ${In}`);R(this,M,"a",te)&&console.debug("[blocks] processing events loop iteration",o.length);let T=[];if(!o[0].async)T.push(o.shift());else for(;o[0]?.async;)T.push(o.shift());if(!T.length)throw Error("batch must have at least one event");try{if(T[0].async){let D=Yc(i._state);await R(this,M,"m",ed).call(this,i,...T),i._state=D}else await R(this,M,"m",td).call(this,i,...T)}catch(D){if(!ln(D))throw D;if(R(this,M,"a",te)&&console.debug("[blocks] caught in handler",D),i._latestRenderContent=void 0,p){i._state=p._state,i._changed=g,i._effects=p._effects;let oe=_.map(Rl=>{let Jo={...Rl};return Jo.retry=!0,Jo});i.addToRequeueEvents(...oe);break}else throw ln(D)||console.error("[blocks] unhandled error in handler",D),D}R(this,M,"a",te)&&console.debug("[blocks] remaining events",i._requeueEvents);let L=[];for(let D of i._requeueEvents){if(!l&&!D.async){R(this,M,"a",te)&&console.debug("[blocks] NOT reprocessing event in BlocksHandler, sync mismatch A",D),L.push(D);continue}if(l&&D.async&&!u){R(this,M,"a",te)&&console.debug("[blocks] NOT reprocessing event in BlocksHandler, sync mismatch B",D),L.push(D);continue}R(this,M,"a",te)&&console.debug("[blocks] reprocessing event in BlocksHandler",D),o.push(D)}i._requeueEvents=L,o.length>0&&(g={...i._changed},p={_state:Yc(i._state),_effects:{...i._effects}},_=[...o])}if(l){i._latestRenderContent||(i._latestRenderContent=R(this,M,"m",Io).call(this,R(this,$r,"f"),i.request.props??{},i));let T=i._latestRenderContent;T&&(n=R(this,xn,"f").createBlocksElementOrThrow(T),n=R(this,xn,"f").ensureRootBlock(n))}return{state:i._changedState,effects:i.effects,blocks:n,events:i._requeueEvents}}};$r=new WeakMap,Po=new WeakMap,xn=new WeakMap,M=new WeakSet,te=function(){return!!this._latestRenderContext?.devvitContext.debug.blocks},An=function(e,...r){e._hooks={},R(this,M,"m",Io).call(this,R(this,$r,"f"),e.request.props??{},e)},ed=async function(e,...r){R(this,M,"m",An).call(this,e,...r),await Promise.all(r.map(async i=>{if(!i.async)throw new Error("You can't mix main and other queues in one batch. This is likely a platform bug. Please file an issue in the Discord for someone to help! https://discord.com/channels/1050224141732687912/1115441897079574620");await R(this,M,"m",Co).call(this,e,i)}))},Co=async function(e,r){let i=e._hooks[r.hook];if(i?.onUIEvent)try{await i.onUIEvent(r,e)}catch(n){throw ln(n)?R(this,M,"a",te)&&console.error("Server call required",n):console.error("Error in event handler",n),n}else await e.handleUndeliveredEvent(r)},td=async function(e,...r){for(let i of r)R(this,M,"a",te)&&console.log("[blocks] handling main queue event",i),R(this,M,"a",te)&&console.log("[blocks] before",e._state),R(this,M,"m",An).call(this,e,i),await R(this,M,"m",Co).call(this,e,i),R(this,M,"a",te)&&console.log("[blocks] after",e._state);R(this,M,"m",An).call(this,e)},Io=function(e,r,i){R(this,M,"a",te)&&console.debug("[blocks] renderRoot"),i._generated={},se=i,this._latestRenderContext=i;try{let n=R(this,M,"m",Fo).call(this,e,r,i);if(n.length!==1)throw new Error(`There can only be one root element, received: ${n.length}. Please wrap these elements in a <vstack></vstack> or <hstack></hstack> to continue. Fragments cannot be used as a root element.`);let s=n[0];if(s==="[object Promise]")throw new Error('Root elements cannot be async. To use data from an async endpoint, please use "const [data] = useState(async () => {/** your async code */})".');if(typeof s=="string")throw new Error("The root element must return a valid block, not a string. Try wrapping the element in a <text>your content</text> tag to continue.");return i._latestRenderContent=s,s}catch(n){if(n instanceof bt)return;throw n}finally{se=null}},Fo=function(e,r,i){i.push({namespace:e.name||"anonymous",...r});try{let n=e(r,i.devvitContext);if(n instanceof Promise)throw new Error(`Components (found: ${e.name??"unknown component"}) cannot be async. To use data from an async endpoint, please use "const [data] = useState(async () => {/** your async code */})".`);return R(this,M,"m",Ao).call(this,n,i)}finally{i.pop()}},Pn=function(e,r){return e=e.flat(1/0),e.flatMap((i,n)=>(i&&typeof i=="object"&&"props"in i&&(i.props?.key||(i.props=i.props??{},i.props.key=`${n}`)),R(this,M,"m",Ao).call(this,i,r)))},Ao=function(e,r){if(Array.isArray(e))return R(this,M,"m",Pn).call(this,e,r);if(Jh(e))if(e.type===void 0)try{return r.push({namespace:"fragment",...e.props}),R(this,M,"m",Pn).call(this,e.children,r)}finally{r.pop()}else if(typeof e.type=="function"){let i={...e.props,children:e.children.flat(1/0)};return R(this,M,"m",Fo).call(this,e.type,i,r)}else try{r.push({namespace:e.type,...e.props});let i=R(this,M,"m",Pn).call(this,e.children,r),n=R(this,M,"m",Xc).call(this,e.props??{});return[{type:e.type,children:i,props:n}]}finally{r.pop()}else return[(e??"").toString()]},Xc=function(e){let r={};for(let i in e)if(!(typeof e[i]>"u"))if(typeof e[i]=="function"){let n=Y({namespace:i,key:!1,initializer:({hookId:s})=>({hookId:s,state:null,onUIEvent:o=>{if(o.userAction)return e[i](o.userAction.data);if(o.webView?.postMessage){let d=o.webView.postMessage.jsonString?JSON.parse(o.webView.postMessage.jsonString):o.webView.postMessage.message;return e[i](d)}}})});r[i]=n.hookId,"captureHookRef"in e[i]&&e[i].captureHookRef()}else{let n=JSON.parse(JSON.stringify(e[i]));n!=null&&(r[i]=n)}return r};function Jh(t){return typeof t=="object"&&t!=null&&"type"in t}var rd=t=>{let e=Number(t.trim().split(".").pop());return isNaN(e)?void 0:e},id=t=>{let[e,r,i]=t.trim().split(";");if(!e||!r||!i){console.warn(`Received a malformed devvit-user-agent! Received: '${t}'`);return}if(e!=="Reddit"){console.warn(`Received unknown company name in user agent! Received: '${t}'`);return}if(r==="iOS"){let n=rd(i);if(n===void 0){console.warn(`Could not parse version number from user agent! Received: '${t}'`);return}return{company:"Reddit",platform:"iOS",rawVersion:i,versionNumber:n}}if(r==="Android"){let n=rd(i);if(n===void 0){console.warn(`Could not parse version number from user agent! Received: '${t}'`);return}return{company:"Reddit",platform:"Android",rawVersion:i,versionNumber:n}}if(r==="Shreddit")return{company:"Reddit",platform:"Shreddit",rawVersion:i};if(r==="Play")return{company:"Reddit",platform:"Play",rawVersion:i};console.warn("Received unknown platform:",r)},nd=t=>t?t.platform==="Android"?t.versionNumber<1875012:t.platform==="iOS"?t.versionNumber<614973:!1:(console.warn(`Could not parse devvit-user-agent! Received: '${JSON.stringify(t)}'`),!1),Zh=t=>{switch(t){case"Android":return"https://play.google.com/store/apps/details?id=com.reddit.frontpage";case"iOS":return"https://apps.apple.com/us/app/reddit/id1064216828";case"Play":case"Shreddit":break;default:console.error(`No upgrade link for platform: ${t}`)}},Qh=({platform:t},e)=>a.createElement("blocks",null,a.createElement("vstack",{alignment:"middle center",height:100,width:100},a.createElement("vstack",{maxWidth:"300px",gap:"large",alignment:"middle center"},a.createElement("vstack",{gap:"medium",alignment:"middle center"},a.createElement("image",{imageHeight:100,imageWidth:100,url:"https://i.redd.it/p1vmc5ulmpib1.png"}),a.createElement("text",{size:"large",weight:"bold",wrap:!0,alignment:"center"},"Uh oh, the app you're trying to use requires the latest version of Reddit. Please upgrade your app to continue.")),a.createElement("hstack",{alignment:"middle center"},a.createElement("button",{onPress:()=>{let r=Zh(t);r?e.ui.navigateTo(r):console.warn("No upgrade link found for platform:",t)}},"Upgrade"))))),sd=t=>()=>a.createElement(Qh,{platform:t});var Xh=()=>a.createElement("vstack",{alignment:"center middle",width:"100%",height:"100%"},a.createElement("text",null,"This feature is not available yet")),Yh=[[Sn,Sn.methods.renderPostContent,(t,e)=>a.customPostType?.render(e)??null],[Sn,Sn.methods.renderPostComposer,(t,e)=>a.createElement(Xh,null)]];function ef(t){return async(e,r)=>{let i=id(r["devvit-user-agent"]?.values?.[0]??"");if(i&&nd(i)){let s=new _t(sd(i.platform));return od.fromJSON(await s.handle(e,r))}let n=new _t(t);return od.fromJSON(await n.handle(e,r))}}function ad(t){for(let[e,r,i]of Yh)t.provides(e),x(r.name,ef(i))}var v=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},lr=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},f,Tn,xo,ur,zr,Kr,Rn,Mn,qr,hr,So,To,Jr,W,a=class extends Di{static configure(e){lr(this,f,{...v(this,f,"f",ur),...e},"f",ur),ue(e.http)&&this.use(w.HTTPDefinition),(e.redis===void 0||ue(e.kvStore)||ue(e.redis))&&(this.use(w.KVStoreDefinition),this.use(w.RedisAPIDefinition)),ue(e.media)&&this.use(w.MediaServiceDefinition),ue(e.modLog)&&this.use(w.ModlogDefinition),ue(e.redditAPI)&&(this.use(w.FlairDefinition),this.use(w.GraphQLDefinition),this.use(w.LinksAndCommentsDefinition),this.use(w.ListingsDefinition),this.use(w.ModerationDefinition),this.use(w.ModNoteDefinition),this.use(w.NewModmailDefinition),this.use(w.PrivateMessagesDefinition),this.use(w.SubredditsDefinition),this.use(w.UsersDefinition),this.use(w.WidgetsDefinition),this.use(w.WikiDefinition)),ue(e.realtime)&&this.use(w.RealtimeDefinition),ue(e.userActions)&&this.use(w.UserActionsDefinition)}static addMenuItem(e){v(this,f,"f",Mn).push(e)}static addCustomPostType(e){lr(this,f,e,"f",zr)}static createForm(e,r){let i=`form.${v(this,f,"f",Kr).size}`;return v(this,f,"f",Kr).set(i,{form:e,onSubmit:r}),i}static addSchedulerJob(e){if(v(this,f,"f",W)[w.SchedulerDefinition.fullName]||this.use(w.SchedulerDefinition),v(this,f,"f",qr).has(e.name))throw new Error(`Job ${e.name} is already defined`);v(this,f,"f",qr).set(e.name,e.onRun)}static addSettings(e){it(e);let r=e.filter(n=>n.type==="group"||!n.scope||n.scope===rt.Installation),i=e.filter(n=>n.type!=="group"&&n.scope===rt.App);r.length>0&&lr(this,f,r,"f",Rn),i.length>0&&lr(this,f,i,"f",Tn),v(this,f,"f",W)[w.SettingsDefinition.fullName]||this.use(w.SettingsDefinition)}static addTrigger(e){if("events"in e){for(let r of e.events)this.addTrigger({event:r,onEvent:(i,n)=>e.onEvent(i,n)});return this}return v(this,f,"f",hr).has(e.event)?v(this,f,"f",hr).get(e.event)?.push(e.onEvent):v(this,f,"f",hr).set(e.event,[e.onEvent]),f}static provide(e){v(this,f,"f",To).push(e)}static use(e,r){v(this,f,"f",Jr)[e.fullName]={def:e,options:r??{},handler:void 0};let i={};for(let n of Object.values(e.methods))i[n.name]=(s,o)=>v(this,f,"f",Jr)[e.fullName].handler?.[n.name]?.(n.requestType?.fromPartial(s??{}),o);return v(this,f,"f",W)[e.fullName]=i,i}static get redditAPIPlugins(){if(!ue(v(this,f,"f",ur).redditAPI))throw new Error("Reddit API is not enabled. You can enable it by passing `redditAPI: true` to `Devvit.configure`.");return{Flair:v(this,f,"f",W)[w.FlairDefinition.fullName],GraphQL:v(this,f,"f",W)[w.GraphQLDefinition.fullName],LinksAndComments:v(this,f,"f",W)[w.LinksAndCommentsDefinition.fullName],Listings:v(this,f,"f",W)[w.ListingsDefinition.fullName],Moderation:v(this,f,"f",W)[w.ModerationDefinition.fullName],ModNote:v(this,f,"f",W)[w.ModNoteDefinition.fullName],NewModmail:v(this,f,"f",W)[w.NewModmailDefinition.fullName],PrivateMessages:v(this,f,"f",W)[w.PrivateMessagesDefinition.fullName],Subreddits:v(this,f,"f",W)[w.SubredditsDefinition.fullName],Users:v(this,f,"f",W)[w.UsersDefinition.fullName],Widgets:v(this,f,"f",W)[w.WidgetsDefinition.fullName],Wiki:v(this,f,"f",W)[w.WikiDefinition.fullName]}}static get modLogPlugin(){let e=v(this,f,"f",W)[w.ModlogDefinition.fullName];if(!e)throw new Error("ModLog is not enabled. You can enable it by passing `modLog: true` to `Devvit.configure`");return e}static get schedulerPlugin(){let e=v(this,f,"f",W)[w.SchedulerDefinition.fullName];if(!e)throw new Error("Scheduler is not enabled. You can enable it by calling `Devvit.addSchedulerJob` at the top level of your app.");return e}static get kvStorePlugin(){let e=v(this,f,"f",W)[w.KVStoreDefinition.fullName];if(!e)throw new Error("Key Value Store is not enabled. You can enable it by passing `kvStore: true` to `Devvit.configure`");return e}static get redisPlugin(){let e=v(this,f,"f",W)[w.RedisAPIDefinition.fullName];if(!e)throw new Error("Redis is not enabled. You can enable it by passing `redis: true` to `Devvit.configure`");return e}static get mediaPlugin(){let e=v(this,f,"f",W)[w.MediaServiceDefinition.fullName];if(!e)throw new Error("MediaService is not enabled. You can enable it by passing `media: true` to `Devvit.configure`");return e}static get settingsPlugin(){let e=v(this,f,"f",W)[w.SettingsDefinition.fullName];if(!e)throw new Error("Settings must first be configured with `Devvit.addSettings()` before they can be accessed");return e}static get realtimePlugin(){let e=v(this,f,"f",W)[w.RealtimeDefinition.fullName];if(!e)throw new Error("Realtime is not enabled. You can enable it by passing `realtime: true` to `Devvit.configure`");return e}static get userActionsPlugin(){if(!(ue(v(this,f,"f",ur).userActions)&&ue(v(this,f,"f",ur).redditAPI)))throw new Error("UserActions is not enabled. You can enable it by passing both `userActions: true` and `redditAPI: true` to `Devvit.configure`");return v(this,f,"f",W)[w.UserActionsDefinition.fullName]}static get menuItems(){return v(this,f,"f",Mn)}static get customPostType(){return v(this,f,"f",zr)}static get formDefinitions(){return v(this,f,"f",Kr)}static get scheduledJobHandlers(){return v(this,f,"f",qr)}static get installationSettings(){return v(this,f,"f",Rn)}static get appSettings(){return v(this,f,"f",Tn)}static get triggerOnEventHandlers(){return v(this,f,"f",hr)}static get assets(){return v(this,f,"f",xo)}static get webViewAssets(){return v(this,f,"f",So)}constructor(e){super(e),lr(f,f,e.assets??{},"f",xo),lr(f,f,e.webviewAssets??{},"f",So);for(let r in v(f,f,"f",Jr)){let i=v(f,f,"f",Jr)[r];i.handler=e.use(i.def,i.options)}v(f,f,"f",Mn).length>0&&hc(e),v(f,f,"f",qr).size>0&&fc(e),v(f,f,"f",zr)&&(rc(e),ad(e)),(v(f,f,"f",zr)||v(f,f,"f",Kr).size>0)&&Rc(e),v(f,f,"f",Rn)&&ic(e),v(f,f,"f",Tn)&&Da(e),v(f,f,"f",hr).size>0&&mc(e);for(let r of v(f,f,"f",To))e.provides(r)}};f=a;a.debug={};Tn={value:void 0};xo={value:{}};ur={value:{}};zr={value:void 0};Kr={value:new Map};Rn={value:void 0};Mn={value:[]};qr={value:new Map};hr={value:new Map};So={value:{}};To={value:[]};Jr={value:{}};W={value:{}};(function(t){function e(r,i,...n){return{type:r,props:i,children:n}}t.createElement=e})(a||(a={}));function re(t){let e=Object.getOwnPropertyDescriptors(t.constructor.prototype);for(let[r,i]of Object.entries(e))i.get&&Object.defineProperty(t,r,{...i,enumerable:!0})}var Ro;(function(t){t[t.bold=1]="bold",t[t.italic=2]="italic",t[t.underline=4]="underline",t[t.strikethrough=8]="strikethrough",t[t.subscript=16]="subscript",t[t.superscript=32]="superscript",t[t.monospace=64]="monospace"})(Ro||(Ro={}));var cd="text",dd="raw",ld="br",ud="link",hd="c/",fd="p/",md="r/",pd="u/",gd="@",wd="spoilertext",yd="par",bd="h",vd="hr",kd="blockquote",_d="code",Ed="li",Cd="list",Fd="L",Ad="R",Pd="C",Id="table",xd="embed",Sd="img",Td="gif",Rd="video";function Md(t){return{e:Td,id:t.mediaId,...t.caption&&{c:t.caption},...t.blur&&{o:t.blur}}}function Nd(t,e){let r={},i=[];return Object.assign(r,Zr(r,i),Qr(r,i),Xr(r,i),ti(r,i),ri(r,i),ii(r,i)),e(r),{e:kd,c:i,...t.author&&{a:t.author}}}function Bd(t,e){let r={},i=[];return Object.assign(r,No(r,i)),e(r),{e:_d,c:i,...t.language&&{l:t.language}}}function Dd(t){return{e:hd,t:t.permalink}}function Od(t,e){let r={},i=[];return Object.assign(r,No(r,i),ei(r,i)),e(r),{e:bd,l:t.level,c:i}}function Ud(t){return{e:xd,u:t.sourceUrl,c:t.contentUrl,x:t.width,y:t.height}}function Ld(){return{e:vd}}function Wd(t){return{e:Sd,id:t.mediaId,...t.caption&&{c:t.caption},...t.blur&&{o:t.blur}}}function Hd(){return{e:ld}}function jd(t){return{e:ud,t:t.text,u:t.url,...t.formatting&&{f:t.formatting},...t.tooltip&&{a:t.tooltip}}}function Gd(t,e){let r={},i=[];return Object.assign(r,sl(r,i)),e(r),{e:Cd,o:t.ordered,c:i}}function Vd(t){let e={},r=[];return Object.assign(e,Zr(e,r),Qr(e,r),Xr(e,r),Nn(e,r),ti(e,r),ri(e,r),ii(e,r)),t(e),{e:Ed,c:r}}function $d(t){let e={},r=[];return Object.assign(e,Bn(e,r),ei(e,r),Mo(e,r),Bo(e,r),Yr(e,r)),t(e),{e:yd,c:r}}function zd(t){return{e:fd,t:t.permalink}}function Kd(t){return{e:dd,t}}function qd(t){let e={},r=[];return Object.assign(e,Bn(e,r),ei(e,r),Mo(e,r)),t(e),{e:wd,c:r}}function Jd(t){return{e:md,t:t.subredditName,l:t.showPrefix}}function Zd(t){let e={},r=[],i=[];return Object.assign(e,ol(e,r,i)),t(e),{e:Id,h:r,c:i}}function Qd(t){let[e,r]=nl();return t(e),{c:r}}function Xd(t,e){let[r,i]=nl();e(r);let n;switch(t.columnAlignment){case"left":n=Fd;break;case"right":n=Ad;break;case"center":n=Pd;break}return{...n&&{a:n},...i&&{c:i}}}function Yd(t){let e={},r=[];return Object.assign(e,al(e,r)),t(e),r}function el(t){return{e:cd,t:t.text,...t.formatting&&{f:t.formatting}}}function tl(t){return{e:pd,t:t.username,l:t.showPrefix}}function rl(t){return{e:gd,t:t.username,l:t.showPrefix}}function il(t){return{e:Rd,id:t.mediaId,...t.caption&&{c:t.caption},...t.blur&&{o:t.blur},...t.thumbnail&&{p:t.thumbnail},...t.convertToGif&&{gifify:t.convertToGif}}}function nl(){let t={},e=[];return Object.assign(t,Bn(t,e),ei(t,e),Bo(t,e),Yr(t,e)),[t,e]}function Zr(t,e){return{blockQuote(r,i){return e.push(Nd(r,i)),t}}}function Qr(t,e){return{codeBlock(r,i){return e.push(Bd(r,i)),t}}}function cl(t,e){return{embed(r){return e.push(Ud(r)),t}}}function Xr(t,e){return{heading(r,i){return e.push(Od(r,i)),t}}}function Nn(t,e){return{horizontalRule(){return e.push(Ld()),t}}}function Yr(t,e){return{image(r){return e.push(Wd(r)),t},animatedImage(r){return e.push(Md(r)),t}}}function Mo(t,e){return{linebreak(){return e.push(Hd()),t}}}function ei(t,e){return{link(r){return e.push(jd(r)),t},commentLink(r){return e.push(Dd(r)),t},postLink(r){return e.push(zd(r)),t},subredditLink(r){return e.push(Jd(r)),t},userLink(r){return e.push(tl(r)),t},userMention(r){return e.push(rl(r)),t}}}function ti(t,e){return{list(r,i){return e.push(Gd(r,i)),t}}}function sl(t,e){return{item(r){return e.push(Vd(r)),t}}}function ri(t,e){return{paragraph(r){return e.push($d(r)),t}}}function No(t,e){return{rawText(r){return e.push(Kd(r)),t}}}function Bo(t,e){return{spoiler(r){return e.push(qd(r)),t}}}function ol(t,e,r){return{headerCell(i,n){return e.push(Xd(i,n)),t},row(i){return r.push(Yd(i)),t}}}function ii(t,e){return{table(r){return e.push(Zd(r)),t}}}function al(t,e){return{cell(r){return e.push(Qd(r)),t}}}function Bn(t,e){return{text(r){return e.push(el(r)),t}}}function dl(t,e){return{video(r){return e.push(il(r)),t}}}var tf=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},rf=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Dn,Et=class{constructor(){Dn.set(this,void 0);let e=[];Object.assign(this,ri(this,e),Xr(this,e),Nn(this,e),Zr(this,e),Qr(this,e),cl(this,e),ti(this,e),ii(this,e),Yr(this,e),dl(this,e)),tf(this,Dn,{document:e},"f")}build(){return JSON.stringify(rf(this,Dn,"f"))}paragraph(e){return this}heading(e,r){return this}horizontalRule(){return this}blockQuote(e,r){return this}codeBlock(e,r){return this}embed(e){return this}list(e,r){return this}table(e){return this}image(e){return this}animatedImage(e){return this}video(e){return this}};Dn=new WeakMap;function fr(t){let e;return t instanceof Et?e=t.build():typeof t=="object"?e=JSON.stringify(t):e=t,e}var Ne=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},Fe=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},ni,mr,pr,Ct,si,On,ll=100,ul=1/0,j=class{constructor(e){ni.add(this),mr.set(this,void 0),pr.set(this,void 0),Ct.set(this,void 0),si.set(this,!1),this.pageSize=ll,this.limit=ul,this.children=[],re(this),this._fetch=e.fetch,this.pageSize=e.pageSize??ll,this.limit=e.limit??ul,Ne(this,pr,e.after,"f"),Ne(this,mr,e.before,"f"),Ne(this,Ct,e.more,"f"),e.children&&(this.children=e.children)}get hasMore(){return!Fe(this,si,"f")||!!(Fe(this,pr,"f")||Fe(this,mr,"f")||Fe(this,Ct,"f"))}async*[(mr=new WeakMap,pr=new WeakMap,Ct=new WeakMap,si=new WeakMap,ni=new WeakSet,Symbol.asyncIterator)](){let e=0;for(;;){if(e===this.children.length)if(this.hasMore){if((await Fe(this,ni,"m",On).call(this)).length===0)break}else break;if(yield this.children[e],e++,e===this.limit)break}}setMore(e){Ne(this,Ct,e,"f")}preventInitialFetch(){Ne(this,si,!0,"f")}async all(){for(;this.hasMore&&this.children.length<this.limit;)await Fe(this,ni,"m",On).call(this);return this.children.slice(0,this.limit)}async get(e){let r=e<=this.limit?e:this.limit;for(;this.hasMore&&this.children.length<r;)await Fe(this,ni,"m",On).call(this);return this.children.slice(0,r)}};On=async function(){if(!this.hasMore)throw new Error("This listing does not have any more items to load.");let{children:e,before:r,after:i,more:n}=await this._fetch({before:Fe(this,mr,"f"),after:Fe(this,pr,"f"),limit:this.pageSize,more:Fe(this,Ct,"f")});return this.children.push(...e),Ne(this,mr,r,"f"),Ne(this,pr,i,"f"),Ne(this,Ct,n,"f"),Ne(this,si,!0,"f"),e};var hl=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Do,Oo,qe=class{constructor(){}static get(e,r){let i=a.redditAPIPlugins.ModNote;return new j({hasMore:!0,before:e.before,limit:e.limit,pageSize:e.limit,fetch:async n=>{let s=await i.GetNotes({subreddit:e.subreddit,user:e.user,filter:e.filter,before:n.before,limit:n.limit},r);return{children:s.modNotes?.map(o=>hl(this,Do,"m",Oo).call(this,o))||[],before:s.hasNextPage?s.endCursor:void 0,hasMore:s.hasNextPage}}})}static async delete(e,r){let i=a.redditAPIPlugins.ModNote,{deleted:n}=await i.DeleteNotes(e,r);return!!n}static async add(e,r){let n=await a.redditAPIPlugins.ModNote.PostNotes(e,r);if(!n?.created)throw new Error("Failed to create mod note");return hl(this,Do,"m",Oo).call(this,n.created)}static async addRemovalNote(e,r){await a.redditAPIPlugins.ModNote.PostRemovalNote(e,r)}};Do=qe,Oo=function(e){return m(e.id,"Mod note ID is null or undefined"),m(e.createdAt,"Mod note createdAt is null or undefined"),m(e.type,"Mod note type is null or undefined"),m(e.subreddit,"Mod note subreddit is null or undefined"),m(e.subredditId,"Mod note subredditId is null or undefined"),m(e.operator,"Mod note operator is null or undefined"),m(e.operatorId,"Mod note operatorId is null or undefined"),m(e.user,"Mod note user is null or undefined"),m(e.userId,"Mod note userId is null or undefined"),m(e.userNoteData,"Mod note userNote is null or undefined"),m(e.modActionData,"Mod note modAction is null or undefined"),{id:e.id,user:{id:ie(e.userId??""),name:e.user},subreddit:{id:ge(e.subredditId??""),name:e.subreddit},operator:{id:ie(e.operatorId??""),name:e.operator},createdAt:new Date(e.createdAt*1e3),userNote:{note:e.userNoteData?.note,redditId:e.userNoteData?.redditId?Gt(e.userNoteData?.redditId):void 0,label:e.userNoteData?.label},type:e.type}};var fe=class{static queryWithQueryString(e,r){return a.redditAPIPlugins.GraphQL.Query({query:e},r)}static query(e,r,i,n){return a.redditAPIPlugins.GraphQL.PersistedQuery({operationName:e,id:r,variables:i},n)}};var fl=["all","wiki","posts","access","mail","config","flair","channels","chat_config","chat_operator","community_chat"];function nf(t,e){return e.map(r=>(t.includes(r)?"+":"-")+r).join(",")}function Uo(t){return nf(t,fl)}function ml(t){return t.filter(e=>fl.includes(e))}import"@devvit/protos";var Ae=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},B=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},Q,gr,oi,ai,ci,di,li,ui,hi,fi,mi,Un,q,Lo,pl,Wo,Ln;(function(t){t.User="USER_FLAIR",t.Post="LINK_FLAIR"})(Ln||(Ln={}));var pi=class{constructor(e,r,i){gr.set(this,void 0),oi.set(this,void 0),ai.set(this,void 0),ci.set(this,void 0),di.set(this,void 0),li.set(this,void 0),ui.set(this,void 0),hi.set(this,void 0),fi.set(this,void 0),mi.set(this,void 0),re(this),m(e.id),m(e.text),Ae(this,gr,e.id,"f"),Ae(this,oi,r,"f"),Ae(this,ai,e.text,"f"),Ae(this,ci,sf(e.textColor),"f"),Ae(this,di,of(e.backgroundColor),"f"),Ae(this,li,af(e.allowableContent),"f"),Ae(this,ui,e.modOnly,"f"),Ae(this,hi,e.maxEmojis,"f"),Ae(this,fi,e.textEditable,"f"),Ae(this,mi,i,"f")}get id(){return B(this,gr,"f")}get text(){return B(this,ai,"f")}get textColor(){return B(this,ci,"f")}get backgroundColor(){return B(this,di,"f")}get allowableContent(){return B(this,li,"f")}get modOnly(){return B(this,ui,"f")}get maxEmojis(){return B(this,hi,"f")}get allowUserEdits(){return B(this,fi,"f")}async delete(){return Q.deleteFlairTemplate(B(this,gr,"f"),B(this,oi,"f"),B(this,mi,"f"))}async edit(e){return Q.editFlairTemplate({id:B(this,gr,"f"),subredditName:B(this,oi,"f"),text:e.text??B(this,ai,"f"),allowableContent:e.allowableContent??B(this,li,"f"),backgroundColor:e.backgroundColor??B(this,di,"f"),maxEmojis:e.maxEmojis??B(this,hi,"f"),modOnly:e.modOnly??B(this,ui,"f"),textColor:e.textColor??B(this,ci,"f"),allowUserEdits:e.allowUserEdits??B(this,fi,"f")},B(this,mi,"f"))}static async createPostFlairTemplate(e,r){return B(Q,Q,"m",Un).call(Q,{...e,flairType:Ln.Post},r)}static async createUserFlairTemplate(e,r){return B(Q,Q,"m",Un).call(Q,{...e,flairType:Ln.User},r)}static async editFlairTemplate(e,r){return B(Q,Q,"m",Un).call(Q,e,r)}static async getPostFlairTemplates(e,r){return(await a.redditAPIPlugins.Flair.LinkFlair({subreddit:e},r)).flair?.map(s=>new Q(s,e,r))||[]}static async getUserFlairTemplates(e,r){return(await a.redditAPIPlugins.Flair.UserFlair({subreddit:e},r)).flair?.map(s=>new Q(s,e,r))||[]}static async deleteFlairTemplate(e,r,i){await a.redditAPIPlugins.Flair.DeleteFlairTemplate({subreddit:e,flairTemplateId:r},i)}};Q=pi,gr=new WeakMap,oi=new WeakMap,ai=new WeakMap,ci=new WeakMap,di=new WeakMap,li=new WeakMap,ui=new WeakMap,hi=new WeakMap,fi=new WeakMap,mi=new WeakMap,Un=async function(e,r){let{subredditName:i,allowableContent:n="all",backgroundColor:s="transparent",flairType:o="",maxEmojis:d=10,modOnly:l=!1,text:u,textColor:g="dark",allowUserEdits:p=!1,id:_=""}=e;if(l&&p)throw new Error("Cannot have a mod only flair that is editable by users");let T=await a.redditAPIPlugins.Flair.FlairTemplate({subreddit:i,allowableContent:n,backgroundColor:s,flairType:o,maxEmojis:d,modOnly:l,text:u,textColor:g,textEditable:p,flairTemplateId:_,cssClass:"",overrideCss:!1},r);return new Q(T,i,r)};function Ho(t){return{flairCssClass:t.flairCssClass,user:t.user,flairText:t.flairText}}var Ft=class{static async getUserFlairBySubreddit(e,r){return a.redditAPIPlugins.Flair.FlairList(e,r)}static setUserFlair(e,r){return B(q,q,"m",Lo).call(q,e,r)}static setUserFlairBatch(e,r,i){return B(q,q,"m",pl).call(q,e,r,i)}static setPostFlair(e,r){return B(q,q,"m",Lo).call(q,{...e,postId:ce(e.postId)},r)}static async removePostFlair(e,r,i){return B(q,q,"m",Wo).call(q,e,r,void 0,i)}static async removeUserFlair(e,r,i){return B(q,q,"m",Wo).call(q,e,void 0,r,i)}};q=Ft,Lo=async function(e,r){await a.redditAPIPlugins.Flair.SelectFlair({subreddit:e.subredditName,flairTemplateId:e.flairTemplateId??"",text:e.text??"",name:e.username,link:e.postId,backgroundColor:e.backgroundColor??"",textColor:e.textColor??"dark",cssClass:e.cssClass??"",returnRtjson:"none"},r)},pl=async function(e,r,i){if(!r.length)return[];if(r.length>100)throw new Error("Unexpected input: flairs array cannot be longer than 100 entries.");let s=",",o=r.map(u=>{for(let g in u)if(u[g]?.includes(s))throw new Error(`Unexpected input: ${g} cannot contain the "," character`);return[u.username,u.text||"",u.cssClass||""].join(s)}).join(`
|
|
4
|
-
`);return(await a.redditAPIPlugins.Flair.FlairCsv({subreddit:e,flairCsv:o},i)).result},Wo=async function(e,r,i,n){await a.redditAPIPlugins.Flair.SelectFlair({subreddit:e,name:i??"",link:r??"",flairTemplateId:"",backgroundColor:"",text:"",textColor:"",cssClass:"",returnRtjson:"none"},n)};function sf(t){if(m(t,"Flair text color is required"),t==="light"||t==="dark")return t;throw new Error(`Invalid flair text color: ${t}`)}function of(t){if(!t||t.length===0||t==="transparent")return"transparent";if(/^#([A-Fa-f0-9]{6})$/.test(t))return t;throw new Error(`Invalid flair background color: ${t}`)}function af(t){if(t==="all"||t==="text"||t==="emoji")return t;throw new Error(`Invalid allowable content: ${t}`)}import"@devvit/protos";import{Block as bl,UIResponse as gf}from"@devvit/protos";var Vo=Xo(yl(),1);var Go=t=>"text"in t?t.text:pf(t.richtext),pf=t=>t instanceof Et?t.build():typeof t=="object"?JSON.stringify(t):t;var y=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},h=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},wi,Hn,yi,jn,bi,Gn,Vn,$n,wr,zn,Kn,qn,Jn,Zn,Qn,Pt,Xn,Yn,yr,vi,It,ki,_i,Ei,xt,St,Tt,Ci,Rt,Mt,Nt,Je,es,ts,Fi,Ai,N,wf={NONE:0,BLOCKS:1,UNRECOGNIZED:-1},Be=class t{constructor(e,r){wi.set(this,void 0),Hn.set(this,void 0),yi.set(this,void 0),jn.set(this,void 0),bi.set(this,void 0),Gn.set(this,void 0),Vn.set(this,void 0),$n.set(this,void 0),wr.set(this,void 0),zn.set(this,void 0),Kn.set(this,void 0),qn.set(this,void 0),Jn.set(this,void 0),Zn.set(this,void 0),Qn.set(this,void 0),Pt.set(this,void 0),Xn.set(this,void 0),Yn.set(this,void 0),yr.set(this,void 0),vi.set(this,void 0),It.set(this,void 0),ki.set(this,void 0),_i.set(this,void 0),Ei.set(this,void 0),xt.set(this,void 0),St.set(this,void 0),Tt.set(this,void 0),Ci.set(this,void 0),Rt.set(this,void 0),Mt.set(this,void 0),Nt.set(this,void 0),Je.set(this,void 0),es.set(this,void 0),ts.set(this,void 0),Fi.set(this,void 0),Ai.set(this,void 0),N.set(this,void 0),re(this),m(e.id,"Post is missing id"),m(e.title,"Post is missing title"),m(e.createdUtc,"Post is missing created date"),m(e.author,"Post is missing author name"),m(e.subreddit,"Post is missing subreddit name"),m(e.subredditId,"Post is missing subreddit id"),m(e.url,"Post is missing url"),m(e.permalink,"Post is missing permalink"),y(this,wi,ce(`t3_${e.id}`),"f"),y(this,yi,e.author,"f"),y(this,Hn,e.authorFullname?ie(e.authorFullname):void 0,"f"),y(this,bi,ge(e.subredditId),"f"),y(this,Gn,e.subreddit,"f"),y(this,qn,e.score??0,"f"),y(this,Jn,e.numComments??0,"f"),y(this,Zn,e.numReports??0,"f");let i=new Date(0);i.setUTCSeconds(e.createdUtc),y(this,jn,i,"f"),y(this,$n,e.title,"f"),y(this,wr,e.selftext,"f"),y(this,zn,e.selftextHtml,"f"),y(this,Kn,e.url,"f"),y(this,Vn,e.permalink,"f"),e.thumbnail&&e.thumbnail!=="self"&&e.thumbnail!=="nsfw"&&e.thumbnailHeight!=null&&e.thumbnailWidth!=null&&y(this,Qn,{url:e.thumbnail,height:e.thumbnailHeight,width:e.thumbnailWidth},"f"),y(this,Pt,e.approved??!1,"f"),y(this,Xn,e.approvedAtUtc??0,"f"),y(this,Yn,e.bannedAtUtc??0,"f"),y(this,It,e.removed??!1,"f"),y(this,ki,e.removedBy,"f"),y(this,_i,e.removedByCategory,"f"),y(this,yr,e.spam??!1,"f"),y(this,vi,e.stickied??!1,"f"),y(this,Ei,e.archived??!1,"f"),y(this,xt,e.edited??!1,"f"),y(this,St,e.locked??!1,"f"),y(this,Tt,e.over18??!1,"f"),y(this,Ci,e.quarantine??!1,"f"),y(this,Rt,e.spoiler,"f"),y(this,Mt,e.hidden??!1,"f"),y(this,Nt,e.ignoreReports??!1,"f"),y(this,Je,e.distinguished,"f"),y(this,ts,e.secureMedia,"f"),y(this,Fi,(e.modReports??[]).map(([n])=>n),"f"),y(this,Ai,(e.userReports??[]).map(([n])=>n),"f"),y(this,N,r,"f"),(e.linkFlairBackgroundColor||e.linkFlairCssClass||e.linkFlairText||e.linkFlairType||e.linkFlairTemplateId||e.linkFlairRichtext||e.linkFlairTextColor)&&y(this,es,{backgroundColor:e.linkFlairBackgroundColor,cssClass:e.linkFlairCssClass,text:e.linkFlairText,type:e.linkFlairType,templateId:e.linkFlairTemplateId,richtext:(e.linkFlairRichtext??[]).map(({e:n,t:s,a:o,u:d})=>({elementType:n,text:s,emojiRef:o,url:d})),textColor:e.linkFlairTextColor},"f")}get id(){return h(this,wi,"f")}get authorId(){return h(this,Hn,"f")}get authorName(){return h(this,yi,"f")}get subredditId(){return h(this,bi,"f")}get subredditName(){return h(this,Gn,"f")}get permalink(){return h(this,Vn,"f")}get title(){return h(this,$n,"f")}get body(){return h(this,wr,"f")}get bodyHtml(){return h(this,zn,"f")}get url(){return h(this,Kn,"f")}get thumbnail(){return h(this,Qn,"f")}get createdAt(){return h(this,jn,"f")}get score(){return h(this,qn,"f")}get numberOfComments(){return h(this,Jn,"f")}get numberOfReports(){return h(this,Zn,"f")}get approved(){return h(this,Pt,"f")}get approvedAtUtc(){return h(this,Xn,"f")}get bannedAtUtc(){return h(this,Yn,"f")}get spam(){return h(this,yr,"f")}get stickied(){return h(this,vi,"f")}get removed(){return h(this,It,"f")}get removedBy(){return h(this,ki,"f")}get removedByCategory(){return h(this,_i,"f")}get archived(){return h(this,Ei,"f")}get edited(){return h(this,xt,"f")}get locked(){return h(this,St,"f")}get nsfw(){return h(this,Tt,"f")}get quarantined(){return h(this,Ci,"f")}get spoiler(){return h(this,Rt,"f")}get hidden(){return h(this,Mt,"f")}get ignoringReports(){return h(this,Nt,"f")}get distinguishedBy(){return h(this,Je,"f")}get comments(){return pe.getComments({postId:this.id},h(this,N,"f"))}get flair(){return h(this,es,"f")}get secureMedia(){return h(this,ts,"f")}get userReportReasons(){return h(this,Ai,"f")}get modReportReasons(){return h(this,Fi,"f")}toJSON(){return{id:this.id,authorId:this.authorId,authorName:this.authorName,subredditId:this.subredditId,subredditName:this.subredditName,permalink:this.permalink,title:this.title,body:this.body,bodyHtml:this.bodyHtml,url:this.url,thumbnail:this.thumbnail,score:this.score,numberOfComments:this.numberOfComments,numberOfReports:this.numberOfReports,createdAt:this.createdAt,approved:this.approved,spam:this.spam,stickied:this.stickied,removed:this.removed,removedBy:h(this,ki,"f"),removedByCategory:h(this,_i,"f"),archived:this.archived,edited:this.edited,locked:this.locked,nsfw:this.nsfw,quarantined:this.quarantined,spoiler:this.spoiler,hidden:this.hidden,ignoringReports:this.ignoringReports,distinguishedBy:this.distinguishedBy,flair:this.flair,secureMedia:this.secureMedia,modReportReasons:h(this,Fi,"f"),userReportReasons:h(this,Ai,"f")}}isApproved(){return h(this,Pt,"f")}isSpam(){return h(this,yr,"f")}isStickied(){return h(this,vi,"f")}isRemoved(){return h(this,It,"f")}isArchived(){return h(this,Ei,"f")}isEdited(){return h(this,xt,"f")}isLocked(){return h(this,St,"f")}isNsfw(){return h(this,Tt,"f")}isQuarantined(){return h(this,Ci,"f")}isSpoiler(){return h(this,Rt,"f")}isHidden(){return h(this,Mt,"f")}isIgnoringReports(){return h(this,Nt,"f")}isDistinguishedBy(){return h(this,Je,"f")}async edit(e){let r=await t.edit({id:this.id,...e},h(this,N,"f"));y(this,wr,r.body,"f"),y(this,xt,r.edited,"f")}async setSuggestedCommentSort(e){await t.setSuggestedCommentSort({id:this.id,subredditId:h(this,bi,"f"),suggestedSort:e},h(this,N,"f"))}async setCustomPostPreview(e){await t.setCustomPostPreview({id:this.id,ui:e},h(this,N,"f"))}async setTextFallback(e){let r=await t.setTextFallback(e,this.id,h(this,N,"f"));y(this,wr,r.body,"f"),y(this,xt,r.edited,"f")}async addComment(e){return pe.submit({id:this.id,...e},h(this,N,"f"))}async delete(){return t.delete(this.id,h(this,N,"f"))}async approve(){await t.approve(this.id,h(this,N,"f")),y(this,Pt,!0,"f"),y(this,It,!1,"f")}async remove(e=!1){await t.remove(this.id,e,h(this,N,"f")),y(this,It,!0,"f"),y(this,yr,e,"f"),y(this,Pt,!1,"f")}async lock(){await t.lock(this.id,h(this,N,"f")),y(this,St,!0,"f")}async unlock(){await t.unlock(this.id,h(this,N,"f")),y(this,St,!1,"f")}async hide(){await t.hide(this.id,h(this,N,"f")),y(this,Mt,!0,"f")}async unhide(){await t.unhide(this.id,h(this,N,"f")),y(this,Mt,!1,"f")}async markAsNsfw(){await t.markAsNsfw(this.id,h(this,N,"f")),y(this,Tt,!0,"f")}async unmarkAsNsfw(){await t.unmarkAsNsfw(this.id,h(this,N,"f")),y(this,Tt,!1,"f")}async markAsSpoiler(){await t.markAsSpoiler(this.id,h(this,N,"f")),y(this,Rt,!0,"f")}async unmarkAsSpoiler(){await t.unmarkAsSpoiler(this.id,h(this,N,"f")),y(this,Rt,!1,"f")}async sticky(e){await t.sticky(this.id,e,h(this,N,"f"))}async unsticky(){await t.unsticky(this.id,h(this,N,"f"))}async distinguish(){let{distinguishedBy:e}=await t.distinguish(this.id,!1,h(this,N,"f"));y(this,Je,e,"f")}async distinguishAsAdmin(){let{distinguishedBy:e}=await t.distinguish(this.id,!0,h(this,N,"f"));y(this,Je,e,"f")}async undistinguish(){let{distinguishedBy:e}=await t.undistinguish(this.id,h(this,N,"f"));y(this,Je,e,"f")}async ignoreReports(){await t.ignoreReports(this.id,h(this,N,"f")),y(this,Nt,!0,"f")}async unignoreReports(){await t.unignoreReports(this.id,h(this,N,"f")),y(this,Nt,!1,"f")}async getAuthor(){return be.getByUsername(h(this,yi,"f"),h(this,N,"f"))}async crosspost(e){return t.crosspost({...e,postId:this.id},h(this,N,"f"))}addRemovalNote(e){return qe.addRemovalNote({itemIds:[h(this,wi,"f")],...e},h(this,N,"f"))}async getEnrichedThumbnail(){return yf({id:this.id},h(this,N,"f"))}static async getById(e,r){let i=a.redditAPIPlugins.LinksAndComments,n=Fr(e)?e:`t3_${e}`,s=await i.Info({subreddits:[],thingIds:[n]},r);if(!s.data?.children?.length)throw new Error("could not find post");let o=s.data.children[0];if(!o?.data)throw new Error("could not find post");return new t(o.data,r)}static async submit(e,r){let{runAs:i="APP"}=e,n=ae[i],s=n===ae.USER?a.userActionsPlugin:a.redditAPIPlugins.LinksAndComments,o;if("preview"in e){m(r,"Missing metadata in `SubmitPostOptions`"),n===ae.USER&&m(e.userGeneratedContent,"userGeneratedContent must be set in `SubmitPostOptions` when RunAs=USER for experience posts");let u=await new Se(()=>e.preview,void 0,{},r,void 0).buildBlocksUI(),g=bl.encode(u).finish(),{textFallback:p,..._}=e,I=p?Go(p):"",T={kind:"custom",sr:e.subredditName,richtextJson:(0,Vo.fromByteArray)(g),richtextFallback:I,..._,runAs:n};o=await s.SubmitCustomPost(T,r)}else o=await s.Submit({kind:"kind"in e?e.kind:"url"in e?"link":"self",sr:e.subredditName,richtextJson:"richtext"in e?fr(e.richtext):void 0,...e,runAs:n},r);if("kind"in e&&["image","video","videogif"].includes(e.kind)&&!o.json?.data?.id){if(e.kind==="image"&&"imageUrls"in e)throw new Error(`Image post type with ${e.imageUrls} is being created asynchronously and should be updated in the subreddit soon.`);if("videoPosterUrl"in e)throw new Error(`Post of ${e.kind} type with ${e.videoPosterUrl} is being created asynchronously and should be updated in the subreddit soon.`)}if(!o.json?.data?.id||o.json?.errors?.length)throw new Error(`failed to submit post - either post ID is empty or request failed with errors: ${o.json?.errors}`);return t.getById(`t3_${o.json.data.id}`,r)}static async crosspost(e,r){let{runAs:i="APP"}=e,n=ae[i],s=n===ae.USER?a.userActionsPlugin:a.redditAPIPlugins.LinksAndComments,{postId:o,subredditName:d,...l}=e,u=await s.Submit({kind:"crosspost",sr:d,crosspostFullname:ce(o),...l,runAs:n},r);if(!u.json?.data?.id||u.json?.errors?.length)throw new Error("failed to crosspost post");return t.getById(`t3_${u.json.data.id}`,r)}static async edit(e,r){let i=a.redditAPIPlugins.LinksAndComments,{id:n}=e,s;if("richtext"in e&&(s=fr(e.richtext)),(await i.EditUserText({thingId:n,text:"text"in e?e.text:"",richtextJson:s,runAs:ae.APP},r)).json?.errors?.length)throw new Error("Failed to edit post");return t.getById(n,r)}static async setSuggestedCommentSort(e,r){if(!(await fe.query("SetSuggestedSort","cf6052acc7fefaa65b710625b81dba8041f258313aafe9730e2a3dc855e5d10d",{input:{subredditId:e.subredditId,postId:e.id,sort:e.suggestedSort}},r)).data?.setSuggestedSort?.ok)throw new Error("Failed to set suggested sort")}static async setCustomPostPreview(e,r){if(!r)throw new Error("Failed to set custom post preview. Metadata not found");let i=a.redditAPIPlugins.LinksAndComments,n=new _t(e.ui),o=gf.fromJSON(await n.handle({events:[]},r)).blocks,d=(0,Vo.fromByteArray)(bl.encode(o).finish());await i.SetCustomPostPreview({thingId:e.id,bodyType:wf.BLOCKS,blocksRenderContent:d},r)}static async setTextFallback(e,r,i){if(!("text"in e)&&!("richtext"in e))throw new Error(`No text fallback provided for post ${r}.`);let n=a.redditAPIPlugins.LinksAndComments,s=Go(e);if((await n.EditCustomPost({thingId:r,richtextFallback:s},i)).json?.errors?.length)throw new Error("Failed to set post text fallback");return t.getById(r,i)}static async delete(e,r){await a.redditAPIPlugins.LinksAndComments.Del({id:e},r)}static async approve(e,r){await a.redditAPIPlugins.Moderation.Approve({id:e},r)}static async remove(e,r=!1,i){await a.redditAPIPlugins.Moderation.Remove({id:e,spam:r},i)}static async hide(e,r){await a.redditAPIPlugins.LinksAndComments.Hide({id:e},r)}static async unhide(e,r){await a.redditAPIPlugins.LinksAndComments.Unhide({id:e},r)}static async markAsNsfw(e,r){await a.redditAPIPlugins.LinksAndComments.MarkNSFW({id:e},r)}static async unmarkAsNsfw(e,r){await a.redditAPIPlugins.LinksAndComments.UnmarkNSFW({id:e},r)}static async markAsSpoiler(e,r){await a.redditAPIPlugins.LinksAndComments.Spoiler({id:e},r)}static async unmarkAsSpoiler(e,r){await a.redditAPIPlugins.LinksAndComments.Unspoiler({id:e},r)}static async sticky(e,r,i){await a.redditAPIPlugins.LinksAndComments.SetSubredditSticky({id:e,state:!0,num:r},i)}static async unsticky(e,r){await a.redditAPIPlugins.LinksAndComments.SetSubredditSticky({id:e,state:!1},r)}static async lock(e,r){await a.redditAPIPlugins.LinksAndComments.Lock({id:e},r)}static async unlock(e,r){await a.redditAPIPlugins.LinksAndComments.Unlock({id:e},r)}static async distinguish(e,r,i){let o=(await a.redditAPIPlugins.Moderation.Distinguish({id:e,how:r?"admin":"yes",sticky:!1},i)).json?.data?.things?.[0]?.data;return m(o),{distinguishedBy:o.distinguished}}static async undistinguish(e,r){let s=(await a.redditAPIPlugins.Moderation.Distinguish({id:e,how:"no",sticky:!1},r)).json?.data?.things?.[0]?.data;return m(s),{distinguishedBy:s.distinguished}}static async ignoreReports(e,r){await a.redditAPIPlugins.Moderation.IgnoreReports({id:e},r)}static async unignoreReports(e,r){await a.redditAPIPlugins.Moderation.UnignoreReports({id:e},r)}static getControversialPosts(e={},r){return this.getSortedPosts({...e,sort:"controversial"},r)}static getTopPosts(e={},r){return this.getSortedPosts({...e,sort:"top"},r)}static getSortedPosts(e,r){let i=a.redditAPIPlugins.Listings;return new j({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,fetch:async n=>{let s=await i.Sort({show:"all",sort:e.sort,t:e.timeframe,subreddit:e.subredditName,...n},r);return gi(s,r)}})}static getHotPosts(e={location:"GLOBAL"},r){let i=a.redditAPIPlugins.Listings;return new j({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,fetch:async n=>{let s=await i.Hot({g:e.location,show:"all",subreddit:e.subredditName,...n},r);return gi(s,r)}})}static getNewPosts(e,r){let i=a.redditAPIPlugins.Listings;return new j({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,fetch:async n=>{let s=await i.New({show:"all",subreddit:e.subredditName,...n},r);return gi(s,r)}})}static getRisingPosts(e,r){let i=a.redditAPIPlugins.Listings;return new j({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,fetch:async n=>{let s=await i.Rising({show:"all",subreddit:e.subredditName,...n},r);return gi(s,r)}})}static getPostsByUser(e,r){let i=a.redditAPIPlugins.Users;return new j({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,async fetch(n){let s=await i.UserWhere({username:e.username,where:"submitted",...n},r);return gi(s,r)}})}};wi=new WeakMap,Hn=new WeakMap,yi=new WeakMap,jn=new WeakMap,bi=new WeakMap,Gn=new WeakMap,Vn=new WeakMap,$n=new WeakMap,wr=new WeakMap,zn=new WeakMap,Kn=new WeakMap,qn=new WeakMap,Jn=new WeakMap,Zn=new WeakMap,Qn=new WeakMap,Pt=new WeakMap,Xn=new WeakMap,Yn=new WeakMap,yr=new WeakMap,vi=new WeakMap,It=new WeakMap,ki=new WeakMap,_i=new WeakMap,Ei=new WeakMap,xt=new WeakMap,St=new WeakMap,Tt=new WeakMap,Ci=new WeakMap,Rt=new WeakMap,Mt=new WeakMap,Nt=new WeakMap,Je=new WeakMap,es=new WeakMap,ts=new WeakMap,Fi=new WeakMap,Ai=new WeakMap,N=new WeakMap;function gi(t,e){if(!t.data?.children)throw new Error("Listing response is missing children");return{children:t.data.children.map(i=>new Be(i.data,e)),before:t.data.before,after:t.data.after}}async function yf(t,e){let s=(await fe.query("GetThumbnailV2","81580ce4e23d748c5a59a1618489b559bf4518b6a73af41f345d8d074c8b2ce9",{id:t.id},e)).data?.postInfoById?.thumbnailV2;if(s){if(!s.image)return}else throw new Error("Failed to get thumbnail");return{attribution:s.attribution,image:{url:s.image.url,width:s.image.dimensions.width,height:s.image.dimensions.height},isObfuscatedDefault:s.isObfuscatedDefault,...s.obfuscatedImage&&{obfuscatedImage:{url:s.obfuscatedImage.url,width:s.obfuscatedImage.dimensions.width,height:s.obfuscatedImage.dimensions.height}}}}var ve=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},H=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},rs,Pi,is,ns,ss,os,as,Bt,cs,ds,ls,De,vl;(function(t){t.Custom="CUSTOM",t.Reddit="REDDIT",t.Instagram="INSTAGRAM",t.Twitter="TWITTER",t.Tiktok="TIKTOK",t.Twitch="TWITCH",t.Facebook="FACEBOOK",t.Youtube="YOUTUBE",t.Tumblr="TUMBLR",t.Spotify="SPOTIFY",t.Soundcloud="SOUNDCLOUD",t.Beacons="BEACONS",t.Linktree="LINKTREE",t.Discord="DISCORD",t.Venmo="VENMO",t.CashApp="CASH_APP",t.Patreon="PATREON",t.Kofi="KOFI",t.Paypal="PAYPAL",t.Cameo="CAMEO",t.Onlyfans="ONLYFANS",t.Substack="SUBSTACK",t.Kickstarter="KICKSTARTER",t.Indiegogo="INDIEGOGO",t.BuyMeACoffee="BUY_ME_A_COFFEE",t.Shopify="SHOPIFY"})(vl||(vl={}));var be=class t{constructor(e,r){rs.set(this,void 0),Pi.set(this,void 0),is.set(this,void 0),ns.set(this,void 0),ss.set(this,void 0),os.set(this,void 0),as.set(this,void 0),Bt.set(this,new Map),cs.set(this,void 0),ds.set(this,void 0),ls.set(this,void 0),De.set(this,void 0),re(this),m(e.id,"User ID is missing or undefined"),m(e.name,"Username is missing or undefined"),m(e.createdUtc,"User is missing created date"),ve(this,rs,ie(Bi(e.id)?e.id:`t2_${e.id}`),"f"),ve(this,Pi,e.name,"f"),ve(this,os,e.over18??!1,"f"),ve(this,as,e.isEmployee??!1,"f");let i=new Date(0);if(i.setUTCSeconds(e.createdUtc),ve(this,is,i,"f"),ve(this,ns,e.linkKarma??0,"f"),ve(this,ss,e.commentKarma??0,"f"),e.modPermissions)for(let[n,s]of Object.entries(e.modPermissions))H(this,Bt,"f").set(n,ml(s));ve(this,cs,new URL(e.subreddit?.url??"","https://www.reddit.com").toString(),"f"),ve(this,ds,e.subreddit?.url??"","f"),ve(this,ls,e.hasVerifiedEmail??!1,"f"),ve(this,De,r,"f")}get id(){return H(this,rs,"f")}get username(){return H(this,Pi,"f")}get createdAt(){return H(this,is,"f")}get linkKarma(){return H(this,ns,"f")}get commentKarma(){return H(this,ss,"f")}get nsfw(){return H(this,os,"f")}get isAdmin(){return H(this,as,"f")}get modPermissions(){return H(this,Bt,"f")}get url(){return H(this,cs,"f")}get permalink(){return H(this,ds,"f")}get hasVerifiedEmail(){return H(this,ls,"f")}toJSON(){return{id:this.id,username:this.username,createdAt:this.createdAt,linkKarma:this.linkKarma,commentKarma:this.commentKarma,nsfw:this.nsfw,modPermissionsBySubreddit:Object.fromEntries(this.modPermissions)}}async getModPermissionsForSubreddit(e){if(H(this,Bt,"f").has(e))return H(this,Bt,"f").get(e);let r=await t.getSubredditUsersByType({subredditName:e,type:"moderators",username:this.username},H(this,De,"f")).all();if(r.length===0)return[];let i=r[0].modPermissions.get(e)??[];return i.length>0&&H(this,Bt,"f").set(e,i),i}getComments(e){return pe.getCommentsByUser({username:this.username,...e},H(this,De,"f"))}getPosts(e){return Be.getPostsByUser({username:this.username,...e},H(this,De,"f"))}async getUserFlairBySubreddit(e){let r=await Ft.getUserFlairBySubreddit({subreddit:e,name:H(this,Pi,"f")},H(this,De,"f"));return r.users[0]?Ho(r.users[0]):void 0}getSnoovatarUrl(){return t.getSnoovatarUrl(this.username,H(this,De,"f"))}async getSocialLinks(){let i=await fe.query("GetUserSocialLinks","2aca18ef5f4fc75fb91cdaace3e9aeeae2cb3843b5c26ad511e6f01b8521593a",{name:this.username},H(this,De,"f"));return i.data?.user?.profile?.socialLinks?i.data.user.profile.socialLinks.map(n=>({...n,handle:n.handle??void 0})):[]}static async getById(e,r){let i=await kl(e,r);return i==null?void 0:t.getByUsername(i,r)}static async getByUsername(e,r){let i=a.redditAPIPlugins.Users;try{let n=await i.UserAbout({username:e},r);if(n.data?.id)return new t(n.data,r)}catch(n){if(n instanceof Error&&n.message.includes("404 Not Found"))return;throw n}}static async getFromMetadata(e,r){m(r);let i=r?.[e]?.values[0];return i?t.getById(ie(i),r):Promise.resolve(void 0)}static getSubredditUsersByType(e,r){let i=a.redditAPIPlugins.Subreddits;return new j({hasMore:!0,pageSize:e.pageSize,limit:e.limit,after:e.after,before:e.before,fetch:async n=>{let s=await i.AboutWhere({where:e.type,user:e.username,subreddit:e.subredditName,show:"all",...n},r);return vf(s,e.subredditName,r)}})}static async createRelationship(e,r){let i=a.redditAPIPlugins.Users,{type:n,subredditName:s,username:o,permissions:d,...l}=e,u=await i.Friend({type:n,subreddit:s,name:o,permissions:d?Uo(d):void 0,...l},r);if(u.json?.errors?.length)throw new Error(u.json.errors.join(`
|
|
5
|
-
`))}static async removeRelationship(e,r){await a.redditAPIPlugins.Users.Unfriend({type:e.type,subreddit:e.subredditName,name:e.username},r)}static async setModeratorPermissions(e,r,i
|
|
6
|
-
`))}static async getSnoovatarUrl(e,r){return(await fe.query("GetSnoovatarUrlByName","c47fd42345af268616d2d8904b56856acdc05cf61d3650380f539ad7d596ac0c",{username:e},r)).data?.redditorInfoByName?.snoovatarIcon?.url}static getOverview(e,r){let i=a.redditAPIPlugins.Users;return new j({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,async fetch(n){let s=await i.UserWhere({username:e.username,where:"overview",...n},r);return bf(s,r)}})}};rs=new WeakMap,Pi=new WeakMap,is=new WeakMap,ns=new WeakMap,ss=new WeakMap,os=new WeakMap,as=new WeakMap,Bt=new WeakMap,cs=new WeakMap,ds=new WeakMap,ls=new WeakMap,De=new WeakMap;function bf(t,e){if(!t.data?.children)throw new Error("Listing response is missing children");return{children:t.data.children.map(i=>{if(i.kind==="t3")return new Be(i.data,e);if(i.kind==="t1")return new pe(i.data,e);throw new Error(`Type ${i.kind} is not supported`)}),before:t.data.before,after:t.data.after}}async function vf(t,e,r){let i=a.redditAPIPlugins.Users;if(!t.data?.children)throw new Error("Listing response is missing children");let n=t.data.children.map(g=>(m(g.data?.id,"User id is still from listing data"),g.data.id)),s=100,o=[];for(let g=0;g<n.length;g+=s)o.push(n.slice(g,g+s));let l=(await Promise.all(o.map(g=>i.UserDataByAccountIds({ids:g.join(",")},r)))).reduce((g,p)=>({...g,...p.users}),{});return{children:t.data.children.map(g=>{let p=g.data?.id;m(p,"User id is missing from listing");let _=l[p];return m(_,"User data is missing from response"),new be({id:p,name:_.name,linkKarma:_.linkKarma,commentKarma:_.commentKarma,createdUtc:_.createdUtc,over18:_.profileOver18,snoovatarSize:[],modPermissions:{[e]:g.data?.modPermissions??[]}},r)}),before:t.data.before,after:t.data.after}}async function kl(t,e){return(await a.redditAPIPlugins.Users.UserDataByAccountIds({ids:t},e))?.users?.[t]?.name}async function _l(t){m(t);let e=t?.[C.Username]?.values[0];if(e)return e;let r=t?.[C.User]?.values[0];if(r)return kl(r,t)}var k=function(t,e,r,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r},b=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},S,br,us,Ii,xi,hs,fs,Si,ms,ps,Ti,Dt,gs,ws,vr,Ot,Ut,Ze,kr,Qe,ys,bs,vs,ks,_s,Es,Cs,Lt,K,Fs,$o,pe=class{constructor(e,r){br.set(this,void 0),us.set(this,void 0),Ii.set(this,void 0),xi.set(this,void 0),hs.set(this,void 0),fs.set(this,void 0),Si.set(this,void 0),ms.set(this,void 0),ps.set(this,void 0),Ti.set(this,void 0),Dt.set(this,void 0),gs.set(this,void 0),ws.set(this,void 0),vr.set(this,void 0),Ot.set(this,void 0),Ut.set(this,void 0),Ze.set(this,void 0),kr.set(this,void 0),Qe.set(this,void 0),ys.set(this,void 0),bs.set(this,void 0),vs.set(this,void 0),ks.set(this,void 0),_s.set(this,void 0),Es.set(this,void 0),Cs.set(this,void 0),Lt.set(this,void 0),K.set(this,void 0),re(this),m(e.id,"Comment id is null or undefined"),m(e.body,"Comment body is null or undefined"),m(e.createdUtc,"Comment is missing created date"),m(e.author,"Comment author is null or undefined"),m(e.parentId,"Comment parentId is null or undefined"),m(e.linkId,"Comment linkId is null or undefined"),m(e.permalink,"Comment permalink is null or undefined"),m(e.subreddit,"Comment is missing subreddit name"),m(e.subredditId,"Comment is missing subreddit id"),k(this,br,jt(`t1_${e.id}`),"f"),k(this,us,e.authorFullname?ie(e.authorFullname):void 0,"f"),k(this,Ii,e.author,"f"),k(this,xi,e.body,"f"),k(this,ms,ge(e.subredditId),"f"),k(this,ps,e.subreddit,"f"),k(this,fs,Ss(e.parentId)?jt(e.parentId):ce(e.parentId),"f"),k(this,Si,ce(e.linkId),"f"),k(this,vr,e.edited??!1,"f"),k(this,Ot,e.locked??!1,"f"),k(this,Ut,e.removed??!1,"f"),k(this,Ze,e.stickied??!1,"f"),k(this,Dt,e.approved??!1,"f"),k(this,gs,e.approvedAtUtc??0,"f"),k(this,ws,e.bannedAtUtc??0,"f"),k(this,kr,e.spam??!1,"f"),k(this,Qe,e.distinguished,"f"),k(this,ys,e.numReports??0,"f"),k(this,bs,e.collapsedBecauseCrowdControl??!1,"f"),k(this,vs,e.score??0,"f"),k(this,ks,e.permalink,"f"),k(this,Cs,new URL(e.permalink??"","https://www.reddit.com/").toString(),"f"),k(this,Lt,e.ignoreReports??!1,"f"),k(this,_s,(e.modReports??[]).map(([n])=>n),"f"),k(this,Es,(e.userReports??[]).map(([n])=>n),"f");let i=new Date(0);i.setUTCSeconds(e.createdUtc),k(this,hs,i,"f"),k(this,Ti,b(S,S,"m",Fs).call(S,{postId:b(this,Si,"f"),commentId:b(this,br,"f")},r),"f"),k(this,K,r,"f")}get id(){return b(this,br,"f")}get authorId(){return b(this,us,"f")}get authorName(){return b(this,Ii,"f")}get subredditId(){return b(this,ms,"f")}get subredditName(){return b(this,ps,"f")}get body(){return b(this,xi,"f")}get createdAt(){return b(this,hs,"f")}get parentId(){return b(this,fs,"f")}get postId(){return b(this,Si,"f")}get replies(){return b(this,Ti,"f")}get distinguishedBy(){return b(this,Qe,"f")}get locked(){return b(this,Ot,"f")}get stickied(){return b(this,Ze,"f")}get removed(){return b(this,Ut,"f")}get approved(){return b(this,Dt,"f")}get approvedAtUtc(){return b(this,gs,"f")}get bannedAtUtc(){return b(this,ws,"f")}get spam(){return b(this,kr,"f")}get edited(){return b(this,vr,"f")}get numReports(){return b(this,ys,"f")}get collapsedBecauseCrowdControl(){return b(this,bs,"f")}get score(){return b(this,vs,"f")}get permalink(){return b(this,ks,"f")}get userReportReasons(){return b(this,Es,"f")}get modReportReasons(){return b(this,_s,"f")}get url(){return b(this,Cs,"f")}get ignoringReports(){return b(this,Lt,"f")}toJSON(){return{id:this.id,authorName:this.authorName,subredditId:this.subredditId,subredditName:this.subredditName,body:this.body,createdAt:this.createdAt,parentId:this.parentId,postId:this.postId,replies:this.replies,approved:this.approved,locked:this.locked,removed:this.removed,stickied:this.stickied,spam:this.spam,edited:this.edited,distinguishedBy:this.distinguishedBy,numReports:this.numReports,collapsedBecauseCrowdControl:this.collapsedBecauseCrowdControl,score:this.score,permalink:this.permalink,modReportReasons:this.modReportReasons,userReportReasons:this.userReportReasons,url:this.url,ignoringReports:this.ignoringReports}}isLocked(){return b(this,Ot,"f")}isApproved(){return b(this,Dt,"f")}isRemoved(){return b(this,Ut,"f")}isSpam(){return b(this,kr,"f")}isStickied(){return b(this,Ze,"f")}isDistinguished(){return!!b(this,Qe,"f")}isEdited(){return b(this,vr,"f")}isIgnoringReports(){return b(this,Lt,"f")}async delete(){return S.delete(this.id,b(this,K,"f"))}async edit(e){let r=await S.edit({id:this.id,...e},b(this,K,"f"));return k(this,xi,r.body,"f"),k(this,vr,r.edited,"f"),this}async approve(){await S.approve(this.id,b(this,K,"f")),k(this,Dt,!0,"f"),k(this,Ut,!1,"f")}async remove(e=!1){await S.remove(this.id,e,b(this,K,"f")),k(this,Ut,!0,"f"),k(this,kr,e,"f"),k(this,Dt,!1,"f")}async lock(){await S.lock(this.id,b(this,K,"f")),k(this,Ot,!0,"f")}async unlock(){await S.unlock(this.id,b(this,K,"f")),k(this,Ot,!1,"f")}async reply(e){return S.submit({id:this.id,...e},b(this,K,"f"))}async getAuthor(){return be.getByUsername(b(this,Ii,"f"),b(this,K,"f"))}async distinguish(e=!1){let{distinguishedBy:r,stickied:i}=await S.distinguish(this.id,e,!1,b(this,K,"f"));k(this,Qe,r,"f"),k(this,Ze,i,"f")}async distinguishAsAdmin(e=!1){let{distinguishedBy:r,stickied:i}=await S.distinguish(this.id,e,!0,b(this,K,"f"));k(this,Qe,r,"f"),k(this,Ze,i,"f")}async undistinguish(){let{distinguishedBy:e,stickied:r}=await S.undistinguish(this.id,b(this,K,"f"));k(this,Qe,e,"f"),k(this,Ze,r,"f")}async ignoreReports(){await S.ignoreReports(this.id,b(this,K,"f")),k(this,Lt,!0,"f")}async unignoreReports(){await S.unignoreReports(this.id,b(this,K,"f")),k(this,Lt,!1,"f")}addRemovalNote(e){return qe.addRemovalNote({itemIds:[b(this,br,"f")],...e},b(this,K,"f"))}static async getById(e,r){let i=a.redditAPIPlugins.LinksAndComments,n=Ht(e)?e:`t1_${e}`,s=await i.Info({subreddits:[],thingIds:[n]},r);if(!s.data?.children?.[0]?.data)throw new Error("not found");return new S(s.data.children[0].data,r)}static getComments(e,r){let{postId:i,commentId:n,...s}=e;return b(S,S,"m",Fs).call(S,{postId:ce(i),commentId:n?jt(n):void 0,...s},r)}static async edit(e,r){let i=a.redditAPIPlugins.LinksAndComments,{id:n}=e,s;"richtext"in e&&(s=fr(e.richtext));let o=await i.EditUserText({thingId:n,text:"text"in e?e.text:"",richtextJson:s,runAs:ae.APP},r);if(o.json?.errors?.length)throw new Error("Failed to edit comment");let d=o.json?.data?.things?.[0]?.data;return m(d),new S(d,r)}static async delete(e,r){await a.redditAPIPlugins.LinksAndComments.Del({id:e},r)}static async approve(e,r){await a.redditAPIPlugins.Moderation.Approve({id:e},r)}static async remove(e,r=!1,i){await a.redditAPIPlugins.Moderation.Remove({id:e,spam:r},i)}static async lock(e,r){await a.redditAPIPlugins.LinksAndComments.Lock({id:e},r)}static async unlock(e,r){await a.redditAPIPlugins.LinksAndComments.Unlock({id:e},r)}static async submit(e,r){let{runAs:i="APP"}=e,n=ae[i],s=n===ae.USER?a.userActionsPlugin:a.redditAPIPlugins.LinksAndComments,{id:o}=e,d;"richtext"in e&&(d=fr(e.richtext));let l=await s.Comment({thingId:o,text:"text"in e?e.text:"",richtextJson:d,runAs:n},r);if(l.json?.errors?.length)throw new Error("failed to reply to comment");let u=l.json?.data?.things?.[0]?.data;return m(u),new S(u,r)}static async distinguish(e,r,i,n){let d=(await a.redditAPIPlugins.Moderation.Distinguish({id:e,how:i?"admin":"yes",sticky:r},n)).json?.data?.things?.[0]?.data;return m(d),{distinguishedBy:d.distinguished,stickied:!!d.stickied}}static async undistinguish(e,r){let s=(await a.redditAPIPlugins.Moderation.Distinguish({id:e,how:"no",sticky:!1},r)).json?.data?.things?.[0]?.data;return m(s),{distinguishedBy:s.distinguished,stickied:!!s.stickied}}static getCommentsByUser(e,r){let i=a.redditAPIPlugins.Users;return new j({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,async fetch(n){let s=await i.UserWhere({username:e.username,where:"comments",...n},r);return m(s.data,"Failed to get comments for user"),{children:s.data.children?.map(d=>new S(d.data,r))||[],before:s.data.before,after:s.data.after}}})}static async ignoreReports(e,r){await a.redditAPIPlugins.Moderation.IgnoreReports({id:e},r)}static async unignoreReports(e,r){await a.redditAPIPlugins.Moderation.UnignoreReports({id:e},r)}};S=pe,br=new WeakMap,us=new WeakMap,Ii=new WeakMap,xi=new WeakMap,hs=new WeakMap,fs=new WeakMap,Si=new WeakMap,ms=new WeakMap,ps=new WeakMap,Ti=new WeakMap,Dt=new WeakMap,gs=new WeakMap,ws=new WeakMap,vr=new WeakMap,Ot=new WeakMap,Ut=new WeakMap,Ze=new WeakMap,kr=new WeakMap,Qe=new WeakMap,ys=new WeakMap,bs=new WeakMap,vs=new WeakMap,ks=new WeakMap,_s=new WeakMap,Es=new WeakMap,Cs=new WeakMap,Lt=new WeakMap,K=new WeakMap,Fs=function(e,r,i=0){return new j({limit:e.limit,pageSize:e.pageSize,fetch:async n=>{let s=n.limit,o=a.redditAPIPlugins.Listings,d=a.redditAPIPlugins.LinksAndComments,l=e.commentId;if(n.more)if(n.more.children.length){let _=n.more;(!s||s>100)&&(s=100);let I=_.children.splice(0,s),T=await d.MoreChildren({linkId:e.postId,children:I,sort:e.sort},r);if(!T.json?.data?.things?.length)return{children:[]};let{children:L}=b(S,S,"m",$o).call(S,T.json.data.things,e.postId,e,r);return{children:L,more:_.children.length?_:void 0}}else l=n.more.parentId,i=i+n.more.depth;let g=(await o.Comments({article:e.postId.substring(3),comment:l?.substring(3),limit:s,depth:e.depth,sort:e.sort},r)).listings?.[1]?.data?.children??[],p=g[0];return l&&p?.data?.replyList?.data&&(g=p.data.replyList.data.children),b(S,S,"m",$o).call(S,g,l??e.postId,e,r,i)}})},$o=function t(e,r,i,n,s=0){let o=[],d,l={};for(let u of e){if(!u.data||(u.data.depth!=null&&(u.data.depth=u.data.depth+s),u.data.depth!=null&&i.depth!=null&&u.data.depth>=i.depth))continue;let g=u.data.parentId?l[u.data.parentId]:void 0;if(u.kind==="t1"){if(u.data.name===r)continue;let p=new S(u.data,n);if(l[p.id]=p,k(p,Ti,b(S,S,"m",Fs).call(S,{...i,postId:p.postId,commentId:p.id},n,s),"f"),"replyList"in u.data&&u.data.replyList?.data){let{children:_,more:I}=b(S,S,"m",t).call(S,u.data.replyList.data.children,p.id,i,n,s);_.length&&p.replies.children.push(..._),I&&p.replies.setMore(I)}p.replies.preventInitialFetch(),g?g.replies.children.push(p):o.push(p)}else if(u.kind==="more"&&u.data.parentId&&u.data.depth!=null){let p={parentId:Ss(u.data.parentId)?jt(u.data.parentId):ce(u.data.parentId),children:u.data.children??[],depth:u.data.depth};g?g.replies.setMore(p):p.parentId===r&&(d=p)}}return{children:o,more:d}};import"@devvit/protos";var El=function(t,e,r,i){if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?i:r==="a"?i.call(t):i?i.value:e.get(t)},zo,kf,_f,Cl,Fl,Xe;(function(t){t.New="New",t.InProgress="InProgress",t.Archived="Archived",t.Appeals="Appeals",t.JoinRequests="JoinRequests",t.Filtered="Filtered"})(Xe||(Xe={}));var Ef={0:Xe.New,1:Xe.InProgress,2:Xe.Archived,3:Xe.Appeals,4:Xe.JoinRequests,5:Xe.Filtered},X;(function(t){t.Highlighted="Highlighted",t.Unhighlighted="Unhighlighted",t.Archived="Archived",t.Unarchived="Unarchived",t.ReportedToAdmins="ReportedToAdmins",t.Muted="Muted",t.Unmuted="Unmuted",t.Banned="Banned",t.Unbanned="Unbanned",t.Approved="Approved",t.Disapproved="Disapproved",t.Filtered="Filtered",t.Unfiltered="Unfiltered"})(X||(X={}));var Cf={0:X.Highlighted,1:X.Unhighlighted,2:X.Archived,3:X.Unarchived,4:X.ReportedToAdmins,5:X.Muted,6:X.Unmuted,7:X.Banned,8:X.Unbanned,9:X.Approved,10:X.Disapproved,11:X.Filtered,12:X.Unfiltered};kf=new WeakMap,zo=new WeakSet,_f=function({protoConversation:e,protoMessages:r,protoModActions:i}){return{...e,state:Ef[e.state],messages:El(this,zo,"m",Cl).call(this,e,r),modActions:El(this,zo,"m",Fl).call(this,e,i)}},Cl=function(e,r){let i={},n=e.objIds.filter(s=>s.key==="messages").map(({id:s})=>s);for(let s of n){let o=r[s];o&&(i[s]=o)}return i},Fl=function(e,r){let i={},n=e.objIds.filter(s=>s.key==="modActions").map(({id:s})=>s);for(let s of n){let o=r[s];o&&(i[s]={...o,actionType:Cf[o.actionTypeId]})}return i};var Ff,Af,Pf,If,xf,Sf;Ff=new WeakMap,Af=new WeakMap,Pf=new WeakMap,If=new WeakMap,xf=new WeakMap,Sf=new WeakMap;var Rf,Mf,Nf,Bf,Df,Of,Uf,Lf,Wf,Hf,jf,Gf,Vf,Ko;(function(t){t.Reports="reports",t.Spam="spam",t.Modqueue="modqueue",t.Unmoderated="unmoderated",t.Edited="edited"})(Ko||(Ko={}));Rf=new WeakMap,Mf=new WeakMap,Nf=new WeakMap,Bf=new WeakMap,Df=new WeakMap,Of=new WeakMap,Uf=new WeakMap,Lf=new WeakMap,Wf=new WeakMap,Hf=new WeakMap,jf=new WeakMap,Gf=new WeakMap,Vf=new WeakMap;async function Al(t,e){let s=(await fe.query("GetSubredditInfoById","315a9b75c22a017d526afdf2d274616946156451aacfd56dfb91e7ad3f7a2fde",{id:t},e)).data?.subredditInfoById;if(!s)throw new Error("subreddit info not found");return s}import{CommunityListWidget_CommunityData as uk,GetWidgetsResponse_WidgetItem as hk}from"@devvit/protos";var $f,zf,Kf,qf,Jf,Zf,Qf,Xf,Yf,em,tm,rm,im,nm,sm,om,am,cm,dm,lm,um,hm,fm,mm;$f=new WeakMap,zf=new WeakMap,Kf=new WeakMap,qf=new WeakMap;Jf=new WeakMap;Zf=new WeakMap,Qf=new WeakMap,Xf=new WeakMap;Yf=new WeakMap,em=new WeakMap;tm=new WeakMap,rm=new WeakMap,im=new WeakMap;nm=new WeakMap,sm=new WeakMap;om=new WeakMap,am=new WeakMap,cm=new WeakMap;dm=new WeakMap,lm=new WeakMap,um=new WeakMap,hm=new WeakMap,fm=new WeakMap;mm=new WeakMap;var pm,gm,wm,ym,bm,vm,km,_m,Em,Cm,Fm,Am,Pm,Im,xm,Sm,Tm,Rm,Pl;(function(t){t[t.SUBREDDIT_PERMISSIONS=0]="SUBREDDIT_PERMISSIONS",t[t.APPROVED_CONTRIBUTORS_ONLY=1]="APPROVED_CONTRIBUTORS_ONLY",t[t.MODS_ONLY=2]="MODS_ONLY"})(Pl||(Pl={}));pm=new WeakMap,gm=new WeakMap,wm=new WeakMap,ym=new WeakMap,bm=new WeakMap,vm=new WeakMap,km=new WeakMap,_m=new WeakMap,Em=new WeakMap;Cm=new WeakMap,Fm=new WeakMap,Am=new WeakMap,Pm=new WeakMap,Im=new WeakMap,xm=new WeakMap;Sm=new WeakMap,Tm=new WeakMap,Rm=new WeakMap;function ac(t){let e=Vt();return Al(t,e)}function cc(t){let e=Vt();return Be.getById(Gt(t),e)}async function Il(){let t=Vt();return _l(t)}function dc(t){let e=Vt();return pe.getById(Gt(t),e)}function lc(t){let e=Vt();return be.getSubredditUsersByType({type:"moderators",...t},e)}import{EffectType as f_}from"@devvit/protos";import{WebViewVisibility as p_}from"@devvit/protos";var Mm,Nm,Bm,Dm,Om,Um;Mm=new WeakMap,Nm=new WeakMap,Bm=new WeakMap,Dm=new WeakMap,Om=new WeakMap,Um=new WeakMap;import"@devvit/protos/payments.js";import{OrderStatus as et}from"@devvit/protos/payments.js";var Lm="devvit-";function Wm(t){return t.startsWith(Lm)}function As(t){return Object.fromEntries(Object.entries(t).filter(([e])=>!Wm(e)))}import{AccountingType as Ye}from"@devvit/protos/payments.js";var ke;(function(t){t.INSTANT="INSTANT",t.DURABLE="DURABLE",t.CONSUMABLE="CONSUMABLE",t.VALID_FOR_1D="VALID_FOR_1D",t.VALID_FOR_7D="VALID_FOR_7D",t.VALID_FOR_30D="VALID_FOR_30D",t.VALID_FOR_1Y="VALID_FOR_1Y",t.UNRECOGNIZED="UNRECOGNIZED"})(ke||(ke={}));var Hm={[ke.INSTANT]:Ye.ACCOUNTING_TYPE_INSTANT,[ke.DURABLE]:Ye.ACCOUNTING_TYPE_DURABLE,[ke.CONSUMABLE]:Ye.ACCOUNTING_TYPE_CONSUMABLE,[ke.VALID_FOR_1D]:Ye.ACCOUNTING_TYPE_VALID_FOR_1D,[ke.VALID_FOR_7D]:Ye.ACCOUNTING_TYPE_VALID_FOR_7D,[ke.VALID_FOR_30D]:Ye.ACCOUNTING_TYPE_VALID_FOR_30D,[ke.VALID_FOR_1Y]:Ye.ACCOUNTING_TYPE_VALID_FOR_1Y,[ke.UNRECOGNIZED]:Ye.UNRECOGNIZED};function jm(t){let e=Object.entries(Hm).find(([r,i])=>i===t);return e?e[0]:ke.UNRECOGNIZED}function Ps(t){m(t.price,"Product price is null or undefined");let e=t.images.icon;return{sku:t.sku,price:t.price.amount,accountingType:jm(t.accountingType),displayName:t.name,description:t.description,metadata:As(t.productMetadata),...e?{images:{icon:e}}:{}}}var Oe;(function(t){t.NEW="NEW",t.CREATED="CREATED",t.PAID="PAID",t.DELIVERED="DELIVERED",t.CANCELED="CANCELED",t.REVERTED="REVERTED",t.UNRECOGNIZED="UNRECOGNIZED"})(Oe||(Oe={}));function Gm(t){switch(t){case et.ORDER_STATUS_NEW:return Oe.NEW;case et.ORDER_STATUS_CREATED:return Oe.CREATED;case et.ORDER_STATUS_PAID:return Oe.PAID;case et.ORDER_STATUS_DELIVERED:return Oe.DELIVERED;case et.ORDER_STATUS_CANCELED:return Oe.CANCELED;case et.ORDER_STATUS_REVERTED:return Oe.REVERTED;case et.ORDER_STATUS_UNSPECIFIED:case et.UNRECOGNIZED:return Oe.UNRECOGNIZED}}function Is(t){return{id:t.id,status:Gm(t.status),createdAt:t.createdAt??null,updatedAt:t.updatedAt??null,products:t.products.map(Ps),metadata:As(t.metadata)}}import{PaymentsServiceDefinition as Vm}from"@devvit/protos/payments.js";var xs=a.use(Vm);a.addMenuItem({location:"post",label:"Get Payments Help",onPress:async(t,e)=>{let r=new URL("https://support.reddithelp.com/hc/en-us/requests/new?ticket_form_id=29770197409428&tf_29764567374740=devvit_product_not_working"),i=await Il();i&&r.searchParams.append("tf_360026362751",i);let n=e.postId;if(n){let s=n.replace("t3_","");if(s){let o=`https://www.reddit.com/r/${e.subredditName}/comments/${s}`;r.searchParams.append("tf_29770117862932",o)}}r.searchParams.append("tf_subject",`[${e.appName} v${e.appVersion}] Payments Help`),e.ui.navigateTo(r.toString())}});async function xl(t={}){let e={sku:"",buyer:"",metadata:{},status:0,...t,limit:t.limit||100,cursor:t.nextPageToken||""},r=await xs.GetOrders(e),i={orders:r.orders.map(Is)};return r.pageInfo?.hasNextPage&&(i.nextPage=r.pageInfo?.endCursor),i}function $m(t){return{...t,createdAt:t.createdAt?.toISOString()??null,updatedAt:t.updatedAt?.toISOString()??null}}function zm(t){return{...t,createdAt:t.createdAt?new Date(t.createdAt):null,updatedAt:t.updatedAt?new Date(t.updatedAt):null}}function Km(t,e={}){let[r,i]=kt(e.nextPageToken??""),{loading:n,data:s,error:o}=Gr(async()=>{let l=await xl({...e,nextPageToken:r});return{orders:l.orders.map($m),nextPageToken:l.nextPage||""}},{depends:r}),d={orders:(s?.orders??[]).map(zm)};return s?.nextPageToken&&(d=Object.assign(d,{nextPage:async()=>{i(s?.nextPageToken)}})),n?{...d,loading:!0,error:null}:o?{...d,loading:n,error:o}:{...d,loading:n,error:null}}import{EffectType as qm}from"@devvit/protos/types/devvit/ui/effects/v1alpha/effect.js";var _r,Ri,Mi,Er,qo=class{constructor(e,r){Cr(this,_r);Cr(this,Ri);Cr(this,Mi);this.state={};Cr(this,Er,e=>{Ue(this,Mi)&&console.debug(`[payments] ${e}`)});Ni(this,Mi,!!r.context._devvitContext?.debug.payments),Ni(this,_r,r.context),Ni(this,Ri,e),this.hookId=r.hookId,Ue(this,Er).call(this,`usePurchase hook created (${this.hookId})`)}async onUIEvent(e){if(e.orderResult&&e.hook===this.hookId){Ue(this,Er).call(this,`Received an order result: hookId: ${this.hookId}; Status: ${e.orderResult.status}; Order ID: ${e.orderResult.orderId}; Error Code: ${e.orderResult.errorCode}; Error Message: ${e.orderResult.errorMessage}`);let{status:r,errorCode:i,errorMessage:n,order:s,orderId:o}=e.orderResult;if(!s)throw new Error("Invalid response: missing original order");await Ue(this,Ri).call(this,{status:ra(r),errorCode:i,errorMessage:n,orderId:o,sku:s.skus[0],metadata:s.metadata})}}purchase(e,r={}){if(!e.trim())throw new Error("Invalid purchase; no SKU provided");Ue(this,Er).call(this,`Requesting a purchase for product: ${e}`);let i={[C.Post]:Ue(this,_r)._devvitContext?.postId??""};Ue(this,_r).emitEffect("createOrder",{type:qm.EFFECT_CREATE_ORDER,createOrder:{id:this.hookId,skus:[e],metadata:{...r,...i}}})}};_r=new WeakMap,Ri=new WeakMap,Mi=new WeakMap,Er=new WeakMap;function Jm(t){return Y({namespace:"payments",initializer:e=>new qo(t,e)})}async function Sl(t={}){let e={skus:t.skus||[],metadata:t.metadata||{}};return(await xs.GetProducts(e)).products.map(Ps)}function Zm(t,e={}){let[r,i]=kt(0),{loading:n,data:s,error:o}=Gr(async()=>Sl(e),{depends:r}),u={products:s??[],refetch:async()=>{i(g=>~g)}};return n?{...u,loading:!0,error:null}:o!=null?{...u,loading:!1,error:o}:{...u,loading:!1,error:null}}import{PaymentProcessorDefinition as Qm}from"@devvit/protos/payments.js";function Xm(t){a.provide(Qm),Object.assign(a.prototype,Ym(t))}function Ym(t){return{async FulfillOrder(e,r){if(e.order==null||e.order.products.length===0)return{};let i=Object.assign(Z({metadata:r}),z(r,e.order.metadata[C.Post])),n=Tl(e.order),s=await t.fulfillOrder(n,i);return!s||s.success?{acknowledged:!0}:{rejectionReason:s.reason}},async RefundOrder(e,r){if(e.order==null||!t.refundOrder)return{};let i=Object.assign(Z({metadata:r}),z(r)),n=Tl(e.order);return await t.refundOrder(n,i),{}}}}function Tl(t){let e=Is(t);if(e.products.length>1)throw new Error("Multi-product orders not supported");if(e.products.length===0)throw new Error("No products in order");return e}export{ta as OrderResultStatus,Xm as addPaymentHandler,xl as getOrders,Sl as getProducts,Km as useOrders,Jm as usePayments,Zm as useProducts};
|
|
1
|
+
var Ml=Object.create;var Zo=Object.defineProperty;var Nl=Object.getOwnPropertyDescriptor;var Bl=Object.getOwnPropertyNames;var Dl=Object.getPrototypeOf,Ol=Object.prototype.hasOwnProperty;var Qo=t=>{throw TypeError(t)};var Ul=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Wt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Ll=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Bl(e))!Ol.call(t,i)&&i!==r&&Zo(t,i,{get:()=>e[i],enumerable:!(n=Nl(e,i))||n.enumerable});return t};var Xo=(t,e,r)=>(r=t!=null?Ml(Dl(t)):{},Ll(e||!t||!t.__esModule?Zo(r,"default",{value:t,enumerable:!0}):r,t));var Yo=(t,e,r)=>e.has(t)||Qo("Cannot "+r);var Ue=(t,e,r)=>(Yo(t,e,"read from private field"),r?r.call(t):e.get(t)),Cr=(t,e,r)=>e.has(t)?Qo("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Bn=(t,e,r,n)=>(Yo(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r);var ro=Wt((_y,gc)=>{var fh=Object.prototype.toString;gc.exports=function(e){if(e===void 0)return"undefined";if(e===null)return"null";var r=typeof e;if(r==="boolean")return"boolean";if(r==="string")return"string";if(r==="number")return"number";if(r==="symbol")return"symbol";if(r==="function")return yh(e)?"generatorfunction":"function";if(mh(e))return"array";if(kh(e))return"buffer";if(vh(e))return"arguments";if(gh(e))return"date";if(ph(e))return"error";if(wh(e))return"regexp";switch(pc(e)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(bh(e))return"generator";switch(r=fh.call(e),r){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return r.slice(8,-1).toLowerCase().replace(/\s/g,"")};function pc(t){return typeof t.constructor=="function"?t.constructor.name:null}function mh(t){return Array.isArray?Array.isArray(t):t instanceof Array}function ph(t){return t instanceof Error||typeof t.message=="string"&&t.constructor&&typeof t.constructor.stackTraceLimit=="number"}function gh(t){return t instanceof Date?!0:typeof t.toDateString=="function"&&typeof t.getDate=="function"&&typeof t.setDate=="function"}function wh(t){return t instanceof RegExp?!0:typeof t.flags=="string"&&typeof t.ignoreCase=="boolean"&&typeof t.multiline=="boolean"&&typeof t.global=="boolean"}function yh(t,e){return pc(t)==="GeneratorFunction"}function bh(t){return typeof t.throw=="function"&&typeof t.return=="function"&&typeof t.next=="function"}function vh(t){try{if(typeof t.length=="number"&&typeof t.callee=="function")return!0}catch(e){if(e.message.indexOf("callee")!==-1)return!0}return!1}function kh(t){return t.constructor&&typeof t.constructor.isBuffer=="function"?t.constructor.isBuffer(t):!1}});var bc=Wt((Ey,yc)=>{"use strict";var wc=Symbol.prototype.valueOf,_h=ro();function Eh(t,e){switch(_h(t)){case"array":return t.slice();case"object":return Object.assign({},t);case"date":return new t.constructor(Number(t));case"map":return new Map(t);case"set":return new Set(t);case"buffer":return Ph(t);case"symbol":return Ih(t);case"arraybuffer":return Fh(t);case"float32array":case"float64array":case"int16array":case"int32array":case"int8array":case"uint16array":case"uint32array":case"uint8clampedarray":case"uint8array":return Ah(t);case"regexp":return Ch(t);case"error":return Object.create(t);default:return t}}function Ch(t){let e=t.flags!==void 0?t.flags:/\w+$/.exec(t)||void 0,r=new t.constructor(t.source,e);return r.lastIndex=t.lastIndex,r}function Fh(t){let e=new t.constructor(t.byteLength);return new Uint8Array(e).set(new Uint8Array(t)),e}function Ah(t,e){return new t.constructor(t.buffer,t.byteOffset,t.length)}function Ph(t){let e=t.length,r=Buffer.allocUnsafe?Buffer.allocUnsafe(e):Buffer.from(e);return t.copy(r),r}function Ih(t){return wc?Object(wc.call(t)):{}}yc.exports=Eh});var kc=Wt((Cy,vc)=>{"use strict";vc.exports=function(e){return e!=null&&typeof e=="object"&&Array.isArray(e)===!1}});var Cc=Wt((Fy,Ec)=>{"use strict";var xh=kc();function _c(t){return xh(t)===!0&&Object.prototype.toString.call(t)==="[object Object]"}Ec.exports=function(e){var r,n;return!(_c(e)===!1||(r=e.constructor,typeof r!="function")||(n=r.prototype,_c(n)===!1)||n.hasOwnProperty("isPrototypeOf")===!1)}});var Ac=Wt((Ay,Fc)=>{"use strict";var Sh=bc(),Th=ro(),Rh=Cc();function no(t,e){switch(Th(t)){case"object":return Mh(t,e);case"array":return Nh(t,e);default:return Sh(t)}}function Mh(t,e){if(typeof e=="function")return e(t);if(e||Rh(t)){let r=new t.constructor;for(let n in t)r[n]=no(t[n],e);return r}return t}function Nh(t,e){let r=new t.constructor(t.length);for(let n=0;n<t.length;n++)r[n]=no(t[n],e);return r}Fc.exports=no});var yl=Wt(Wi=>{"use strict";Wi.byteLength=df;Wi.toByteArray=uf;Wi.fromByteArray=mf;var Pe=[],me=[],cf=typeof Uint8Array<"u"?Uint8Array:Array,jo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(At=0,gl=jo.length;At<gl;++At)Pe[At]=jo[At],me[jo.charCodeAt(At)]=At;var At,gl;me[45]=62;me[95]=63;function wl(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function df(t){var e=wl(t),r=e[0],n=e[1];return(r+n)*3/4-n}function lf(t,e,r){return(e+r)*3/4-r}function uf(t){var e,r=wl(t),n=r[0],i=r[1],s=new cf(lf(t,n,i)),o=0,d=i>0?n-4:n,l;for(l=0;l<d;l+=4)e=me[t.charCodeAt(l)]<<18|me[t.charCodeAt(l+1)]<<12|me[t.charCodeAt(l+2)]<<6|me[t.charCodeAt(l+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=me[t.charCodeAt(l)]<<2|me[t.charCodeAt(l+1)]>>4,s[o++]=e&255),i===1&&(e=me[t.charCodeAt(l)]<<10|me[t.charCodeAt(l+1)]<<4|me[t.charCodeAt(l+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function hf(t){return Pe[t>>18&63]+Pe[t>>12&63]+Pe[t>>6&63]+Pe[t&63]}function ff(t,e,r){for(var n,i=[],s=e;s<r;s+=3)n=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(t[s+2]&255),i.push(hf(n));return i.join("")}function mf(t){for(var e,r=t.length,n=r%3,i=[],s=16383,o=0,d=r-n;o<d;o+=s)i.push(ff(t,o,o+s>d?d:o+s));return n===1?(e=t[r-1],i.push(Pe[e>>2]+Pe[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(Pe[e>>10]+Pe[e>>4&63]+Pe[e<<2&63]+"=")),i.join("")}});import{OrderResultStatus as ea}from"@devvit/protos/types/devvit/ui/effects/v1alpha/create_order.js";var ta=(n=>(n[n.Cancelled=0]="Cancelled",n[n.Success=1]="Success",n[n.Error=2]="Error",n))(ta||{});function ra(t){switch(t){case ea.STATUS_SUCCESS:return 1;case ea.STATUS_ERROR:return 2;default:return 0}}var ae={APP:0,USER:1};import"@devvit/protos";var C=Object.freeze({Actor:"devvit-actor",App:"devvit-app",AppUser:"devvit-app-user",AppViewerAuthToken:"devvit-app-viewer-authorization",Caller:"devvit-caller",CallerPortID:"devvit-caller-port-id",Canary:"devvit-canary",Debug:"devvit-debug",GQLHost:"devvit-gql-host",Installation:"devvit-installation",ModPermissions:"devvit-mod-permissions",Post:"devvit-post",PostAuthor:"devvit-post-author",R2Auth:"devvit-sec-authorization",R2Host:"devvit-r2-host",RemoteHostname:"devvit-remote-hostname",SettingsUri:"devvit-sec-settings-uri",StreamID:"devvit-stream-id",Subreddit:"devvit-subreddit",SubredditName:"devvit-subreddit-name",TraceID:"devvit-trace-id",User:"devvit-user",Username:"devvit-user-name",UserSnoovatarUrl:"devvit-user-snoovatar-url",UserAgent:"devvit-user-agent",Version:"devvit-version",Language:"devvit-accept-language",Timezone:"devvit-accept-timezone",Traceparent:"traceparent",AppDependencies:"devvit-app-dependencies"}),na;(function(t){t.Blocks="blocks",t.EmitSnapshots="emitSnapshots",t.EmitState="emitState",t.Realtime="realtime",t.Runtime="runtime",t.Surface="surface",t.UseAsync="useAsync",t.Payments="payments",t.Bootstrap="bootstrap",t.WebView="webView"})(na||(na={}));function tt(t,e){if(!t)throw Error(e)}var J;(function(t){t.COMMENT="t1_",t.ACCOUNT="t2_",t.LINK="t3_",t.MESSAGE="t4_",t.SUBREDDIT="t5_",t.AWARD="t6_"})(J||(J={}));function Ht(t){return t.startsWith(J.COMMENT)}function Dn(t){return t.startsWith(J.ACCOUNT)}function Fr(t){return t.startsWith(J.LINK)}function ia(t){return t.startsWith(J.MESSAGE)}function sa(t){return t.startsWith(J.SUBREDDIT)}function oa(t){return t.startsWith(J.AWARD)}function Wl(t){tt(Ht(t),`Expected comment id to start with ${J.COMMENT}, got ${t}}`)}function Hl(t){tt(Dn(t),`Expected account id to start with ${J.ACCOUNT}, got ${t}}`)}function jl(t){tt(Fr(t),`Expected link id to start with ${J.LINK}, got ${t}}`)}function Gl(t){tt(ia(t),`Expected message id to start with ${J.MESSAGE}, got ${t}}`)}function Vl(t){tt(sa(t),`Expected subreddit id to start with ${J.SUBREDDIT}, got ${t}}`)}function $l(t){tt(oa(t),`Expected award id to start with ${J.AWARD}, got ${t}}`)}function jt(t){return Wl(t),t}function ne(t){return Hl(t),t}function ce(t){return jl(t),t}function zl(t){return Gl(t),t}function ge(t){return Vl(t),t}function Kl(t){return $l(t),t}function Gt(t){if(Ht(t))return jt(t);if(Dn(t))return ne(t);if(Fr(t))return ce(t);if(ia(t))return zl(t);if(sa(t))return ge(t);if(oa(t))return Kl(t);throw new Error(`Expected thing id to start with ${Object.values(J).join(", ")} got ${t}}`)}function Ss(t){return Ht(t)}import*as w from"@devvit/protos";var On=class{constructor(e){}};var rt;(function(t){t.Installation="installation",t.App="app"})(rt||(rt={}));function nt(t,e=new Set){for(let r of t){if(r.type==="group"){nt(r.fields,e);continue}let n=r.name;if(e.has(n))throw new Error(`Duplicate field name: ${n}`);e.add(n)}ql(t)}function ql(t){for(let e of t)if(e.type==="string"&&e.isSecret&&e.scope!==rt.App)throw`Invalid setting: only app settings can be secrets. Add "scope: SettingScope.App" to field "${e.name}"`}var Le=Object.freeze({INTERVAL:0,FORM:1,STATE:2,CHANNEL:3,WEB_VIEW:4});import{DeletionReason as gp,EventSource as wp}from"@devvit/protos";import{AppSettingsDefinition as vu,GetFieldsResponse as ku}from"@devvit/protos";import{FormFieldType as de}from"@devvit/protos";function Ie(t){return t.map(e=>{switch(e.type){case"string":return Jl(e);case"image":return Zl(e);case"paragraph":return Ql(e);case"number":return Xl(e);case"select":return Yl(e);case"boolean":return eu(e);case"group":return tu(e);default:throw new Error("Unknown field type.")}})}function Jl(t){return{defaultValue:{fieldType:de.STRING,stringValue:t.defaultValue},disabled:t.disabled,fieldConfig:{stringConfig:{placeholder:t.placeholder}},fieldId:t.name,fieldType:de.STRING,helpText:t.helpText,label:t.label,required:t.required,isSecret:t.isSecret}}function Zl(t){return{disabled:t.disabled,fieldId:t.name,fieldType:de.IMAGE,helpText:t.helpText,label:t.label,required:t.required}}function Ql(t){return{defaultValue:{fieldType:de.PARAGRAPH,stringValue:t.defaultValue},disabled:t.disabled,fieldConfig:{paragraphConfig:{lineHeight:t.lineHeight,placeholder:t.placeholder}},fieldId:t.name,fieldType:de.PARAGRAPH,helpText:t.helpText,label:t.label,required:t.required}}function Xl(t){return{defaultValue:{fieldType:de.NUMBER,numberValue:t.defaultValue},disabled:t.disabled,fieldConfig:{numberConfig:{}},fieldId:t.name,fieldType:de.NUMBER,helpText:t.helpText,label:t.label,required:t.required}}function Yl(t){return{defaultValue:{fieldType:de.SELECTION,selectionValue:{values:t.defaultValue??[]}},disabled:t.disabled,fieldConfig:{selectionConfig:{choices:t.options,multiSelect:t.multiSelect}},fieldId:t.name,fieldType:de.SELECTION,helpText:t.helpText,label:t.label,required:t.required}}function eu(t){return{defaultValue:{fieldType:de.BOOLEAN,boolValue:t.defaultValue},disabled:t.disabled,fieldId:t.name,fieldType:de.BOOLEAN,helpText:t.helpText,label:t.label}}function tu(t){return{fieldId:"",fieldType:de.GROUP,fieldConfig:{groupConfig:{fields:Ie(t.fields)}},label:t.label,helpText:t.helpText}}var Un=function(){try{let{AsyncLocalStorage:t}=Ul("node:async_hooks");return new t}catch{}}(),Ln;function Vt(){if(Un){let t=Un.getStore();if(!t)throw Error("API error; metadata should never be accessed outside a request");return t}if(!Ln)throw Error("Devvit metadata can only be accessed within a request");return Ln}async function aa(t,e){if(Un)return Un.run(t,e);try{return Ln=t,await e()}finally{Ln=void 0}}function x(t,e){a.prototype[t]=(r,n,...i)=>{let s=n??{};return aa(s,()=>e(r,s,...i))}}import{ValidateFormResponse as bu}from"@devvit/protos";import{RealtimeSubscriptionStatus as ca}from"@devvit/protos";function m(t,e){if(t==null)throw Error(e??"Expected nonnullish value.")}var ie;(function(t){t[t.Unknown=0]="Unknown",t[t.Connecting=1]="Connecting",t[t.Connected=2]="Connected",t[t.Disconnecting=3]="Disconnecting",t[t.Disconnected=4]="Disconnected"})(ie||(ie={}));function da(t){function e(r){let i=t.currentHookIndex,s=t.getCurrentComponentState(),o=t.getPreviousComponentState(),d=t.metadata[C.App]?.values[0];m(d,"useChannel - app is missing from Context");let l=t.metadata[C.Installation]?.values[0];m(l,"useChannel - installation is missing from Context");async function u(D){let oe=s[i].channel;if(s[i].active)if(s[i].connected)await t.realtime.send(oe,D);else throw Error(`Failed to send to channel '${oe}'; it is active but not yet connected`);else throw Error(`Cannot send a message over inactive channel: ${oe}`)}function g(){if(!s[i].active){let D=s[i].channel;s[i].active=!0,t.addRealtimeChannel(D)}}function p(){if(s[i].active){let D=s[i].channel;s[i].active=!1,t.removeRealtimeChannel(D)}}function _(D){return async()=>{let oe;switch(D.status){case ca.REALTIME_SUBSCRIBED:s[i].connected=!0,oe=r.onSubscribed?.();break;case ca.REALTIME_UNSUBSCRIBED:s[i].connected=!1,oe=r.onUnsubscribed?.();break;default:oe=r.onMessage(D.event?.data?.msg);break}await oe}}let I={channel:`${d}:${l}:${r.name}`,active:!1,connected:!1,preventCallback:!1,type:Le.CHANNEL};i in s?I=s[i]:i in o&&(I=o[i]);let T=t.realtimeEvent;t.isInitialRender?I.active=!1:T&&I.active&&T.event.channel===I.channel&&(I.preventCallback||t.runHook(_(T)),t.rerenderIn(0)),s[i]=I,t.currentHookIndex++;let L=ie.Unknown;return I.active&&I.connected?L=ie.Connected:I.active&&!I.connected?L=ie.Connecting:!I.active&&I.connected?L=ie.Disconnecting:!I.active&&!I.connected&&(L=ie.Disconnected),{subscribe:g,unsubscribe:p,send:u,status:L}}return e}import{FormFieldType as $t}from"@devvit/protos";function Ts(t){switch(t.fieldType){case $t.STRING:return t.stringValue;case $t.IMAGE:return t.stringValue;case $t.PARAGRAPH:return t.stringValue;case $t.NUMBER:return t.numberValue;case $t.BOOLEAN:return t.boolValue;case $t.SELECTION:return t.selectionValue?.values??[];default:return}}function We(t){return Object.keys(t).reduce((e,r)=>{let n=Ts(t[r]);return n!==void 0&&(e[r]=n),e},{})}function la(t){function e(r,n){let i=t.currentHookIndex,s=t.getCurrentComponentKey(),o=t.getCurrentComponentState(),d=t.getPreviousComponentState(),l=`form.hook.${s}.${i}`,u={formKey:l,preventSubmit:!1,type:Le.FORM};i in o?u=o[i]:i in d&&(u=d[i]),o[i]=u,t.forms.set(l,r);let g=t.formSubmittedEvent;return g&&!u.preventSubmit&&g.formId===l&&t.runHook(async()=>{let p=n(We(g.results));p&&p instanceof Promise&&await p,t.rerenderIn(0)}),o[i].preventSubmit=!1,t.currentHookIndex++,l}return e}function ua(t){function e(r,n){let i=t.currentHookIndex,s=t.getCurrentComponentState(),o=t.getPreviousComponentState(),d=100,l=Math.max(d,n),u={lastRun:void 0,running:!1,preventCallback:!1,type:Le.INTERVAL};i in s?u=s[i]:i in o&&(u=o[i]);function g(){n<d&&console.error(`useInterval delay must be at least ${d}ms. Your interval of ${n}ms was automatically extended.`);for(let[_,I]of Object.entries(s))if(_!==i.toString()&&I?.type===Le.INTERVAL&&I?.running)throw new Error("Only one useInterval hook may be running at a time");s[i]={running:!0,lastRun:s[i]?.lastRun??Date.now(),preventCallback:!1,type:Le.INTERVAL},t.rerenderIn(l)}function p(){s[i].running=!1,s[i].lastRun=void 0,s[i].preventCallback=!1}return t.isEffectRender&&u.running&&(u.preventCallback||(u.lastRun===void 0||u.lastRun+l<Date.now())&&t.runHook(async()=>{let _=r();_&&_ instanceof Promise&&await _,u.lastRun=Date.now()}),t.rerenderIn(l)),u.preventCallback=!1,s[i]=u,t.currentHookIndex++,{start:g,stop:p}}return e}function ha(t){function e(r){let n=t.currentHookIndex,i=t.getCurrentComponentState(),s=t.getPreviousComponentState();if(n in i)return t.currentHookIndex++,[i[n],o];if(t.isInitialRender||!(n in s)){let d=r instanceof Function?r():r;if(d instanceof Promise)throw(async()=>{i[n]=await d,t.currentHookIndex=0})();i[n]=d}else i[n]=s[n];function o(d){if(t.isRendering)throw new Error("Cannot call setState while rendering.");i[n]=d instanceof Function?d(i[n]):d}return t.currentHookIndex++,[i[n],o]}return e}var Wn=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},O=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},le,it,st,we,Ar,ka,_a,fa,ma,pa,ga,Ms,Ea,Ns={now(){return new Date}};function wa(t){return`__autocache__${t}`}function ya(t){return`__lock__${t}`}var ru=300,nu=1e3,Hn=5e3,Rs=3,ba=.1,va=1e3,iu=3e4;function Ca(t){if(t.error)throw new Error(t.error);return t.value}var jn=class{constructor(e,r,n=Ns){le.add(this),it.set(this,void 0),st.set(this,{}),we.set(this,void 0),Ar.set(this,void 0),Wn(this,it,e,"f"),Wn(this,Ar,r,"f"),Wn(this,we,n,"f")}async cache(e,r){Wn(this,st,O(this,Ar,"f").__cache=O(this,Ar,"f").__cache??{},"f"),O(this,le,"m",Ea).call(this,r);let n=O(this,le,"m",ka).call(this,r.key);if(n!==void 0)return n;let i=await O(this,le,"m",Ms).call(this,r.key),s=await O(this,le,"m",_a).call(this,r,i,e);return Ca(s)}};it=new WeakMap,st=new WeakMap,we=new WeakMap,Ar=new WeakMap,le=new WeakSet,ka=function(e){let r=O(this,st,"f")[e];if(r){let n=O(this,we,"f").now().getTime(),i=r?.error&&r?.errorTime&&r.errorCount<Rs&&Math.random()<ba&&r.errorTime+va<n;if(r?.expires&&r.expires<n&&r.checkedAt+va<n||i){delete O(this,st,"f")[e];return}else return Ca(r)}},_a=async function(e,r,n){let i=r?.expires,s=i?O(this,le,"m",ga).call(this,i):1;return!r||r?.error&&r.errorCount<Rs&&ba>Math.random()||s>Math.random()?O(this,le,"m",fa).call(this,e,r,n):r},fa=async function(e,r,n){let i=ya(e.key),s=O(this,we,"f").now().getTime(),o=new Date(s+e.ttl/2);if(await O(this,it,"f").set(i,"1",{expiration:o,nx:!0}))return O(this,le,"m",pa).call(this,e.key,r,n,e.ttl);if(r)return r;{let l=O(this,we,"f").now();return O(this,le,"m",ma).call(this,l,e.key,e.ttl)}},ma=async function t(e,r,n){let i=Math.min(n,nu),s=await O(this,le,"m",Ms).call(this,r);if(s)return s;if(O(this,we,"f").now().getTime()-e.getTime()>=i)throw new Error(`Cache request timed out trying to get data at key: ${r}`);return await new Promise(o=>setTimeout(o,ru)),O(this,le,"m",t).call(this,e,r,n)},pa=async function(e,r,n,i){let s=O(this,we,"f").now().getTime()+i;r=r??{value:null,expires:s,errorCount:0,error:null,errorTime:null,checkedAt:0};try{r.value=await n(),r.error=null,r.errorCount=0,r.errorTime=null}catch(o){r.value=null,r.error=o.message??"Unknown error",r.errorTime=O(this,we,"f").now().getTime(),r.errorCount++}return O(this,st,"f")[e]=r,await O(this,it,"f").set(wa(e),JSON.stringify(r),{expiration:new Date(s+iu)}),r.error&&r.errorCount<Rs&&await O(this,it,"f").del(ya(e)),r},ga=function(e){let r=O(this,we,"f").now().getTime(),n=e-r;return n<0?1:n<1e3?.1:n<2e3?.01:n<3e3?.001:0},Ms=async function(e){let r=await O(this,it,"f").get(wa(e));if(r){let n=JSON.parse(r);return n.checkedAt=O(this,we,"f").now().getTime(),O(this,st,"f")[e]=n,n}},Ea=function(e){e.ttl<Hn&&(console.warn(`Cache TTL cannot be less than ${Hn} milliseconds! Updating ttl value of ${e.ttl} to ${Hn}.`),e.ttl=Hn)};function Fa(t,e,r=Ns){let n=new jn(t,e,r);return n.cache.bind(n)}var Aa=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},zt=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Gn,Pr,Ir,Ia,xa;function Pa(t){new URL(t.slice(0,t.indexOf(",")))}var Kt=class{constructor(){Gn.add(this),Pr.set(this,{}),Ir.set(this,{}),Aa(this,Pr,a.assets,"f"),Aa(this,Ir,a.webViewAssets,"f")}getURL(e,r){return typeof e=="string"?zt(this,Gn,"m",Ia).call(this,e,r??{webView:!1}):zt(this,Gn,"m",xa).call(this,e,r??{webView:!1})}};Pr=new WeakMap,Ir=new WeakMap,Gn=new WeakSet,Ia=function(e,r){let n=r.webView?zt(this,Ir,"f")[e]:zt(this,Pr,"f")[e];if(n)return n;try{return Pa(e),e}catch{return""}},xa=function(e,r){let n={},i=[],s=r.webView?zt(this,Ir,"f"):zt(this,Pr,"f");if(s)for(let o of e)if(s[o])n[o]=s[o];else try{Pa(o),n[o]=o}catch{i.push(o)}else i=e;if(i.length>0)throw new Error(`The following assets were missing from the assets list: ${i.join(", ")}`);return n};var su=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Vn=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},ot,qt=class{constructor(e){ot.set(this,void 0),su(this,ot,e,"f")}async get(e){let{messages:r}=await a.kvStorePlugin.Get({keys:[e]},Vn(this,ot,"f"));try{if(r[e])return JSON.parse(r[e])}catch{return}}async put(e,r){let n={};n[e]=JSON.stringify(r),await a.kvStorePlugin.Put({messages:n},Vn(this,ot,"f"))}async delete(e){await a.kvStorePlugin.Del({keys:[e]},Vn(this,ot,"f"))}async list(){let{keys:e}=await a.kvStorePlugin.List({filter:"*"},Vn(this,ot,"f"));return e}};ot=new WeakMap;var ou=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},au=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},$n,Jt=class{constructor(e){$n.set(this,void 0),ou(this,$n,e,"f")}async upload(e){let r=await a.mediaPlugin.Upload(e,au(this,$n,"f"));if(!r.mediaId)throw new Error("unable to get mediaId via uploads");return Promise.resolve({mediaId:r.mediaId,mediaUrl:r.mediaUrl})}};$n=new WeakMap;var cu=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},du=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},zn,Zt=class{constructor(e){zn.set(this,void 0),cu(this,zn,e,"f")}async add(e){await a.modLogPlugin.Add(e,du(this,zn,"f"))}};zn=new WeakMap;var lu=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},uu=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Kn,Qt=class{constructor(e){Kn.set(this,void 0),lu(this,Kn,e,"f")}async send(e,r){await a.realtimePlugin.Send({channel:e,data:{msg:r}},uu(this,Kn,"f"))}};Kn=new WeakMap;import{BitfieldOverflowBehavior as Bs,RedisKeyScope as Ds}from"@devvit/protos";var Tr=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},c=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},F,A,P,E,Sr;function xr(t){return t&&typeof t=="object"&&"message"in t&&t.message!==void 0&&typeof t.message=="string"?t.message.includes("redis: nil"):!1}var Os=class{constructor(e,r,n){F.set(this,void 0),A.set(this,void 0),P.set(this,void 0),Tr(this,F,e,"f"),Tr(this,A,r,"f"),Tr(this,P,n,"f")}async get(e){return await c(this,F,"f").Get({key:e,transactionId:c(this,A,"f")},c(this,P,"f")),this}async multi(){await c(this,F,"f").Multi(c(this,A,"f"),c(this,P,"f"))}async set(e,r,n){let i;return n?.expiration&&(i=Math.floor((n.expiration.getTime()-Date.now())/1e3),i<1&&(i=1)),await c(this,F,"f").Set({key:e,value:r,nx:n?.nx===!0,xx:n?.xx===!0,expiration:i||0,transactionId:c(this,A,"f")},c(this,P,"f")),this}async del(...e){return await c(this,F,"f").Del({keys:e,transactionId:c(this,A,"f")},c(this,P,"f")),this}async type(e){return await c(this,F,"f").Type({key:e,transactionId:c(this,A,"f")},c(this,P,"f")),this}async exec(){let e=await c(this,F,"f").Exec(c(this,A,"f"),c(this,P,"f")),r=[];for(let n of e.response)n.members?r.push(n.members):n.nil!==void 0?r.push(null):n.num!==void 0?r.push(n.num):n.values!==void 0?r.push(n.values.values):n.str!==void 0?r.push(n.str):n.dbl!==void 0&&r.push(n.dbl);return r}async discard(){await c(this,F,"f").Discard(c(this,A,"f"),c(this,P,"f"))}async watch(...e){return await c(this,F,"f").Watch({keys:e,transactionId:c(this,A,"f")},c(this,P,"f")),this}async unwatch(){return await c(this,F,"f").Unwatch(c(this,A,"f"),c(this,P,"f")),this}async getRange(e,r,n){return await c(this,F,"f").GetRange({key:e,start:r,end:n,transactionId:c(this,A,"f")},c(this,P,"f")),this}async setRange(e,r,n){return await c(this,F,"f").SetRange({key:e,offset:r,value:n,transactionId:c(this,A,"f")},c(this,P,"f")),this}async strlen(e){return this.strLen(e)}async strLen(e){return await c(this,F,"f").Strlen({key:e,transactionId:c(this,A,"f")},c(this,P,"f")),this}async mget(e){return this.mGet(e)}async mGet(e){return await c(this,F,"f").MGet({keys:e,transactionId:c(this,A,"f")},c(this,P,"f")),this}async mset(e){return this.mSet(e)}async mSet(e){let r=Object.entries(e).map(([n,i])=>({key:n,value:i}));return await c(this,F,"f").MSet({kv:r,transactionId:c(this,A,"f")},c(this,P,"f")),this}async incrBy(e,r){return await c(this,F,"f").IncrBy({key:e,value:r,transactionId:c(this,A,"f")},c(this,P,"f")),this}async expire(e,r){return await c(this,F,"f").Expire({key:e,seconds:r,transactionId:c(this,A,"f")},c(this,P,"f")),this}async expireTime(e){return await c(this,F,"f").ExpireTime({key:e,transactionId:c(this,A,"f")},c(this,P,"f")),this}async zAdd(e,...r){return await c(this,F,"f").ZAdd({key:e,members:r,transactionId:c(this,A,"f")},c(this,P,"f")),this}async zScore(e,r){return await c(this,F,"f").ZScore({key:{key:e,transactionId:c(this,A,"f")},member:r},c(this,P,"f")),this}async zRank(e,r){return await c(this,F,"f").ZRank({key:{key:e,transactionId:c(this,A,"f")},member:r},c(this,P,"f")),this}async zIncrBy(e,r,n){return await c(this,F,"f").ZIncrBy({key:e,member:r,value:n,transactionId:c(this,A,"f")},c(this,P,"f")),this}async zScan(e,r,n,i){let s={key:e,cursor:r,pattern:n,count:i,transactionId:c(this,A,"f")};return await c(this,F,"f").ZScan(s,c(this,P,"f")),this}async zCard(e){return await c(this,F,"f").ZCard({key:e,transactionId:c(this,A,"f")},c(this,P,"f")),this}async zRange(e,r,n,i){let s={rev:!1,byLex:!1,byScore:!1,offset:0,count:1e3};if(i?.reverse&&(s.rev=i.reverse),i?.by==="lex"?s.byLex=!0:i?.by==="score"&&(s.byScore=!0),i?.limit)if(s.byLex||s.byScore)s.offset=i.limit.offset,s.count=i.limit.count;else throw new Error("zRange parsing error: 'limit' only allowed when 'options.by' is 'lex' or 'score'");return await c(this,F,"f").ZRange({key:{key:e,transactionId:c(this,A,"f")},start:r+"",stop:n+"",...s},c(this,P,"f")),this}async zRem(e,r){return await c(this,F,"f").ZRem({key:{key:e,transactionId:c(this,A,"f")},members:r},c(this,P,"f")),this}async zRemRangeByLex(e,r,n){return await c(this,F,"f").ZRemRangeByLex({key:{key:e,transactionId:c(this,A,"f")},min:r,max:n},c(this,P,"f")),this}async zRemRangeByRank(e,r,n){return await c(this,F,"f").ZRemRangeByRank({key:{key:e,transactionId:c(this,A,"f")},start:r,stop:n},c(this,P,"f")),this}async zRemRangeByScore(e,r,n){return await c(this,F,"f").ZRemRangeByScore({key:{key:e,transactionId:c(this,A,"f")},min:r,max:n},c(this,P,"f")),this}async hgetall(e){return this.hGetAll(e)}async hGetAll(e){return await c(this,F,"f").HGetAll({key:e,transactionId:c(this,A,"f")},c(this,P,"f")),this}async hget(e,r){return this.hGet(e,r)}async hGet(e,r){return await c(this,F,"f").HGet({key:e,field:r,transactionId:c(this,A,"f")},c(this,P,"f")),this}async hMGet(e,r){return await c(this,F,"f").HMGet({key:e,fields:r,transactionId:c(this,A,"f")},c(this,P,"f")),this}async hset(e,r){return this.hSet(e,r)}async hSet(e,r){let n=Object.entries(r).map(([i,s])=>({field:i,value:s}));return await c(this,F,"f").HSet({key:e,fv:n,transactionId:c(this,A,"f")},c(this,P,"f")),this}async hincrby(e,r,n){return this.hIncrBy(e,r,n)}async hIncrBy(e,r,n){return await c(this,F,"f").HIncrBy({key:e,field:r,value:n,transactionId:c(this,A,"f")},c(this,P,"f")),this}async hdel(e,r){return this.hDel(e,r)}async hDel(e,r){return await c(this,F,"f").HDel({key:e,fields:r,transactionId:c(this,A,"f")},c(this,P,"f")),this}async hscan(e,r,n,i){return this.hScan(e,r,n,i)}async hScan(e,r,n,i){let s={key:e,cursor:r,pattern:n,count:i,transactionId:c(this,A,"f")};return await c(this,F,"f").HScan(s,c(this,P,"f")),this}async hkeys(e){return this.hKeys(e)}async hKeys(e){return await c(this,F,"f").HKeys({key:e,transactionId:c(this,A,"f")},c(this,P,"f")),this}async hlen(e){return this.hLen(e)}async hLen(e){return await c(this,F,"f").HLen({key:e,transactionId:c(this,A,"f")},c(this,P,"f")),this}};F=new WeakMap,A=new WeakMap,P=new WeakMap;var Xt=class t{constructor(e,r=void 0,n=Ds.INSTALLATION){E.set(this,void 0),Sr.set(this,void 0),Tr(this,E,e,"f"),Tr(this,Sr,r,"f"),this.scope=n,this.global=n===Ds.INSTALLATION?new t(c(this,E,"f"),c(this,Sr,"f"),Ds.GLOBAL):this}get storage(){return c(this,Sr,"f")||a.redisPlugin}async watch(...e){let r=await this.storage.Watch({keys:e},c(this,E,"f"));return new Os(this.storage,r,c(this,E,"f"))}async get(e){try{let r=await this.storage.Get({key:e,scope:this.scope},{...c(this,E,"f"),"throw-redis-nil":{values:["true"]}});return r!==null?r.value??void 0:r}catch(r){if(xr(r))return;throw r}}async getBuffer(e){try{let r=await this.storage.GetBytes({key:e,scope:this.scope},{...c(this,E,"f"),"throw-redis-nil":{values:["true"]}});return r!==null?Buffer.from(r.value):r}catch(r){if(xr(r))return;throw r}}async set(e,r,n){let i;return n?.expiration&&(i=Math.floor((n.expiration.getTime()-Date.now())/1e3),i<1&&(i=1)),(await this.storage.Set({key:e,value:r,nx:n?.nx===!0&&!n.xx,xx:n?.xx===!0&&!n.nx,expiration:i||0,scope:this.scope},c(this,E,"f"))).value}async exists(...e){return(await this.storage.Exists({keys:e,scope:this.scope},c(this,E,"f"))).existingKeys}async del(...e){await this.storage.Del({keys:e,scope:this.scope},c(this,E,"f"))}async incrBy(e,r){return(await this.storage.IncrBy({key:e,value:r,scope:this.scope},c(this,E,"f"))).value}async getRange(e,r,n){let i=await this.storage.GetRange({key:e,start:r,end:n,scope:this.scope},c(this,E,"f"));return i!==null?i.value:i}async setRange(e,r,n){return(await this.storage.SetRange({key:e,offset:r,value:n,scope:this.scope},c(this,E,"f"))).value}async strlen(e){return this.strLen(e)}async strLen(e){return(await this.storage.Strlen({key:e,scope:this.scope},c(this,E,"f"))).value}async expire(e,r){await this.storage.Expire({key:e,seconds:r,scope:this.scope},c(this,E,"f"))}async expireTime(e){return(await this.storage.ExpireTime({key:e,scope:this.scope},c(this,E,"f"))).value}async zAdd(e,...r){return(await this.storage.ZAdd({key:e,members:r,scope:this.scope},c(this,E,"f"))).value}async zRange(e,r,n,i){let s={rev:!1,byLex:!1,byScore:!1,offset:0,count:1e3};if(i?.reverse&&(s.rev=i.reverse),i?.by==="lex"?s.byLex=!0:i?.by==="score"?s.byScore=!0:(s.offset=0,s.count=0),i?.limit)if(s.byLex||s.byScore)s.offset=i.limit.offset,s.count=i.limit.count;else throw new Error("zRange parsing error: 'limit' only allowed when 'options.by' is 'lex' or 'score'");return(await this.storage.ZRange({key:{key:e},start:r+"",stop:n+"",...s,scope:this.scope},c(this,E,"f"))).members}async zRem(e,r){return(await this.storage.ZRem({key:{key:e},members:r,scope:this.scope},c(this,E,"f"))).value}async zRemRangeByLex(e,r,n){return(await this.storage.ZRemRangeByLex({key:{key:e},min:r,max:n,scope:this.scope},c(this,E,"f"))).value}async zRemRangeByRank(e,r,n){return(await this.storage.ZRemRangeByRank({key:{key:e},start:r,stop:n,scope:this.scope},c(this,E,"f"))).value}async zRemRangeByScore(e,r,n){return(await this.storage.ZRemRangeByScore({key:{key:e},min:r,max:n,scope:this.scope},c(this,E,"f"))).value}async zScore(e,r){try{let n=await this.storage.ZScore({key:{key:e},member:r,scope:this.scope},{...c(this,E,"f"),"throw-redis-nil":{values:["true"]}});return n!==null?n.value:n}catch(n){if(xr(n))return;throw n}}async zRank(e,r){try{let n=await this.storage.ZRank({key:{key:e},member:r,scope:this.scope},{...c(this,E,"f"),"throw-redis-nil":{values:["true"]}});return n!==null?n.value:n}catch(n){if(xr(n))return;throw n}}async zIncrBy(e,r,n){let i=await this.storage.ZIncrBy({key:e,member:r,value:n,scope:this.scope},c(this,E,"f"));return i!==null?i.value:i}async mget(e){return this.mGet(e)}async mGet(e){let r=await this.storage.MGet({keys:e,scope:this.scope},c(this,E,"f"));return r!==null?r.values.map(n=>n||null):r}async mset(e){return this.mSet(e)}async mSet(e){let r=Object.entries(e).map(([n,i])=>({key:n,value:i}));await this.storage.MSet({kv:r,scope:this.scope},c(this,E,"f"))}async zCard(e){let r=await this.storage.ZCard({key:e,scope:this.scope},c(this,E,"f"));return r!==null?r.value:r}async zScan(e,r,n,i){let s={key:e,cursor:r,pattern:n,count:i,scope:this.scope};return await this.storage.ZScan(s,c(this,E,"f"))}async type(e){let r=await this.storage.Type({key:e,scope:this.scope},c(this,E,"f"));return r!==null?r.value:r}async rename(e,r){return(await this.storage.Rename({key:e,newKey:r,scope:this.scope},c(this,E,"f"))).result}async hget(e,r){return this.hGet(e,r)}async hGet(e,r){try{let n=await this.storage.HGet({key:e,field:r,scope:this.scope},{...c(this,E,"f"),"throw-redis-nil":{values:["true"]}});return n!==null?n.value??void 0:n}catch(n){if(xr(n))return;throw n}}async hMGet(e,r){let n=await this.storage.HMGet({key:e,fields:r,scope:this.scope},c(this,E,"f"));return n!==null?n.values.map(i=>i||null):n}async hset(e,r){return this.hSet(e,r)}async hSet(e,r){let n=Object.entries(r).map(([s,o])=>({field:s,value:o}));return(await this.storage.HSet({key:e,fv:n,scope:this.scope},c(this,E,"f"))).value}async hSetNX(e,r,n){return(await this.storage.HSetNX({key:e,field:r,value:n,scope:this.scope},c(this,E,"f"))).success}async hgetall(e){return this.hGetAll(e)}async hGetAll(e){let r=await this.storage.HGetAll({key:e,scope:this.scope},c(this,E,"f"));return r!==null?r.fieldValues:r}async hdel(e,r){return this.hDel(e,r)}async hDel(e,r){return(await this.storage.HDel({key:e,fields:r,scope:this.scope},c(this,E,"f"))).value}async hscan(e,r,n,i){return this.hScan(e,r,n,i)}async hScan(e,r,n,i){let s={key:e,cursor:r,pattern:n,count:i,scope:this.scope};return await this.storage.HScan(s,c(this,E,"f"))}async hkeys(e){return this.hKeys(e)}async hKeys(e){let r=await this.storage.HKeys({key:e,scope:this.scope},c(this,E,"f"));return r!==null?r.keys:r}async hincrby(e,r,n){return this.hIncrBy(e,r,n)}async hIncrBy(e,r,n){return(await this.storage.HIncrBy({key:e,field:r,value:n,scope:this.scope},c(this,E,"f"))).value}async hlen(e){return this.hLen(e)}async hLen(e){return(await this.storage.HLen({key:e,scope:this.scope})).value}async bitfield(e,...r){let n=[];for(let s=0;s<r.length;){let o=r[s],d={};switch(o){case"get":{if(s+2>=r.length)throw Error("bitfield command parse failed; not enough arguments for 'get' command");d.get={encoding:r[s+1],offset:r[s+2].toString()},s+=3;break}case"set":{if(s+3>=r.length)throw Error("bitfield command parse failed; not enough arguments for 'set' command");d.set={encoding:r[s+1],offset:r[s+2].toString(),value:r[s+3].toString()},s+=4;break}case"incrBy":{if(s+3>=r.length)throw Error("bitfield command parse failed; not enough arguments for 'incrBy' command");d.incrBy={encoding:r[s+1],offset:r[s+2].toString(),increment:r[s+3].toString()},s+=4;break}case"overflow":{if(s+1>=r.length)throw Error("bitfield command parse failed; not enough arguments for 'overflow' command");let l=r[s+1].toString();d.overflow={behavior:hu(l)},s+=2;break}default:throw Error(`bitfield command parse failed; ${o} unrecognized (must be 'get', 'set', 'incrBy', or 'overflow')`)}n.push(d)}return(await this.storage.Bitfield({key:e,commands:n})).results}};E=new WeakMap,Sr=new WeakMap;function hu(t){let e=t.toLowerCase();switch(e){case"wrap":return Bs.BITFIELD_OVERFLOW_BEHAVIOR_WRAP;case"sat":return Bs.BITFIELD_OVERFLOW_BEHAVIOR_SAT;case"fail":return Bs.BITFIELD_OVERFLOW_BEHAVIOR_FAIL;default:throw Error(`unknown bitfield overflow behavior: ${e}`)}}var fu=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Us=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Yt,er=class{constructor(e){Yt.set(this,void 0),fu(this,Yt,e,"f")}async runJob(e){return(await a.schedulerPlugin.Schedule({action:{type:e.name,data:e.data},cron:"cron"in e?e.cron:void 0,when:"runAt"in e?e.runAt:void 0},Us(this,Yt,"f"))).id}async cancelJob(e){await a.schedulerPlugin.Cancel({id:e},Us(this,Yt,"f"))}async listJobs(){return(await a.schedulerPlugin.List({after:new Date(0),before:new Date(Date.now()+31536e7)},Us(this,Yt,"f"))).actions.map(r=>(m(r.request?.action,"Scheduled job is malformed"),"when"in r.request&&r.request.when!=null?{id:r.id,name:r.request.action.type,runAt:r.request.when,data:r.request.action.data}:{id:r.id,name:r.request.action.type,cron:r.request.cron??"",data:r.request.action}))}};Yt=new WeakMap;import{FormFieldType as qn}from"@devvit/protos";var mu=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},pu=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Jn,tr=class{constructor(e){Jn.set(this,void 0),mu(this,Jn,e,"f")}async get(e){return(await this.getAll())[e]}async getAll(){let r=await a.settingsPlugin.GetSettings({},pu(this,Jn,"f"));if(!r.installationSettings)throw new Error("Could not get installation settings");if(!r.appSettings)throw new Error("Could not get app settings");return gu(r),{...Sa(r.installationSettings.settings,a.installationSettings),...Sa(r.appSettings.settings,a.appSettings)}}};Jn=new WeakMap;function gu(t){if(!t.appSettings)throw new Error("Could not get app settings");for(let[e,r]of Object.entries(t.appSettings.settings)){let n=a.appSettings?.find(i=>i.type!=="group"&&i.name===e);n&&(n.type==="boolean"&&r.fieldType===qn.STRING&&r.boolValue==null&&r.stringValue!=null?(r.fieldType=qn.BOOLEAN,r.boolValue=!!r.stringValue,delete r.stringValue):n.type==="number"&&r.fieldType===qn.STRING&&r.numberValue==null&&r.stringValue!=null&&(r.fieldType=qn.NUMBER,r.numberValue=Number(r.stringValue),delete r.stringValue))}}function Sa(t,e){let r=Object.keys(t).reduce((n,i)=>(n[i]=Ts(t[i]),n),{});return e&&Ta(r,e),r}function Ta(t,e){for(let r of e)r.type==="group"?Ta(t,r.fields):!(r.name in t)&&"defaultValue"in r&&(t[r.name]=r.defaultValue)}import{EffectType as Zn,ToastAppearance as Ma}from"@devvit/protos";var Ra=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},xe=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},at,Rr,Qn,Ls,Xn=class{constructor(e){at.set(this,[]),Rr.set(this,void 0),Qn.set(this,void 0),Ls.set(this,(r,n)=>{let i=n!==void 0?r:"",s=n!==void 0?n:r;xe(this,at,"f").push({type:Zn.EFFECT_WEB_VIEW,webView:{postMessage:{webViewId:i,app:{message:s}}}})}),Ra(this,Rr,e,"f"),Ra(this,Qn,{postMessage:xe(this,Ls,"f")},"f")}get webView(){return xe(this,Qn,"f")}showForm(e,r){let n=a.formDefinitions.get(e);if(!n&&xe(this,Rr,"f")){let o=xe(this,Rr,"f").forms.get(e);o&&(n={form:o,onSubmit:()=>{}})}if(!n)throw new Error("Form does not exist. Make sure you have added it using Devvit.createForm at the root of your app.");let i=n.form instanceof Function?n.form(r??{}):n.form,s={fields:[],id:e,title:i.title,acceptLabel:i.acceptLabel,cancelLabel:i.cancelLabel,shortDescription:i.description};nt(i.fields),s.fields=Ie(i.fields),xe(this,at,"f").push({type:Zn.EFFECT_SHOW_FORM,showForm:{form:s}})}showToast(e){let r;e instanceof Object?r={text:e.text,appearance:e.appearance==="success"?Ma.SUCCESS:Ma.NEUTRAL}:r={text:e},xe(this,at,"f").push({type:Zn.EFFECT_SHOW_TOAST,showToast:{toast:r}})}navigateTo(e){let r;typeof e=="string"?r=new URL(e).toString():r=new URL(e.permalink,"https://www.reddit.com").toString(),xe(this,at,"f").push({type:Zn.EFFECT_NAVIGATE_TO_URL,navigateToUrl:{url:r}})}get __effects(){return xe(this,at,"f")}};at=new WeakMap,Rr=new WeakMap,Qn=new WeakMap,Ls=new WeakMap;function Z({metadata:t,ui:e,hooks:r,reconciler:n}){let i=new Zt(t),s=new qt(t),o=new Xt(t),d=Fa(o,n?n.state:{}),l=new er(t),u=new tr(t),g=e?new Xn(n):void 0,p=new Jt(t),_=new Kt,I=new Qt(t),T=r&&n?ha(n):void 0,L=r&&n?ua(n):void 0,D=r&&n?la(n):void 0,oe=r&&n?da(n):void 0;return{modLog:i,kvStore:s,redis:o,scheduler:l,settings:u,media:p,assets:_,realtime:I,get useForm(){return D??(()=>{throw new Error("useForm() is unavailable")})},get cache(){return d??(()=>{throw new Error("cache() is unavailable")})},get useState(){return T??(()=>{throw new Error("useState() is unavailable")})},get useInterval(){return L??(()=>{throw new Error("useInterval() is unavailable")})},get useChannel(){return oe??(()=>{throw new Error("useChannel() is unavailable")})},get ui(){if(!g)throw new Error("ui client is not available");return g}}}var Na={name:"@devvit/public-api",version:"0.12.0-dev",license:"BSD-3-Clause",repository:{type:"git",url:"https://developers.reddit.com/"},type:"module",exports:{".":"./dist/index.js","./package.json":"./package.json","./*":"./dist/*"},main:"./dist/index.js",files:["dist/**"],scripts:{build:"yarn build:icon-types && yarn build:semantic-colors && tsc && cp -af devvit.tsconfig.json dist/ && yarn build:types && yarn build:min && yarn build:unmin","build:icon-types":"make-icons src/types/icons.ts","build:min":"esbuild --bundle --sourcemap=linked --target=es2020 --format=esm --metafile=dist/meta.min.json --outfile=dist/public-api.min.js --external:@devvit/protos --minify src/index.ts","build:semantic-colors":"node scripts/make-semantic-colors.js","build:types":"api-extractor run && sed -ne '/declare global {/,$ p' src/devvit/Devvit.ts >> dist/public-api.d.ts","build:unmin":"esbuild --bundle --sourcemap=inline --target=es2020 --format=iife --metafile=dist/meta.json --outfile=dist/public-api.iife.js --global-name=devvitPublicAPI src/index.ts",clean:"rm -rf .turbo api-extractor coverage dist src/devvit/internals/semanticColors.ts src/types/icons.ts || :",clobber:"yarn clean && rm -rf node_modules",dev:"tsc -w","dev:build":"chokidar ./src ../shared-types/dist --command 'yarn build' --ignore './src/types/icons.ts' --ignore './src/devvit/internals/semanticColors.ts'",lint:"redlint .","lint:fix":"yarn lint --fix",prepublishOnly:"publish-package-json",test:"yarn test:unit && yarn test:types && yarn test:size","test:size":"filesize","test:types":"tsc --noEmit","test:unit":"vitest run","test:unit-with-coverage":"vitest run --coverage"},types:"./dist/index.d.ts",dependencies:{"@devvit/metrics":"0.12.0-dev","@devvit/protos":"0.12.0-dev","@devvit/shared-types":"0.12.0-dev","base64-js":"1.5.1","clone-deep":"4.0.1",moderndash:"4.0.0"},devDependencies:{"@ampproject/filesize":"4.3.0","@devvit/repo-tools":"0.12.0-dev","@devvit/tsconfig":"0.12.0-dev","@microsoft/api-extractor":"7.41.0","@reddit/faceplate-ui":"18.0.1","@types/clone-deep":"4.0.1","@vitest/coverage-c8":"0.32.0","chokidar-cli":"3.0.0",esbuild:"0.23.0",eslint:"9.11.1",typescript:"5.3.2",vitest:"1.6.0"},publishConfig:{directory:"dist"},filesize:{"dist/public-api.min.js":{gzip:"62 KB",none:"218 KB"}},source:"./src/index.ts"};function z(t,e,r){let n=t[C.Subreddit]?.values[0];m(n,"subreddit is missing from Context");let i=t[C.SubredditName]?.values[0],s=t[C.AppUser]?.values[0],o=t[C.App]?.values[0],d=t[C.Version]?.values[0],l=t[C.User]?.values[0],u=yu(t);return{get appAccountId(){return m(s,"appAccountId is missing from Context"),s},subredditId:n,subredditName:i,userId:l,postId:e,commentId:r,appName:o,appVersion:d,debug:u,metadata:t,toJSON(){return{appAccountId:s,appName:o,appVersion:d,subredditId:n,subredditName:i,userId:l,postId:e,commentId:r,debug:u,metadata:t}}}}function yu(t){var e;let r={blocks:void 0,emitSnapshots:void 0,emitState:void 0,realtime:void 0,runtime:void 0,surface:void 0,useAsync:void 0,payments:void 0,bootstrap:void 0,webView:void 0},n={};for(let s in r)n[s.toLowerCase()]=s;let i={};for(let s of(t[C.Debug]?.values??[]).join().split(",")){let[o,d]=s.split("=");o&&(o=o.trim(),d=d?.trim(),o.toLowerCase()in n&&(o=n[o.toLowerCase()]),i[e=o]??(i[e]=d||"true"))}return t[C.Debug]&&console.info(`[api] @devvit/public-api v${Na.version} ${Object.entries(i).map(([s,o])=>`${s}=${o}`).join(" ")}`),{...i}}function Ba(t){return t.flatMap(e=>e.type==="group"?Ba(e.fields):e)}async function Yn(t,e,r){if(!e)throw new Error("Settings were not defined.");let n={success:!0,errors:{}},i=We(t.fieldValues),s=Ba(e);return await Promise.all(s.map(async o=>{let d=o.name;if(d&&o.onValidate){let l=i[d],u=o.onValidate,g=Object.assign(Z({metadata:r}),z(r)),p=await u({value:l,isEditing:t.editing},g);p&&(n.success=!1,n.errors[d]=p)}})),bu.fromJSON(n)}async function _u(){if(!a.appSettings)throw new Error("App settings were not defined.");return ku.fromJSON({fields:{fields:Ie(a.appSettings)}})}async function Eu(t,e){return Yn(t,a.appSettings,e)}function Da(t){t.provides(vu),x("GetAppSettingsFields",_u),x("ValidateAppForm",Eu)}import{CustomPostDefinition as Mu,RenderPostResponse as Nu}from"@devvit/protos";import{BlockRenderEventType as Ys,EffectType as Qa}from"@devvit/protos";function rr(t){return t.__effects}function Oa(){let t=new Set;return e=>{let r=e,n=1;for(;t.has(r);)r=`${e}.${n++}`;return t.add(r),r}}import{BlockActionType as Xs,BlockAvatarBackground as Ka,BlockAvatarFacing as qa,BlockAvatarSize as He,BlockBorderWidth as ni,BlockButtonAppearance as je,BlockButtonSize as Vs,BlockGap as ii,BlockHorizontalAlignment as $s,BlockIconSize as si,BlockImageResizeMode as Mr,BlockPadding as Nr,BlockRadius as Br,BlockSpacerShape as zs,BlockSpacerSize as oi,BlockStackDirection as Ks,BlockTextOutline as qs,BlockTextOverflow as Js,BlockTextSize as ir,BlockTextStyle as Zs,BlockTextWeight as Ja,BlockType as Ee,BlockVerticalAlignment as Qs}from"@devvit/protos";var Ws={"alienblue-100":"#DCE2FB","alienblue-200":"#B8C5FC","alienblue-25":"#F7F8FD","alienblue-300":"#90A9FD","alienblue-400":"#648EFC","alienblue-50":"#EEF0FB","alienblue-500":"#1870F4","alienblue-600":"#115BCA","alienblue-700":"#0A449B","alienblue-75":"#E6E9FB","alienblue-800":"#0A2F6C","alienblue-900":"#0A1A3F","alienblue-950":"#07102B","berrypurple-100":"#F3DAFB","berrypurple-200":"#EAB3FD","berrypurple-25":"#FBF6FD","berrypurple-300":"#DE8BFF","berrypurple-400":"#CF5FFF","berrypurple-50":"#F8EDFC","berrypurple-500":"#BC0EFF","berrypurple-600":"#9B00D4","berrypurple-700":"#7600A3","berrypurple-75":"#F6E4FB","berrypurple-800":"#520472","berrypurple-900":"#300643","berrypurple-950":"#20042A",black:"#000000","black-opacity-0":"#00000000","black-opacity-10":"#00000019","black-opacity-15":"#00000026","black-opacity-20":"#00000033","black-opacity-25":"#0000003F","black-opacity-33":"#00000054","black-opacity-5":"#0000000C","black-opacity-50":"#0000007F","black-opacity-60":"#00000099","black-opacity-67":"#000000AA","black-opacity-80":"#000000CC","black-opacity-90":"#000000E5","brown-100":"#F1DFCF","brown-200":"#E9BE95","brown-25":"#FBF7F4","brown-300":"#DC9D5D","brown-400":"#BA854E","brown-50":"#F7EFE9","brown-500":"#9A6D3F","brown-600":"#7B5631","brown-700":"#5D4023","brown-75":"#F4E7DC","brown-800":"#3F2C19","brown-900":"#221A11","brown-950":"#15100A","coolgray-100":"#DBE4E9","coolgray-150":"#C9D7DE","coolgray-200":"#B7CAD4","coolgray-25":"#F6F8F9","coolgray-250":"#A4BDCA","coolgray-300":"#97AFBC","coolgray-350":"#8BA2AD","coolgray-400":"#7F949F","coolgray-450":"#748791","coolgray-50":"#EEF1F3","coolgray-500":"#667780","coolgray-525":"#576F76","coolgray-550":"#5C6C74","coolgray-600":"#536168","coolgray-650":"#48545B","coolgray-700":"#3D494E","coolgray-75":"#E5EBEE","coolgray-750":"#333D42","coolgray-800":"#2A3236","coolgray-850":"#21272A","coolgray-900":"#181C1F","coolgray-950":"#0E1113","global-black":{light:"#000000",dark:"#000000"},"global-brand-orangered":{light:"#FF4500",dark:"#FF4500"},"global-white":{light:"#FFFFFF",dark:"#FFFFFF"},"kiwigreen-100":"#A8F5A0","kiwigreen-200":"#58E15B","kiwigreen-25":"#EBFDE7","kiwigreen-300":"#00C61C","kiwigreen-400":"#01A816","kiwigreen-50":"#DDF8D7","kiwigreen-500":"#008A10","kiwigreen-600":"#016E0B","kiwigreen-700":"#005306","kiwigreen-75":"#CAF5C2","kiwigreen-800":"#033902","kiwigreen-900":"#0D2005","kiwigreen-950":"#081404","lightblue-100":"#CAE7FB","lightblue-200":"#87D0FD","lightblue-25":"#F3F9FD","lightblue-300":"#02B9FB","lightblue-400":"#029DD5","lightblue-50":"#E6F3FC","lightblue-500":"#007FAE","lightblue-600":"#01668D","lightblue-700":"#014D6B","lightblue-75":"#D9EDFB","lightblue-800":"#03354B","lightblue-900":"#051E2B","lightblue-950":"#04131A","lime-100":"#B7F28E","lime-200":"#90DA58","lime-25":"#EEFDDC","lime-300":"#6DBF01","lime-400":"#5BA200","lime-50":"#E0F8C8","lime-500":"#4A8500","lime-600":"#3A6A00","lime-700":"#2A5000","lime-75":"#CEF5AD","lime-800":"#1E3702","lime-900":"#151E05","lime-950":"#0D1304","mintgreen-100":"#9BF5D9","mintgreen-200":"#00E2B7","mintgreen-25":"#E7FDF5","mintgreen-300":"#00C29D","mintgreen-400":"#01A484","mintgreen-50":"#D7F8EC","mintgreen-500":"#01876D","mintgreen-600":"#006C56","mintgreen-700":"#015140","mintgreen-75":"#C0F5E3","mintgreen-800":"#00382B","mintgreen-900":"#032019","mintgreen-950":"#03140F","orangered-100":"#FCDBCF","orangered-200":"#FDB498","orangered-25":"#FDF6F4","orangered-300":"#FF895D","orangered-400":"#FF4500","orangered-50":"#FCEEE8","orangered-500":"#D93900","orangered-600":"#AE2C00","orangered-700":"#842100","orangered-75":"#FBE5DC","orangered-800":"#591B02","orangered-900":"#2F1405","orangered-950":"#1C0D04","periwinkle-100":"#E6DFFB","periwinkle-200":"#CDBEFD","periwinkle-25":"#F9F7FD","periwinkle-300":"#B29FFF","periwinkle-400":"#9580FF","periwinkle-50":"#F2EFFC","periwinkle-500":"#6A5CFF","periwinkle-600":"#523DFF","periwinkle-700":"#4001EA","periwinkle-75":"#ECE7FB","periwinkle-800":"#250AA6","periwinkle-900":"#160E5B","periwinkle-950":"#0C083F","poopbrown-100":"#FEEEDD","poopbrown-200":"#F6DDC3","poopbrown-300":"#EECCAA","poopbrown-400":"#CAA075","poopbrown-50":"#FEF7EE","poopbrown-500":"#9A6D3F","poopbrown-600":"#6E4924","poopbrown-700":"#54371A","poopbrown-800":"#3B2510","poopbrown-900":"#29190A","poopbrown-950":"#110B04","puregray-100":"#F2F2F2","puregray-150":"#EBEBEB","puregray-200":"#E4E4E4","puregray-250":"#DDDDDD","puregray-300":"#D6D6D6","puregray-350":"#C3C3C3","puregray-400":"#ACACAC","puregray-450":"#919191","puregray-50":"#F8F8F8","puregray-500":"#767676","puregray-550":"#5C5C5C","puregray-600":"#434343","puregray-650":"#393939","puregray-700":"#303030","puregray-750":"#272727","puregray-800":"#1E1E1E","puregray-850":"#181818","puregray-900":"#131313","puregray-950":"#080808","red-100":"#FBDBD4","red-200":"#FDB3A4","red-25":"#FDF6F5","red-300":"#FF8773","red-400":"#FF4F40","red-50":"#FCEEEA","red-500":"#EB001F","red-600":"#BC0117","red-700":"#90000F","red-75":"#FBE4DF","red-800":"#650405","red-900":"#340F05","red-950":"#1F0B04","sakurapink-100":"#FBD9EB","sakurapink-200":"#FDAEDA","sakurapink-25":"#FDF6F9","sakurapink-300":"#FF7ECA","sakurapink-400":"#FF38BB","sakurapink-50":"#FCEDF4","sakurapink-500":"#DE019F","sakurapink-600":"#B2007F","sakurapink-700":"#880060","sakurapink-75":"#FBE3EF","sakurapink-800":"#5F0443","sakurapink-900":"#380626","sakurapink-950":"#250419",transparent:"transparent",white:"#ffffff","white-opacity-0":"#FFFFFF00","white-opacity-10":"#FFFFFF19","white-opacity-15":"#FFFFFF26","white-opacity-20":"#FFFFFF33","white-opacity-25":"#FFFFFF3F","white-opacity-5":"#FFFFFF0C","white-opacity-50":"#FFFFFF7F","yellow-100":"#FFE284","yellow-200":"#FFBF0B","yellow-25":"#FFF9E0","yellow-300":"#D8A100","yellow-400":"#B78800","yellow-50":"#FFF3C0","yellow-500":"#977000","yellow-600":"#785800","yellow-700":"#5B4200","yellow-75":"#FFEAA2","yellow-800":"#3F2D00","yellow-900":"#231A03","yellow-950":"#161003","yelloworange-100":"#FCDCC8","yelloworange-200":"#FDB586","yelloworange-25":"#FDF7F3","yelloworange-300":"#FF8A35","yelloworange-400":"#E46C00","yelloworange-50":"#FCEEE6","yelloworange-500":"#BD5800","yelloworange-600":"#974500","yelloworange-700":"#733300","yelloworange-75":"#FBE5D7","yelloworange-800":"#4E2402","yelloworange-900":"#2A1705","yelloworange-950":"#1A0E04","action-downvote":{light:"#6A5CFF",dark:"#6A5CFF"},"action-upvote":{light:"#D93900",dark:"#D93900"},"ai-background-weaker":{light:"#E7FDF5",dark:"#00382B"},"ai-plain":{light:"#006C56",dark:"#01A484"},"ai-plain-hover":{light:"#015140",dark:"#00C29D"},"alert-caution":{light:"#977000",dark:"#977000"},"avatar-gradient":{light:"",dark:""},"brand-background":{light:"#D93900",dark:"#D93900"},"brand-background-hover":{light:"#AE2C00",dark:"#AE2C00"},"brand-gradient-active":{light:"",dark:""},"brand-gradient-active-highlight":{light:"",dark:""},"brand-gradient-default":{light:"",dark:""},"brand-gradient-default-highlight":{light:"",dark:""},"brand-gradient-hover":{light:"",dark:""},"brand-gradient-hover-highlight":{light:"",dark:""},"brand-onBackground":{light:"#FFFFFF",dark:"#FFFFFF"},"category-live":{light:"#D93900",dark:"#D93900"},"category-nsfw":{light:"#DE019F",dark:"#DE019F"},"category-spoiler":{light:"#131313",dark:"#F2F2F2"},"caution-background":{light:"#FFBF0B",dark:"#D8A100"},"caution-background-hover":{light:"#D8A100",dark:"#FFBF0B"},"caution-onBackground":{light:"#000000",dark:"#000000"},"caution-plain":{light:"#785800",dark:"#FFBF0B"},"caution-plain-hover":{light:"#5B4200",dark:"#FFE284"},"danger-background":{light:"#EB001F",dark:"#BC0117"},"danger-background-disabled":{light:"#FDB3A4",dark:"#340F05"},"danger-background-hover":{light:"#BC0117",dark:"#EB001F"},"danger-background-weaker":{light:"#FBDBD4",dark:"#650405"},"danger-content":{light:"#BC0117",dark:"#FF4F40"},"danger-content-default":{light:"#ffffff",dark:"#ffffff"},"danger-content-hover":{light:"#90000F",dark:"#FF8773"},"danger-onBackground":{light:"#FFFFFF",dark:"#FFFFFF"},"danger-plain":{light:"#BC0117",dark:"#FF8773"},"danger-plain-hover":{light:"#90000F",dark:"#FDB3A4"},"downvote-background":{light:"#6A5CFF",dark:"#6A5CFF"},"downvote-background-disabled":{light:"#6a5cff4d",dark:"#6a5cff4d"},"downvote-background-hover":{light:"#523DFF",dark:"#523DFF"},"downvote-content":{light:"#523DFF",dark:"#9580FF"},"downvote-content-weak":{light:"#6A5CFF",dark:"#6A5CFF"},"downvote-disabled":{light:"#523DFF4c",dark:"#9580FF4c"},"downvote-onBackground":{light:"#FFFFFF",dark:"#FFFFFF"},"downvote-onStrongScrim":{light:"#B29FFF",dark:"#B29FFF"},"downvote-onStrongScrim-disabled":{light:"#b29fff4d",dark:"#b29fff4d"},"downvote-onStrongScrim-weaker":{light:"#9580FF",dark:"#9580FF"},"downvote-plain":{light:"#523DFF",dark:"#9580FF"},"downvote-plain-disabled":{light:"#523dff4d",dark:"#9580ff4d"},"downvote-plain-weaker":{light:"#6A5CFF",dark:"#6A5CFF"},"elevation-large1":{light:"#0000003F",dark:"#0000007F"},"elevation-large2":{light:"#00000026",dark:"#00000033"},"elevation-medium1":{light:"#0000003F",dark:"#0000007F"},"elevation-medium2":{light:"#00000019",dark:"#00000033"},"elevation-small":{light:"#00000026",dark:"#00000054"},"elevation-xsmall":{light:"#0000003F",dark:"#000000AA"},favorite:{light:"#977000",dark:"#B78800"},"global-admin":{light:"#D93900",dark:"#D93900"},"global-alienblue":{light:"#1870F4",dark:"#1870F4"},"global-darkblue":{light:"#2A3236",dark:"#2A3236"},"global-focus":{light:"#029DD5",dark:"#007FAE"},"global-gold":{light:"#B78800",dark:"#D8A100"},"global-moderator":{light:"#008A10",dark:"#008A10"},"global-nsfw":{light:"#DE019F",dark:"#DE019F"},"global-offline":{light:"#667780",dark:"#667780"},"global-online":{light:"#00C61C",dark:"#00C61C"},"global-orangered":{light:"#FF4500",dark:"#FF4500"},"global-stars":{light:"#977000",dark:"#D8A100"},"gradient-media":{light:"",dark:""},"gradient-media-strong":{light:"",dark:""},"identity-admin":{light:"#D93900",dark:"#D93900"},"identity-coins":{light:"#B78800",dark:"#B78800"},"identity-moderator":{light:"#008A10",dark:"#008A10"},"identity-self":{light:"#01876D",dark:"#01876D"},"interactive-background-disabled":{light:"#0000000C",dark:"#FFFFFF0C"},"interactive-content-disabled":{light:"#0000003F",dark:"#FFFFFF3F"},"interactive-focused":{light:"#007FAE",dark:"#007FAE"},"interactive-pressed":{light:"#00000026",dark:"#FFFFFF26"},"inverted-interactive-background-disabled":{light:"#FFFFFF0C",dark:"#0000000C"},"inverted-interactive-content-disabled":{light:"#FFFFFF3F",dark:"#0000003F"},"inverted-interactive-pressed":{light:"#FFFFFF26",dark:"#00000026"},"inverted-neutral-background":{light:"#0E1113",dark:"#FFFFFF"},"inverted-neutral-background-hover":{light:"#181C1F",dark:"#F6F8F9"},"inverted-neutral-border":{light:"#FFFFFF33",dark:"#00000033"},"inverted-neutral-content":{light:"#B7CAD4",dark:"#333D42"},"inverted-neutral-content-strong":{light:"#EEF1F3",dark:"#181C1F"},"inverted-secondary-background":{light:"#2A3236",dark:"#E5EBEE"},"inverted-secondary-background-hover":{light:"#333D42",dark:"#DBE4E9"},"inverted-secondary-background-selected":{light:"#3D494E",dark:"#C9D7DE"},"inverted-secondary-onBackground":{light:"#FFFFFF",dark:"#000000"},"inverted-secondary-plain":{light:"#DBE4E9",dark:"#181C1F"},"inverted-secondary-plain-hover":{light:"#FFFFFF",dark:"#000000"},"media-background":{light:"#00000099",dark:"#00000099"},"media-background-hover":{light:"#000000cc",dark:"#000000cc"},"media-background-selected":{light:"#000000cc",dark:"#000000cc"},"media-border-selected":{light:"#FFFFFF",dark:"#FFFFFF"},"media-border-weak":{light:"#FFFFFF19",dark:"#FFFFFF19"},"media-onBackground":{light:"#FFFFFF",dark:"#FFFFFF"},"media-onBackground-disabled":{light:"#FFFFFF3F",dark:"#FFFFFF3F"},"media-onBackground-weak":{light:"#E5EBEE",dark:"#E5EBEE"},"media-onbackground":{light:"#ffffff",dark:"#ffffff"},"media-onbackground-disabled":{light:"#ffffff3f",dark:"#ffffff3f"},"media-onbackground-weak":{light:"#B7CAD4",dark:"#B7CAD4"},"neutral-background":{light:"#FFFFFF",dark:"#0E1113"},"neutral-background-container":{light:"#F6F8F9",dark:"#181C1F"},"neutral-background-container-hover":{light:"#EEF1F3",dark:"#21272A"},"neutral-background-container-strong":{light:"#EEF1F3",dark:"#21272A"},"neutral-background-container-strong-hover":{light:"#E5EBEE",dark:"#2A3236"},"neutral-background-gilded":{light:"#FFF9E0",dark:"#181C1F"},"neutral-background-gilded-hover":{light:"#FFF3C0",dark:"#21272A"},"neutral-background-hover":{light:"#F6F8F9",dark:"#181C1F"},"neutral-background-medium":{light:"#F8F8F8",dark:"#131313"},"neutral-background-pinned":{light:"#FFFFFF",dark:"#0E1113"},"neutral-background-selected":{light:"#E5EBEE",dark:"#2A3236"},"neutral-background-strong":{light:"#FFFFFF",dark:"#181C1F"},"neutral-background-strong-hover":{light:"#F6F8F9",dark:"#21272A"},"neutral-background-weak":{light:"#F6F8F9",dark:"#000000"},"neutral-background-weak-hover":{light:"#EEF1F3",dark:"#0E1113"},"neutral-border":{light:"#00000033",dark:"#FFFFFF33"},"neutral-border-medium":{light:"#0000007F",dark:"#FFFFFF7F"},"neutral-border-strong":{light:"#181C1F",dark:"#F6F8F9"},"neutral-border-weak":{light:"#00000019",dark:"#FFFFFF19"},"neutral-content":{light:"#333D42",dark:"#B7CAD4"},"neutral-content-disabled":{light:"#D6D6D6",dark:"#303030"},"neutral-content-strong":{light:"#181C1F",dark:"#EEF1F3"},"neutral-content-weak":{light:"#5C6C74",dark:"#8BA2AD"},offline:{light:"#767676",dark:"#767676"},online:{light:"#01A816",dark:"#01A816"},"opacity-08":{light:"#13131314",dark:"#13131314"},"opacity-50":{light:"#0000007f",dark:"#F2F2F27f"},"opacity-highlight":{light:"",dark:""},pizzaRed:{light:"#ef5350",dark:"#c62828"},primary:{light:"#115BCA",dark:"#648EFC"},"primary-background":{light:"#0A449B",dark:"#115BCA"},"primary-background-hover":{light:"#0A2F6C",dark:"#1870F4"},"primary-background-selected":{light:"#0A1A3F",dark:"#648EFC"},"primary-border":{light:"#0A449B",dark:"#648EFC"},"primary-border-hover":{light:"#0A2F6C",dark:"#90A9FD"},"primary-hover":{light:"#0A449B",dark:"#90A9FD"},"primary-onBackground":{light:"#FFFFFF",dark:"#FFFFFF"},"primary-onBackground-selected":{light:"#FFFFFF",dark:"#000000"},"primary-plain":{light:"#0A449B",dark:"#648EFC"},"primary-plain-hover":{light:"#0A2F6C",dark:"#90A9FD"},"primary-plain-visited":{light:"#7600A3",dark:"#CF5FFF"},"primary-visited":{light:"#9B00D4",dark:"#CF5FFF"},scrim:{light:"#00000099",dark:"#00000099"},"scrim-background":{light:"#00000099",dark:"#00000099"},"scrim-background-strong":{light:"#000000CC",dark:"#000000CC"},"scrim-gradient":{light:"",dark:""},"scrim-strong":{light:"#000000cc",dark:"#000000cc"},secondary:{light:"#21272A",dark:"#DBE4E9"},"secondary-background":{light:"#E5EBEE",dark:"#2A3236"},"secondary-background-hover":{light:"#DBE4E9",dark:"#333D42"},"secondary-background-selected":{light:"#C9D7DE",dark:"#3D494E"},"secondary-hover":{light:"#000000",dark:"#ffffff"},"secondary-onBackground":{light:"#000000",dark:"#FFFFFF"},"secondary-plain":{light:"#181C1F",dark:"#DBE4E9"},"secondary-plain-hover":{light:"#000000",dark:"#FFFFFF"},"secondary-plain-weak":{light:"#5C6C74",dark:"#8BA2AD"},"secondary-weak":{light:"#576F76",dark:"#748791"},"success-background":{light:"#008A10",dark:"#016E0B"},"success-background-hover":{light:"#016E0B",dark:"#008A10"},"success-content":{light:"#016E0B",dark:"#01A816"},"success-hover":{light:"#005306",dark:"#00C61C"},"success-onBackground":{light:"#FFFFFF",dark:"#FFFFFF"},"success-plain":{light:"#016E0B",dark:"#00C61C"},"success-plain-hover":{light:"#005306",dark:"#58E15B"},"tone-1":{light:"#131313",dark:"#F2F2F2"},"tone-2":{light:"#434343",dark:"#ACACAC"},"tone-3":{light:"#ACACAC",dark:"#434343"},"tone-4":{light:"#E4E4E4",dark:"#303030"},"tone-5":{light:"#F2F2F2",dark:"#1E1E1E"},"tone-6":{light:"#F8F8F8",dark:"#131313"},"tone-7":{light:"#ffffff",dark:"#080808"},"transparent-background-hover":{light:"#74879119",dark:"#66778019"},"ui-canvas":{light:"#F2F2F2",dark:"#080808"},"ui-modalbackground":{light:"#FFFFFF",dark:"#181C1F"},"upvote-background":{light:"#D93900",dark:"#D93900"},"upvote-background-disabled":{light:"#d939004d",dark:"#d939004d"},"upvote-background-hover":{light:"#AE2C00",dark:"#AE2C00"},"upvote-content":{light:"#AE2C00",dark:"#FF4500"},"upvote-content-weak":{light:"#FF4500",dark:"#FF4500"},"upvote-disabled":{light:"#AE2C004c",dark:"#FF45004c"},"upvote-onBackground":{light:"#FFFFFF",dark:"#FFFFFF"},"upvote-onStrongScrim":{light:"#FF895D",dark:"#FF895D"},"upvote-onStrongScrim-disabled":{light:"#ff895d4d",dark:"#ff895d4d"},"upvote-onStrongScrim-weaker":{light:"#FF4500",dark:"#FF4500"},"upvote-plain":{light:"#AE2C00",dark:"#FF895D"},"upvote-plain-disabled":{light:"#ae2c004d",dark:"#ff895d4d"},"upvote-plain-weaker":{light:"#FF4500",dark:"#FF4500"},"warning-background":{light:"#B78800",dark:"#B78800"},"warning-background-hover":{light:"#977000",dark:"#D8A100"},"warning-content":{light:"#785800",dark:"#B78800"},"warning-content-hover":{light:"#5B4200",dark:"#D8A100"},"warning-onBackground":{light:"#000000",dark:"#000000"}};var Ua={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",transparent:"#FFFFFF00",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},La=t=>!!t.match(/^(#[0-9a-fA-F]{3,8}).*/),Wa=t=>t in Ws,Hs=t=>t in Ua,Ha=t=>!!t.match(/^rgba?\(.*/),ja=t=>!!t.match(/^hsla?\(.*/),Ga=(t,e="light")=>{if(Hs(t))return ei(t);let n=Ws[t];return typeof n=="string"?n:n[e]},ei=t=>Ua[t]??t,Va=t=>{let[e,r,n,i]=t.replace(/^rgba?\(|\s+|\)$/g,"").split(",");if(!e||!r||!n)return t;let o=[...[e,r,n].map(l=>parseFloat(l))];if(i){let l=parseFloat(i),u=Math.round(l*255);o.push(u)}return`#${o.map(l=>l.toString(16).padStart(2,"0")).join("")}`};import{BlockStackDirection as ti}from"@devvit/protos";var js={stackParentLayout:{hasHeight:!0,hasWidth:!0,direction:ti.UNRECOGNIZED,alignment:void 0}},_e;(function(t){t[t.NONE=0]="NONE",t[t.HORIZONTAL=1]="HORIZONTAL",t[t.VERTICAL=2]="VERTICAL"})(_e||(_e={}));function za(t,e,r){if(!e)return{hasHeight:!1,hasWidth:!1};let{growDirection:n,stretchDirection:i}=Cu(t?.grow,e.direction,e.alignment),s=r?.height?.value?.value||r?.height?.min?.value||$a(_e.VERTICAL,n,i,e.hasHeight),o=r?.width?.value?.value||r?.width?.min?.value||$a(_e.HORIZONTAL,n,i,e.hasWidth);return{hasHeight:!!s,hasWidth:!!o}}function $a(t,e,r,n){return e===t&&n||r===t&&n}function Cu(t,e,r){let n=e===ti.STACK_VERTICAL||e===ti.UNRECOGNIZED,i=e===ti.STACK_HORIZONTAL,s=_e.NONE;i&&t?s=_e.HORIZONTAL:n&&t&&(s=_e.VERTICAL);let o=r===void 0||r.horizontal===void 0,d=r===void 0||r.vertical===void 0,l=i?!!d:n?!!o:!1,u=_e.NONE;return i&&l?u=_e.VERTICAL:n&&l&&(u=_e.HORIZONTAL),{growDirection:s,stretchDirection:u}}import{BlockSizeUnit as ct,BlockStackDirection as ri}from"@devvit/protos";function nr(t){if(t==null)return;if(typeof t=="number")return{value:t,unit:ct.SIZE_UNIT_PERCENT};let e=t.match(/^(\d+(?:\.\d+)?)(px|%)?$/);if(e==null)return;let r=ct.SIZE_UNIT_PERCENT;return e.at(2)==="px"&&(r=ct.SIZE_UNIT_PIXELS),{value:Number.parseFloat(e[1]),unit:r}}function Fu(t,e){return(t.width?.value?.unit===ct.SIZE_UNIT_PERCENT||t.width?.min?.unit===ct.SIZE_UNIT_PERCENT)&&(e.direction===ri.STACK_HORIZONTAL||e.direction===ri.STACK_DEPTH)&&(e.hasWidth||(t.width=void 0)),(t.height?.value?.unit===ct.SIZE_UNIT_PERCENT||t.height?.min?.unit===ct.SIZE_UNIT_PERCENT)&&(e.direction===ri.STACK_VERTICAL||e.direction===ri.STACK_DEPTH)&&(e.hasHeight||(t.height=void 0)),t}function Gs(t,e){if(t){let r=t.width!=null||t.minWidth!=null||t.maxWidth!=null,n=t.height!=null||t.minHeight!=null||t.maxHeight!=null;if(r||n||t.grow!=null){let i={width:r?{value:nr(t.width),min:nr(t.minWidth),max:nr(t.maxWidth)}:void 0,height:n?{value:nr(t.height),min:nr(t.minHeight),max:nr(t.maxHeight)}:void 0,grow:t.grow};return e.stackParentLayout&&(i=Fu(i,e.stackParentLayout)),i}}}var Au=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Pu=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},ai,Za="data-",Iu=new Set(["onPress","onMessage"]),xu=new Map([["onPress",Xs.ACTION_CLICK],["onMessage",Xs.ACTION_WEBVIEW]]),sr=class{constructor(e=()=>{}){ai.set(this,void 0),Au(this,ai,e,"f")}createBlocksElementOrThrow({type:e,props:r,children:n}){let i=this.createBlocksElement({type:e,props:r,children:n},js);if(!i)throw new Error(`Could not create block of type ${e}`);return i}createBlocksElement({type:e,props:r,children:n},i){switch(e){case"blocks":return this.makeRoot(r,...n);case"hstack":return this.makeHStack(r,i,...n);case"vstack":return this.makeVStack(r,i,...n);case"zstack":return this.makeZStack(r,i,...n);case"text":return this.makeText(r,i,...n);case"button":return this.makeButton(r,i,...n);case"image":return this.makeImage(r,i);case"spacer":return this.makeSpacer(r,i);case"icon":return this.makeIcon(r,i);case"avatar":return this.makeAvatar(r,i);case"webview":return this.makeWebView(r,i);case"__fragment":throw new Error("root fragment is not supported - use 'blocks' instead")}}makeRootHeight(e){switch(e){case"regular":return 320;case"tall":return 512}}makeBlockPadding(e){switch(e){case"none":return Nr.PADDING_NONE;case"xsmall":return Nr.PADDING_XSMALL;case"small":return Nr.PADDING_SMALL;case"medium":return Nr.PADDING_MEDIUM;case"large":return Nr.PADDING_LARGE}}makeBlockRadius(e){switch(e){case"none":return Br.RADIUS_NONE;case"small":return Br.RADIUS_SMALL;case"medium":return Br.RADIUS_MEDIUM;case"large":return Br.RADIUS_LARGE;case"full":return Br.RADIUS_FULL}}makeBlockGap(e){switch(e){case"none":return ii.GAP_NONE;case"small":return ii.GAP_SMALL;case"medium":return ii.GAP_MEDIUM;case"large":return ii.GAP_LARGE}}makeBlockAlignment(e){if(e===void 0)return;let r,n;if(e.includes("top")?r=Qs.ALIGN_TOP:e.includes("middle")?r=Qs.ALIGN_MIDDLE:e.includes("bottom")&&(r=Qs.ALIGN_BOTTOM),e.includes("start")?n=$s.ALIGN_START:e.includes("center")?n=$s.ALIGN_CENTER:e.includes("end")&&(n=$s.ALIGN_END),r!==void 0||n!==void 0)return{vertical:r,horizontal:n}}makeBlockBorder(e,r,n,i){if(!e&&!r)return;let s;switch(e){case"none":s=ni.BORDER_WIDTH_NONE;break;case"thin":s=ni.BORDER_WIDTH_THIN;break;case"thick":s=ni.BORDER_WIDTH_THICK;break;default:s=ni.BORDER_WIDTH_THIN;break}let o=r??"neutral-border-weak",d=this.getThemedColors(o,n,i);return{width:s,color:d?.light,colors:d}}makeBlockTextSize(e){switch(e){case"xsmall":return ir.TEXT_SIZE_XSMALL;case"small":return ir.TEXT_SIZE_SMALL;case"medium":return ir.TEXT_SIZE_MEDIUM;case"large":return ir.TEXT_SIZE_LARGE;case"xlarge":return ir.TEXT_SIZE_XLARGE;case"xxlarge":return ir.TEXT_SIZE_XXLARGE}}makeBlockTextStyle(e){switch(e){case"body":return Zs.TEXT_STYLE_BODY;case"metadata":return Zs.TEXT_STYLE_METADATA;case"heading":return Zs.TEXT_STYLE_HEADING}}makeBlockTextOutline(e){switch(e){case"none":return qs.TEXT_OUTLINE_NONE;case"thin":return qs.TEXT_OUTLINE_THIN;case"thick":return qs.TEXT_OUTLINE_THICK}}makeBlockTextWeight(e){switch(e){case"regular":return Ja.TEXT_WEIGHT_REGULAR;case"bold":return Ja.TEXT_WEIGHT_BOLD}}makeBlockTextOverflow(e){switch(e){case"clip":return Js.TEXT_OVERFLOW_CLIP;case"ellipsis":return Js.TEXT_OVERFLOW_ELLIPSE}return Js.TEXT_OVERFLOW_ELLIPSE}makeBlockButtonAppearance(e){switch(e){case"secondary":return je.BUTTON_APPEARANCE_SECONDARY;case"primary":return je.BUTTON_APPEARANCE_PRIMARY;case"plain":return je.BUTTON_APPEARANCE_PLAIN;case"bordered":return je.BUTTON_APPEARANCE_BORDERED;case"media":return je.BUTTON_APPEARANCE_MEDIA;case"destructive":return je.BUTTON_APPEARANCE_DESTRUCTIVE;case"caution":return je.BUTTON_APPEARANCE_CAUTION;case"success":return je.BUTTON_APPEARANCE_SUCCESS}}makeBlockButtonSize(e){switch(e){case"small":return Vs.BUTTON_SIZE_SMALL;case"medium":return Vs.BUTTON_SIZE_MEDIUM;case"large":return Vs.BUTTON_SIZE_LARGE}}makeBlockImageResizeMode(e){switch(e){case"none":return Mr.IMAGE_RESIZE_NONE;case"fit":return Mr.IMAGE_RESIZE_FIT;case"fill":return Mr.IMAGE_RESIZE_FILL;case"cover":return Mr.IMAGE_RESIZE_COVER;case"scale-down":return Mr.IMAGE_RESIZE_SCALE_DOWN}}makeBlockSpacerSize(e){switch(e){case"xsmall":return oi.SPACER_XSMALL;case"small":return oi.SPACER_SMALL;case"medium":return oi.SPACER_MEDIUM;case"large":return oi.SPACER_LARGE}}makeBlockSpacerShape(e){switch(e){case"invisible":return zs.SPACER_INVISIBLE;case"thin":return zs.SPACER_THIN;case"square":return zs.SPACER_SQUARE}}makeBlockIconSize(e){switch(e){case"xsmall":return si.ICON_SIZE_XSMALL;case"small":return si.ICON_SIZE_SMALL;case"medium":return si.ICON_SIZE_MEDIUM;case"large":return si.ICON_SIZE_LARGE}}makeBlockAvatarSize(e){switch(e){case"xxsmall":return He.AVATAR_SIZE_XXSMALL;case"xsmall":return He.AVATAR_SIZE_XSMALL;case"small":return He.AVATAR_SIZE_SMALL;case"medium":return He.AVATAR_SIZE_MEDIUM;case"large":return He.AVATAR_SIZE_LARGE;case"xlarge":return He.AVATAR_SIZE_XXLARGE;case"xxlarge":return He.AVATAR_SIZE_XXLARGE;case"xxxlarge":return He.AVATAR_SIZE_XXXLARGE}}makeBlockAvatarFacing(e){switch(e){case"left":return qa.AVATAR_FACING_LEFT;case"right":return qa.AVATAR_FACING_RIGHT}}makeBlockAvatarBackground(e){switch(e){case"dark":return Ka.AVATAR_BG_DARK;case"light":return Ka.AVATAR_BG_LIGHT}}getDataSet(e){return Object.keys(e).filter(r=>r.startsWith(Za)).reduce((r,n)=>(r[n.substring(Za.length)]=e[n],r),{})}makeActions(e,r){let n=[],i=this.getDataSet(r);return Iu.forEach(s=>{if(s in r){let o=r[s];n.push({type:xu.get(s)??Xs.UNRECOGNIZED,id:o.toString(),data:i})}}),n}blockColorToHex(e,r="light"){if(e)return e=e.toLowerCase(),La(e)?e:Wa(e)?Ga(e,r):Hs(e)?ei(e):Ha(e)?Va(e):ja(e)?e:(console.warn(`Could not parse color: ${e}.`),ei("red"))}childrenToBlocks(e,r){return e.flatMap(n=>(typeof n!="string"?this.createBlocksElement(n,r):void 0)??[])}getThemedColors(e,r,n){let i=this.blockColorToHex(r,"light"),s=this.blockColorToHex(n,"dark"),o=[];if(e&&(!i||!s)){let d=Array.from(e?.matchAll(/[\w#-]+(?:\([\w\t ,.#-]+\))?/g)??[]);o.push(...d.map(l=>l[0]))}return i||(i=this.blockColorToHex(o?.at(0),"light")),s||(s=this.blockColorToHex(o?.at(1)??o?.at(0),"dark")),i||s?{light:i,dark:s}:void 0}parsePixels(e){return typeof e=="string"?Number(e.slice(0,-2)):e}resolveAssetUrl(e,r){return Pu(this,ai,"f").call(this)?.getURL(e,r)??e}childrenToString(e){return e.map(r=>r.toString()).join("")}makeRoot(e,...r){return this.wrapRoot(e,this.childrenToBlocks(r,js))}wrapRoot(e,r){return this.makeBlock(Ee.BLOCK_ROOT,{},{},{rootConfig:{children:r,height:this.makeRootHeight(a.customPostType?.height??e?.height??"regular")}})}makeStackBlock(e,r,n,i){let s=this.getThemedColors(r?.backgroundColor,r?.lightBackgroundColor,r?.darkBackgroundColor),o=this.makeBlockAlignment(r?.alignment),d=Gs(r,n),l=za(r,n.stackParentLayout,d);return this.makeBlock(Ee.BLOCK_STACK,r,n,{stackConfig:{alignment:o,backgroundColor:s?.light,backgroundColors:s,border:this.makeBlockBorder(r?.border,r?.borderColor,r?.lightBorderColor,r?.darkBorderColor),children:this.childrenToBlocks(i,{stackParentLayout:{...l,direction:e,alignment:o}}),cornerRadius:this.makeBlockRadius(r?.cornerRadius),direction:e,gap:this.makeBlockGap(r?.gap),padding:this.makeBlockPadding(r?.padding),reverse:r?.reverse}})}makeHStack(e,r,...n){return this.makeStackBlock(Ks.STACK_HORIZONTAL,e,r,n)}makeVStack(e,r,...n){return this.makeStackBlock(Ks.STACK_VERTICAL,e,r,n)}makeZStack(e,r,...n){return this.makeStackBlock(Ks.STACK_DEPTH,e,r,n)}makeText(e,r,...n){let i=this.getThemedColors(e?.color,e?.lightColor,e?.darkColor);return this.makeBlock(Ee.BLOCK_TEXT,e,r,{textConfig:{alignment:this.makeBlockAlignment(e?.alignment),color:i?.light,colors:i,outline:this.makeBlockTextOutline(e?.outline),size:this.makeBlockTextSize(e?.size),style:this.makeBlockTextStyle(e?.style),text:this.childrenToString(n),weight:this.makeBlockTextWeight(e?.weight),selectable:e?.selectable,wrap:e?.wrap,overflow:this.makeBlockTextOverflow(e?.overflow)}})}makeButton(e,r,...n){let i=this.getThemedColors(e?.textColor,e?.lightTextColor,e?.darkTextColor);return this.makeBlock(Ee.BLOCK_BUTTON,e,r,{buttonConfig:{buttonAppearance:this.makeBlockButtonAppearance(e?.appearance),icon:e?.icon,buttonSize:this.makeBlockButtonSize(e?.size),text:this.childrenToString(n),textColor:i?.light,textColors:i,disabled:e?.disabled}})}makeImage(e,r){return e&&this.makeBlock(Ee.BLOCK_IMAGE,e,r,{imageConfig:{description:e?.description,resizeMode:this.makeBlockImageResizeMode(e.resizeMode),url:this.resolveAssetUrl(e.url),width:this.parsePixels(e.imageWidth),height:this.parsePixels(e.imageHeight)}})}makeSpacer(e,r){return this.makeBlock(Ee.BLOCK_SPACER,e,r,{spacerConfig:{size:this.makeBlockSpacerSize(e?.size),shape:this.makeBlockSpacerShape(e?.shape)}})}makeIcon(e,r){let n=this.getThemedColors(e?.color,e?.lightColor,e?.darkColor);return e&&this.makeBlock(Ee.BLOCK_ICON,e,r,{iconConfig:{icon:e.name,color:n?.light,colors:n,size:this.makeBlockIconSize(e.size)}})}makeAvatar(e,r){return e&&this.makeBlock(Ee.BLOCK_AVATAR,e,r,{avatarConfig:{thingId:e.thingId,size:this.makeBlockAvatarSize(e.size),facing:this.makeBlockAvatarFacing(e.facing),background:this.makeBlockAvatarBackground(e.background)}})}makeWebView(e,r){return e&&this.makeBlock(Ee.BLOCK_WEBVIEW,e,r,{webviewConfig:{url:this.resolveAssetUrl(e.url,{webView:!0})}})}makeBlock(e,r,n,i){return{type:e,sizes:Gs(r,n),config:i,actions:(r&&this.makeActions(e,r))??[],id:r?.id,key:r?.key}}ensureRootBlock(e){let r;if(e.type===Ee.BLOCK_ROOT?(e.config?.rootConfig&&a.customPostType?.height&&(e.config.rootConfig.height=this.makeRootHeight(a.customPostType?.height)),r=e):r=this.wrapRoot(void 0,[e]),!r)throw new Error("Could not create root block");return r}};ai=new WeakMap;var dt=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Su=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Ge,Ya,ci,ec,di;function Xa(t){if(typeof t=="string")throw new Error("Root element cannot be a string")}var tc=t=>{let e="",r=t.props?Object.keys(t.props).map(n=>n==="onPress"?"":`${n}="${t.props[n]}"`).join(" "):"";e+=`<${t.type}${r?" "+r:""}>`;for(let n of t.children)typeof n=="string"?e+=n:e+=tc(n);return e+=`</${t.type}>`,e};function Tu(t){return" ".repeat(t)}function Ru(t){let e="",r=0,n=t.split(/>\s*</);for(let i=0;i<n.length;i++){let s=n[i];i===0&&(s=s.trim()),i===n.length-1&&(s=s.trim());let o=s.charAt(0)==="/";o&&r--,e+=Tu(r),i!==0&&(e+="<"),e+=s,i!==n.length-1&&(e+=`>
|
|
2
|
+
`),!o&&s.indexOf("</")===-1&&s.charAt(s.length-1)!=="/"&&r++}return e}var Se=class{emitEffect(e,r){this.effects.push(r)}constructor(e,r,n,i,s){Ge.add(this),this.renderState={},this.currentComponentKey=[],this.currentHookIndex=0,this.actions=new Map,this.forms=new Map,this.realtimeChannels=[],this.realtimeUpdated=!1,this.pendingHooks=[],this.isRendering=!1,this.transformer=new sr(()=>this.assets),this.effects=[],di.set(this,!1),this.component=e,this.event=r,this.state={__renderState:{},...n},this.metadata=i,this.state.__realtimeChannels&&(this.realtimeChannels=this.state.__realtimeChannels);let o=Z({reconciler:this,hooks:!0,ui:!0,metadata:i});this.cache=o.cache,this.modLog=o.modLog,this.kvStore=o.kvStore,this.redis=o.redis,this.settings=o.settings,this.scheduler=o.scheduler,this.media=o.media,this.assets=o.assets,this.realtime=o.realtime,this.dimensions=s,this.ui=o.ui,this.hooks={useState:o.useState,useInterval:o.useInterval,useForm:o.useForm,useChannel:o.useChannel}}async render(){await this.reconcile(),this.isRendering=!0;let e=await this.buildBlocksUI();return this.isRendering=!1,e}makeUniqueActionID(e){let r=e,n=1;for(;this.actions.has(r);)r=`${e}.${n++}`;return r}async reconcile(){let e=dt(this,Ge,"m",ci).call(this),r={type:this.component,props:e,children:[]},n=await this.processBlock(r);if(Xa(n),this.transformer.createBlocksElementOrThrow(n),this.isUserActionRender&&this.blockRenderEventId){let i=this.actions.get(this.blockRenderEventId);i&&await i(this.event.data)}for(let i of this.pendingHooks)await i();this.buildNextState(),dt(this,Ge,"m",Ya).call(this)}async buildBlocksUI(){let e=dt(this,Ge,"m",ci).call(this),r={type:this.component,props:e,children:[]},n=await this.renderElement(e,r);return this.transformer.ensureRootBlock(n)}async renderElement(e,r){let n=await this.processBlock(r);return Xa(n),(a.debug.emitSnapshots||e.debug.emitSnapshots)&&console.debug(Ru(tc(n))),(a.debug.emitState||e.debug.emitState)&&console.debug(JSON.stringify(this.state,void 0,2)),this.transformer.createBlocksElementOrThrow(n)}async processProps(e){let r=e.props??{},n=["onPress","onMessage"];for(let i of n)if(i in r){let s=r[i],o=s?.name,d=this.makeUniqueActionID(`${e.type}.${o??i}`);this.actions.set(d,s),r[i]=d}}async processBlock(e,r=Oa(),n=[]){if(typeof e=="string")return e;if(typeof e=="number")return`${e}`;let i=e;if(typeof i.type=="string"){let d=[];for(let g=0;g<i.children.length;g++){let p=i.children[g];p!=null&&d.push(await this.processBlock(p,r,[...n,`${i.type}.${g}`]))}let l=d.flat(),u=dt(this,Ge,"m",ec).call(this,l);return await this.processProps(i),{type:i.type,props:i.props,children:u}}if(typeof i.type=="function"){let d=r(`${n.length?n.join("."):"root"}.${i.type.name.length?i.type.name:"anonymous"}`);this.currentComponentKey.push(d),this.renderState[d]||(this.renderState[d]={});let l=i.children.flatMap(_=>_),u=dt(this,Ge,"m",ci).call(this),g={...u,...i.props,children:l},p;for(;p===void 0;)try{p=await i.type(g,u)}catch(_){if(_ instanceof Promise)p=await _;else throw _}if(!this.isInitialRender){let _=this.getPreviousComponentState();if(Object.keys(_).length!==this.currentHookIndex)throw new Error("Invalid hook call. Hooks can only be called at the top-level of a function component. Make sure that you are not calling hooks inside loops, conditions, or nested functions.")}if(this.currentComponentKey.pop(),this.currentHookIndex=0,typeof p=="object")return this.processBlock(p,r,[...n,i.type.name])}let s=[],o="";return Array.isArray(i)?s=i:typeof i.type>"u"&&i.children&&(s=i.children,o="fragmentChild."),{type:"__fragment",props:void 0,children:await Promise.all(s.flatMap(async(d,l)=>await this.processBlock(d,r,[...n,`${o}${l}`])))}}getCurrentComponentKey(){if(!this.currentComponentKey.at(-1))throw new Error("Current component key is missing");return this.currentComponentKey}getCurrentComponentState(){let e=this.currentComponentKey.at(-1);if(!e)throw new Error("Current component key is missing");return this.renderState[e]}getPreviousComponentState(){let e=this.currentComponentKey.at(-1);if(!e)throw new Error("Current component key is missing");return this.state.__renderState[e]||(this.state.__renderState[e]={}),this.state.__renderState[e]}get isInitialRender(){return this.event?this.event.type===Ys.RENDER_INITIAL:!1}get isUserActionRender(){return this.event?this.event.type===Ys.RENDER_USER_ACTION:!1}get isEffectRender(){return this.event?this.event.type===Ys.RENDER_EFFECT_EVENT:!1}get formSubmittedEvent(){return this.event?this.event.formSubmitted:!1}get blockRenderEventId(){return this.event?this.event.id:!1}get realtimeEvent(){if(!this.event)return!1;let e=this.event.realtimeEvent;return e?.event?.channel?e:!1}runHook(e){this.pendingHooks.push(e)}rerenderIn(e){dt(this,di,"f")||(Su(this,di,!0,"f"),this.effects.push({type:Qa.EFFECT_RERENDER_UI,rerenderUi:{delaySeconds:e/1e3}}))}addRealtimeChannel(e){this.realtimeChannels.push(e),this.realtimeUpdated=!0}removeRealtimeChannel(e){this.realtimeChannels=this.realtimeChannels.filter(r=>r!==e),this.realtimeUpdated=!0}get realtimeEffect(){return this.realtimeUpdated&&this.realtimeChannels.length>0?[{type:Qa.EFFECT_REALTIME_SUB,realtimeSubscriptions:{subscriptionIds:this.realtimeChannels}}]:[]}getEffects(){return[...rr(this.ui),...this.effects,...this.realtimeEffect]}buildNextState(){for(let e of Object.keys(this.renderState))this.renderState[e]=Object.values(this.renderState[e]);this.state={__postData:this.state.__postData,__renderState:this.renderState,__cache:this.state.__cache,...this.realtimeChannels.length>0?{__realtimeChannels:this.realtimeChannels}:{}}}};di=new WeakMap,Ge=new WeakSet,Ya=function(){this.actions.clear(),this.currentComponentKey=[],this.currentHookIndex=0,this.pendingHooks=[],this.realtimeChannels=[],this.realtimeUpdated=!1},ci=function(){let e={...z(this.metadata,this.state.__postData?.thingId),modLog:this.modLog,cache:this.cache,kvStore:this.kvStore,redis:this.redis,settings:this.settings,scheduler:this.scheduler,media:this.media,assets:this.assets,realtime:this.realtime,ui:this.ui,dimensions:this.dimensions,uiEnvironment:{timezone:this.metadata[C.Timezone]?.values[0],locale:this.metadata[C.Language]?.values[0],dimensions:this.dimensions},...this.hooks};return e.debug.effects=this,e},ec=function t(e){let r=[];for(let n of e)typeof n=="string"?r.push(n):n.type==="__fragment"?r.push(...dt(this,Ge,"m",t).call(this,n.children)):r.push(n);return r};async function Bu(t,e){let r=a.customPostType;if(!r)throw new Error("Custom post type not registered");let n=new Se((s,o)=>r.render(o),t.blocks,t.state,e,t.dimensions),i=await n.render();return Nu.fromJSON({state:n.state,blocks:{ui:i},effects:n.getEffects()})}function rc(t){t.provides(Mu),x("RenderPost",Bu)}import{GetFieldsResponse as Du,InstallationSettingsDefinition as Ou}from"@devvit/protos";async function Uu(){if(!a.installationSettings)throw new Error("Installation settings were not defined.");return Du.fromJSON({fields:{fields:Ie(a.installationSettings)}})}async function Lu(t,e){return Yn(t,a.installationSettings,e)}function nc(t){t.provides(Ou),x("GetSettingsFields",Uu),x("ValidateForm",Lu)}import{ContextActionDefinition as Wu,ContextActionList as Hu,ContextActionResponse as ju}from"@devvit/protos";function eo(t){let e=t.metadata[C.User].values[0];if(!e)throw new Error("User missing from context");return e}function to(t){let e=t.metadata[C.Subreddit].values[0];if(!e)throw new Error("Subreddit missing from context");return e}async function ic(t,e){let r=eo(t),n=to(t);if(!r||!n)throw new Error("User or subreddit missing from context");let i=e.comment?.id&&`t1_${e.comment.id}`,s=e.post?.id&&`t3_${e.post.id}`,o=e.subreddit?.id&&`t5_${e.subreddit.id}`,d=i||s||o;if(!d)throw new Error("targetId is missing from ContextActionRequest");if(i){let p=await dc(i);if(!p)throw new Error(`Comment ${i} not found`);if(p.subredditId!==n)throw new Error("Comment does not belong to the subreddit")}if(s){let p=await cc(s);if(!p)throw new Error(`Post ${s} not found`);if(p.subredditId!==n)throw new Error("Post does not belong to the subreddit")}if(o&&o!==n)throw new Error(`Subreddit ${o} ${n} not found`);let l=Dr(e.actionId);if(!l)throw new Error("Action not found");let u=!!l.forUserType?.includes("moderator");if(u&&!sc(t))throw new Error("User is not a moderator");let g={needsModCheck:u};await t.redis.set(`${r}${n}${d}${e.actionId}`,JSON.stringify(g)),await t.redis.expire(`${r}${n}${d}${e.actionId}`,600)}async function sc(t){let e=eo(t),r=to(t),n=await ac(r);return!!(await lc({subredditName:n.name}).all()).find(s=>s.id===e)}async function oc(t,e){let r=eo(t),n=to(t),{actionId:i,thingId:s}=e.state?.__contextAction??{},o=await t.redis.get(`${r}${n}${s}${i}`);if(!o)throw new Error("CSRF token not found");if(JSON.parse(o).needsModCheck&&!await sc(t))throw new Error("User is not a moderator: "+r+"; "+n)}var uc=t=>`menuItem.${t}`;function Dr(t){return a.menuItems.find((e,r)=>uc(r)===t)}async function Gu(t,e){let r=a.menuItems;if(!r.length)throw new Error("No menu items registered.");let n=r.map((i,s)=>({actionId:uc(s),name:i.label,description:i.description,contexts:{subreddit:i.location.includes("subreddit"),post:i.location.includes("post"),comment:i.location.includes("comment")},users:{loggedOut:i.forUserType?.includes("loggedOut"),moderator:i.forUserType?.includes("moderator")},postFilters:i.postFilter==="currentApp"?{currentApp:!0}:void 0}));return Hu.fromJSON({actions:n})}async function Vu(t,e){let r=Dr(t.actionId);if(!r)throw new Error(`MenuItem ${t.actionId} not found`);let n=t.comment?.id&&`t1_${t.comment.id}`,i=t.post?.id&&`t3_${t.post.id}`,s=t.subreddit?.id&&`t5_${t.subreddit.id}`,o=n||i||s;m(o,"targetId is missing from ContextActionRequest");let d={targetId:o,location:t.comment?"comment":t.post?"post":"subreddit"},l=Object.assign(Z({ui:!0,metadata:e}),z(e,i,n),{uiEnvironment:{timezone:e[C.Timezone]?.values[0],locale:e[C.Language]?.values[0]}});return await ic(l,t),await r.onPress(d,l),ju.fromJSON({effects:rr(l.ui)})}function hc(t){t.provides(Wu),x("GetActions",Gu),x("OnAction",Vu)}function ue(t){return t?t===!0?!0:t.enabled:!1}import{SchedulerHandlerDefinition as $u}from"@devvit/protos";async function zu(t,e){let r=t.type,n=a.scheduledJobHandlers.get(r);if(!n)throw new Error(`Job ${r} not found`);let i={name:r,data:t.data},s=Object.assign(Z({metadata:e}),z(e));await n(i,s)}function fc(t){t.provides($u),x("HandleScheduledAction",zu)}import{OnAppInstallDefinition as Ku,OnAppUpgradeDefinition as qu,OnAutomoderatorFilterCommentDefinition as Ju,OnAutomoderatorFilterPostDefinition as Zu,OnCommentCreateDefinition as Qu,OnCommentDeleteDefinition as Xu,OnCommentReportDefinition as Yu,OnCommentSubmitDefinition as eh,OnCommentUpdateDefinition as th,OnModActionDefinition as rh,OnModMailDefinition as nh,OnPostCreateDefinition as ih,OnPostDeleteDefinition as sh,OnPostFlairUpdateDefinition as oh,OnPostNsfwUpdateDefinition as ah,OnPostReportDefinition as ch,OnPostSpoilerUpdateDefinition as dh,OnPostSubmitDefinition as lh,OnPostUpdateDefinition as uh}from"@devvit/protos";var lt;(function(t){function e(o,d){return o.length<=d?o:`${o.slice(0,d-1)}\u2026`}t.ellipsize=e;function r(o){return o[0]==null?o:`${o[0].toLocaleUpperCase()}${o.slice(1)}`}t.capitalize=r;function n(o){return o==null||/^\s*$/.test(o)}t.isBlank=n;function i(o,d="stack"){return o instanceof Error?`${o[d]||o.stack||o.message||o.name}`:String(o)}t.caughtToString=i;function s(o,d="stack"){return o instanceof Error?`${o[d]||o.stack||o.message||o.name}`:String(o)}t.caughtToStringUntyped=s})(lt||(lt={}));function G(t,e){return m(e),async(r,n)=>{let i={...r,type:t},s=Object.assign(Z({metadata:n}),z(n)),o=await Promise.allSettled(e.map(l=>l(i,s))),d=hh(o);if(d)throw d.err;return{}}}function mc(t){for(let e of a.triggerOnEventHandlers.keys())switch(e){case"PostSubmit":t.provides(lh),x("OnPostSubmit",G("PostSubmit",a.triggerOnEventHandlers.get(e)));break;case"PostCreate":t.provides(ih),x("OnPostCreate",G("PostCreate",a.triggerOnEventHandlers.get(e)));break;case"PostUpdate":t.provides(uh),x("OnPostUpdate",G("PostUpdate",a.triggerOnEventHandlers.get(e)));break;case"PostReport":t.provides(ch),x("OnPostReport",G("PostReport",a.triggerOnEventHandlers.get(e)));break;case"PostDelete":t.provides(sh),x("OnPostDelete",G("PostDelete",a.triggerOnEventHandlers.get(e)));break;case"PostFlairUpdate":t.provides(oh),x("OnPostFlairUpdate",G("PostFlairUpdate",a.triggerOnEventHandlers.get(e)));break;case"CommentSubmit":t.provides(eh),x("OnCommentSubmit",G("CommentSubmit",a.triggerOnEventHandlers.get(e)));break;case"CommentCreate":t.provides(Qu),x("OnCommentCreate",G("CommentCreate",a.triggerOnEventHandlers.get(e)));break;case"CommentUpdate":t.provides(th),x("OnCommentUpdate",G("CommentUpdate",a.triggerOnEventHandlers.get(e)));break;case"CommentReport":t.provides(Yu),x("OnCommentReport",G("CommentReport",a.triggerOnEventHandlers.get(e)));break;case"CommentDelete":t.provides(Xu),x("OnCommentDelete",G("CommentDelete",a.triggerOnEventHandlers.get(e)));break;case"AppInstall":t.provides(Ku),x("OnAppInstall",G("AppInstall",a.triggerOnEventHandlers.get(e)));break;case"AppUpgrade":t.provides(qu),x("OnAppUpgrade",G("AppUpgrade",a.triggerOnEventHandlers.get(e)));break;case"ModAction":t.provides(rh),x("OnModAction",G("ModAction",a.triggerOnEventHandlers.get(e)));break;case"ModMail":t.provides(nh),x("OnModMail",G("ModMail",a.triggerOnEventHandlers.get(e)));break;case"PostNsfwUpdate":t.provides(ah),x("OnPostNsfwUpdate",G("PostNsfwUpdate",a.triggerOnEventHandlers.get(e)));break;case"PostSpoilerUpdate":t.provides(dh),x("OnPostSpoilerUpdate",G("PostSpoilerUpdate",a.triggerOnEventHandlers.get(e)));break;case"AutomoderatorFilterPost":t.provides(Zu),x("OnAutomoderatorFilterPost",G("AutomoderatorFilterPost",a.triggerOnEventHandlers.get(e)));break;case"AutomoderatorFilterComment":t.provides(Ju),x("OnAutomoderatorFilterComment",G("AutomoderatorFilterComment",a.triggerOnEventHandlers.get(e)));break;default:throw new Error(`Unknown trigger event: ${e}`)}}function hh(t){let e=t.reduce((r,n)=>n.status==="rejected"?[...r,n.reason]:r,[]);if(e.length!==0)return e.length===1?{err:e[0]}:{err:new Error(e.map(r=>lt.caughtToString(r)).join(`
|
|
3
|
+
`))}}import{EffectType as Dh,HandleUIEventResponse as io,UIEventHandlerDefinition as Oh}from"@devvit/protos";var Tc=Xo(Ac(),1);function Pc(t){return t?.constructor===Object}function ut(t,e){return Object.is(t,e)?!0:typeof t!=typeof e?!1:Array.isArray(t)&&Array.isArray(e)?Ic(t,e):t instanceof Date&&e instanceof Date?t.getTime()===e.getTime():t instanceof RegExp&&e instanceof RegExp?t.toString()===e.toString():Pc(t)&&Pc(e)?Bh(t,e):t instanceof ArrayBuffer&&e instanceof ArrayBuffer?xc(new DataView(t),new DataView(e)):t instanceof DataView&&e instanceof DataView?xc(t,e):Sc(t)&&Sc(e)?t.byteLength!==e.byteLength?!1:Ic(t,e):!1}function Bh(t,e){let r=Object.keys(t),n=Object.keys(e);if(!ut(r,n))return!1;for(let i of r)if(!ut(t[i],e[i]))return!1;return!0}function Ic(t,e){return t.length!==e.length?!1:t.every((r,n)=>ut(r,e[n]))}function xc(t,e){if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t.getUint8(r)!==e.getUint8(r))return!1;return!0}function Sc(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}async function Uh(t,e){let r=t.state??{},n=(0,Tc.default)(r),i=Z({ui:!0,metadata:e});if(t.event?.formSubmitted&&t.event.formSubmitted.formId){let l=t.event.formSubmitted.formId;if(l.includes("form.hook.")&&a.customPostType){let I=new Se((T,L)=>a.customPostType?.render(L)??null,t.event,t.state,e,void 0);return await I.reconcile(),io.fromJSON({state:I.state,effects:I.getEffects()})}let u=a.formDefinitions.get(l);if(!u)throw new Error(`Form with key ${l} not found`);let g,p;if(n.__contextAction){let{actionId:I,thingId:T}=n.__contextAction,L=Dr(I);L?.location==="post"?g=T:L?.location==="comment"&&(p=T)}let _=Object.assign(i,z(e,g,p),{uiEnvironment:{timezone:e[C.Timezone]?.values[0],locale:e[C.Language]?.values[0]}});await oc(_,t),await u.onSubmit({values:We(t.event.formSubmitted.results)},_)}else if(t.event?.realtimeEvent){if(a.customPostType){let l=new Se((u,g)=>a.customPostType?.render(g)??null,t.event,t.state,e,void 0);return await l.reconcile(),io.fromJSON({state:l.state,effects:l.getEffects()})}}else if(t.event?.toastAction)throw new Error("Toast actions not yet implemented");let s=!ut(r,n),o=rr(i.ui),d=s?[...o,{type:Dh.EFFECT_RERENDER_UI,rerenderUi:{delaySeconds:0}}]:o;return io.fromJSON({state:n,effects:d})}function Rc(t){t.provides(Oh),x("HandleUIEvent",Uh)}import{CustomPostDefinition as Si,UIResponse as od}from"@devvit/protos";import{UIEventScope as zh}from"@devvit/protos";var so="ServerCallRequired";function li(t){return t?.message===so}var ui=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},U=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},he,ht,ft,ye,Or,Hc,jc,Mc,Nc,Bc,Dc,ao,Gc,co={now(){return new Date}};function Oc(t){return`__autocache__${t}`}function Uc(t){return`__lock__${t}`}var Lh=300,Wh=1e3,hi=5e3,oo=3,Lc=.1,Wc=1e3,Hh=3e4;function Vc(t){if(t.error)throw new Error(t.error);return t.value}var fi=class{constructor(e,r,n=co){he.add(this),ht.set(this,void 0),ft.set(this,{}),ye.set(this,void 0),Or.set(this,void 0),ui(this,ht,e,"f"),ui(this,Or,r,"f"),ui(this,ye,n,"f")}async cache(e,r){var n;(n=U(this,Or,"f")).__cache??(n.__cache={}),ui(this,ft,U(this,Or,"f").__cache,"f"),U(this,he,"m",Gc).call(this,r);let i=U(this,he,"m",Hc).call(this,r.key);if(i!==void 0)return i;let s=await U(this,he,"m",ao).call(this,r.key),o=await U(this,he,"m",jc).call(this,r,s,e);return Vc(o)}};ht=new WeakMap,ft=new WeakMap,ye=new WeakMap,Or=new WeakMap,he=new WeakSet,Hc=function(e){let r=U(this,ft,"f")[e];if(r){let n=U(this,ye,"f").now().getTime(),i=r?.error&&r?.errorTime&&r.errorCount<oo&&Math.random()<Lc&&r.errorTime+Wc<n;if(r?.expires&&r.expires<n&&r.checkedAt+Wc<n||i){delete U(this,ft,"f")[e];return}else return Vc(r)}},jc=async function(e,r,n){let i=r?.expires,s=i?U(this,he,"m",Dc).call(this,i):1;return!r||r?.error&&r.errorCount<oo&&Lc>Math.random()||s>Math.random()?U(this,he,"m",Mc).call(this,e,r,n):r},Mc=async function(e,r,n){let i=Uc(e.key),s=U(this,ye,"f").now().getTime(),o=new Date(s+e.ttl/2);if(await U(this,ht,"f").set(i,"1",{expiration:o,nx:!0}))return U(this,he,"m",Bc).call(this,e.key,r,n,e.ttl);if(r)return r;{let l=U(this,ye,"f").now();return U(this,he,"m",Nc).call(this,l,e.key,e.ttl)}},Nc=async function t(e,r,n){let i=Math.min(n,Wh),s=await U(this,he,"m",ao).call(this,r);if(s)return s;if(U(this,ye,"f").now().getTime()-e.getTime()>=i)throw new Error(`Cache request timed out trying to get data at key: ${r}`);return await new Promise(o=>setTimeout(o,Lh)),U(this,he,"m",t).call(this,e,r,n)},Bc=async function(e,r,n,i){let s=U(this,ye,"f").now().getTime()+i;r=r??{value:null,expires:s,errorCount:0,error:null,errorTime:null,checkedAt:0};try{r.value=await n(),r.error=null,r.errorCount=0,r.errorTime=null}catch(o){r.value=null,r.error=o.message??"Unknown error",r.errorTime=U(this,ye,"f").now().getTime(),r.errorCount++}return U(this,ft,"f")[e]=r,await U(this,ht,"f").set(Oc(e),JSON.stringify(r),{expiration:new Date(s+Hh)}),r.error&&r.errorCount<oo&&await U(this,ht,"f").del(Uc(e)),r},Dc=function(e){let r=U(this,ye,"f").now().getTime(),n=e-r;return n<0?1:n<1e3?.1:n<2e3?.01:n<3e3?.001:0},ao=async function(e){let r=await U(this,ht,"f").get(Oc(e));if(r){let n=JSON.parse(r);return n.checkedAt=U(this,ye,"f").now().getTime(),U(this,ft,"f")[e]=n,n}},Gc=function(e){e.ttl<hi&&(console.warn(`Cache TTL cannot be less than ${hi} milliseconds! Updating ttl value of ${e.ttl} to ${hi}.`),e.ttl=hi)};function $c(t,e,r=co){let n=new fi(t,e,r);return n.cache.bind(n)}import{EffectType as mi,ToastAppearance as qc}from"@devvit/protos";function zc(t){let e=t.match(/form\.hook\.(.+)\.0/);if(e?.[1])return e[1]}var lo=class{constructor(e,r,n){this.state=null,this.hookId=e.hookId,this.form=r,this.onSubmit=n,this.onUIEvent=async i=>{i.formSubmitted&&await n(We(i.formSubmitted.results))}}};function uo(t,e){let r=Y({namespace:"useForm",initializer:n=>new lo(n,t,e)});return jh({id:r.hookId})}function jh(t){return`form.hook.${t.id}.0`}function Kc(t,e){let r=zc(e);return t.getHook({id:r})}var ho=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Ve=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},$e,pi,gi,fo;var wi=class{constructor(e){$e.set(this,void 0),pi.set(this,0),gi.set(this,void 0),fo.set(this,(r,n)=>{var i,s;let o=n!==void 0?r:"",d=n!==void 0?n:r;Ve(this,$e,"f").emitEffect(`postMessage${ho(this,pi,(s=Ve(this,pi,"f"),i=s++,s),"f"),i}`,{type:mi.EFFECT_WEB_VIEW,webView:{postMessage:{webViewId:o,app:{message:d,jsonString:JSON.stringify(d)}}}})}),ho(this,$e,e,"f"),ho(this,gi,{postMessage:Ve(this,fo,"f")},"f")}get webView(){return Ve(this,gi,"f")}showForm(e,r){let n=Kc(Ve(this,$e,"f"),e);if(!n)throw new Error("Form does not exist. Make sure you have added it using useForm.");let i=n.form instanceof Function?n.form(r??{}):n.form,s={fields:[],id:e,title:i.title,acceptLabel:i.acceptLabel,cancelLabel:i.cancelLabel,shortDescription:i.description};nt(i.fields),s.fields=Ie(i.fields),Ve(this,$e,"f").emitEffect(e,{type:mi.EFFECT_SHOW_FORM,showForm:{form:s}})}showToast(e){let r;e instanceof Object?r={text:e.text,appearance:e.appearance==="success"?qc.SUCCESS:qc.NEUTRAL}:r={text:e},Ve(this,$e,"f").emitEffect(e.toString(),{type:mi.EFFECT_SHOW_TOAST,showToast:{toast:r}})}navigateTo(e){let r;typeof e=="string"?r=new URL(e).toString():r=new URL(e.permalink,"https://www.reddit.com").toString(),Ve(this,$e,"f").emitEffect(r,{type:mi.EFFECT_NAVIGATE_TO_URL,navigateToUrl:{url:r}})}};$e=new WeakMap,pi=new WeakMap,gi=new WeakMap,fo=new WeakMap;import{EffectType as Gh,RealtimeSubscriptionStatus as Jc}from"@devvit/protos";var yi=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},V=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},bi,mo,pt,Te,mt,or,po,vi=class{constructor(e,r){bi.add(this),pt.set(this,void 0),Te.set(this,void 0),mt.set(this,void 0),or.set(this,void 0),yi(this,pt,r.context,"f"),yi(this,Te,!!r.context._devvitContext?.debug.realtime,"f"),yi(this,or,e,"f"),yi(this,mt,r.invalidate,"f");let n=r.context.meta[C.App]?.values[0];if(!n)throw Error("useChannel missing app ID metadata");let i=r.context.meta[C.Installation]?.values[0];if(!i)throw Error("useChannel missing install ID from metadata");let s=`${n}:${i}:${e.name}`;if(Object.values(V(this,pt,"f")._hooks).filter(d=>d instanceof mo).some(d=>d.state.channel===s))throw Error(`useChannel channel names must be unique; "${s}" duplicated`);this.state={channel:s,connected:!1,subscribed:!1}}async onUIEvent(e){let r=e.realtimeEvent;if(!(!r||!this.state.subscribed))switch(r.status){case Jc.REALTIME_SUBSCRIBED:V(this,Te,"f")&&console.debug(`[realtime] "${this.state.channel}" connected`),this.state.connected=!0,V(this,mt,"f").call(this),await V(this,or,"f").onSubscribed?.();break;case Jc.REALTIME_UNSUBSCRIBED:V(this,Te,"f")&&console.debug(`[realtime] "${this.state.channel}" disconnected`),this.state.connected=!1,V(this,mt,"f").call(this),await V(this,or,"f").onUnsubscribed?.();break;default:V(this,Te,"f")&&console.debug(`[realtime] "${this.state.channel}" received message: ${JSON.stringify(e,void 0,2)}`),V(this,or,"f").onMessage(r.event?.data?.msg);break}}async send(e){if(V(this,Te,"f")&&console.debug(`[realtime] "${this.state.channel}" send message: ${JSON.stringify(e,void 0,2)}`),!this.state.subscribed||!this.state.connected)throw console.debug(`[realtime] "${this.state.channel}" send failed; channel not connected`),Error(`useChannel send failed; "${this.state.channel}" channel not connected`);await V(this,pt,"f").devvitContext.realtime.send(this.state.channel,e)}get status(){return this.state.subscribed&&this.state.connected?ie.Connected:this.state.subscribed&&!this.state.connected?ie.Connecting:!this.state.subscribed&&this.state.connected?ie.Disconnecting:ie.Disconnected}subscribe(){this.state.subscribed||(V(this,Te,"f")&&console.debug(`[realtime] "${this.state.channel}" subscribed`),this.state.subscribed=!0,V(this,mt,"f").call(this),V(this,bi,"m",po).call(this))}unsubscribe(){this.state.subscribed&&(V(this,Te,"f")&&console.debug(`[realtime] "${this.state.channel}" unsubscribed`),this.state.subscribed=!1,V(this,mt,"f").call(this),V(this,bi,"m",po).call(this))}};mo=vi,pt=new WeakMap,Te=new WeakMap,mt=new WeakMap,or=new WeakMap,bi=new WeakSet,po=function(){let e=Object.values(V(this,pt,"f")._hooks).filter(r=>r instanceof mo&&r.state.subscribed).map(r=>r.state.channel);V(this,pt,"f").emitEffect(this.state.channel,{type:Gh.EFFECT_REALTIME_SUB,realtimeSubscriptions:{subscriptionIds:e}})};function go(t){if(!t.name||/[^a-zA-Z0-9_]/.test(t.name))throw Error(`useChannel error: The name "${t.name}" you provided for the hook is invalid. Valid names can only contain letters, numbers, and underscores (_).`);let e=`useChannel:${t.name}`;return Y({id:e,namespace:e,initializer:r=>new vi(t,r)})}import{EffectType as yo}from"@devvit/protos";var wo=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},ar=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},cr,gt;function Zc(t){return typeof t=="object"&&t!==null&&"__deleted"in t}var wt=class t{get devvitContext(){if(!this._devvitContext)throw new Error("Devvit context not available");return this._devvitContext}set devvitContext(e){this._devvitContext=e}constructor(e,r){cr.set(this,void 0),this._segments=[],gt.set(this,{}),this._prevHooks={},this._prevHookId="",this._effects={},this._changed={},this._touched={},this._requeueEvents=[],this._rootProps={},this._generated={},this._undeliveredHandlers={},this.request=e,this.meta=r,wo(this,cr,e.state??{__cache:{}},"f"),this._rootProps=e.props??{}}get _changedState(){let e={__cache:ar(this,cr,"f").__cache??{}};for(let n in this._changed)e[n]=this._state[n];let r=new Set(Object.keys(this._state));return Object.keys(ar(this,gt,"f")).forEach(n=>{n!=="__cache"&&r.delete(n)}),r.forEach(n=>{if(n==="__cache")return;let i={__deleted:!0};this._state[n]=e[n]=i}),e}get _hooks(){return ar(this,gt,"f")}set _hooks(e){this._prevHooks=ar(this,gt,"f"),wo(this,gt,e,"f")}get _state(){return ar(this,cr,"f")}set _state(e){wo(this,cr,e,"f")}push(e){this._segments.push({...e,next:0})}pop(){this._segments.pop()}addUndeliveredEventHandler(e,r){this._undeliveredHandlers[e]=r}addGlobalUndeliveredEventHandler(e,r){t.addGlobalUndeliveredEventHandler(e,r)}getHook(e){return ar(this,gt,"f")[e.id]}static addGlobalUndeliveredEventHandler(e,r){t._staticUndeliveredHandlers[e]=r}async handleUndeliveredEvent(e){let r={...t._staticUndeliveredHandlers,...this._undeliveredHandlers};for(let[n,i]of Object.entries(r))await i(e,this)}emitEffect(e,r){this._effects[e]=r}addToRequeueEvents(...e){this._devvitContext?.debug.blocks&&console.debug("[blocks] requeueing events",e);let r=e.reduce((n,i)=>(i.retry?n.retry.push(i):n.normal.push(i),n),{retry:[],normal:[]});this._requeueEvents=[...r.retry,...this._requeueEvents,...r.normal]}get effects(){return Object.values(this._effects)}nextHookId(e){e.key===void 0&&(e.key=this._segments[this._segments.length-1].next+++""),this.push(e);try{let r=[];for(let i=this._segments.length-1;i>=0;i--){let s=this._segments[i];if(s.id){r.unshift(s.id);break}let o=[];s.namespace&&o.push(s.namespace),s.key!==void 0&&s.key!==!1&&o.push(s.key),r.unshift(o.join("-"))}let n=r.join(".");if(this._generated[n]&&!e.shared)throw new Error(`Hook id ${n} already used, cannot register another hook with the same id`);return this._generated[n]=!0,this._prevHookId=n,n}finally{this.pop()}}};cr=new WeakMap,gt=new WeakMap;wt._staticUndeliveredHandlers={};var ki=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Re=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},yt,Ur,_i,Lr,ze={};wt.addGlobalUndeliveredEventHandler("intervals",async(t,e)=>{t.timer&&t.hook&&(delete ze[t.hook],e.emitEffect("timers",{type:yo.EFFECT_SET_INTERVALS,interval:{intervals:ze}}))});var bo=class{constructor(e,r,n){yt.set(this,void 0),Ur.set(this,void 0),_i.set(this,void 0),Lr.set(this,void 0),this.state={duration:{seconds:0,nanos:0},running:!1},ki(this,Ur,n.invalidate,"f"),ki(this,yt,n.hookId,"f"),ki(this,_i,e,"f"),ki(this,Lr,n.context,"f");let i=Math.floor(r/1e3),s=r%1e3*1e6;this.state.duration={seconds:i,nanos:s}}onStateLoaded(){this.state.running?ze[Re(this,yt,"f")]={duration:this.state.duration}:delete ze[Re(this,yt,"f")]}async onUIEvent(e){await Re(this,_i,"f").call(this)}start(){ze[Re(this,yt,"f")]={duration:this.state.duration},this.state.running=!0,Re(this,Ur,"f").call(this),Re(this,Lr,"f").emitEffect("timers",{type:yo.EFFECT_SET_INTERVALS,interval:{intervals:ze}})}stop(){delete ze[Re(this,yt,"f")],this.state.running=!1,Re(this,Ur,"f").call(this),Re(this,Lr,"f").emitEffect("timers",{type:yo.EFFECT_SET_INTERVALS,interval:{intervals:ze}})}};yt=new WeakMap,Ur=new WeakMap,_i=new WeakMap,Lr=new WeakMap;function vo(t,e){let r=Y({namespace:"useInterval",initializer:n=>new bo(t,e,n)});return{start:()=>r.start(),stop:()=>r.stop()}}import{UIEventScope as Vh}from"@devvit/protos";var bt=class extends Error{};import{UIEventScope as Qc}from"@devvit/protos";var Wr=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},$=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Ce,Me,Hr,Ei,jr;function _o(t){if(t instanceof Error){if(t.message===so)throw t;return console.error(t),{message:t.message,details:t.stack??""}}else return console.error(t),{message:"Unknown error",details:lt.caughtToString(t)}}var ko=class{constructor(e,r,n){Ce.set(this,void 0),Me.set(this,void 0),Hr.set(this,void 0),Ei.set(this,void 0),jr.set(this,void 0),Wr(this,Ce,!!n.context.devvitContext.debug.useAsync,"f"),$(this,Ce,"f")&&console.debug("[useAsync] v1",r),this.state={data:null,load_state:"initial",error:null,depends:null},Wr(this,Me,n.hookId,"f"),this.initializer=e,Wr(this,Hr,n.invalidate,"f"),Wr(this,Ei,n.context,"f"),this.localDepends=r.depends??null,Wr(this,jr,r,"f")}onStateLoaded(){if($(this,Ce,"f")&&console.debug("[useAsync] async onLoad ",$(this,Me,"f"),this.state),$(this,Ce,"f")&&console.debug("[useAsync] async onLoad have ",this.localDepends,"and",this.state.depends),!ut(this.localDepends,this.state.depends)||this.state.load_state==="initial"){$(this,Ce,"f")&&console.debug("[useAsync] attempting to resolve for hookId",$(this,Me,"f")),this.state.load_state="loading",this.state.depends=this.localDepends,$(this,Hr,"f").call(this);let e={scope:Qc.ALL,hook:$(this,Me,"f"),async:!0,asyncRequest:{requestId:$(this,Me,"f")+"-"+JSON.stringify(this.state.depends)}};$(this,Ce,"f")&&console.debug("[useAsync] onLoad requeue"),$(this,Ei,"f").addToRequeueEvents(e)}}async onUIEvent(e,r){if(e.asyncRequest){let n={requestId:e.asyncRequest.requestId};try{n.data={value:await this.initializer()}}catch(s){n.error=_o(s)}let i={scope:Qc.ALL,asyncResponse:n,hook:$(this,Me,"f")};$(this,Ce,"f")&&console.debug("[useAsync] onReq requeue"),r.addToRequeueEvents(i)}else if(e.asyncResponse){let n=$(this,Me,"f")+"-"+JSON.stringify(this.state.depends);e.asyncResponse.requestId===n?(this.state={...this.state,data:e.asyncResponse.data?.value??null,error:e.asyncResponse.error??null,load_state:e.asyncResponse.error?"error":"loaded"},$(this,jr,"f").finally&&await $(this,jr,"f").finally(this.state.data,this.state.error?new Error(this.state.error?.message??"Unknown error"):null),$(this,Hr,"f").call(this)):$(this,Ce,"f")&&console.debug("[useAsync] onResp skip, stale event",e.asyncResponse.requestId," !== ",n)}else throw new Error("Unknown event type")}};Ce=new WeakMap,Me=new WeakMap,Hr=new WeakMap,Ei=new WeakMap,jr=new WeakMap;function Gr(t,e={}){let r=Y({namespace:"useAsync",initializer:n=>new ko(t,e,n)});return{data:r.state.data,error:r.state.error,loading:r.state.load_state==="loading"}}var Ci=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},ee=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Ke,Vr,dr,vt,Eo=class{constructor(e,r){this.state={value:null,load_state:"initial",error:null},Ke.set(this,void 0),Vr.set(this,void 0),dr.set(this,void 0),vt.set(this,void 0),Ci(this,dr,e,"f"),Ci(this,vt,r.hookId,"f"),Ci(this,Ke,r.invalidate,"f"),Ci(this,Vr,r.context,"f")}async onUIEvent(){if(this.state.load_state==="loading"&&this._promise){try{this.state.value=await this._promise,this.state.load_state="loaded"}catch(e){this.state.load_state="error",this.state.error=_o(e)}ee(this,Ke,"f").call(this)}else console.warn(`Invalid state for hook (${ee(this,vt,"f")}):`,this.state.load_state,this._promise)}setter(e){this.state.value=e instanceof Function?e(this.state.value):e,this.state.load_state="loaded",ee(this,Ke,"f").call(this)}onStateLoaded(){if(this._promise=ee(this,Vr,"f")._prevHooks[ee(this,vt,"f")]?._promise,this.state.load_state==="loading")throw new bt;if(this.state.load_state==="error")throw new Error(this.state.error?.message??"Unknown error");if(this.state.load_state==="initial"){let e;try{e=ee(this,dr,"f")instanceof Function?ee(this,dr,"f").call(this):ee(this,dr,"f")}catch(r){console.log("error in loading async",r),this.state.load_state="error",ee(this,Ke,"f").call(this);return}if(e instanceof Promise){this._promise=e,this.state.load_state="loading";let r={scope:Vh.ALL,asyncRequest:{requestId:ee(this,vt,"f")},hook:ee(this,vt,"f")};throw ee(this,Vr,"f").addToRequeueEvents(r),ee(this,Ke,"f").call(this),new bt}else this.state.value=e,this.state.load_state="loaded";ee(this,Ke,"f").call(this)}}};Ke=new WeakMap,Vr=new WeakMap,dr=new WeakMap,vt=new WeakMap;function kt(t){let e=Y({namespace:"useState",initializer:r=>new Eo(t,r)});return[e.state.value,e.setter.bind(e)]}var Fi=class{buildContext(e,r,n){let i=new Zt(n),s=new qt(n),o=new Xt(n),d=new er(n),l=new tr(n),u=new wi(e),g=new Jt(n),p=new Kt,_=new Qt(n),I=$c(o,e._state),T={modLog:i,kvStore:s,redis:o,scheduler:d,settings:l,media:g,assets:p,realtime:_,ui:u,useState:kt,useChannel:go,useInterval:vo,useForm:uo,cache:I,dimensions:r.env?.dimensions,uiEnvironment:{timezone:n[C.Timezone]?.values[0],locale:n[C.Language]?.values[0],dimensions:r.env?.dimensions,colorScheme:r.env?.colorScheme}},L=z(n,r.props?.postId);return L.debug.effects=e,{...L,...T}}};var R=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},$h=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},M,$r,Po,xi,te,Ai,ed,Co,td,Io,Fo,Pi,Ao,Xc,se=null;function Yc(t){return JSON.parse(JSON.stringify(t))}function Kh(t){if(!(t!==""&&!/[-.]/.test(t)))throw new Error(`Hook with namespace '${t}' is invalid. Hook namespaces cannot be empty string or contain dashes/dots because they are used as delimiters internally. Please update the hook namespace and try again.`)}function Y({initializer:t,...e}){if(!se)throw new Error("Hooks can only be declared at the top of a component. You cannot declare hooks outside of components or inside of event handlers. It's almost always a mistake to declare hooks inside of loops or conditionals.");Kh(e.namespace);let r=se.nextHookId(e),n=se,i={hookId:r,invalidate:()=>{n._changed[r]=!0,n._state[r]=n?._hooks[r]?.state},context:se},s=se._state[r]===void 0||Zc(se._state[r]);se._hooks[r]=se._hooks[r]??t(i);let o=se._hooks[r];return s||(o.state=se._state[r]),o.onStateLoaded?.(),s&&o.state!==void 0&&o.state!==null&&i.invalidate(),o}var qh=null,Ii=128,_t=class{constructor(e){M.add(this),$r.set(this,void 0),Po.set(this,new Fi),xi.set(this,new sr(()=>this._latestRenderContext?.devvitContext?.assets)),this._latestRenderContext=null,R(this,M,"a",te)&&console.debug("[blocks] BlocksHandler v1"),$h(this,$r,e,"f"),qh=this}async handle(e,r){let n=new wt(e,r);n.devvitContext=R(this,Po,"f").buildContext(n,e,r);let i,s=e.events.length-Ii,o=e.events;if(s>0){o=[];{let T=0;for(let L of e.events)T<s&&L.realtimeEvent?T++:o.push(L)}for(;o.length>Ii;)o.shift();console.warn(`dropped ${s} events`)}let l=!o.length||o.some(T=>!T.async),u=o.some(T=>T.blocking),g,p,_=[...o];o.length===0&&o.push({scope:zh.ALL}),R(this,M,"a",te)&&console.debug("[blocks] starting processing events");let I=0;for(;o.length>0;){if(I++>Ii)throw new Error(`Exceeded maximum iterations of ${Ii}`);R(this,M,"a",te)&&console.debug("[blocks] processing events loop iteration",o.length);let T=[];if(!o[0].async)T.push(o.shift());else for(;o[0]?.async;)T.push(o.shift());if(!T.length)throw Error("batch must have at least one event");try{if(T[0].async){let D=Yc(n._state);await R(this,M,"m",ed).call(this,n,...T),n._state=D}else await R(this,M,"m",td).call(this,n,...T)}catch(D){if(!li(D))throw D;if(R(this,M,"a",te)&&console.debug("[blocks] caught in handler",D),n._latestRenderContent=void 0,p){n._state=p._state,n._changed=g,n._effects=p._effects;let oe=_.map(Rl=>{let Jo={...Rl};return Jo.retry=!0,Jo});n.addToRequeueEvents(...oe);break}else throw li(D)||console.error("[blocks] unhandled error in handler",D),D}R(this,M,"a",te)&&console.debug("[blocks] remaining events",n._requeueEvents);let L=[];for(let D of n._requeueEvents){if(!l&&!D.async){R(this,M,"a",te)&&console.debug("[blocks] NOT reprocessing event in BlocksHandler, sync mismatch A",D),L.push(D);continue}if(l&&D.async&&!u){R(this,M,"a",te)&&console.debug("[blocks] NOT reprocessing event in BlocksHandler, sync mismatch B",D),L.push(D);continue}R(this,M,"a",te)&&console.debug("[blocks] reprocessing event in BlocksHandler",D),o.push(D)}n._requeueEvents=L,o.length>0&&(g={...n._changed},p={_state:Yc(n._state),_effects:{...n._effects}},_=[...o])}if(l){n._latestRenderContent||(n._latestRenderContent=R(this,M,"m",Io).call(this,R(this,$r,"f"),n.request.props??{},n));let T=n._latestRenderContent;T&&(i=R(this,xi,"f").createBlocksElementOrThrow(T),i=R(this,xi,"f").ensureRootBlock(i))}return{state:n._changedState,effects:n.effects,blocks:i,events:n._requeueEvents}}};$r=new WeakMap,Po=new WeakMap,xi=new WeakMap,M=new WeakSet,te=function(){return!!this._latestRenderContext?.devvitContext.debug.blocks},Ai=function(e,...r){e._hooks={},R(this,M,"m",Io).call(this,R(this,$r,"f"),e.request.props??{},e)},ed=async function(e,...r){R(this,M,"m",Ai).call(this,e,...r),await Promise.all(r.map(async n=>{if(!n.async)throw new Error("You can't mix main and other queues in one batch. This is likely a platform bug. Please file an issue in the Discord for someone to help! https://discord.com/channels/1050224141732687912/1115441897079574620");await R(this,M,"m",Co).call(this,e,n)}))},Co=async function(e,r){let n=e._hooks[r.hook];if(n?.onUIEvent)try{await n.onUIEvent(r,e)}catch(i){throw li(i)?R(this,M,"a",te)&&console.error("Server call required",i):console.error("Error in event handler",i),i}else await e.handleUndeliveredEvent(r)},td=async function(e,...r){for(let n of r)R(this,M,"a",te)&&console.log("[blocks] handling main queue event",n),R(this,M,"a",te)&&console.log("[blocks] before",e._state),R(this,M,"m",Ai).call(this,e,n),await R(this,M,"m",Co).call(this,e,n),R(this,M,"a",te)&&console.log("[blocks] after",e._state);R(this,M,"m",Ai).call(this,e)},Io=function(e,r,n){R(this,M,"a",te)&&console.debug("[blocks] renderRoot"),n._generated={},se=n,this._latestRenderContext=n;try{let i=R(this,M,"m",Fo).call(this,e,r,n);if(i.length!==1)throw new Error(`There can only be one root element, received: ${i.length}. Please wrap these elements in a <vstack></vstack> or <hstack></hstack> to continue. Fragments cannot be used as a root element.`);let s=i[0];if(s==="[object Promise]")throw new Error('Root elements cannot be async. To use data from an async endpoint, please use "const [data] = useState(async () => {/** your async code */})".');if(typeof s=="string")throw new Error("The root element must return a valid block, not a string. Try wrapping the element in a <text>your content</text> tag to continue.");return n._latestRenderContent=s,s}catch(i){if(i instanceof bt)return;throw i}finally{se=null}},Fo=function(e,r,n){n.push({namespace:e.name||"anonymous",...r});try{let i=e(r,n.devvitContext);if(i instanceof Promise)throw new Error(`Components (found: ${e.name??"unknown component"}) cannot be async. To use data from an async endpoint, please use "const [data] = useState(async () => {/** your async code */})".`);return R(this,M,"m",Ao).call(this,i,n)}finally{n.pop()}},Pi=function(e,r){return e=e.flat(1/0),e.flatMap((n,i)=>(n&&typeof n=="object"&&"props"in n&&(n.props?.key||(n.props=n.props??{},n.props.key=`${i}`)),R(this,M,"m",Ao).call(this,n,r)))},Ao=function(e,r){if(Array.isArray(e))return R(this,M,"m",Pi).call(this,e,r);if(Jh(e))if(e.type===void 0)try{return r.push({namespace:"fragment",...e.props}),R(this,M,"m",Pi).call(this,e.children,r)}finally{r.pop()}else if(typeof e.type=="function"){let n={...e.props,children:e.children.flat(1/0)};return R(this,M,"m",Fo).call(this,e.type,n,r)}else try{r.push({namespace:e.type,...e.props});let n=R(this,M,"m",Pi).call(this,e.children,r),i=R(this,M,"m",Xc).call(this,e.props??{});return[{type:e.type,children:n,props:i}]}finally{r.pop()}else return[(e??"").toString()]},Xc=function(e){let r={};for(let n in e)if(!(typeof e[n]>"u"))if(typeof e[n]=="function"){let i=Y({namespace:n,key:!1,initializer:({hookId:s})=>({hookId:s,state:null,onUIEvent:o=>{if(o.userAction)return e[n](o.userAction.data);if(o.webView?.postMessage){let d=o.webView.postMessage.jsonString?JSON.parse(o.webView.postMessage.jsonString):o.webView.postMessage.message;return e[n](d)}}})});r[n]=i.hookId,"captureHookRef"in e[n]&&e[n].captureHookRef()}else{let i=JSON.parse(JSON.stringify(e[n]));i!=null&&(r[n]=i)}return r};function Jh(t){return typeof t=="object"&&t!=null&&"type"in t}var rd=t=>{let e=Number(t.trim().split(".").pop());return isNaN(e)?void 0:e},nd=t=>{let[e,r,n]=t.trim().split(";");if(!e||!r||!n){console.warn(`Received a malformed devvit-user-agent! Received: '${t}'`);return}if(e!=="Reddit"){console.warn(`Received unknown company name in user agent! Received: '${t}'`);return}if(r==="iOS"){let i=rd(n);if(i===void 0){console.warn(`Could not parse version number from user agent! Received: '${t}'`);return}return{company:"Reddit",platform:"iOS",rawVersion:n,versionNumber:i}}if(r==="Android"){let i=rd(n);if(i===void 0){console.warn(`Could not parse version number from user agent! Received: '${t}'`);return}return{company:"Reddit",platform:"Android",rawVersion:n,versionNumber:i}}if(r==="Shreddit")return{company:"Reddit",platform:"Shreddit",rawVersion:n};if(r==="Play")return{company:"Reddit",platform:"Play",rawVersion:n};console.warn("Received unknown platform:",r)},id=t=>t?t.platform==="Android"?t.versionNumber<1875012:t.platform==="iOS"?t.versionNumber<614973:!1:(console.warn(`Could not parse devvit-user-agent! Received: '${JSON.stringify(t)}'`),!1),Zh=t=>{switch(t){case"Android":return"https://play.google.com/store/apps/details?id=com.reddit.frontpage";case"iOS":return"https://apps.apple.com/us/app/reddit/id1064216828";case"Play":case"Shreddit":break;default:console.error(`No upgrade link for platform: ${t}`)}},Qh=({platform:t},e)=>a.createElement("blocks",null,a.createElement("vstack",{alignment:"middle center",height:100,width:100},a.createElement("vstack",{maxWidth:"300px",gap:"large",alignment:"middle center"},a.createElement("vstack",{gap:"medium",alignment:"middle center"},a.createElement("image",{imageHeight:100,imageWidth:100,url:"https://i.redd.it/p1vmc5ulmpib1.png"}),a.createElement("text",{size:"large",weight:"bold",wrap:!0,alignment:"center"},"Uh oh, the app you're trying to use requires the latest version of Reddit. Please upgrade your app to continue.")),a.createElement("hstack",{alignment:"middle center"},a.createElement("button",{onPress:()=>{let r=Zh(t);r?e.ui.navigateTo(r):console.warn("No upgrade link found for platform:",t)}},"Upgrade"))))),sd=t=>()=>a.createElement(Qh,{platform:t});var Xh=()=>a.createElement("vstack",{alignment:"center middle",width:"100%",height:"100%"},a.createElement("text",null,"This feature is not available yet")),Yh=[[Si,Si.methods.renderPostContent,(t,e)=>a.customPostType?.render(e)??null],[Si,Si.methods.renderPostComposer,(t,e)=>a.createElement(Xh,null)]];function ef(t){return async(e,r)=>{let n=nd(r["devvit-user-agent"]?.values?.[0]??"");if(n&&id(n)){let s=new _t(sd(n.platform));return od.fromJSON(await s.handle(e,r))}let i=new _t(t);return od.fromJSON(await i.handle(e,r))}}function ad(t){for(let[e,r,n]of Yh)t.provides(e),x(r.name,ef(n))}var v=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},lr=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},f,Ti,xo,ur,zr,Kr,Ri,Mi,qr,hr,So,To,Jr,W,a=class extends On{static configure(e){lr(this,f,{...v(this,f,"f",ur),...e},"f",ur),ue(e.http)&&this.use(w.HTTPDefinition),(e.redis===void 0||ue(e.kvStore)||ue(e.redis))&&(this.use(w.KVStoreDefinition),this.use(w.RedisAPIDefinition)),ue(e.media)&&this.use(w.MediaServiceDefinition),ue(e.modLog)&&this.use(w.ModlogDefinition),ue(e.redditAPI)&&(this.use(w.FlairDefinition),this.use(w.GraphQLDefinition),this.use(w.LinksAndCommentsDefinition),this.use(w.ListingsDefinition),this.use(w.ModerationDefinition),this.use(w.ModNoteDefinition),this.use(w.NewModmailDefinition),this.use(w.PrivateMessagesDefinition),this.use(w.SubredditsDefinition),this.use(w.UsersDefinition),this.use(w.WidgetsDefinition),this.use(w.WikiDefinition)),ue(e.realtime)&&this.use(w.RealtimeDefinition),ue(e.userActions)&&this.use(w.UserActionsDefinition)}static addMenuItem(e){v(this,f,"f",Mi).push(e)}static addCustomPostType(e){lr(this,f,e,"f",zr)}static createForm(e,r){let n=`form.${v(this,f,"f",Kr).size}`;return v(this,f,"f",Kr).set(n,{form:e,onSubmit:r}),n}static addSchedulerJob(e){if(v(this,f,"f",W)[w.SchedulerDefinition.fullName]||this.use(w.SchedulerDefinition),v(this,f,"f",qr).has(e.name))throw new Error(`Job ${e.name} is already defined`);v(this,f,"f",qr).set(e.name,e.onRun)}static addSettings(e){nt(e);let r=e.filter(i=>i.type==="group"||!i.scope||i.scope===rt.Installation),n=e.filter(i=>i.type!=="group"&&i.scope===rt.App);r.length>0&&lr(this,f,r,"f",Ri),n.length>0&&lr(this,f,n,"f",Ti),v(this,f,"f",W)[w.SettingsDefinition.fullName]||this.use(w.SettingsDefinition)}static addTrigger(e){if("events"in e){for(let r of e.events)this.addTrigger({event:r,onEvent:(n,i)=>e.onEvent(n,i)});return this}return v(this,f,"f",hr).has(e.event)?v(this,f,"f",hr).get(e.event)?.push(e.onEvent):v(this,f,"f",hr).set(e.event,[e.onEvent]),f}static provide(e){v(this,f,"f",To).push(e)}static use(e,r){v(this,f,"f",Jr)[e.fullName]={def:e,options:r??{},handler:void 0};let n={};for(let i of Object.values(e.methods))n[i.name]=(s,o)=>v(this,f,"f",Jr)[e.fullName].handler?.[i.name]?.(i.requestType?.fromPartial(s??{}),o);return v(this,f,"f",W)[e.fullName]=n,n}static get redditAPIPlugins(){if(!ue(v(this,f,"f",ur).redditAPI))throw new Error("Reddit API is not enabled. You can enable it by passing `redditAPI: true` to `Devvit.configure`.");return{Flair:v(this,f,"f",W)[w.FlairDefinition.fullName],GraphQL:v(this,f,"f",W)[w.GraphQLDefinition.fullName],LinksAndComments:v(this,f,"f",W)[w.LinksAndCommentsDefinition.fullName],Listings:v(this,f,"f",W)[w.ListingsDefinition.fullName],Moderation:v(this,f,"f",W)[w.ModerationDefinition.fullName],ModNote:v(this,f,"f",W)[w.ModNoteDefinition.fullName],NewModmail:v(this,f,"f",W)[w.NewModmailDefinition.fullName],PrivateMessages:v(this,f,"f",W)[w.PrivateMessagesDefinition.fullName],Subreddits:v(this,f,"f",W)[w.SubredditsDefinition.fullName],Users:v(this,f,"f",W)[w.UsersDefinition.fullName],Widgets:v(this,f,"f",W)[w.WidgetsDefinition.fullName],Wiki:v(this,f,"f",W)[w.WikiDefinition.fullName]}}static get modLogPlugin(){let e=v(this,f,"f",W)[w.ModlogDefinition.fullName];if(!e)throw new Error("ModLog is not enabled. You can enable it by passing `modLog: true` to `Devvit.configure`");return e}static get schedulerPlugin(){let e=v(this,f,"f",W)[w.SchedulerDefinition.fullName];if(!e)throw new Error("Scheduler is not enabled. You can enable it by calling `Devvit.addSchedulerJob` at the top level of your app.");return e}static get kvStorePlugin(){let e=v(this,f,"f",W)[w.KVStoreDefinition.fullName];if(!e)throw new Error("Key Value Store is not enabled. You can enable it by passing `kvStore: true` to `Devvit.configure`");return e}static get redisPlugin(){let e=v(this,f,"f",W)[w.RedisAPIDefinition.fullName];if(!e)throw new Error("Redis is not enabled. You can enable it by passing `redis: true` to `Devvit.configure`");return e}static get mediaPlugin(){let e=v(this,f,"f",W)[w.MediaServiceDefinition.fullName];if(!e)throw new Error("MediaService is not enabled. You can enable it by passing `media: true` to `Devvit.configure`");return e}static get settingsPlugin(){let e=v(this,f,"f",W)[w.SettingsDefinition.fullName];if(!e)throw new Error("Settings must first be configured with `Devvit.addSettings()` before they can be accessed");return e}static get realtimePlugin(){let e=v(this,f,"f",W)[w.RealtimeDefinition.fullName];if(!e)throw new Error("Realtime is not enabled. You can enable it by passing `realtime: true` to `Devvit.configure`");return e}static get userActionsPlugin(){if(!(ue(v(this,f,"f",ur).userActions)&&ue(v(this,f,"f",ur).redditAPI)))throw new Error("UserActions is not enabled. You can enable it by passing both `userActions: true` and `redditAPI: true` to `Devvit.configure`");return v(this,f,"f",W)[w.UserActionsDefinition.fullName]}static get menuItems(){return v(this,f,"f",Mi)}static get customPostType(){return v(this,f,"f",zr)}static get formDefinitions(){return v(this,f,"f",Kr)}static get scheduledJobHandlers(){return v(this,f,"f",qr)}static get installationSettings(){return v(this,f,"f",Ri)}static get appSettings(){return v(this,f,"f",Ti)}static get triggerOnEventHandlers(){return v(this,f,"f",hr)}static get assets(){return v(this,f,"f",xo)}static get webViewAssets(){return v(this,f,"f",So)}constructor(e){super(e),lr(f,f,e.assets??{},"f",xo),lr(f,f,e.webviewAssets??{},"f",So);for(let r in v(f,f,"f",Jr)){let n=v(f,f,"f",Jr)[r];n.handler=e.use(n.def,n.options)}v(f,f,"f",Mi).length>0&&hc(e),v(f,f,"f",qr).size>0&&fc(e),v(f,f,"f",zr)&&(rc(e),ad(e)),(v(f,f,"f",zr)||v(f,f,"f",Kr).size>0)&&Rc(e),v(f,f,"f",Ri)&&nc(e),v(f,f,"f",Ti)&&Da(e),v(f,f,"f",hr).size>0&&mc(e);for(let r of v(f,f,"f",To))e.provides(r)}};f=a;a.debug={};Ti={value:void 0};xo={value:{}};ur={value:{}};zr={value:void 0};Kr={value:new Map};Ri={value:void 0};Mi={value:[]};qr={value:new Map};hr={value:new Map};So={value:{}};To={value:[]};Jr={value:{}};W={value:{}};(function(t){function e(r,n,...i){return{type:r,props:n,children:i}}t.createElement=e})(a||(a={}));function re(t){let e=Object.getOwnPropertyDescriptors(t.constructor.prototype);for(let[r,n]of Object.entries(e))n.get&&Object.defineProperty(t,r,{...n,enumerable:!0})}var Ro;(function(t){t[t.bold=1]="bold",t[t.italic=2]="italic",t[t.underline=4]="underline",t[t.strikethrough=8]="strikethrough",t[t.subscript=16]="subscript",t[t.superscript=32]="superscript",t[t.monospace=64]="monospace"})(Ro||(Ro={}));var cd="text",dd="raw",ld="br",ud="link",hd="c/",fd="p/",md="r/",pd="u/",gd="@",wd="spoilertext",yd="par",bd="h",vd="hr",kd="blockquote",_d="code",Ed="li",Cd="list",Fd="L",Ad="R",Pd="C",Id="table",xd="embed",Sd="img",Td="gif",Rd="video";function Md(t){return{e:Td,id:t.mediaId,...t.caption&&{c:t.caption},...t.blur&&{o:t.blur}}}function Nd(t,e){let r={},n=[];return Object.assign(r,Zr(r,n),Qr(r,n),Xr(r,n),tn(r,n),rn(r,n),nn(r,n)),e(r),{e:kd,c:n,...t.author&&{a:t.author}}}function Bd(t,e){let r={},n=[];return Object.assign(r,No(r,n)),e(r),{e:_d,c:n,...t.language&&{l:t.language}}}function Dd(t){return{e:hd,t:t.permalink}}function Od(t,e){let r={},n=[];return Object.assign(r,No(r,n),en(r,n)),e(r),{e:bd,l:t.level,c:n}}function Ud(t){return{e:xd,u:t.sourceUrl,c:t.contentUrl,x:t.width,y:t.height}}function Ld(){return{e:vd}}function Wd(t){return{e:Sd,id:t.mediaId,...t.caption&&{c:t.caption},...t.blur&&{o:t.blur}}}function Hd(){return{e:ld}}function jd(t){return{e:ud,t:t.text,u:t.url,...t.formatting&&{f:t.formatting},...t.tooltip&&{a:t.tooltip}}}function Gd(t,e){let r={},n=[];return Object.assign(r,sl(r,n)),e(r),{e:Cd,o:t.ordered,c:n}}function Vd(t){let e={},r=[];return Object.assign(e,Zr(e,r),Qr(e,r),Xr(e,r),Ni(e,r),tn(e,r),rn(e,r),nn(e,r)),t(e),{e:Ed,c:r}}function $d(t){let e={},r=[];return Object.assign(e,Bi(e,r),en(e,r),Mo(e,r),Bo(e,r),Yr(e,r)),t(e),{e:yd,c:r}}function zd(t){return{e:fd,t:t.permalink}}function Kd(t){return{e:dd,t}}function qd(t){let e={},r=[];return Object.assign(e,Bi(e,r),en(e,r),Mo(e,r)),t(e),{e:wd,c:r}}function Jd(t){return{e:md,t:t.subredditName,l:t.showPrefix}}function Zd(t){let e={},r=[],n=[];return Object.assign(e,ol(e,r,n)),t(e),{e:Id,h:r,c:n}}function Qd(t){let[e,r]=il();return t(e),{c:r}}function Xd(t,e){let[r,n]=il();e(r);let i;switch(t.columnAlignment){case"left":i=Fd;break;case"right":i=Ad;break;case"center":i=Pd;break}return{...i&&{a:i},...n&&{c:n}}}function Yd(t){let e={},r=[];return Object.assign(e,al(e,r)),t(e),r}function el(t){return{e:cd,t:t.text,...t.formatting&&{f:t.formatting}}}function tl(t){return{e:pd,t:t.username,l:t.showPrefix}}function rl(t){return{e:gd,t:t.username,l:t.showPrefix}}function nl(t){return{e:Rd,id:t.mediaId,...t.caption&&{c:t.caption},...t.blur&&{o:t.blur},...t.thumbnail&&{p:t.thumbnail},...t.convertToGif&&{gifify:t.convertToGif}}}function il(){let t={},e=[];return Object.assign(t,Bi(t,e),en(t,e),Bo(t,e),Yr(t,e)),[t,e]}function Zr(t,e){return{blockQuote(r,n){return e.push(Nd(r,n)),t}}}function Qr(t,e){return{codeBlock(r,n){return e.push(Bd(r,n)),t}}}function cl(t,e){return{embed(r){return e.push(Ud(r)),t}}}function Xr(t,e){return{heading(r,n){return e.push(Od(r,n)),t}}}function Ni(t,e){return{horizontalRule(){return e.push(Ld()),t}}}function Yr(t,e){return{image(r){return e.push(Wd(r)),t},animatedImage(r){return e.push(Md(r)),t}}}function Mo(t,e){return{linebreak(){return e.push(Hd()),t}}}function en(t,e){return{link(r){return e.push(jd(r)),t},commentLink(r){return e.push(Dd(r)),t},postLink(r){return e.push(zd(r)),t},subredditLink(r){return e.push(Jd(r)),t},userLink(r){return e.push(tl(r)),t},userMention(r){return e.push(rl(r)),t}}}function tn(t,e){return{list(r,n){return e.push(Gd(r,n)),t}}}function sl(t,e){return{item(r){return e.push(Vd(r)),t}}}function rn(t,e){return{paragraph(r){return e.push($d(r)),t}}}function No(t,e){return{rawText(r){return e.push(Kd(r)),t}}}function Bo(t,e){return{spoiler(r){return e.push(qd(r)),t}}}function ol(t,e,r){return{headerCell(n,i){return e.push(Xd(n,i)),t},row(n){return r.push(Yd(n)),t}}}function nn(t,e){return{table(r){return e.push(Zd(r)),t}}}function al(t,e){return{cell(r){return e.push(Qd(r)),t}}}function Bi(t,e){return{text(r){return e.push(el(r)),t}}}function dl(t,e){return{video(r){return e.push(nl(r)),t}}}var tf=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},rf=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Di,Et=class{constructor(){Di.set(this,void 0);let e=[];Object.assign(this,rn(this,e),Xr(this,e),Ni(this,e),Zr(this,e),Qr(this,e),cl(this,e),tn(this,e),nn(this,e),Yr(this,e),dl(this,e)),tf(this,Di,{document:e},"f")}build(){return JSON.stringify(rf(this,Di,"f"))}paragraph(e){return this}heading(e,r){return this}horizontalRule(){return this}blockQuote(e,r){return this}codeBlock(e,r){return this}embed(e){return this}list(e,r){return this}table(e){return this}image(e){return this}animatedImage(e){return this}video(e){return this}};Di=new WeakMap;function fr(t){let e;return t instanceof Et?e=t.build():typeof t=="object"?e=JSON.stringify(t):e=t,e}var Ne=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Fe=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},sn,mr,pr,Ct,on,Oi,ll=100,ul=1/0,j=class{constructor(e){sn.add(this),mr.set(this,void 0),pr.set(this,void 0),Ct.set(this,void 0),on.set(this,!1),this.pageSize=ll,this.limit=ul,this.children=[],re(this),this._fetch=e.fetch,this.pageSize=e.pageSize??ll,this.limit=e.limit??ul,Ne(this,pr,e.after,"f"),Ne(this,mr,e.before,"f"),Ne(this,Ct,e.more,"f"),e.children&&(this.children=e.children)}get hasMore(){return!Fe(this,on,"f")||!!(Fe(this,pr,"f")||Fe(this,mr,"f")||Fe(this,Ct,"f"))}async*[(mr=new WeakMap,pr=new WeakMap,Ct=new WeakMap,on=new WeakMap,sn=new WeakSet,Symbol.asyncIterator)](){let e=0;for(;;){if(e===this.children.length)if(this.hasMore){if((await Fe(this,sn,"m",Oi).call(this)).length===0)break}else break;if(yield this.children[e],e++,e===this.limit)break}}setMore(e){Ne(this,Ct,e,"f")}preventInitialFetch(){Ne(this,on,!0,"f")}async all(){for(;this.hasMore&&this.children.length<this.limit;)await Fe(this,sn,"m",Oi).call(this);return this.children.slice(0,this.limit)}async get(e){let r=e<=this.limit?e:this.limit;for(;this.hasMore&&this.children.length<r;)await Fe(this,sn,"m",Oi).call(this);return this.children.slice(0,r)}};Oi=async function(){if(!this.hasMore)throw new Error("This listing does not have any more items to load.");let{children:e,before:r,after:n,more:i}=await this._fetch({before:Fe(this,mr,"f"),after:Fe(this,pr,"f"),limit:this.pageSize,more:Fe(this,Ct,"f")});return this.children.push(...e),Ne(this,mr,r,"f"),Ne(this,pr,n,"f"),Ne(this,Ct,i,"f"),Ne(this,on,!0,"f"),e};var hl=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Do,Oo,qe=class{constructor(){}static get(e,r){let n=a.redditAPIPlugins.ModNote;return new j({hasMore:!0,before:e.before,limit:e.limit,pageSize:e.limit,fetch:async i=>{let s=await n.GetNotes({subreddit:e.subreddit,user:e.user,filter:e.filter,before:i.before,limit:i.limit},r);return{children:s.modNotes?.map(o=>hl(this,Do,"m",Oo).call(this,o))||[],before:s.hasNextPage?s.endCursor:void 0,hasMore:s.hasNextPage}}})}static async delete(e,r){let n=a.redditAPIPlugins.ModNote,{deleted:i}=await n.DeleteNotes(e,r);return!!i}static async add(e,r){let i=await a.redditAPIPlugins.ModNote.PostNotes(e,r);if(!i?.created)throw new Error("Failed to create mod note");return hl(this,Do,"m",Oo).call(this,i.created)}static async addRemovalNote(e,r){await a.redditAPIPlugins.ModNote.PostRemovalNote(e,r)}};Do=qe,Oo=function(e){return m(e.id,"Mod note ID is null or undefined"),m(e.createdAt,"Mod note createdAt is null or undefined"),m(e.type,"Mod note type is null or undefined"),m(e.subreddit,"Mod note subreddit is null or undefined"),m(e.subredditId,"Mod note subredditId is null or undefined"),m(e.operator,"Mod note operator is null or undefined"),m(e.operatorId,"Mod note operatorId is null or undefined"),m(e.user,"Mod note user is null or undefined"),m(e.userId,"Mod note userId is null or undefined"),m(e.userNoteData,"Mod note userNote is null or undefined"),m(e.modActionData,"Mod note modAction is null or undefined"),{id:e.id,user:{id:ne(e.userId??""),name:e.user},subreddit:{id:ge(e.subredditId??""),name:e.subreddit},operator:{id:ne(e.operatorId??""),name:e.operator},createdAt:new Date(e.createdAt*1e3),userNote:{note:e.userNoteData?.note,redditId:e.userNoteData?.redditId?Gt(e.userNoteData?.redditId):void 0,label:e.userNoteData?.label},type:e.type}};var fe=class{static queryWithQueryString(e,r){return a.redditAPIPlugins.GraphQL.Query({query:e},r)}static query(e,r,n,i){return a.redditAPIPlugins.GraphQL.PersistedQuery({operationName:e,id:r,variables:n},i)}};var fl=["all","wiki","posts","access","mail","config","flair","channels","chat_config","chat_operator","community_chat"];function nf(t,e){return e.map(r=>(t.includes(r)?"+":"-")+r).join(",")}function Uo(t){return nf(t,fl)}function ml(t){return t.filter(e=>fl.includes(e))}import"@devvit/protos";var Ae=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},B=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Q,gr,an,cn,dn,ln,un,hn,fn,mn,pn,Ui,q,Lo,pl,Wo,Li;(function(t){t.User="USER_FLAIR",t.Post="LINK_FLAIR"})(Li||(Li={}));var gn=class{constructor(e,r,n){gr.set(this,void 0),an.set(this,void 0),cn.set(this,void 0),dn.set(this,void 0),ln.set(this,void 0),un.set(this,void 0),hn.set(this,void 0),fn.set(this,void 0),mn.set(this,void 0),pn.set(this,void 0),re(this),m(e.id),m(e.text),Ae(this,gr,e.id,"f"),Ae(this,an,r,"f"),Ae(this,cn,e.text,"f"),Ae(this,dn,sf(e.textColor),"f"),Ae(this,ln,of(e.backgroundColor),"f"),Ae(this,un,af(e.allowableContent),"f"),Ae(this,hn,e.modOnly,"f"),Ae(this,fn,e.maxEmojis,"f"),Ae(this,mn,e.textEditable,"f"),Ae(this,pn,n,"f")}get id(){return B(this,gr,"f")}get text(){return B(this,cn,"f")}get textColor(){return B(this,dn,"f")}get backgroundColor(){return B(this,ln,"f")}get allowableContent(){return B(this,un,"f")}get modOnly(){return B(this,hn,"f")}get maxEmojis(){return B(this,fn,"f")}get allowUserEdits(){return B(this,mn,"f")}async delete(){return Q.deleteFlairTemplate(B(this,gr,"f"),B(this,an,"f"),B(this,pn,"f"))}async edit(e){return Q.editFlairTemplate({id:B(this,gr,"f"),subredditName:B(this,an,"f"),text:e.text??B(this,cn,"f"),allowableContent:e.allowableContent??B(this,un,"f"),backgroundColor:e.backgroundColor??B(this,ln,"f"),maxEmojis:e.maxEmojis??B(this,fn,"f"),modOnly:e.modOnly??B(this,hn,"f"),textColor:e.textColor??B(this,dn,"f"),allowUserEdits:e.allowUserEdits??B(this,mn,"f")},B(this,pn,"f"))}static async createPostFlairTemplate(e,r){return B(Q,Q,"m",Ui).call(Q,{...e,flairType:Li.Post},r)}static async createUserFlairTemplate(e,r){return B(Q,Q,"m",Ui).call(Q,{...e,flairType:Li.User},r)}static async editFlairTemplate(e,r){return B(Q,Q,"m",Ui).call(Q,e,r)}static async getPostFlairTemplates(e,r){return(await a.redditAPIPlugins.Flair.LinkFlair({subreddit:e},r)).flair?.map(s=>new Q(s,e,r))||[]}static async getUserFlairTemplates(e,r){return(await a.redditAPIPlugins.Flair.UserFlair({subreddit:e},r)).flair?.map(s=>new Q(s,e,r))||[]}static async deleteFlairTemplate(e,r,n){await a.redditAPIPlugins.Flair.DeleteFlairTemplate({subreddit:e,flairTemplateId:r},n)}};Q=gn,gr=new WeakMap,an=new WeakMap,cn=new WeakMap,dn=new WeakMap,ln=new WeakMap,un=new WeakMap,hn=new WeakMap,fn=new WeakMap,mn=new WeakMap,pn=new WeakMap,Ui=async function(e,r){let{subredditName:n,allowableContent:i="all",backgroundColor:s="transparent",flairType:o="",maxEmojis:d=10,modOnly:l=!1,text:u,textColor:g="dark",allowUserEdits:p=!1,id:_=""}=e;if(l&&p)throw new Error("Cannot have a mod only flair that is editable by users");let T=await a.redditAPIPlugins.Flair.FlairTemplate({subreddit:n,allowableContent:i,backgroundColor:s,flairType:o,maxEmojis:d,modOnly:l,text:u,textColor:g,textEditable:p,flairTemplateId:_,cssClass:"",overrideCss:!1},r);return new Q(T,n,r)};function Ho(t){return{flairCssClass:t.flairCssClass,user:t.user,flairText:t.flairText}}var Ft=class{static async getUserFlairBySubreddit(e,r){return a.redditAPIPlugins.Flair.FlairList(e,r)}static setUserFlair(e,r){return B(q,q,"m",Lo).call(q,e,r)}static setUserFlairBatch(e,r,n){return B(q,q,"m",pl).call(q,e,r,n)}static setPostFlair(e,r){return B(q,q,"m",Lo).call(q,{...e,postId:ce(e.postId)},r)}static async removePostFlair(e,r,n){return B(q,q,"m",Wo).call(q,e,r,void 0,n)}static async removeUserFlair(e,r,n){return B(q,q,"m",Wo).call(q,e,void 0,r,n)}};q=Ft,Lo=async function(e,r){await a.redditAPIPlugins.Flair.SelectFlair({subreddit:e.subredditName,flairTemplateId:e.flairTemplateId??"",text:e.text??"",name:e.username,link:e.postId,backgroundColor:e.backgroundColor??"",textColor:e.textColor??"dark",cssClass:e.cssClass??"",returnRtjson:"none"},r)},pl=async function(e,r,n){if(!r.length)return[];if(r.length>100)throw new Error("Unexpected input: flairs array cannot be longer than 100 entries.");let s=",",o=r.map(u=>{for(let g in u)if(u[g]?.includes(s))throw new Error(`Unexpected input: ${g} cannot contain the "," character`);return[u.username,u.text||"",u.cssClass||""].join(s)}).join(`
|
|
4
|
+
`);return(await a.redditAPIPlugins.Flair.FlairCsv({subreddit:e,flairCsv:o},n)).result},Wo=async function(e,r,n,i){await a.redditAPIPlugins.Flair.SelectFlair({subreddit:e,name:n??"",link:r??"",flairTemplateId:"",backgroundColor:"",text:"",textColor:"",cssClass:"",returnRtjson:"none"},i)};function sf(t){if(m(t,"Flair text color is required"),t==="light"||t==="dark")return t;throw new Error(`Invalid flair text color: ${t}`)}function of(t){if(!t||t.length===0||t==="transparent")return"transparent";if(/^#([A-Fa-f0-9]{6})$/.test(t))return t;throw new Error(`Invalid flair background color: ${t}`)}function af(t){if(t==="all"||t==="text"||t==="emoji")return t;throw new Error(`Invalid allowable content: ${t}`)}import"@devvit/protos";import{Block as bl,UIResponse as gf}from"@devvit/protos";var Vo=Xo(yl(),1);var Go=t=>"text"in t?t.text:pf(t.richtext),pf=t=>t instanceof Et?t.build():typeof t=="object"?JSON.stringify(t):t;var y=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},h=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},yn,Hi,bn,ji,vn,Gi,Vi,$i,wr,zi,Ki,qi,Ji,Zi,Qi,Pt,Xi,Yi,yr,kn,It,_n,En,Cn,xt,St,Tt,Fn,Rt,Mt,Nt,Je,es,ts,An,Pn,N,wf={NONE:0,BLOCKS:1,UNRECOGNIZED:-1},Be=class t{constructor(e,r){yn.set(this,void 0),Hi.set(this,void 0),bn.set(this,void 0),ji.set(this,void 0),vn.set(this,void 0),Gi.set(this,void 0),Vi.set(this,void 0),$i.set(this,void 0),wr.set(this,void 0),zi.set(this,void 0),Ki.set(this,void 0),qi.set(this,void 0),Ji.set(this,void 0),Zi.set(this,void 0),Qi.set(this,void 0),Pt.set(this,void 0),Xi.set(this,void 0),Yi.set(this,void 0),yr.set(this,void 0),kn.set(this,void 0),It.set(this,void 0),_n.set(this,void 0),En.set(this,void 0),Cn.set(this,void 0),xt.set(this,void 0),St.set(this,void 0),Tt.set(this,void 0),Fn.set(this,void 0),Rt.set(this,void 0),Mt.set(this,void 0),Nt.set(this,void 0),Je.set(this,void 0),es.set(this,void 0),ts.set(this,void 0),An.set(this,void 0),Pn.set(this,void 0),N.set(this,void 0),re(this),m(e.id,"Post is missing id"),m(e.title,"Post is missing title"),m(e.createdUtc,"Post is missing created date"),m(e.author,"Post is missing author name"),m(e.subreddit,"Post is missing subreddit name"),m(e.subredditId,"Post is missing subreddit id"),m(e.url,"Post is missing url"),m(e.permalink,"Post is missing permalink"),y(this,yn,ce(`t3_${e.id}`),"f"),y(this,bn,e.author,"f"),y(this,Hi,e.authorFullname?ne(e.authorFullname):void 0,"f"),y(this,vn,ge(e.subredditId),"f"),y(this,Gi,e.subreddit,"f"),y(this,qi,e.score??0,"f"),y(this,Ji,e.numComments??0,"f"),y(this,Zi,e.numReports??0,"f");let n=new Date(0);n.setUTCSeconds(e.createdUtc),y(this,ji,n,"f"),y(this,$i,e.title,"f"),y(this,wr,e.selftext,"f"),y(this,zi,e.selftextHtml,"f"),y(this,Ki,e.url,"f"),y(this,Vi,e.permalink,"f"),e.thumbnail&&e.thumbnail!=="self"&&e.thumbnail!=="nsfw"&&e.thumbnailHeight!=null&&e.thumbnailWidth!=null&&y(this,Qi,{url:e.thumbnail,height:e.thumbnailHeight,width:e.thumbnailWidth},"f"),y(this,Pt,e.approved??!1,"f"),y(this,Xi,e.approvedAtUtc??0,"f"),y(this,Yi,e.bannedAtUtc??0,"f"),y(this,It,e.removed??!1,"f"),y(this,_n,e.removedBy,"f"),y(this,En,e.removedByCategory,"f"),y(this,yr,e.spam??!1,"f"),y(this,kn,e.stickied??!1,"f"),y(this,Cn,e.archived??!1,"f"),y(this,xt,e.edited??!1,"f"),y(this,St,e.locked??!1,"f"),y(this,Tt,e.over18??!1,"f"),y(this,Fn,e.quarantine??!1,"f"),y(this,Rt,e.spoiler,"f"),y(this,Mt,e.hidden??!1,"f"),y(this,Nt,e.ignoreReports??!1,"f"),y(this,Je,e.distinguished,"f"),y(this,ts,e.secureMedia,"f"),y(this,An,(e.modReports??[]).map(([i])=>i),"f"),y(this,Pn,(e.userReports??[]).map(([i])=>i),"f"),y(this,N,r,"f"),(e.linkFlairBackgroundColor||e.linkFlairCssClass||e.linkFlairText||e.linkFlairType||e.linkFlairTemplateId||e.linkFlairRichtext||e.linkFlairTextColor)&&y(this,es,{backgroundColor:e.linkFlairBackgroundColor,cssClass:e.linkFlairCssClass,text:e.linkFlairText,type:e.linkFlairType,templateId:e.linkFlairTemplateId,richtext:(e.linkFlairRichtext??[]).map(({e:i,t:s,a:o,u:d})=>({elementType:i,text:s,emojiRef:o,url:d})),textColor:e.linkFlairTextColor},"f")}get id(){return h(this,yn,"f")}get authorId(){return h(this,Hi,"f")}get authorName(){return h(this,bn,"f")}get subredditId(){return h(this,vn,"f")}get subredditName(){return h(this,Gi,"f")}get permalink(){return h(this,Vi,"f")}get title(){return h(this,$i,"f")}get body(){return h(this,wr,"f")}get bodyHtml(){return h(this,zi,"f")}get url(){return h(this,Ki,"f")}get thumbnail(){return h(this,Qi,"f")}get createdAt(){return h(this,ji,"f")}get score(){return h(this,qi,"f")}get numberOfComments(){return h(this,Ji,"f")}get numberOfReports(){return h(this,Zi,"f")}get approved(){return h(this,Pt,"f")}get approvedAtUtc(){return h(this,Xi,"f")}get bannedAtUtc(){return h(this,Yi,"f")}get spam(){return h(this,yr,"f")}get stickied(){return h(this,kn,"f")}get removed(){return h(this,It,"f")}get removedBy(){return h(this,_n,"f")}get removedByCategory(){return h(this,En,"f")}get archived(){return h(this,Cn,"f")}get edited(){return h(this,xt,"f")}get locked(){return h(this,St,"f")}get nsfw(){return h(this,Tt,"f")}get quarantined(){return h(this,Fn,"f")}get spoiler(){return h(this,Rt,"f")}get hidden(){return h(this,Mt,"f")}get ignoringReports(){return h(this,Nt,"f")}get distinguishedBy(){return h(this,Je,"f")}get comments(){return pe.getComments({postId:this.id},h(this,N,"f"))}get flair(){return h(this,es,"f")}get secureMedia(){return h(this,ts,"f")}get userReportReasons(){return h(this,Pn,"f")}get modReportReasons(){return h(this,An,"f")}toJSON(){return{id:this.id,authorId:this.authorId,authorName:this.authorName,subredditId:this.subredditId,subredditName:this.subredditName,permalink:this.permalink,title:this.title,body:this.body,bodyHtml:this.bodyHtml,url:this.url,thumbnail:this.thumbnail,score:this.score,numberOfComments:this.numberOfComments,numberOfReports:this.numberOfReports,createdAt:this.createdAt,approved:this.approved,spam:this.spam,stickied:this.stickied,removed:this.removed,removedBy:h(this,_n,"f"),removedByCategory:h(this,En,"f"),archived:this.archived,edited:this.edited,locked:this.locked,nsfw:this.nsfw,quarantined:this.quarantined,spoiler:this.spoiler,hidden:this.hidden,ignoringReports:this.ignoringReports,distinguishedBy:this.distinguishedBy,flair:this.flair,secureMedia:this.secureMedia,modReportReasons:h(this,An,"f"),userReportReasons:h(this,Pn,"f")}}isApproved(){return h(this,Pt,"f")}isSpam(){return h(this,yr,"f")}isStickied(){return h(this,kn,"f")}isRemoved(){return h(this,It,"f")}isArchived(){return h(this,Cn,"f")}isEdited(){return h(this,xt,"f")}isLocked(){return h(this,St,"f")}isNsfw(){return h(this,Tt,"f")}isQuarantined(){return h(this,Fn,"f")}isSpoiler(){return h(this,Rt,"f")}isHidden(){return h(this,Mt,"f")}isIgnoringReports(){return h(this,Nt,"f")}isDistinguishedBy(){return h(this,Je,"f")}async edit(e){let r=await t.edit({id:this.id,...e},h(this,N,"f"));y(this,wr,r.body,"f"),y(this,xt,r.edited,"f")}async setSuggestedCommentSort(e){await t.setSuggestedCommentSort({id:this.id,subredditId:h(this,vn,"f"),suggestedSort:e},h(this,N,"f"))}async setCustomPostPreview(e){await t.setCustomPostPreview({id:this.id,ui:e},h(this,N,"f"))}async setTextFallback(e){let r=await t.setTextFallback(e,this.id,h(this,N,"f"));y(this,wr,r.body,"f"),y(this,xt,r.edited,"f")}async addComment(e){return pe.submit({id:this.id,...e},h(this,N,"f"))}async delete(){return t.delete(this.id,h(this,N,"f"))}async approve(){await t.approve(this.id,h(this,N,"f")),y(this,Pt,!0,"f"),y(this,It,!1,"f")}async remove(e=!1){await t.remove(this.id,e,h(this,N,"f")),y(this,It,!0,"f"),y(this,yr,e,"f"),y(this,Pt,!1,"f")}async lock(){await t.lock(this.id,h(this,N,"f")),y(this,St,!0,"f")}async unlock(){await t.unlock(this.id,h(this,N,"f")),y(this,St,!1,"f")}async hide(){await t.hide(this.id,h(this,N,"f")),y(this,Mt,!0,"f")}async unhide(){await t.unhide(this.id,h(this,N,"f")),y(this,Mt,!1,"f")}async markAsNsfw(){await t.markAsNsfw(this.id,h(this,N,"f")),y(this,Tt,!0,"f")}async unmarkAsNsfw(){await t.unmarkAsNsfw(this.id,h(this,N,"f")),y(this,Tt,!1,"f")}async markAsSpoiler(){await t.markAsSpoiler(this.id,h(this,N,"f")),y(this,Rt,!0,"f")}async unmarkAsSpoiler(){await t.unmarkAsSpoiler(this.id,h(this,N,"f")),y(this,Rt,!1,"f")}async sticky(e){await t.sticky(this.id,e,h(this,N,"f"))}async unsticky(){await t.unsticky(this.id,h(this,N,"f"))}async distinguish(){let{distinguishedBy:e}=await t.distinguish(this.id,!1,h(this,N,"f"));y(this,Je,e,"f")}async distinguishAsAdmin(){let{distinguishedBy:e}=await t.distinguish(this.id,!0,h(this,N,"f"));y(this,Je,e,"f")}async undistinguish(){let{distinguishedBy:e}=await t.undistinguish(this.id,h(this,N,"f"));y(this,Je,e,"f")}async ignoreReports(){await t.ignoreReports(this.id,h(this,N,"f")),y(this,Nt,!0,"f")}async unignoreReports(){await t.unignoreReports(this.id,h(this,N,"f")),y(this,Nt,!1,"f")}async getAuthor(){return be.getByUsername(h(this,bn,"f"),h(this,N,"f"))}async crosspost(e){return t.crosspost({...e,postId:this.id},h(this,N,"f"))}addRemovalNote(e){return qe.addRemovalNote({itemIds:[h(this,yn,"f")],...e},h(this,N,"f"))}async getEnrichedThumbnail(){return yf({id:this.id},h(this,N,"f"))}static async getById(e,r){let n=a.redditAPIPlugins.LinksAndComments,i=Fr(e)?e:`t3_${e}`,s=await n.Info({subreddits:[],thingIds:[i]},r);if(!s.data?.children?.length)throw new Error("could not find post");let o=s.data.children[0];if(!o?.data)throw new Error("could not find post");return new t(o.data,r)}static async submit(e,r){let{runAs:n="APP"}=e,i=ae[n],s=i===ae.USER?a.userActionsPlugin:a.redditAPIPlugins.LinksAndComments,o;if("preview"in e){m(r,"Missing metadata in `SubmitPostOptions`"),i===ae.USER&&m(e.userGeneratedContent,"userGeneratedContent must be set in `SubmitPostOptions` when RunAs=USER for experience posts");let u=await new Se(()=>e.preview,void 0,{},r,void 0).buildBlocksUI(),g=bl.encode(u).finish(),{textFallback:p,..._}=e,I=p?Go(p):"",T={kind:"custom",sr:e.subredditName,richtextJson:(0,Vo.fromByteArray)(g),richtextFallback:I,..._,runAs:i};o=await s.SubmitCustomPost(T,r)}else o=await s.Submit({kind:"kind"in e?e.kind:"url"in e?"link":"self",sr:e.subredditName,richtextJson:"richtext"in e?fr(e.richtext):void 0,...e,runAs:i},r);if("kind"in e&&["image","video","videogif"].includes(e.kind)&&!o.json?.data?.id){if(e.kind==="image"&&"imageUrls"in e)throw new Error(`Image post type with ${e.imageUrls} is being created asynchronously and should be updated in the subreddit soon.`);if("videoPosterUrl"in e)throw new Error(`Post of ${e.kind} type with ${e.videoPosterUrl} is being created asynchronously and should be updated in the subreddit soon.`)}if(!o.json?.data?.id||o.json?.errors?.length)throw new Error(`failed to submit post - either post ID is empty or request failed with errors: ${o.json?.errors}`);return t.getById(`t3_${o.json.data.id}`,r)}static async crosspost(e,r){let{runAs:n="APP"}=e,i=ae[n],s=i===ae.USER?a.userActionsPlugin:a.redditAPIPlugins.LinksAndComments,{postId:o,subredditName:d,...l}=e,u=await s.Submit({kind:"crosspost",sr:d,crosspostFullname:ce(o),...l,runAs:i},r);if(!u.json?.data?.id||u.json?.errors?.length)throw new Error("failed to crosspost post");return t.getById(`t3_${u.json.data.id}`,r)}static async edit(e,r){let n=a.redditAPIPlugins.LinksAndComments,{id:i}=e,s;if("richtext"in e&&(s=fr(e.richtext)),(await n.EditUserText({thingId:i,text:"text"in e?e.text:"",richtextJson:s,runAs:ae.APP},r)).json?.errors?.length)throw new Error("Failed to edit post");return t.getById(i,r)}static async setSuggestedCommentSort(e,r){if(!(await fe.query("SetSuggestedSort","cf6052acc7fefaa65b710625b81dba8041f258313aafe9730e2a3dc855e5d10d",{input:{subredditId:e.subredditId,postId:e.id,sort:e.suggestedSort}},r)).data?.setSuggestedSort?.ok)throw new Error("Failed to set suggested sort")}static async setCustomPostPreview(e,r){if(!r)throw new Error("Failed to set custom post preview. Metadata not found");let n=a.redditAPIPlugins.LinksAndComments,i=new _t(e.ui),o=gf.fromJSON(await i.handle({events:[]},r)).blocks,d=(0,Vo.fromByteArray)(bl.encode(o).finish());await n.SetCustomPostPreview({thingId:e.id,bodyType:wf.BLOCKS,blocksRenderContent:d},r)}static async setTextFallback(e,r,n){if(!("text"in e)&&!("richtext"in e))throw new Error(`No text fallback provided for post ${r}.`);let i=a.redditAPIPlugins.LinksAndComments,s=Go(e);if((await i.EditCustomPost({thingId:r,richtextFallback:s},n)).json?.errors?.length)throw new Error("Failed to set post text fallback");return t.getById(r,n)}static async delete(e,r){await a.redditAPIPlugins.LinksAndComments.Del({id:e},r)}static async approve(e,r){await a.redditAPIPlugins.Moderation.Approve({id:e},r)}static async remove(e,r=!1,n){await a.redditAPIPlugins.Moderation.Remove({id:e,spam:r},n)}static async hide(e,r){await a.redditAPIPlugins.LinksAndComments.Hide({id:e},r)}static async unhide(e,r){await a.redditAPIPlugins.LinksAndComments.Unhide({id:e},r)}static async markAsNsfw(e,r){await a.redditAPIPlugins.LinksAndComments.MarkNSFW({id:e},r)}static async unmarkAsNsfw(e,r){await a.redditAPIPlugins.LinksAndComments.UnmarkNSFW({id:e},r)}static async markAsSpoiler(e,r){await a.redditAPIPlugins.LinksAndComments.Spoiler({id:e},r)}static async unmarkAsSpoiler(e,r){await a.redditAPIPlugins.LinksAndComments.Unspoiler({id:e},r)}static async sticky(e,r,n){await a.redditAPIPlugins.LinksAndComments.SetSubredditSticky({id:e,state:!0,num:r},n)}static async unsticky(e,r){await a.redditAPIPlugins.LinksAndComments.SetSubredditSticky({id:e,state:!1},r)}static async lock(e,r){await a.redditAPIPlugins.LinksAndComments.Lock({id:e},r)}static async unlock(e,r){await a.redditAPIPlugins.LinksAndComments.Unlock({id:e},r)}static async distinguish(e,r,n){let o=(await a.redditAPIPlugins.Moderation.Distinguish({id:e,how:r?"admin":"yes",sticky:!1},n)).json?.data?.things?.[0]?.data;return m(o),{distinguishedBy:o.distinguished}}static async undistinguish(e,r){let s=(await a.redditAPIPlugins.Moderation.Distinguish({id:e,how:"no",sticky:!1},r)).json?.data?.things?.[0]?.data;return m(s),{distinguishedBy:s.distinguished}}static async ignoreReports(e,r){await a.redditAPIPlugins.Moderation.IgnoreReports({id:e},r)}static async unignoreReports(e,r){await a.redditAPIPlugins.Moderation.UnignoreReports({id:e},r)}static getControversialPosts(e={},r){return this.getSortedPosts({...e,sort:"controversial"},r)}static getTopPosts(e={},r){return this.getSortedPosts({...e,sort:"top"},r)}static getSortedPosts(e,r){let n=a.redditAPIPlugins.Listings;return new j({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,fetch:async i=>{let s=await n.Sort({show:"all",sort:e.sort,t:e.timeframe,subreddit:e.subredditName,...i},r);return wn(s,r)}})}static getHotPosts(e={location:"GLOBAL"},r){let n=a.redditAPIPlugins.Listings;return new j({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,fetch:async i=>{let s=await n.Hot({g:e.location,show:"all",subreddit:e.subredditName,...i},r);return wn(s,r)}})}static getNewPosts(e,r){let n=a.redditAPIPlugins.Listings;return new j({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,fetch:async i=>{let s=await n.New({show:"all",subreddit:e.subredditName,...i},r);return wn(s,r)}})}static getRisingPosts(e,r){let n=a.redditAPIPlugins.Listings;return new j({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,fetch:async i=>{let s=await n.Rising({show:"all",subreddit:e.subredditName,...i},r);return wn(s,r)}})}static getPostsByUser(e,r){let n=a.redditAPIPlugins.Users;return new j({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,async fetch(i){let s=await n.UserWhere({username:e.username,where:"submitted",...i},r);return wn(s,r)}})}};yn=new WeakMap,Hi=new WeakMap,bn=new WeakMap,ji=new WeakMap,vn=new WeakMap,Gi=new WeakMap,Vi=new WeakMap,$i=new WeakMap,wr=new WeakMap,zi=new WeakMap,Ki=new WeakMap,qi=new WeakMap,Ji=new WeakMap,Zi=new WeakMap,Qi=new WeakMap,Pt=new WeakMap,Xi=new WeakMap,Yi=new WeakMap,yr=new WeakMap,kn=new WeakMap,It=new WeakMap,_n=new WeakMap,En=new WeakMap,Cn=new WeakMap,xt=new WeakMap,St=new WeakMap,Tt=new WeakMap,Fn=new WeakMap,Rt=new WeakMap,Mt=new WeakMap,Nt=new WeakMap,Je=new WeakMap,es=new WeakMap,ts=new WeakMap,An=new WeakMap,Pn=new WeakMap,N=new WeakMap;function wn(t,e){if(!t.data?.children)throw new Error("Listing response is missing children");return{children:t.data.children.map(n=>new Be(n.data,e)),before:t.data.before,after:t.data.after}}async function yf(t,e){let s=(await fe.query("GetThumbnailV2","81580ce4e23d748c5a59a1618489b559bf4518b6a73af41f345d8d074c8b2ce9",{id:t.id},e)).data?.postInfoById?.thumbnailV2;if(s){if(!s.image)return}else throw new Error("Failed to get thumbnail");return{attribution:s.attribution,image:{url:s.image.url,width:s.image.dimensions.width,height:s.image.dimensions.height},isObfuscatedDefault:s.isObfuscatedDefault,...s.obfuscatedImage&&{obfuscatedImage:{url:s.obfuscatedImage.url,width:s.obfuscatedImage.dimensions.width,height:s.obfuscatedImage.dimensions.height}}}}var ve=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},H=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},rs,In,ns,is,ss,os,as,Bt,cs,ds,ls,De,vl;(function(t){t.Custom="CUSTOM",t.Reddit="REDDIT",t.Instagram="INSTAGRAM",t.Twitter="TWITTER",t.Tiktok="TIKTOK",t.Twitch="TWITCH",t.Facebook="FACEBOOK",t.Youtube="YOUTUBE",t.Tumblr="TUMBLR",t.Spotify="SPOTIFY",t.Soundcloud="SOUNDCLOUD",t.Beacons="BEACONS",t.Linktree="LINKTREE",t.Discord="DISCORD",t.Venmo="VENMO",t.CashApp="CASH_APP",t.Patreon="PATREON",t.Kofi="KOFI",t.Paypal="PAYPAL",t.Cameo="CAMEO",t.Onlyfans="ONLYFANS",t.Substack="SUBSTACK",t.Kickstarter="KICKSTARTER",t.Indiegogo="INDIEGOGO",t.BuyMeACoffee="BUY_ME_A_COFFEE",t.Shopify="SHOPIFY"})(vl||(vl={}));var be=class t{constructor(e,r){rs.set(this,void 0),In.set(this,void 0),ns.set(this,void 0),is.set(this,void 0),ss.set(this,void 0),os.set(this,void 0),as.set(this,void 0),Bt.set(this,new Map),cs.set(this,void 0),ds.set(this,void 0),ls.set(this,void 0),De.set(this,void 0),re(this),m(e.id,"User ID is missing or undefined"),m(e.name,"Username is missing or undefined"),m(e.createdUtc,"User is missing created date"),ve(this,rs,ne(Dn(e.id)?e.id:`t2_${e.id}`),"f"),ve(this,In,e.name,"f"),ve(this,os,e.over18??!1,"f"),ve(this,as,e.isEmployee??!1,"f");let n=new Date(0);if(n.setUTCSeconds(e.createdUtc),ve(this,ns,n,"f"),ve(this,is,e.linkKarma??0,"f"),ve(this,ss,e.commentKarma??0,"f"),e.modPermissions)for(let[i,s]of Object.entries(e.modPermissions))H(this,Bt,"f").set(i,ml(s));ve(this,cs,new URL(e.subreddit?.url??"","https://www.reddit.com").toString(),"f"),ve(this,ds,e.subreddit?.url??"","f"),ve(this,ls,e.hasVerifiedEmail??!1,"f"),ve(this,De,r,"f")}get id(){return H(this,rs,"f")}get username(){return H(this,In,"f")}get createdAt(){return H(this,ns,"f")}get linkKarma(){return H(this,is,"f")}get commentKarma(){return H(this,ss,"f")}get nsfw(){return H(this,os,"f")}get isAdmin(){return H(this,as,"f")}get modPermissions(){return H(this,Bt,"f")}get url(){return H(this,cs,"f")}get permalink(){return H(this,ds,"f")}get hasVerifiedEmail(){return H(this,ls,"f")}toJSON(){return{id:this.id,username:this.username,createdAt:this.createdAt,linkKarma:this.linkKarma,commentKarma:this.commentKarma,nsfw:this.nsfw,modPermissionsBySubreddit:Object.fromEntries(this.modPermissions)}}async getModPermissionsForSubreddit(e){if(H(this,Bt,"f").has(e))return H(this,Bt,"f").get(e);let r=await t.getSubredditUsersByType({subredditName:e,type:"moderators",username:this.username},H(this,De,"f")).all();if(r.length===0)return[];let n=r[0].modPermissions.get(e)??[];return n.length>0&&H(this,Bt,"f").set(e,n),n}getComments(e){return pe.getCommentsByUser({username:this.username,...e},H(this,De,"f"))}getPosts(e){return Be.getPostsByUser({username:this.username,...e},H(this,De,"f"))}async getUserFlairBySubreddit(e){let r=await Ft.getUserFlairBySubreddit({subreddit:e,name:H(this,In,"f")},H(this,De,"f"));return r.users[0]?Ho(r.users[0]):void 0}getSnoovatarUrl(){return t.getSnoovatarUrl(this.username,H(this,De,"f"))}async getSocialLinks(){let n=await fe.query("GetUserSocialLinks","2aca18ef5f4fc75fb91cdaace3e9aeeae2cb3843b5c26ad511e6f01b8521593a",{name:this.username},H(this,De,"f"));return n.data?.user?.profile?.socialLinks?n.data.user.profile.socialLinks.map(i=>({...i,handle:i.handle??void 0})):[]}static async getById(e,r){let n=await kl(e,r);return n==null?void 0:t.getByUsername(n,r)}static async getByUsername(e,r){let n=a.redditAPIPlugins.Users;try{let i=await n.UserAbout({username:e},r);if(i.data?.id)return new t(i.data,r)}catch(i){if(i instanceof Error&&i.message.includes("404 Not Found"))return;throw i}}static async getFromMetadata(e,r){m(r);let n=r?.[e]?.values[0];return n?t.getById(ne(n),r):Promise.resolve(void 0)}static getSubredditUsersByType(e,r){let n=a.redditAPIPlugins.Subreddits;return new j({hasMore:!0,pageSize:e.pageSize,limit:e.limit,after:e.after,before:e.before,fetch:async i=>{let s=await n.AboutWhere({where:e.type,user:e.username,subreddit:e.subredditName,show:"all",...i},r);return vf(s,e.subredditName,r)}})}static async createRelationship(e,r){let n=a.redditAPIPlugins.Users,{type:i,subredditName:s,username:o,permissions:d,...l}=e,u=await n.Friend({type:i,subreddit:s,name:o,permissions:d?Uo(d):void 0,...l},r);if(u.json?.errors?.length)throw new Error(u.json.errors.join(`
|
|
5
|
+
`))}static async removeRelationship(e,r){await a.redditAPIPlugins.Users.Unfriend({type:e.type,subreddit:e.subredditName,name:e.username},r)}static async setModeratorPermissions(e,r,n,i){let o=await a.redditAPIPlugins.Users.SetPermissions({subreddit:r,name:e,type:"moderator",permissions:Uo(n)},i);if(o.json?.errors?.length)throw new Error(o.json.errors.join(`
|
|
6
|
+
`))}static async getSnoovatarUrl(e,r){return(await fe.query("GetSnoovatarUrlByName","c47fd42345af268616d2d8904b56856acdc05cf61d3650380f539ad7d596ac0c",{username:e},r)).data?.redditorInfoByName?.snoovatarIcon?.url}static getOverview(e,r){let n=a.redditAPIPlugins.Users;return new j({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,async fetch(i){let s=await n.UserWhere({username:e.username,where:"overview",...i},r);return bf(s,r)}})}};rs=new WeakMap,In=new WeakMap,ns=new WeakMap,is=new WeakMap,ss=new WeakMap,os=new WeakMap,as=new WeakMap,Bt=new WeakMap,cs=new WeakMap,ds=new WeakMap,ls=new WeakMap,De=new WeakMap;function bf(t,e){if(!t.data?.children)throw new Error("Listing response is missing children");return{children:t.data.children.map(n=>{if(n.kind==="t3")return new Be(n.data,e);if(n.kind==="t1")return new pe(n.data,e);throw new Error(`Type ${n.kind} is not supported`)}),before:t.data.before,after:t.data.after}}async function vf(t,e,r){let n=a.redditAPIPlugins.Users;if(!t.data?.children)throw new Error("Listing response is missing children");let i=t.data.children.map(g=>(m(g.data?.id,"User id is still from listing data"),g.data.id)),s=100,o=[];for(let g=0;g<i.length;g+=s)o.push(i.slice(g,g+s));let l=(await Promise.all(o.map(g=>n.UserDataByAccountIds({ids:g.join(",")},r)))).reduce((g,p)=>({...g,...p.users}),{});return{children:t.data.children.map(g=>{let p=g.data?.id;m(p,"User id is missing from listing");let _=l[p];return m(_,"User data is missing from response"),new be({id:p,name:_.name,linkKarma:_.linkKarma,commentKarma:_.commentKarma,createdUtc:_.createdUtc,over18:_.profileOver18,snoovatarSize:[],modPermissions:{[e]:g.data?.modPermissions??[]}},r)}),before:t.data.before,after:t.data.after}}async function kl(t,e){return(await a.redditAPIPlugins.Users.UserDataByAccountIds({ids:t},e))?.users?.[t]?.name}async function _l(t){m(t);let e=t?.[C.Username]?.values[0];if(e)return e;let r=t?.[C.User]?.values[0];if(r)return kl(r,t)}var k=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},b=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},S,br,us,xn,Sn,hs,fs,Tn,ms,ps,Rn,Dt,gs,ws,vr,Ot,Ut,Ze,kr,Qe,ys,bs,vs,ks,_s,Es,Cs,Lt,K,Fs,$o,pe=class{constructor(e,r){br.set(this,void 0),us.set(this,void 0),xn.set(this,void 0),Sn.set(this,void 0),hs.set(this,void 0),fs.set(this,void 0),Tn.set(this,void 0),ms.set(this,void 0),ps.set(this,void 0),Rn.set(this,void 0),Dt.set(this,void 0),gs.set(this,void 0),ws.set(this,void 0),vr.set(this,void 0),Ot.set(this,void 0),Ut.set(this,void 0),Ze.set(this,void 0),kr.set(this,void 0),Qe.set(this,void 0),ys.set(this,void 0),bs.set(this,void 0),vs.set(this,void 0),ks.set(this,void 0),_s.set(this,void 0),Es.set(this,void 0),Cs.set(this,void 0),Lt.set(this,void 0),K.set(this,void 0),re(this),m(e.id,"Comment id is null or undefined"),m(e.body,"Comment body is null or undefined"),m(e.createdUtc,"Comment is missing created date"),m(e.author,"Comment author is null or undefined"),m(e.parentId,"Comment parentId is null or undefined"),m(e.linkId,"Comment linkId is null or undefined"),m(e.permalink,"Comment permalink is null or undefined"),m(e.subreddit,"Comment is missing subreddit name"),m(e.subredditId,"Comment is missing subreddit id"),k(this,br,jt(`t1_${e.id}`),"f"),k(this,us,e.authorFullname?ne(e.authorFullname):void 0,"f"),k(this,xn,e.author,"f"),k(this,Sn,e.body,"f"),k(this,ms,ge(e.subredditId),"f"),k(this,ps,e.subreddit,"f"),k(this,fs,Ss(e.parentId)?jt(e.parentId):ce(e.parentId),"f"),k(this,Tn,ce(e.linkId),"f"),k(this,vr,e.edited??!1,"f"),k(this,Ot,e.locked??!1,"f"),k(this,Ut,e.removed??!1,"f"),k(this,Ze,e.stickied??!1,"f"),k(this,Dt,e.approved??!1,"f"),k(this,gs,e.approvedAtUtc??0,"f"),k(this,ws,e.bannedAtUtc??0,"f"),k(this,kr,e.spam??!1,"f"),k(this,Qe,e.distinguished,"f"),k(this,ys,e.numReports??0,"f"),k(this,bs,e.collapsedBecauseCrowdControl??!1,"f"),k(this,vs,e.score??0,"f"),k(this,ks,e.permalink,"f"),k(this,Cs,new URL(e.permalink??"","https://www.reddit.com/").toString(),"f"),k(this,Lt,e.ignoreReports??!1,"f"),k(this,_s,(e.modReports??[]).map(([i])=>i),"f"),k(this,Es,(e.userReports??[]).map(([i])=>i),"f");let n=new Date(0);n.setUTCSeconds(e.createdUtc),k(this,hs,n,"f"),k(this,Rn,b(S,S,"m",Fs).call(S,{postId:b(this,Tn,"f"),commentId:b(this,br,"f")},r),"f"),k(this,K,r,"f")}get id(){return b(this,br,"f")}get authorId(){return b(this,us,"f")}get authorName(){return b(this,xn,"f")}get subredditId(){return b(this,ms,"f")}get subredditName(){return b(this,ps,"f")}get body(){return b(this,Sn,"f")}get createdAt(){return b(this,hs,"f")}get parentId(){return b(this,fs,"f")}get postId(){return b(this,Tn,"f")}get replies(){return b(this,Rn,"f")}get distinguishedBy(){return b(this,Qe,"f")}get locked(){return b(this,Ot,"f")}get stickied(){return b(this,Ze,"f")}get removed(){return b(this,Ut,"f")}get approved(){return b(this,Dt,"f")}get approvedAtUtc(){return b(this,gs,"f")}get bannedAtUtc(){return b(this,ws,"f")}get spam(){return b(this,kr,"f")}get edited(){return b(this,vr,"f")}get numReports(){return b(this,ys,"f")}get collapsedBecauseCrowdControl(){return b(this,bs,"f")}get score(){return b(this,vs,"f")}get permalink(){return b(this,ks,"f")}get userReportReasons(){return b(this,Es,"f")}get modReportReasons(){return b(this,_s,"f")}get url(){return b(this,Cs,"f")}get ignoringReports(){return b(this,Lt,"f")}toJSON(){return{id:this.id,authorName:this.authorName,subredditId:this.subredditId,subredditName:this.subredditName,body:this.body,createdAt:this.createdAt,parentId:this.parentId,postId:this.postId,replies:this.replies,approved:this.approved,locked:this.locked,removed:this.removed,stickied:this.stickied,spam:this.spam,edited:this.edited,distinguishedBy:this.distinguishedBy,numReports:this.numReports,collapsedBecauseCrowdControl:this.collapsedBecauseCrowdControl,score:this.score,permalink:this.permalink,modReportReasons:this.modReportReasons,userReportReasons:this.userReportReasons,url:this.url,ignoringReports:this.ignoringReports}}isLocked(){return b(this,Ot,"f")}isApproved(){return b(this,Dt,"f")}isRemoved(){return b(this,Ut,"f")}isSpam(){return b(this,kr,"f")}isStickied(){return b(this,Ze,"f")}isDistinguished(){return!!b(this,Qe,"f")}isEdited(){return b(this,vr,"f")}isIgnoringReports(){return b(this,Lt,"f")}async delete(){return S.delete(this.id,b(this,K,"f"))}async edit(e){let r=await S.edit({id:this.id,...e},b(this,K,"f"));return k(this,Sn,r.body,"f"),k(this,vr,r.edited,"f"),this}async approve(){await S.approve(this.id,b(this,K,"f")),k(this,Dt,!0,"f"),k(this,Ut,!1,"f")}async remove(e=!1){await S.remove(this.id,e,b(this,K,"f")),k(this,Ut,!0,"f"),k(this,kr,e,"f"),k(this,Dt,!1,"f")}async lock(){await S.lock(this.id,b(this,K,"f")),k(this,Ot,!0,"f")}async unlock(){await S.unlock(this.id,b(this,K,"f")),k(this,Ot,!1,"f")}async reply(e){return S.submit({id:this.id,...e},b(this,K,"f"))}async getAuthor(){return be.getByUsername(b(this,xn,"f"),b(this,K,"f"))}async distinguish(e=!1){let{distinguishedBy:r,stickied:n}=await S.distinguish(this.id,e,!1,b(this,K,"f"));k(this,Qe,r,"f"),k(this,Ze,n,"f")}async distinguishAsAdmin(e=!1){let{distinguishedBy:r,stickied:n}=await S.distinguish(this.id,e,!0,b(this,K,"f"));k(this,Qe,r,"f"),k(this,Ze,n,"f")}async undistinguish(){let{distinguishedBy:e,stickied:r}=await S.undistinguish(this.id,b(this,K,"f"));k(this,Qe,e,"f"),k(this,Ze,r,"f")}async ignoreReports(){await S.ignoreReports(this.id,b(this,K,"f")),k(this,Lt,!0,"f")}async unignoreReports(){await S.unignoreReports(this.id,b(this,K,"f")),k(this,Lt,!1,"f")}addRemovalNote(e){return qe.addRemovalNote({itemIds:[b(this,br,"f")],...e},b(this,K,"f"))}static async getById(e,r){let n=a.redditAPIPlugins.LinksAndComments,i=Ht(e)?e:`t1_${e}`,s=await n.Info({subreddits:[],thingIds:[i]},r);if(!s.data?.children?.[0]?.data)throw new Error("not found");return new S(s.data.children[0].data,r)}static getComments(e,r){let{postId:n,commentId:i,...s}=e;return b(S,S,"m",Fs).call(S,{postId:ce(n),commentId:i?jt(i):void 0,...s},r)}static async edit(e,r){let n=a.redditAPIPlugins.LinksAndComments,{id:i}=e,s;"richtext"in e&&(s=fr(e.richtext));let o=await n.EditUserText({thingId:i,text:"text"in e?e.text:"",richtextJson:s,runAs:ae.APP},r);if(o.json?.errors?.length)throw new Error("Failed to edit comment");let d=o.json?.data?.things?.[0]?.data;return m(d),new S(d,r)}static async delete(e,r){await a.redditAPIPlugins.LinksAndComments.Del({id:e},r)}static async approve(e,r){await a.redditAPIPlugins.Moderation.Approve({id:e},r)}static async remove(e,r=!1,n){await a.redditAPIPlugins.Moderation.Remove({id:e,spam:r},n)}static async lock(e,r){await a.redditAPIPlugins.LinksAndComments.Lock({id:e},r)}static async unlock(e,r){await a.redditAPIPlugins.LinksAndComments.Unlock({id:e},r)}static async submit(e,r){let{runAs:n="APP"}=e,i=ae[n],s=i===ae.USER?a.userActionsPlugin:a.redditAPIPlugins.LinksAndComments,{id:o}=e,d;"richtext"in e&&(d=fr(e.richtext));let l=await s.Comment({thingId:o,text:"text"in e?e.text:"",richtextJson:d,runAs:i},r);if(l.json?.errors?.length)throw new Error("failed to reply to comment");let u=l.json?.data?.things?.[0]?.data;return m(u),new S(u,r)}static async distinguish(e,r,n,i){let d=(await a.redditAPIPlugins.Moderation.Distinguish({id:e,how:n?"admin":"yes",sticky:r},i)).json?.data?.things?.[0]?.data;return m(d),{distinguishedBy:d.distinguished,stickied:!!d.stickied}}static async undistinguish(e,r){let s=(await a.redditAPIPlugins.Moderation.Distinguish({id:e,how:"no",sticky:!1},r)).json?.data?.things?.[0]?.data;return m(s),{distinguishedBy:s.distinguished,stickied:!!s.stickied}}static getCommentsByUser(e,r){let n=a.redditAPIPlugins.Users;return new j({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,async fetch(i){let s=await n.UserWhere({username:e.username,where:"comments",...i},r);return m(s.data,"Failed to get comments for user"),{children:s.data.children?.map(d=>new S(d.data,r))||[],before:s.data.before,after:s.data.after}}})}static async ignoreReports(e,r){await a.redditAPIPlugins.Moderation.IgnoreReports({id:e},r)}static async unignoreReports(e,r){await a.redditAPIPlugins.Moderation.UnignoreReports({id:e},r)}};S=pe,br=new WeakMap,us=new WeakMap,xn=new WeakMap,Sn=new WeakMap,hs=new WeakMap,fs=new WeakMap,Tn=new WeakMap,ms=new WeakMap,ps=new WeakMap,Rn=new WeakMap,Dt=new WeakMap,gs=new WeakMap,ws=new WeakMap,vr=new WeakMap,Ot=new WeakMap,Ut=new WeakMap,Ze=new WeakMap,kr=new WeakMap,Qe=new WeakMap,ys=new WeakMap,bs=new WeakMap,vs=new WeakMap,ks=new WeakMap,_s=new WeakMap,Es=new WeakMap,Cs=new WeakMap,Lt=new WeakMap,K=new WeakMap,Fs=function(e,r,n=0){return new j({limit:e.limit,pageSize:e.pageSize,fetch:async i=>{let s=i.limit,o=a.redditAPIPlugins.Listings,d=a.redditAPIPlugins.LinksAndComments,l=e.commentId;if(i.more)if(i.more.children.length){let _=i.more;(!s||s>100)&&(s=100);let I=_.children.splice(0,s),T=await d.MoreChildren({linkId:e.postId,children:I,sort:e.sort},r);if(!T.json?.data?.things?.length)return{children:[]};let{children:L}=b(S,S,"m",$o).call(S,T.json.data.things,e.postId,e,r);return{children:L,more:_.children.length?_:void 0}}else l=i.more.parentId,n=n+i.more.depth;let g=(await o.Comments({article:e.postId.substring(3),comment:l?.substring(3),limit:s,depth:e.depth,sort:e.sort},r)).listings?.[1]?.data?.children??[],p=g[0];return l&&p?.data?.replyList?.data&&(g=p.data.replyList.data.children),b(S,S,"m",$o).call(S,g,l??e.postId,e,r,n)}})},$o=function t(e,r,n,i,s=0){let o=[],d,l={};for(let u of e){if(!u.data||(u.data.depth!=null&&(u.data.depth=u.data.depth+s),u.data.depth!=null&&n.depth!=null&&u.data.depth>=n.depth))continue;let g=u.data.parentId?l[u.data.parentId]:void 0;if(u.kind==="t1"){if(u.data.name===r)continue;let p=new S(u.data,i);if(l[p.id]=p,k(p,Rn,b(S,S,"m",Fs).call(S,{...n,postId:p.postId,commentId:p.id},i,s),"f"),"replyList"in u.data&&u.data.replyList?.data){let{children:_,more:I}=b(S,S,"m",t).call(S,u.data.replyList.data.children,p.id,n,i,s);_.length&&p.replies.children.push(..._),I&&p.replies.setMore(I)}p.replies.preventInitialFetch(),g?g.replies.children.push(p):o.push(p)}else if(u.kind==="more"&&u.data.parentId&&u.data.depth!=null){let p={parentId:Ss(u.data.parentId)?jt(u.data.parentId):ce(u.data.parentId),children:u.data.children??[],depth:u.data.depth};g?g.replies.setMore(p):p.parentId===r&&(d=p)}}return{children:o,more:d}};import"@devvit/protos";var El=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},zo,kf,_f,Cl,Fl,Xe;(function(t){t.New="New",t.InProgress="InProgress",t.Archived="Archived",t.Appeals="Appeals",t.JoinRequests="JoinRequests",t.Filtered="Filtered"})(Xe||(Xe={}));var Ef={0:Xe.New,1:Xe.InProgress,2:Xe.Archived,3:Xe.Appeals,4:Xe.JoinRequests,5:Xe.Filtered},X;(function(t){t.Highlighted="Highlighted",t.Unhighlighted="Unhighlighted",t.Archived="Archived",t.Unarchived="Unarchived",t.ReportedToAdmins="ReportedToAdmins",t.Muted="Muted",t.Unmuted="Unmuted",t.Banned="Banned",t.Unbanned="Unbanned",t.Approved="Approved",t.Disapproved="Disapproved",t.Filtered="Filtered",t.Unfiltered="Unfiltered"})(X||(X={}));var Cf={0:X.Highlighted,1:X.Unhighlighted,2:X.Archived,3:X.Unarchived,4:X.ReportedToAdmins,5:X.Muted,6:X.Unmuted,7:X.Banned,8:X.Unbanned,9:X.Approved,10:X.Disapproved,11:X.Filtered,12:X.Unfiltered};kf=new WeakMap,zo=new WeakSet,_f=function({protoConversation:e,protoMessages:r,protoModActions:n}){return{...e,state:Ef[e.state],messages:El(this,zo,"m",Cl).call(this,e,r),modActions:El(this,zo,"m",Fl).call(this,e,n)}},Cl=function(e,r){let n={},i=e.objIds.filter(s=>s.key==="messages").map(({id:s})=>s);for(let s of i){let o=r[s];o&&(n[s]=o)}return n},Fl=function(e,r){let n={},i=e.objIds.filter(s=>s.key==="modActions").map(({id:s})=>s);for(let s of i){let o=r[s];o&&(n[s]={...o,actionType:Cf[o.actionTypeId]})}return n};var Ff,Af,Pf,If,xf,Sf;Ff=new WeakMap,Af=new WeakMap,Pf=new WeakMap,If=new WeakMap,xf=new WeakMap,Sf=new WeakMap;var Rf,Mf,Nf,Bf,Df,Of,Uf,Lf,Wf,Hf,jf,Gf,Vf,Ko;(function(t){t.Reports="reports",t.Spam="spam",t.Modqueue="modqueue",t.Unmoderated="unmoderated",t.Edited="edited"})(Ko||(Ko={}));Rf=new WeakMap,Mf=new WeakMap,Nf=new WeakMap,Bf=new WeakMap,Df=new WeakMap,Of=new WeakMap,Uf=new WeakMap,Lf=new WeakMap,Wf=new WeakMap,Hf=new WeakMap,jf=new WeakMap,Gf=new WeakMap,Vf=new WeakMap;async function Al(t,e){let s=(await fe.query("GetSubredditInfoById","315a9b75c22a017d526afdf2d274616946156451aacfd56dfb91e7ad3f7a2fde",{id:t},e)).data?.subredditInfoById;if(!s)throw new Error("subreddit info not found");return s}import{CommunityListWidget_CommunityData as uk,GetWidgetsResponse_WidgetItem as hk}from"@devvit/protos";var $f,zf,Kf,qf,Jf,Zf,Qf,Xf,Yf,em,tm,rm,nm,im,sm,om,am,cm,dm,lm,um,hm,fm,mm;$f=new WeakMap,zf=new WeakMap,Kf=new WeakMap,qf=new WeakMap;Jf=new WeakMap;Zf=new WeakMap,Qf=new WeakMap,Xf=new WeakMap;Yf=new WeakMap,em=new WeakMap;tm=new WeakMap,rm=new WeakMap,nm=new WeakMap;im=new WeakMap,sm=new WeakMap;om=new WeakMap,am=new WeakMap,cm=new WeakMap;dm=new WeakMap,lm=new WeakMap,um=new WeakMap,hm=new WeakMap,fm=new WeakMap;mm=new WeakMap;var pm,gm,wm,ym,bm,vm,km,_m,Em,Cm,Fm,Am,Pm,Im,xm,Sm,Tm,Rm,Pl;(function(t){t[t.SUBREDDIT_PERMISSIONS=0]="SUBREDDIT_PERMISSIONS",t[t.APPROVED_CONTRIBUTORS_ONLY=1]="APPROVED_CONTRIBUTORS_ONLY",t[t.MODS_ONLY=2]="MODS_ONLY"})(Pl||(Pl={}));pm=new WeakMap,gm=new WeakMap,wm=new WeakMap,ym=new WeakMap,bm=new WeakMap,vm=new WeakMap,km=new WeakMap,_m=new WeakMap,Em=new WeakMap;Cm=new WeakMap,Fm=new WeakMap,Am=new WeakMap,Pm=new WeakMap,Im=new WeakMap,xm=new WeakMap;Sm=new WeakMap,Tm=new WeakMap,Rm=new WeakMap;function ac(t){let e=Vt();return Al(t,e)}function cc(t){let e=Vt();return Be.getById(Gt(t),e)}async function Il(){let t=Vt();return _l(t)}function dc(t){let e=Vt();return pe.getById(Gt(t),e)}function lc(t){let e=Vt();return be.getSubredditUsersByType({type:"moderators",...t},e)}import{EffectType as f_}from"@devvit/protos";import{WebViewVisibility as p_}from"@devvit/protos";var Mm,Nm,Bm,Dm,Om,Um;Mm=new WeakMap,Nm=new WeakMap,Bm=new WeakMap,Dm=new WeakMap,Om=new WeakMap,Um=new WeakMap;import"@devvit/protos/payments.js";import{OrderStatus as et}from"@devvit/protos/payments.js";var Lm="devvit-";function Wm(t){return t.startsWith(Lm)}function As(t){return Object.fromEntries(Object.entries(t).filter(([e])=>!Wm(e)))}import{AccountingType as Ye}from"@devvit/protos/payments.js";var ke;(function(t){t.INSTANT="INSTANT",t.DURABLE="DURABLE",t.CONSUMABLE="CONSUMABLE",t.VALID_FOR_1D="VALID_FOR_1D",t.VALID_FOR_7D="VALID_FOR_7D",t.VALID_FOR_30D="VALID_FOR_30D",t.VALID_FOR_1Y="VALID_FOR_1Y",t.UNRECOGNIZED="UNRECOGNIZED"})(ke||(ke={}));var Hm={[ke.INSTANT]:Ye.ACCOUNTING_TYPE_INSTANT,[ke.DURABLE]:Ye.ACCOUNTING_TYPE_DURABLE,[ke.CONSUMABLE]:Ye.ACCOUNTING_TYPE_CONSUMABLE,[ke.VALID_FOR_1D]:Ye.ACCOUNTING_TYPE_VALID_FOR_1D,[ke.VALID_FOR_7D]:Ye.ACCOUNTING_TYPE_VALID_FOR_7D,[ke.VALID_FOR_30D]:Ye.ACCOUNTING_TYPE_VALID_FOR_30D,[ke.VALID_FOR_1Y]:Ye.ACCOUNTING_TYPE_VALID_FOR_1Y,[ke.UNRECOGNIZED]:Ye.UNRECOGNIZED};function jm(t){let e=Object.entries(Hm).find(([r,n])=>n===t);return e?e[0]:ke.UNRECOGNIZED}function Ps(t){m(t.price,"Product price is null or undefined");let e=t.images.icon;return{sku:t.sku,price:t.price.amount,accountingType:jm(t.accountingType),displayName:t.name,description:t.description,metadata:As(t.productMetadata),...e?{images:{icon:e}}:{}}}var Oe;(function(t){t.NEW="NEW",t.CREATED="CREATED",t.PAID="PAID",t.DELIVERED="DELIVERED",t.CANCELED="CANCELED",t.REVERTED="REVERTED",t.UNRECOGNIZED="UNRECOGNIZED"})(Oe||(Oe={}));function Gm(t){switch(t){case et.ORDER_STATUS_NEW:return Oe.NEW;case et.ORDER_STATUS_CREATED:return Oe.CREATED;case et.ORDER_STATUS_PAID:return Oe.PAID;case et.ORDER_STATUS_DELIVERED:return Oe.DELIVERED;case et.ORDER_STATUS_CANCELED:return Oe.CANCELED;case et.ORDER_STATUS_REVERTED:return Oe.REVERTED;case et.ORDER_STATUS_UNSPECIFIED:case et.UNRECOGNIZED:return Oe.UNRECOGNIZED}}function Is(t){return{id:t.id,status:Gm(t.status),createdAt:t.createdAt??null,updatedAt:t.updatedAt??null,products:t.products.map(Ps),metadata:As(t.metadata)}}import{PaymentsServiceDefinition as Vm}from"@devvit/protos/payments.js";var xs=a.use(Vm);a.addMenuItem({location:"post",label:"Get Payments Help",onPress:async(t,e)=>{let r=new URL("https://support.reddithelp.com/hc/en-us/requests/new?ticket_form_id=29770197409428&tf_29764567374740=devvit_product_not_working"),n=await Il();n&&r.searchParams.append("tf_360026362751",n);let i=e.postId;if(i){let s=i.replace("t3_","");if(s){let o=`https://www.reddit.com/r/${e.subredditName}/comments/${s}`;r.searchParams.append("tf_29770117862932",o)}}r.searchParams.append("tf_subject",`[${e.appName} v${e.appVersion}] Payments Help`),e.ui.navigateTo(r.toString())}});async function xl(t={}){let e={sku:"",buyer:"",metadata:{},status:0,...t,limit:t.limit||100,cursor:t.nextPageToken||""},r=await xs.GetOrders(e),n={orders:r.orders.map(Is)};return r.pageInfo?.hasNextPage&&(n.nextPage=r.pageInfo?.endCursor),n}function $m(t){return{...t,createdAt:t.createdAt?.toISOString()??null,updatedAt:t.updatedAt?.toISOString()??null}}function zm(t){return{...t,createdAt:t.createdAt?new Date(t.createdAt):null,updatedAt:t.updatedAt?new Date(t.updatedAt):null}}function Km(t,e={}){let[r,n]=kt(e.nextPageToken??""),{loading:i,data:s,error:o}=Gr(async()=>{let l=await xl({...e,nextPageToken:r});return{orders:l.orders.map($m),nextPageToken:l.nextPage||""}},{depends:r}),d={orders:(s?.orders??[]).map(zm)};return s?.nextPageToken&&(d=Object.assign(d,{nextPage:async()=>{n(s?.nextPageToken)}})),i?{...d,loading:!0,error:null}:o?{...d,loading:i,error:o}:{...d,loading:i,error:null}}import{EffectType as qm}from"@devvit/protos/types/devvit/ui/effects/v1alpha/effect.js";var _r,Mn,Nn,Er,qo=class{constructor(e,r){Cr(this,_r);Cr(this,Mn);Cr(this,Nn);this.state={};Cr(this,Er,e=>{Ue(this,Nn)&&console.debug(`[payments] ${e}`)});Bn(this,Nn,!!r.context._devvitContext?.debug.payments),Bn(this,_r,r.context),Bn(this,Mn,e),this.hookId=r.hookId,Ue(this,Er).call(this,`usePurchase hook created (${this.hookId})`)}async onUIEvent(e){if(e.orderResult&&e.hook===this.hookId){Ue(this,Er).call(this,`Received an order result: hookId: ${this.hookId}; Status: ${e.orderResult.status}; Order ID: ${e.orderResult.orderId}; Error Code: ${e.orderResult.errorCode}; Error Message: ${e.orderResult.errorMessage}`);let{status:r,errorCode:n,errorMessage:i,order:s,orderId:o}=e.orderResult;if(!s)throw new Error("Invalid response: missing original order");await Ue(this,Mn).call(this,{status:ra(r),errorCode:n,errorMessage:i,orderId:o,sku:s.skus[0],metadata:s.metadata})}}purchase(e,r={}){if(!e.trim())throw new Error("Invalid purchase; no SKU provided");Ue(this,Er).call(this,`Requesting a purchase for product: ${e}`);let n={[C.Post]:Ue(this,_r)._devvitContext?.postId??""};Ue(this,_r).emitEffect("createOrder",{type:qm.EFFECT_CREATE_ORDER,createOrder:{id:this.hookId,skus:[e],metadata:{...r,...n}}})}};_r=new WeakMap,Mn=new WeakMap,Nn=new WeakMap,Er=new WeakMap;function Jm(t){return Y({namespace:"payments",initializer:e=>new qo(t,e)})}async function Sl(t={}){let e={skus:t.skus||[],metadata:t.metadata||{}};return(await xs.GetProducts(e)).products.map(Ps)}function Zm(t,e={}){let[r,n]=kt(0),{loading:i,data:s,error:o}=Gr(async()=>Sl(e),{depends:r}),u={products:s??[],refetch:async()=>{n(g=>~g)}};return i?{...u,loading:!0,error:null}:o!=null?{...u,loading:!1,error:o}:{...u,loading:!1,error:null}}import{PaymentProcessorDefinition as Qm}from"@devvit/protos/payments.js";function Xm(t){a.provide(Qm),Object.assign(a.prototype,Ym(t))}function Ym(t){return{async FulfillOrder(e,r){if(e.order==null||e.order.products.length===0)return{};let n=Object.assign(Z({metadata:r}),z(r,e.order.metadata[C.Post])),i=Tl(e.order),s=await t.fulfillOrder(i,n);return!s||s.success?{acknowledged:!0}:{rejectionReason:s.reason}},async RefundOrder(e,r){if(e.order==null||!t.refundOrder)return{};let n=Object.assign(Z({metadata:r}),z(r)),i=Tl(e.order);return await t.refundOrder(i,n),{}}}}function Tl(t){let e=Is(t);if(e.products.length>1)throw new Error("Multi-product orders not supported");if(e.products.length===0)throw new Error("No products in order");return e}export{ta as OrderResultStatus,Xm as addPaymentHandler,xl as getOrders,Sl as getProducts,Km as useOrders,Jm as usePayments,Zm as useProducts};
|
|
7
7
|
/*! Bundled license information:
|
|
8
8
|
|
|
9
9
|
shallow-clone/index.js:
|