@devvit/public-api 0.11.20-next-2025-07-30-16-24-10-26641c67c.0 → 0.11.20-next-2025-07-30-17-03-36-c9e16f6ff.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/apis/reddit/RedditAPIClient.js +1 -1
  2. package/apis/reddit/models/Comment.d.ts +1 -1
  3. package/apis/reddit/models/Comment.d.ts.map +1 -1
  4. package/apis/reddit/models/Comment.js +1 -1
  5. package/apis/reddit/models/Flair.d.ts +1 -1
  6. package/apis/reddit/models/Flair.d.ts.map +1 -1
  7. package/apis/reddit/models/Flair.js +1 -1
  8. package/apis/reddit/models/Listing.d.ts +1 -1
  9. package/apis/reddit/models/Listing.d.ts.map +1 -1
  10. package/apis/reddit/models/ModMail.js +1 -1
  11. package/apis/reddit/models/ModNote.d.ts +1 -1
  12. package/apis/reddit/models/ModNote.d.ts.map +1 -1
  13. package/apis/reddit/models/ModNote.js +1 -1
  14. package/apis/reddit/models/Post.d.ts +1 -1
  15. package/apis/reddit/models/Post.d.ts.map +1 -1
  16. package/apis/reddit/models/Post.js +1 -1
  17. package/apis/reddit/models/PrivateMessage.d.ts +1 -1
  18. package/apis/reddit/models/PrivateMessage.d.ts.map +1 -1
  19. package/apis/reddit/models/PrivateMessage.js +1 -1
  20. package/apis/reddit/models/Subreddit.d.ts +1 -1
  21. package/apis/reddit/models/Subreddit.d.ts.map +1 -1
  22. package/apis/reddit/models/Subreddit.js +1 -1
  23. package/apis/reddit/models/User.d.ts +1 -1
  24. package/apis/reddit/models/User.d.ts.map +1 -1
  25. package/apis/reddit/models/User.js +1 -1
  26. package/apis/reddit/models/Vault.d.ts +1 -1
  27. package/apis/reddit/models/Vault.d.ts.map +1 -1
  28. package/apis/reddit/models/Vault.js +1 -1
  29. package/meta.min.json +89 -75
  30. package/package.json +8 -8
  31. package/public-api.min.js +6 -6
  32. package/public-api.min.js.map +4 -4
  33. package/types/tid.d.ts +47 -0
  34. package/types/tid.d.ts.map +1 -0
  35. package/types/tid.js +114 -0
package/public-api.min.js CHANGED
@@ -1,9 +1,9 @@
1
- var jc=Object.create;var ad=Object.defineProperty;var Vc=Object.getOwnPropertyDescriptor;var Wc=Object.getOwnPropertyNames;var Gc=Object.getPrototypeOf,Jc=Object.prototype.hasOwnProperty;var dd=i=>{throw TypeError(i)};var ai=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var zc=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Wc(e))!Jc.call(i,s)&&s!==t&&ad(i,s,{get:()=>e[s],enumerable:!(r=Vc(e,s))||r.enumerable});return i};var ld=(i,e,t)=>(t=i!=null?jc(Gc(i)):{},zc(e||!i||!i.__esModule?ad(t,"default",{value:i,enumerable:!0}):t,i));var Vo=(i,e,t)=>e.has(i)||dd("Cannot "+t);var n=(i,e,t)=>(Vo(i,e,"read from private field"),t?t.call(i):e.get(i)),l=(i,e,t)=>e.has(i)?dd("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),a=(i,e,t,r)=>(Vo(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),h=(i,e,t)=>(Vo(i,e,"access private method"),t);var ud=(i,e,t,r)=>({set _(s){a(i,e,s,t)},get _(){return n(i,e,r)}});var ba=ai((Wb,Fl)=>{var up=Object.prototype.toString;Fl.exports=function(e){if(e===void 0)return"undefined";if(e===null)return"null";var t=typeof e;if(t==="boolean")return"boolean";if(t==="string")return"string";if(t==="number")return"number";if(t==="symbol")return"symbol";if(t==="function")return hp(e)?"generatorfunction":"function";if(cp(e))return"array";if(bp(e))return"buffer";if(yp(e))return"arguments";if(pp(e))return"date";if(mp(e))return"error";if(gp(e))return"regexp";switch(wl(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(fp(e))return"generator";switch(t=up.call(e),t){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 t.slice(8,-1).toLowerCase().replace(/\s/g,"")};function wl(i){return typeof i.constructor=="function"?i.constructor.name:null}function cp(i){return Array.isArray?Array.isArray(i):i instanceof Array}function mp(i){return i instanceof Error||typeof i.message=="string"&&i.constructor&&typeof i.constructor.stackTraceLimit=="number"}function pp(i){return i instanceof Date?!0:typeof i.toDateString=="function"&&typeof i.getDate=="function"&&typeof i.setDate=="function"}function gp(i){return i instanceof RegExp?!0:typeof i.flags=="string"&&typeof i.ignoreCase=="boolean"&&typeof i.multiline=="boolean"&&typeof i.global=="boolean"}function hp(i,e){return wl(i)==="GeneratorFunction"}function fp(i){return typeof i.throw=="function"&&typeof i.return=="function"&&typeof i.next=="function"}function yp(i){try{if(typeof i.length=="number"&&typeof i.callee=="function")return!0}catch(e){if(e.message.indexOf("callee")!==-1)return!0}return!1}function bp(i){return i.constructor&&typeof i.constructor.isBuffer=="function"?i.constructor.isBuffer(i):!1}});var Il=ai((Gb,Al)=>{"use strict";var xl=Symbol.prototype.valueOf,vp=ba();function kp(i,e){switch(vp(i)){case"array":return i.slice();case"object":return Object.assign({},i);case"date":return new i.constructor(Number(i));case"map":return new Map(i);case"set":return new Set(i);case"buffer":return wp(i);case"symbol":return Fp(i);case"arraybuffer":return Pp(i);case"float32array":case"float64array":case"int16array":case"int32array":case"int8array":case"uint16array":case"uint32array":case"uint8clampedarray":case"uint8array":return Sp(i);case"regexp":return Cp(i);case"error":return Object.create(i);default:return i}}function Cp(i){let e=i.flags!==void 0?i.flags:/\w+$/.exec(i)||void 0,t=new i.constructor(i.source,e);return t.lastIndex=i.lastIndex,t}function Pp(i){let e=new i.constructor(i.byteLength);return new Uint8Array(e).set(new Uint8Array(i)),e}function Sp(i,e){return new i.constructor(i.buffer,i.byteOffset,i.length)}function wp(i){let e=i.length,t=Buffer.allocUnsafe?Buffer.allocUnsafe(e):Buffer.from(e);return i.copy(t),t}function Fp(i){return xl?Object(xl.call(i)):{}}Al.exports=kp});var Tl=ai((Jb,El)=>{"use strict";El.exports=function(e){return e!=null&&typeof e=="object"&&Array.isArray(e)===!1}});var Ml=ai((zb,Ol)=>{"use strict";var xp=Tl();function Rl(i){return xp(i)===!0&&Object.prototype.toString.call(i)==="[object Object]"}Ol.exports=function(e){var t,r;return!(Rl(e)===!1||(t=e.constructor,typeof t!="function")||(r=t.prototype,Rl(r)===!1)||r.hasOwnProperty("isPrototypeOf")===!1)}});var Bl=ai((qb,Ul)=>{"use strict";var Ap=Il(),Ip=ba(),Ep=Ml();function va(i,e){switch(Ip(i)){case"object":return Tp(i,e);case"array":return Rp(i,e);default:return Ap(i)}}function Tp(i,e){if(typeof e=="function")return e(i);if(e||Ep(i)){let t=new i.constructor;for(let r in i)t[r]=va(i[r],e);return t}return i}function Rp(i,e){let t=new i.constructor(i.length);for(let r=0;r<i.length;r++)t[r]=va(i[r],e);return t}Ul.exports=va});var xc=ai(wo=>{"use strict";wo.byteLength=og;wo.toByteArray=dg;wo.fromByteArray=cg;var Be=[],we=[],sg=typeof Uint8Array<"u"?Uint8Array:Array,Xa="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Zt=0,wc=Xa.length;Zt<wc;++Zt)Be[Zt]=Xa[Zt],we[Xa.charCodeAt(Zt)]=Zt;var Zt,wc;we[45]=62;we[95]=63;function Fc(i){var e=i.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=i.indexOf("=");t===-1&&(t=e);var r=t===e?0:4-t%4;return[t,r]}function og(i){var e=Fc(i),t=e[0],r=e[1];return(t+r)*3/4-r}function ag(i,e,t){return(e+t)*3/4-t}function dg(i){var e,t=Fc(i),r=t[0],s=t[1],o=new sg(ag(i,r,s)),d=0,c=s>0?r-4:r,m;for(m=0;m<c;m+=4)e=we[i.charCodeAt(m)]<<18|we[i.charCodeAt(m+1)]<<12|we[i.charCodeAt(m+2)]<<6|we[i.charCodeAt(m+3)],o[d++]=e>>16&255,o[d++]=e>>8&255,o[d++]=e&255;return s===2&&(e=we[i.charCodeAt(m)]<<2|we[i.charCodeAt(m+1)]>>4,o[d++]=e&255),s===1&&(e=we[i.charCodeAt(m)]<<10|we[i.charCodeAt(m+1)]<<4|we[i.charCodeAt(m+2)]>>2,o[d++]=e>>8&255,o[d++]=e&255),o}function lg(i){return Be[i>>18&63]+Be[i>>12&63]+Be[i>>6&63]+Be[i&63]}function ug(i,e,t){for(var r,s=[],o=e;o<t;o+=3)r=(i[o]<<16&16711680)+(i[o+1]<<8&65280)+(i[o+2]&255),s.push(lg(r));return s.join("")}function cg(i){for(var e,t=i.length,r=t%3,s=[],o=16383,d=0,c=t-r;d<c;d+=o)s.push(ug(i,d,d+o>c?c:d+o));return r===1?(e=i[t-1],s.push(Be[e>>2]+Be[e<<4&63]+"==")):r===2&&(e=(i[t-2]<<8)+i[t-1],s.push(Be[e>>10]+Be[e>>4&63]+Be[e<<2&63]+"=")),s.join("")}});var fe={APP:0,USER:1,UNSPECIFIED:2};function p(i,e){if(i==null)throw Error(e??"Expected nonnullish value.")}function Et(i,e){if(!i)throw Error(e)}var ee;(function(i){i.COMMENT="t1_",i.ACCOUNT="t2_",i.LINK="t3_",i.MESSAGE="t4_",i.SUBREDDIT="t5_",i.AWARD="t6_"})(ee||(ee={}));function qe(i){return i.startsWith(ee.COMMENT)}function _s(i){return i.startsWith(ee.ACCOUNT)}function Tt(i){return i.startsWith(ee.LINK)}function cd(i){return i.startsWith(ee.MESSAGE)}function md(i){return i.startsWith(ee.SUBREDDIT)}function pd(i){return i.startsWith(ee.AWARD)}function qc(i){Et(qe(i),`Expected comment id to start with ${ee.COMMENT}, got ${i}}`)}function $c(i){Et(_s(i),`Expected account id to start with ${ee.ACCOUNT}, got ${i}}`)}function Kc(i){Et(Tt(i),`Expected link id to start with ${ee.LINK}, got ${i}}`)}function Xc(i){Et(cd(i),`Expected message id to start with ${ee.MESSAGE}, got ${i}}`)}function Zc(i){Et(md(i),`Expected subreddit id to start with ${ee.SUBREDDIT}, got ${i}}`)}function Qc(i){Et(pd(i),`Expected award id to start with ${ee.AWARD}, got ${i}}`)}function di(i){return qc(i),i}function te(i){return $c(i),i}function de(i){return Kc(i),i}function Yc(i){return Xc(i),i}function K(i){return Zc(i),i}function em(i){return Qc(i),i}function ye(i){if(qe(i))return di(i);if(_s(i))return te(i);if(Tt(i))return de(i);if(cd(i))return Yc(i);if(md(i))return K(i);if(pd(i))return em(i);throw new Error(`Expected thing id to start with ${Object.values(ee).join(", ")} got ${i}}`)}function Wo(i){return qe(i)}import*as k from"@devvit/protos";var Hs=class{constructor(e){}};var tm=/\.[a-zA-Z]{2,}$/;function gd(i){if(i.length>25)throw new Error("The size of requestedFetchDomains is limited to 25 domains.")}function hd(i){let e=new Set;for(let t of i)try{if(!tm.test(t))throw new Error("The domain does not have a valid top-level domain.");t.includes("://")||(t="http://"+t);let s=new URL(t).hostname.replace(/^www\./,"");e.add(s)}catch(r){throw new Error(`Failed to determine hostname from requested domain: '${t}'. ${r}`)}return Array.from(e)}var $e;(function(i){i.Installation="installation",i.App="app"})($e||($e={}));import"@devvit/protos/json/devvit/events/v1alpha/events.js";import{DeletionReason as $g,EventSource as Kg}from"@devvit/protos/json/devvit/events/v1alpha/events.js";import{CrowdControlLevel as Zg,DistinguishType as Qg}from"@devvit/protos/json/devvit/reddit/v2alpha/postv2.js";import{SubredditRating as eh,SubredditType as th}from"@devvit/protos/json/devvit/reddit/v2alpha/subredditv2.js";function Rt(i,e=new Set){for(let t of i){if(t.type==="group"){Rt(t.fields,e);continue}let r=t.name;if(e.has(r))throw new Error(`Duplicate field name: ${r}`);e.add(r)}im(i)}function im(i){for(let e of i)if(e.type==="string"&&e.isSecret&&e.scope!==$e.App)throw`Invalid setting: only app settings can be secrets. Add "scope: SettingScope.App" to field "${e.name}"`}var Ke=Object.freeze({INTERVAL:0,FORM:1,STATE:2,CHANNEL:3,WEB_VIEW:4});var gh=["3rd-party","activity","add-emoji","add","add-media","add-to-feed","admin","ads","ai","align-center","align-left","align-right","all","ama","appearance","approve","archived","aspect-ratio","aspect-rectangle","attach","audience","audio","author","automod","avatar-style","award","back","backup","ban","best","block","blockchain","bold","boost","bot","bounce","brand-awareness","browse","browser","cake","calendar","camera","campaign","caret-down","caret-left","caret-right","caret-up","chat","chat-group","chat-new","chat-private","checkbox-dismiss","checkbox","checkmark","chrome","clear","client-list","close","closed-captioning","code-block","code-inline","coins-color-old","coins","collapse-left","collapse-right","collectible-expressions","collection","comment","comments","communities","community","confidence","contest","controversial","conversion","copy-clipboard","crop","crosspost","crowd-control","custom-feed","customize","dashboard","day","delete-column","delete","delete-row","devvit","discover","dismiss-all","distinguish","down-arrow","down","download","downvote","downvotes","drag","drugs","duplicate","edit","effect","embed","emoji","end-live-chat","error","expand-left","expand-right","external","feed-video","filter","format","forward","funnel","gif-post","gold","hashtag","heart","help","hide","history","home","hot","ignore-reports","image-post","inbox","info","insert-column-left","insert-column-right","insert-row-above","insert-row-below","internet","invite","italic","join","joined","jump-down","jump-up","karma","keyboard","kick","language","leave","left","link","link-post","list-bulleted","list-numbered","live-chat","live","load","location","lock","logout","loop","macro","mark-read","marketplace","mask","media-gallery","meme","menu","message","mic","mic-mute","mod","mod-mail","mod-mode","mod-mute","mod-overflow","mod-queue","mod-unmute","music","mute","new","night","no-internet","notification","notification-frequent","notification-off","nsfw","nsfw-language","nsfw-violence","official","original","overflow-caret","overflow-horizontal","overflow-vertical","pause","payment","peace","pending-posts","phone","pin","play","poll-post","popular","posts","powerup","predictions","premium","privacy","profile","qa","qr-code","quarantined","quote","r-slash","radar","radio-button","raise-hand","random","ratings-everyone","ratings-mature","ratings-nsfw","ratings-violence","recovery-phrase","refresh","removal-reasons","remove","reply","report","reverse","rich-text","right","rising","rotate","rotate-image","rpan","rules","safari","save","save-view","saved","saved-response","search","self","send","settings","severity","share","share-new","show","side-menu","skipback10","skipforward10","sort-az","sort","sort-price","sort-za","spam","spoiler","sponsored","spreadsheet","star","statistics","status-live","sticker","strikethrough","subtract","superscript","swap-camera","swipe-back","swipe-down","swipe","swipe-up","table","tag","tap","text","text-post","text-size","toggle","tools","top","topic-activism","topic-addictionsupport","topic-advice","topic-animals","topic-anime","topic-art","topic-beauty","topic-business","topic-careers","topic-cars","topic-celebrity","topic-craftsdiy","topic-crypto","topic-culture","topic-diy","topic-entertainment","topic-ethics","topic-family","topic-fashion","topic","topic-fitness","topic-food","topic-funny","topic-gender","topic-health","topic-help","topic-history","topic-hobbies","topic-homegarden","topic-internet","topic-law","topic-learning","topic-lifestyle","topic-marketplace","topic-mature","topic-mensfashion","topic-menshealth","topic-meta","topic-military","topic-movies","topic-music","topic-news","topic-other","topic-outdoors","topic-pets","topic-photography","topic-places","topic-podcasts","topic-politics","topic-programming","topic-reading","topic-religion","topic-science","topic-sexorientation","topic-sports","topic-style","topic-tabletop","topic-technology","topic-television","topic-traumasupport","topic-travel","topic-videogaming","topic-womensfashion","topic-womenshealth","translate","translation-off","trim","u-slash","unban","undo","unheart","unlock","unmod","unpin","unstar","unverified","up-arrow","up","upload","upvote","upvotes","user","user-note","users","vault","verified","video-camera","video-feed","video-post","video-thread","video-transcription","view-card","view-classic","view-compact","view-grid","view-sort","views","volume","wallet","warning","webhook","whale","wiki-ban","wiki","wiki-unban","world","coins-color","powerup-color","powerup-fill-color","share-android","share-ios","video-live-1","video-live-fill-1","video-live","volume-mute","binoculars","caret-updown","planet","telescope"];import{DeletionReason as bh,EventSource as vh}from"@devvit/protos";import{AppSettingsDefinition as km,GetFieldsResponse as Cm}from"@devvit/protos";import{FormFieldType as be}from"@devvit/protos";function Le(i){return i.map(e=>{switch(e.type){case"string":return rm(e);case"image":return nm(e);case"paragraph":return sm(e);case"number":return om(e);case"select":return am(e);case"boolean":return dm(e);case"group":return lm(e);default:throw new Error("Unknown field type.")}})}function rm(i){return{defaultValue:{fieldType:be.STRING,stringValue:i.defaultValue},disabled:i.disabled,fieldConfig:{stringConfig:{placeholder:i.placeholder}},fieldId:i.name,fieldType:be.STRING,helpText:i.helpText,label:i.label,required:i.required,isSecret:i.isSecret}}function nm(i){return{disabled:i.disabled,fieldId:i.name,fieldType:be.IMAGE,helpText:i.helpText,label:i.label,required:i.required}}function sm(i){return{defaultValue:{fieldType:be.PARAGRAPH,stringValue:i.defaultValue},disabled:i.disabled,fieldConfig:{paragraphConfig:{lineHeight:i.lineHeight,placeholder:i.placeholder}},fieldId:i.name,fieldType:be.PARAGRAPH,helpText:i.helpText,label:i.label,required:i.required}}function om(i){return{defaultValue:{fieldType:be.NUMBER,numberValue:i.defaultValue},disabled:i.disabled,fieldConfig:{numberConfig:{}},fieldId:i.name,fieldType:be.NUMBER,helpText:i.helpText,label:i.label,required:i.required}}function am(i){return{defaultValue:{fieldType:be.SELECTION,selectionValue:{values:i.defaultValue??[]}},disabled:i.disabled,fieldConfig:{selectionConfig:{choices:i.options,multiSelect:i.multiSelect}},fieldId:i.name,fieldType:be.SELECTION,helpText:i.helpText,label:i.label,required:i.required}}function dm(i){return{defaultValue:{fieldType:be.BOOLEAN,boolValue:i.defaultValue},disabled:i.disabled,fieldId:i.name,fieldType:be.BOOLEAN,helpText:i.helpText,label:i.label}}function lm(i){return{fieldId:"",fieldType:be.GROUP,fieldConfig:{groupConfig:{fields:Le(i.fields)}},label:i.label,helpText:i.helpText}}function O(i,e){u.prototype[i]=e}import{ValidateFormResponse as vm}from"@devvit/protos";import{RealtimeSubscriptionStatus as yd}from"@devvit/protos";var P=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",PostData:"devvit-post-data",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"});var fd;(function(i){i.Blocks="blocks",i.EmitSnapshots="emitSnapshots",i.EmitState="emitState",i.Realtime="realtime",i.Runtime="runtime",i.Surface="surface",i.UseAsync="useAsync",i.Payments="payments",i.Bootstrap="bootstrap",i.WebView="webView"})(fd||(fd={}));function bd(i){function e(t){let s=i.currentHookIndex,o=i.getCurrentComponentState(),d=i.getPreviousComponentState(),c=i.metadata[P.App]?.values[0];p(c,"useChannel - app is missing from Context");let m=i.metadata[P.Installation]?.values[0];p(m,"useChannel - installation is missing from Context");async function y(N){let B=o[s].channel;if(o[s].active)if(o[s].connected)await i.realtime.send(B,N);else throw Error(`Failed to send to channel '${B}'; it is active but not yet connected`);else throw Error(`Cannot send a message over inactive channel: ${B}`)}function v(){if(!o[s].active){let N=o[s].channel;o[s].active=!0,i.addRealtimeChannel(N)}}function f(){if(o[s].active){let N=o[s].channel;o[s].active=!1,i.removeRealtimeChannel(N)}}function S(N){return async()=>{let B;switch(N.status){case yd.REALTIME_SUBSCRIBED:o[s].connected=!0,B=t.onSubscribed?.();break;case yd.REALTIME_UNSUBSCRIBED:o[s].connected=!1,B=t.onUnsubscribed?.();break;default:B=t.onMessage(N.event?.data?.msg);break}await B}}let b={channel:`${c}:${m}:${t.name}`,active:!1,connected:!1,preventCallback:!1,type:Ke.CHANNEL};s in o?b=o[s]:s in d&&(b=d[s]);let _=i.realtimeEvent;i.isInitialRender?b.active=!1:_&&b.active&&_.event.channel===b.channel&&(b.preventCallback||i.runHook(S(_)),i.rerenderIn(0)),o[s]=b,i.currentHookIndex++;let A=0;return b.active&&b.connected?A=2:b.active&&!b.connected?A=1:!b.active&&b.connected?A=3:!b.active&&!b.connected&&(A=4),{subscribe:v,unsubscribe:f,send:y,status:A}}return e}import{FormFieldType as li}from"@devvit/protos";function Go(i){switch(i.fieldType){case li.STRING:return i.stringValue;case li.IMAGE:return i.stringValue;case li.PARAGRAPH:return i.stringValue;case li.NUMBER:return i.numberValue;case li.BOOLEAN:return i.boolValue;case li.SELECTION:return i.selectionValue?.values??[];default:return}}function Xe(i){return Object.keys(i).reduce((e,t)=>{let r=Go(i[t]);return r!==void 0&&(e[t]=r),e},{})}function vd(i){function e(t,r){let s=i.currentHookIndex,o=i.getCurrentComponentKey(),d=i.getCurrentComponentState(),c=i.getPreviousComponentState(),m=`form.hook.${o}.${s}`,y={formKey:m,preventSubmit:!1,type:Ke.FORM};s in d?y=d[s]:s in c&&(y=c[s]),d[s]=y,i.forms.set(m,t);let v=i.formSubmittedEvent;return v&&!y.preventSubmit&&v.formId===m&&i.runHook(async()=>{let f=r(Xe(v.results));f&&f instanceof Promise&&await f,i.rerenderIn(0)}),d[s].preventSubmit=!1,i.currentHookIndex++,m}return e}function kd(i){function e(t,r){let s=i.currentHookIndex,o=i.getCurrentComponentState(),d=i.getPreviousComponentState(),c=100,m=Math.max(c,r),y={lastRun:void 0,running:!1,preventCallback:!1,type:Ke.INTERVAL};s in o?y=o[s]:s in d&&(y=d[s]);function v(){r<c&&console.error(`useInterval delay must be at least ${c}ms. Your interval of ${r}ms was automatically extended.`);for(let[S,b]of Object.entries(o))if(S!==s.toString()&&b?.type===Ke.INTERVAL&&b?.running)throw new Error("Only one useInterval hook may be running at a time");o[s]={running:!0,lastRun:o[s]?.lastRun??Date.now(),preventCallback:!1,type:Ke.INTERVAL},i.rerenderIn(m)}function f(){o[s].running=!1,o[s].lastRun=void 0,o[s].preventCallback=!1}return i.isEffectRender&&y.running&&(y.preventCallback||(y.lastRun===void 0||y.lastRun+m<Date.now())&&i.runHook(async()=>{let S=t();S&&S instanceof Promise&&await S,y.lastRun=Date.now()}),i.rerenderIn(m)),y.preventCallback=!1,o[s]=y,i.currentHookIndex++,{start:v,stop:f}}return e}function Cd(i){function e(t){let r=i.currentHookIndex,s=i.getCurrentComponentState(),o=i.getPreviousComponentState();if(r in s)return i.currentHookIndex++,[s[r],d];if(i.isInitialRender||!(r in o)){let c=t instanceof Function?t():t;if(c instanceof Promise)throw(async()=>{s[r]=await c,i.currentHookIndex=0})();s[r]=c}else s[r]=o[r];function d(c){if(i.isRendering)throw new Error("Cannot call setState while rendering.");s[r]=c instanceof Function?c(s[r]):c}return i.currentHookIndex++,[s[r],d]}return e}var $o={now(){return new Date}};function Pd(i){return`__autocache__${i}`}function Sd(i){return`__lock__${i}`}var cm=300,mm=1e3,js=5e3,Jo=3,wd=.1,Fd=1e3,pm=3e4;function xd(i){if(i.error)throw new Error(i.error);return i.value}var Ze,Qe,ve,ui,z,Ad,Id,Ed,zo,Td,Rd,qo,Od,Vs=class{constructor(e,t,r=$o){l(this,z);l(this,Ze);l(this,Qe,{});l(this,ve);l(this,ui);a(this,Ze,e),a(this,ui,t),a(this,ve,r)}async cache(e,t){a(this,Qe,n(this,ui).__cache=n(this,ui).__cache??{}),h(this,z,Od).call(this,t);let r=h(this,z,Ad).call(this,t.key);if(r!==void 0)return r;let s=await h(this,z,qo).call(this,t.key),o=await h(this,z,Id).call(this,t,s,e);return xd(o)}};Ze=new WeakMap,Qe=new WeakMap,ve=new WeakMap,ui=new WeakMap,z=new WeakSet,Ad=function(e){let t=n(this,Qe)[e];if(t){let r=n(this,ve).now().getTime(),s=t?.error&&t?.errorTime&&t.errorCount<Jo&&Math.random()<wd&&t.errorTime+Fd<r;if(t?.expires&&t.expires<r&&t.checkedAt+Fd<r||s){delete n(this,Qe)[e];return}else return xd(t)}},Id=async function(e,t,r){let s=t?.expires,o=s?h(this,z,Rd).call(this,s):1;return!t||t?.error&&t.errorCount<Jo&&wd>Math.random()||o>Math.random()?h(this,z,Ed).call(this,e,t,r):t},Ed=async function(e,t,r){let s=Sd(e.key),o=n(this,ve).now().getTime(),d=new Date(o+e.ttl/2);if(await n(this,Ze).set(s,"1",{expiration:d,nx:!0}))return h(this,z,Td).call(this,e.key,t,r,e.ttl);if(t)return t;{let m=n(this,ve).now();return h(this,z,zo).call(this,m,e.key,e.ttl)}},zo=async function(e,t,r){let s=Math.min(r,mm),o=await h(this,z,qo).call(this,t);if(o)return o;if(n(this,ve).now().getTime()-e.getTime()>=s)throw new Error(`Cache request timed out trying to get data at key: ${t}`);return await new Promise(d=>setTimeout(d,cm)),h(this,z,zo).call(this,e,t,r)},Td=async function(e,t,r,s){let o=n(this,ve).now().getTime()+s;t=t??{value:null,expires:o,errorCount:0,error:null,errorTime:null,checkedAt:0};try{t.value=await r(),t.error=null,t.errorCount=0,t.errorTime=null}catch(d){t.value=null,t.error=d.message??"Unknown error",t.errorTime=n(this,ve).now().getTime(),t.errorCount++}return n(this,Qe)[e]=t,await n(this,Ze).set(Pd(e),JSON.stringify(t),{expiration:new Date(o+pm)}),t.error&&t.errorCount<Jo&&await n(this,Ze).del(Sd(e)),t},Rd=function(e){let t=n(this,ve).now().getTime(),r=e-t;return r<0?1:r<1e3?.1:r<2e3?.01:r<3e3?.001:0},qo=async function(e){let t=await n(this,Ze).get(Pd(e));if(t){let r=JSON.parse(t);return r.checkedAt=n(this,ve).now().getTime(),n(this,Qe)[e]=r,r}},Od=function(e){e.ttl<js&&(console.warn(`Cache TTL cannot be less than ${js} milliseconds! Updating ttl value of ${e.ttl} to ${js}.`),e.ttl=js)};function Md(i,e,t=$o){let r=new Vs(i,e,t);return r.cache.bind(r)}function Ud(i){new URL(i.slice(0,i.indexOf(",")))}var ci,pi,Bd,Dd,mi=class{constructor(){l(this,pi);l(this,ci,{});a(this,ci,u.webViewAssets)}getURL(e,t){return typeof e=="string"?h(this,pi,Bd).call(this,e,t??{webView:!1}):h(this,pi,Dd).call(this,e,t??{webView:!1})}};ci=new WeakMap,pi=new WeakSet,Bd=function(e,t){let r=t.webView?n(this,ci)[e]:u.assets[e];if(r)return r;try{return Ud(e),e}catch{return""}},Dd=function(e,t){let r={},s=[],o=t.webView?n(this,ci):u.assets;if(o)for(let d of e)if(o[d])r[d]=o[d];else try{Ud(d),r[d]=d}catch{s.push(d)}else s=e;if(s.length>0)throw new Error(`The following assets were missing from the assets list: ${s.join(", ")}`);return r};var Ye,gi=class{constructor(e){l(this,Ye);a(this,Ye,e)}async get(e){let{messages:t}=await u.kvStorePlugin.Get({keys:[e]},n(this,Ye));try{if(t[e])return JSON.parse(t[e])}catch{return}}async put(e,t){let r={};r[e]=JSON.stringify(t),await u.kvStorePlugin.Put({messages:r},n(this,Ye))}async delete(e){await u.kvStorePlugin.Del({keys:[e]},n(this,Ye))}async list(){let{keys:e}=await u.kvStorePlugin.List({filter:"*"},n(this,Ye));return e}};Ye=new WeakMap;var Ur,hi=class{constructor(e){l(this,Ur);a(this,Ur,e)}async upload(e){let t=await u.mediaPlugin.Upload(e,n(this,Ur));if(!t.mediaId)throw new Error("unable to get mediaId via uploads");return{mediaId:t.mediaId,mediaUrl:t.mediaUrl}}};Ur=new WeakMap;var Br,fi=class{constructor(e){l(this,Br);a(this,Br,e)}async add(e){await u.modLogPlugin.Add(e,n(this,Br))}};Br=new WeakMap;var Dr,yi=class{constructor(e){l(this,Dr);a(this,Dr,e)}async send(e,t){await u.realtimePlugin.Send({channel:e,data:{msg:t}},n(this,Dr))}};Dr=new WeakMap;import"@devvit/protos";var g,Nr,Lr,_r,bi=class{constructor(e){l(this,g);l(this,Nr);l(this,Lr);l(this,_r);a(this,g,e),a(this,Nr,new Gs(e))}get modMail(){return n(this,Nr)}getSubredditById(e){return le.getById(ye(e),n(this,g))}getSubredditInfoById(e){return _d(e,n(this,g))}getSubredditByName(e){return le.getByName(e,n(this,g))}getSubredditInfoByName(e){return Hd(e,n(this,g))}addSubredditRemovalReason(e,t){return le.addRemovalReason(e,t.title,t.message,n(this,g))}getSubredditRemovalReasons(e){return le.getRemovalReasons(e,n(this,g))}async getCurrentSubredditName(){let e=n(this,g)?.[P.SubredditName]?.values[0];if(e)return e;let t=n(this,g)?.[P.Subreddit]?.values[0],r=await Ko(K(t),n(this,g));if(!r)throw new Error("Couldn't get current subreddit's name");return r}async getCurrentSubreddit(){let e=await le.getFromMetadata(n(this,g));if(!e)throw new Error("Couldn't get current subreddit");return e}getPostById(e){return G.getById(ye(e),n(this,g))}submitPost(e){return G.submit(e,n(this,g))}crosspost(e){return G.crosspost(e,n(this,g))}getUserById(e){return C.getById(ye(e),n(this,g))}getUserByUsername(e){return C.getByUsername(e,n(this,g))}async getCurrentUsername(){return n(this,_r)??a(this,_r,Nd(n(this,g))),n(this,_r)}async getCurrentUser(){return n(this,Lr)??a(this,Lr,this.getCurrentUsername().then(e=>e?C.getByUsername(e,n(this,g)):void 0)),n(this,Lr)}getAppUser(){return C.getFromMetadata(P.AppUser,n(this,g))}async getSnoovatarUrl(e){let t=await this.getCurrentUsername();if(t&&e===t){let r=n(this,g)?.[P.UserSnoovatarUrl]?.values[0];if(r)return r}return C.getSnoovatarUrl(e,n(this,g))}getCommentById(e){return Q.getById(ye(e),n(this,g))}getComments(e){return Q.getComments(e,n(this,g))}getCommentsByUser(e){return Q.getCommentsByUser(e,n(this,g))}submitComment(e){return Q.submit({...e,id:ye(e.id)},n(this,g))}getControversialPosts(e){return G.getControversialPosts(e,n(this,g))}getTopPosts(e){return G.getTopPosts(e,n(this,g))}getHotPosts(e){return G.getHotPosts(e,n(this,g))}getNewPosts(e){return G.getNewPosts(e,n(this,g))}getRisingPosts(e){return G.getRisingPosts(e,n(this,g))}getPostsByUser(e){return G.getPostsByUser(e,n(this,g))}getCommentsAndPostsByUser(e){return C.getOverview(e,n(this,g))}getModerationLog(e){return Ws(e,n(this,g))}getApprovedUsers(e){return C.getSubredditUsersByType({type:"contributors",...e},n(this,g))}approveUser(e,t){return C.createRelationship({username:e,subredditName:t,type:"contributor"},n(this,g))}removeUser(e,t){return C.removeRelationship({username:e,subredditName:t,type:"contributor"},n(this,g))}getWikiContributors(e){return C.getSubredditUsersByType({type:"wikicontributors",...e},n(this,g))}addWikiContributor(e,t){return C.createRelationship({username:e,subredditName:t,type:"wikicontributor"},n(this,g))}removeWikiContributor(e,t){return C.removeRelationship({username:e,subredditName:t,type:"wikicontributor"},n(this,g))}getBannedUsers(e){return C.getSubredditUsersByType({type:"banned",...e},n(this,g))}banUser(e){return C.createRelationship({username:e.username,subredditName:e.subredditName,type:"banned",banReason:e.reason,banMessage:e.message,note:e.note,duration:e.duration,banContext:e.context},n(this,g))}unbanUser(e,t){return C.removeRelationship({username:e,subredditName:t,type:"banned"},n(this,g))}getBannedWikiContributors(e){return C.getSubredditUsersByType({type:"wikibanned",...e},n(this,g))}banWikiContributor(e){return C.createRelationship({...e,type:"wikibanned"},n(this,g))}unbanWikiContributor(e,t){return C.removeRelationship({username:e,subredditName:t,type:"wikibanned"},n(this,g))}getModerators(e){return C.getSubredditUsersByType({type:"moderators",...e},n(this,g))}inviteModerator(e){return C.createRelationship({type:"moderator_invite",subredditName:e.subredditName,username:e.username,permissions:e.permissions??[]},n(this,g))}revokeModeratorInvite(e,t){return C.removeRelationship({username:e,subredditName:t,type:"moderator_invite"},n(this,g))}removeModerator(e,t){return C.removeRelationship({type:"moderator",subredditName:t,username:e},n(this,g))}setModeratorPermissions(e,t,r){return C.setModeratorPermissions(e,t,r,n(this,g))}getMutedUsers(e){return C.getSubredditUsersByType({type:"muted",...e},n(this,g))}muteUser(e){return C.createRelationship({...e,type:"muted"},n(this,g))}unmuteUser(e,t){return C.removeRelationship({username:e,subredditName:t,type:"muted"},n(this,g))}getModNotes(e){return ke.get(e,n(this,g))}deleteModNote(e){return ke.delete(e,n(this,g))}addModNote(e){let t={...e,redditId:e.redditId?ye(e.redditId):void 0};return ke.add(t,n(this,g))}addRemovalNote(e){return ke.addRemovalNote(e,n(this,g))}async sendPrivateMessage(e){return Ot.send(e,n(this,g))}async sendPrivateMessageAsSubreddit(e){return Ot.sendAsSubreddit(e,n(this,g))}async approve(e){if(qe(e))return Q.approve(e,n(this,g));if(Tt(e))return G.approve(e,n(this,g));throw new Error("id must start with either t1_ or t3_")}async remove(e,t){if(qe(e))return Q.remove(e,t,n(this,g));if(Tt(e))return G.remove(e,t,n(this,g));throw new Error("id must start with either t1_ or t3_")}async getPostFlairTemplates(e){return ne.getPostFlairTemplates(e,n(this,g))}async getUserFlairTemplates(e){return ne.getUserFlairTemplates(e,n(this,g))}async createPostFlairTemplate(e){return ne.createPostFlairTemplate(e,n(this,g))}async createUserFlairTemplate(e){return ne.createUserFlairTemplate(e,n(this,g))}async editFlairTemplate(e){return ne.editFlairTemplate(e,n(this,g))}async deleteFlairTemplate(e,t){return ne.deleteFlairTemplate(e,t,n(this,g))}async setUserFlair(e){return ce.setUserFlair(e,n(this,g))}async setUserFlairBatch(e,t){return ce.setUserFlairBatch(e,t,n(this,g))}async removeUserFlair(e,t){return ce.removeUserFlair(e,t,n(this,g))}async setPostFlair(e){return ce.setPostFlair(e,n(this,g))}async removePostFlair(e,t){return ce.removePostFlair(e,de(t),n(this,g))}async getWidgets(e){return ie.getWidgets(e,n(this,g))}async deleteWidget(e,t){return ie.delete(e,t,n(this,g))}async addWidget(e){return ie.add(e,n(this,g))}async reorderWidgets(e,t){return ie.reorder(e,t,n(this,g))}async getWikiPage(e,t){return ue.getPage(e,t,n(this,g))}async getWikiPages(e){return ue.getPages(e,n(this,g))}async createWikiPage(e){return ue.createPage(e,n(this,g))}async updateWikiPage(e){return ue.updatePage(e,n(this,g))}getWikiPageRevisions(e){return ue.getPageRevisions(e,n(this,g))}async revertWikiPage(e,t,r){return ue.revertPage(e,t,r,n(this,g))}async getWikiPageSettings(e,t){return ue.getPageSettings(e,t,n(this,g))}async updateWikiPageSettings(e){return ue.updatePageSettings(e,n(this,g))}async addEditorToWikiPage(e,t,r){return ue.addEditor(e,t,r,n(this,g))}async removeEditorFromWikiPage(e,t,r){return ue.removeEditor(e,t,r,n(this,g))}getMessages(e){return Ot.getMessages(e,n(this,g))}markAllMessagesAsRead(){return Ot.markAllAsRead(n(this,g))}report(e,t){return u.redditAPIPlugins.LinksAndComments.Report({reason:t.reason,thingId:e.id,srName:e.subredditName,usernames:e.authorName},n(this,g))}getModQueue(e){return le.aboutLocation({...e,location:"modqueue"},n(this,g))}getReports(e){return le.aboutLocation({...e,location:"reports"},n(this,g))}getSpam(e){return le.aboutLocation({...e,location:"spam"},n(this,g))}getUnmoderated(e){return le.aboutLocation({...e,location:"unmoderated"},n(this,g))}getEdited(e){return le.aboutLocation({...e,location:"edited"},n(this,g))}getVaultByAddress(e){return Wd(e,n(this,g))}getVaultByUserId(e){return Gd(ye(e),n(this,g))}getSubredditLeaderboard(e){return jd(e,n(this,g))}getSubredditStyles(e){return Vd(e,n(this,g))}async subscribeToCurrentSubreddit(){let e=await this.getCurrentSubreddit();await u.redditAPIPlugins.Subreddits.Subscribe({action:"sub",actionSource:"",srName:e.name,sr:"",skipInitialDefaults:!0},n(this,g))}async unsubscribeFromCurrentSubreddit(){let e=await this.getCurrentSubreddit();await u.redditAPIPlugins.Subreddits.Subscribe({action:"unsub",actionSource:"",srName:e.name,sr:"",skipInitialDefaults:!1},n(this,g))}};g=new WeakMap,Nr=new WeakMap,Lr=new WeakMap,_r=new WeakMap;import{BitfieldOverflowBehavior as Xo,RedisKeyScope as Zo}from"@devvit/protos";function Hr(i){return i&&typeof i=="object"&&"message"in i&&i.message!==void 0&&typeof i.message=="string"?i.message.includes("redis: nil"):!1}var I,E,T,Qo=class{constructor(e,t,r){l(this,I);l(this,E);l(this,T);a(this,I,e),a(this,E,t),a(this,T,r)}async get(e){return await n(this,I).Get({key:e,transactionId:n(this,E)},n(this,T)),this}async multi(){await n(this,I).Multi(n(this,E),n(this,T))}async set(e,t,r){let s;return r?.expiration&&(s=Math.floor((r.expiration.getTime()-Date.now())/1e3),s<1&&(s=1)),await n(this,I).Set({key:e,value:t,nx:r?.nx===!0,xx:r?.xx===!0,expiration:s||0,transactionId:n(this,E)},n(this,T)),this}async del(...e){return await n(this,I).Del({keys:e,transactionId:n(this,E)},n(this,T)),this}async type(e){return await n(this,I).Type({key:e,transactionId:n(this,E)},n(this,T)),this}async exec(){let e=await n(this,I).Exec(n(this,E),n(this,T)),t=[];for(let r of e.response)r.members?t.push(r.members):r.nil!==void 0?t.push(null):r.num!==void 0?t.push(r.num):r.values!==void 0?t.push(r.values.values):r.str!==void 0?t.push(r.str):r.dbl!==void 0?t.push(r.dbl):r.bool!==void 0&&t.push(r.bool);return t}async discard(){await n(this,I).Discard(n(this,E),n(this,T))}async watch(...e){return await n(this,I).Watch({keys:e,transactionId:n(this,E)},n(this,T)),this}async unwatch(){return await n(this,I).Unwatch(n(this,E),n(this,T)),this}async getRange(e,t,r){return await n(this,I).GetRange({key:e,start:t,end:r,transactionId:n(this,E)},n(this,T)),this}async setRange(e,t,r){return await n(this,I).SetRange({key:e,offset:t,value:r,transactionId:n(this,E)},n(this,T)),this}async strlen(e){return this.strLen(e)}async strLen(e){return await n(this,I).Strlen({key:e,transactionId:n(this,E)},n(this,T)),this}async mget(e){return this.mGet(e)}async mGet(e){return await n(this,I).MGet({keys:e,transactionId:n(this,E)},n(this,T)),this}async mset(e){return this.mSet(e)}async mSet(e){let t=Object.entries(e).map(([r,s])=>({key:r,value:s}));return await n(this,I).MSet({kv:t,transactionId:n(this,E)},n(this,T)),this}async incrBy(e,t){return await n(this,I).IncrBy({key:e,value:t,transactionId:n(this,E)},n(this,T)),this}async expire(e,t){return await n(this,I).Expire({key:e,seconds:t,transactionId:n(this,E)},n(this,T)),this}async expireTime(e){return await n(this,I).ExpireTime({key:e,transactionId:n(this,E)},n(this,T)),this}async zAdd(e,...t){return await n(this,I).ZAdd({key:e,members:t,transactionId:n(this,E)},n(this,T)),this}async zScore(e,t){return await n(this,I).ZScore({key:{key:e,transactionId:n(this,E)},member:t},n(this,T)),this}async zRank(e,t){return await n(this,I).ZRank({key:{key:e,transactionId:n(this,E)},member:t},n(this,T)),this}async zIncrBy(e,t,r){return await n(this,I).ZIncrBy({key:e,member:t,value:r,transactionId:n(this,E)},n(this,T)),this}async zScan(e,t,r,s){let o={key:e,cursor:t,pattern:r,count:s,transactionId:n(this,E)};return await n(this,I).ZScan(o,n(this,T)),this}async zCard(e){return await n(this,I).ZCard({key:e,transactionId:n(this,E)},n(this,T)),this}async zRange(e,t,r,s){let o={rev:!1,byLex:!1,byScore:!1,offset:0,count:1e3};if(s?.reverse&&(o.rev=s.reverse),s?.by==="lex"?o.byLex=!0:s?.by==="score"&&(o.byScore=!0),s?.limit)if(o.byLex||o.byScore)o.offset=s.limit.offset,o.count=s.limit.count;else throw new Error("zRange parsing error: 'limit' only allowed when 'options.by' is 'lex' or 'score'");return await n(this,I).ZRange({key:{key:e,transactionId:n(this,E)},start:t+"",stop:r+"",...o},n(this,T)),this}async zRem(e,t){return await n(this,I).ZRem({key:{key:e,transactionId:n(this,E)},members:t},n(this,T)),this}async zRemRangeByLex(e,t,r){return await n(this,I).ZRemRangeByLex({key:{key:e,transactionId:n(this,E)},min:t,max:r},n(this,T)),this}async zRemRangeByRank(e,t,r){return await n(this,I).ZRemRangeByRank({key:{key:e,transactionId:n(this,E)},start:t,stop:r},n(this,T)),this}async zRemRangeByScore(e,t,r){return await n(this,I).ZRemRangeByScore({key:{key:e,transactionId:n(this,E)},min:t,max:r},n(this,T)),this}async hgetall(e){return this.hGetAll(e)}async hGetAll(e){return await n(this,I).HGetAll({key:e,transactionId:n(this,E)},n(this,T)),this}async hget(e,t){return this.hGet(e,t)}async hGet(e,t){return await n(this,I).HGet({key:e,field:t,transactionId:n(this,E)},n(this,T)),this}async hMGet(e,t){return await n(this,I).HMGet({key:e,fields:t,transactionId:n(this,E)},n(this,T)),this}async hset(e,t){return this.hSet(e,t)}async hSet(e,t){let r=Object.entries(t).map(([s,o])=>({field:s,value:o}));return await n(this,I).HSet({key:e,fv:r,transactionId:n(this,E)},n(this,T)),this}async hincrby(e,t,r){return this.hIncrBy(e,t,r)}async hIncrBy(e,t,r){return await n(this,I).HIncrBy({key:e,field:t,value:r,transactionId:n(this,E)},n(this,T)),this}async hdel(e,t){return this.hDel(e,t)}async hDel(e,t){return await n(this,I).HDel({key:e,fields:t,transactionId:n(this,E)},n(this,T)),this}async hscan(e,t,r,s){return this.hScan(e,t,r,s)}async hScan(e,t,r,s){let o={key:e,cursor:t,pattern:r,count:s,transactionId:n(this,E)};return await n(this,I).HScan(o,n(this,T)),this}async hkeys(e){return this.hKeys(e)}async hKeys(e){return await n(this,I).HKeys({key:e,transactionId:n(this,E)},n(this,T)),this}async hlen(e){return this.hLen(e)}async hLen(e){return await n(this,I).HLen({key:e,transactionId:n(this,E)},n(this,T)),this}};I=new WeakMap,E=new WeakMap,T=new WeakMap;var w,vi,Yo=class Yo{constructor(e,t=void 0,r=Zo.INSTALLATION){l(this,w);l(this,vi);a(this,w,e),a(this,vi,t),this.scope=r,this.global=r===Zo.INSTALLATION?new Yo(n(this,w),n(this,vi),Zo.GLOBAL):this}get storage(){return n(this,vi)||u.redisPlugin}async watch(...e){let t=await this.storage.Watch({keys:e},n(this,w));return new Qo(this.storage,t,n(this,w))}async get(e){try{let t=await this.storage.Get({key:e,scope:this.scope},{...n(this,w),"throw-redis-nil":{values:["true"]}});return t!==null?t.value??void 0:t}catch(t){if(Hr(t))return;throw t}}async getBuffer(e){try{let t=await this.storage.GetBytes({key:e,scope:this.scope},{...n(this,w),"throw-redis-nil":{values:["true"]}});return t!==null?Buffer.from(t.value):t}catch(t){if(Hr(t))return;throw t}}async set(e,t,r){let s;return r?.expiration&&(s=Math.floor((r.expiration.getTime()-Date.now())/1e3),s<1&&(s=1)),(await this.storage.Set({key:e,value:t,nx:r?.nx===!0&&!r.xx,xx:r?.xx===!0&&!r.nx,expiration:s||0,scope:this.scope},n(this,w))).value}async exists(...e){return(await this.storage.Exists({keys:e,scope:this.scope},n(this,w))).existingKeys}async del(...e){await this.storage.Del({keys:e,scope:this.scope},n(this,w))}async incrBy(e,t){return(await this.storage.IncrBy({key:e,value:t,scope:this.scope},n(this,w))).value}async getRange(e,t,r){let s=await this.storage.GetRange({key:e,start:t,end:r,scope:this.scope},n(this,w));return s!==null?s.value:s}async setRange(e,t,r){return(await this.storage.SetRange({key:e,offset:t,value:r,scope:this.scope},n(this,w))).value}async strlen(e){return this.strLen(e)}async strLen(e){return(await this.storage.Strlen({key:e,scope:this.scope},n(this,w))).value}async expire(e,t){await this.storage.Expire({key:e,seconds:t,scope:this.scope},n(this,w))}async expireTime(e){return(await this.storage.ExpireTime({key:e,scope:this.scope},n(this,w))).value}async zAdd(e,...t){return(await this.storage.ZAdd({key:e,members:t,scope:this.scope},n(this,w))).value}async zRange(e,t,r,s){let o={rev:!1,byLex:!1,byScore:!1,offset:0,count:1e3};if(s?.reverse&&(o.rev=s.reverse),s?.by==="lex"?o.byLex=!0:s?.by==="score"?o.byScore=!0:(o.offset=0,o.count=0),s?.limit)if(o.byLex||o.byScore)o.offset=s.limit.offset,o.count=s.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:t+"",stop:r+"",...o,scope:this.scope},n(this,w))).members}async zRem(e,t){return(await this.storage.ZRem({key:{key:e},members:t,scope:this.scope},n(this,w))).value}async zRemRangeByLex(e,t,r){return(await this.storage.ZRemRangeByLex({key:{key:e},min:t,max:r,scope:this.scope},n(this,w))).value}async zRemRangeByRank(e,t,r){return(await this.storage.ZRemRangeByRank({key:{key:e},start:t,stop:r,scope:this.scope},n(this,w))).value}async zRemRangeByScore(e,t,r){return(await this.storage.ZRemRangeByScore({key:{key:e},min:t,max:r,scope:this.scope},n(this,w))).value}async zScore(e,t){try{let r=await this.storage.ZScore({key:{key:e},member:t,scope:this.scope},{...n(this,w),"throw-redis-nil":{values:["true"]}});return r!==null?r.value:r}catch(r){if(Hr(r))return;throw r}}async zRank(e,t){try{let r=await this.storage.ZRank({key:{key:e},member:t,scope:this.scope},{...n(this,w),"throw-redis-nil":{values:["true"]}});return r!==null?r.value:r}catch(r){if(Hr(r))return;throw r}}async zIncrBy(e,t,r){let s=await this.storage.ZIncrBy({key:e,member:t,value:r,scope:this.scope},n(this,w));return s!==null?s.value:s}async mget(e){return this.mGet(e)}async mGet(e){let t=await this.storage.MGet({keys:e,scope:this.scope},n(this,w));return t!==null?t.values.map(r=>r||null):t}async mset(e){return this.mSet(e)}async mSet(e){let t=Object.entries(e).map(([r,s])=>({key:r,value:s}));await this.storage.MSet({kv:t,scope:this.scope},n(this,w))}async zCard(e){let t=await this.storage.ZCard({key:e,scope:this.scope},n(this,w));return t!==null?t.value:t}async zScan(e,t,r,s){let o={key:e,cursor:t,pattern:r,count:s,scope:this.scope};return await this.storage.ZScan(o,n(this,w))}async type(e){let t=await this.storage.Type({key:e,scope:this.scope},n(this,w));return t!==null?t.value:t}async rename(e,t){return(await this.storage.Rename({key:e,newKey:t,scope:this.scope},n(this,w))).result}async hget(e,t){return this.hGet(e,t)}async hGet(e,t){try{let r=await this.storage.HGet({key:e,field:t,scope:this.scope},{...n(this,w),"throw-redis-nil":{values:["true"]}});return r!==null?r.value??void 0:r}catch(r){if(Hr(r))return;throw r}}async hMGet(e,t){let r=await this.storage.HMGet({key:e,fields:t,scope:this.scope},n(this,w));return r!==null?r.values.map(s=>s||null):r}async hset(e,t){return this.hSet(e,t)}async hSet(e,t){let r=Object.entries(t).map(([o,d])=>({field:o,value:d}));return(await this.storage.HSet({key:e,fv:r,scope:this.scope},n(this,w))).value}async hSetNX(e,t,r){return(await this.storage.HSetNX({key:e,field:t,value:r,scope:this.scope},n(this,w))).success}async hgetall(e){return this.hGetAll(e)}async hGetAll(e){let t=await this.storage.HGetAll({key:e,scope:this.scope},n(this,w));return t!==null?t.fieldValues:t}async hdel(e,t){return this.hDel(e,t)}async hDel(e,t){return(await this.storage.HDel({key:e,fields:t,scope:this.scope},n(this,w))).value}async hscan(e,t,r,s){return this.hScan(e,t,r,s)}async hScan(e,t,r,s){let o={key:e,cursor:t,pattern:r,count:s,scope:this.scope};return await this.storage.HScan(o,n(this,w))}async hkeys(e){return this.hKeys(e)}async hKeys(e){let t=await this.storage.HKeys({key:e,scope:this.scope},n(this,w));return t!==null?t.keys:t}async hincrby(e,t,r){return this.hIncrBy(e,t,r)}async hIncrBy(e,t,r){return(await this.storage.HIncrBy({key:e,field:t,value:r,scope:this.scope},n(this,w))).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,...t){let r=[];for(let o=0;o<t.length;){let d=t[o],c={};switch(d){case"get":{if(o+2>=t.length)throw Error("bitfield command parse failed; not enough arguments for 'get' command");c.get={encoding:t[o+1],offset:t[o+2].toString()},o+=3;break}case"set":{if(o+3>=t.length)throw Error("bitfield command parse failed; not enough arguments for 'set' command");c.set={encoding:t[o+1],offset:t[o+2].toString(),value:t[o+3].toString()},o+=4;break}case"incrBy":{if(o+3>=t.length)throw Error("bitfield command parse failed; not enough arguments for 'incrBy' command");c.incrBy={encoding:t[o+1],offset:t[o+2].toString(),increment:t[o+3].toString()},o+=4;break}case"overflow":{if(o+1>=t.length)throw Error("bitfield command parse failed; not enough arguments for 'overflow' command");let m=t[o+1].toString();c.overflow={behavior:gm(m)},o+=2;break}default:throw Error(`bitfield command parse failed; ${d} unrecognized (must be 'get', 'set', 'incrBy', or 'overflow')`)}r.push(c)}return(await this.storage.Bitfield({key:e,commands:r})).results}};w=new WeakMap,vi=new WeakMap;var ki=Yo;function gm(i){let e=i.toLowerCase();switch(e){case"wrap":return Xo.BITFIELD_OVERFLOW_BEHAVIOR_WRAP;case"sat":return Xo.BITFIELD_OVERFLOW_BEHAVIOR_SAT;case"fail":return Xo.BITFIELD_OVERFLOW_BEHAVIOR_FAIL;default:throw Error(`unknown bitfield overflow behavior: ${e}`)}}var Mt,Ci=class{constructor(e){l(this,Mt);a(this,Mt,e)}async runJob(e){return(await u.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},n(this,Mt))).id}async cancelJob(e){await u.schedulerPlugin.Cancel({id:e},n(this,Mt))}async listJobs(){return(await u.schedulerPlugin.List({after:new Date(0),before:new Date(Date.now()+31536e7)},n(this,Mt))).actions.map(t=>(p(t.request?.action,"Scheduled job is malformed"),"when"in t.request&&t.request.when!=null?{id:t.id,name:t.request.action.type,runAt:t.request.when,data:t.request.action.data}:{id:t.id,name:t.request.action.type,cron:t.request.cron??"",data:t.request.action.data}))}};Mt=new WeakMap;import{FormFieldType as Js}from"@devvit/protos";var jr,Pi=class{constructor(e){l(this,jr);a(this,jr,e)}async get(e){return(await this.getAll())[e]}async getAll(){let t=await u.settingsPlugin.GetSettings({},n(this,jr));if(!t.installationSettings)throw new Error("Could not get installation settings");if(!t.appSettings)throw new Error("Could not get app settings");return hm(t),{...Jd(t.installationSettings.settings,u.installationSettings),...Jd(t.appSettings.settings,u.appSettings)}}};jr=new WeakMap;function hm(i){if(!i.appSettings)throw new Error("Could not get app settings");for(let[e,t]of Object.entries(i.appSettings.settings)){let r=u.appSettings?.find(s=>s.type!=="group"&&s.name===e);r&&(r.type==="boolean"&&t.fieldType===Js.STRING&&t.boolValue==null&&t.stringValue!=null?(t.fieldType=Js.BOOLEAN,t.boolValue=!!t.stringValue,delete t.stringValue):r.type==="number"&&t.fieldType===Js.STRING&&t.numberValue==null&&t.stringValue!=null&&(t.fieldType=Js.NUMBER,t.numberValue=Number(t.stringValue),delete t.stringValue))}}function Jd(i,e){let t=Object.keys(i).reduce((r,s)=>(r[s]=Go(i[s]),r),{});return e&&zd(t,e),t}function zd(i,e){for(let t of e)t.type==="group"?zd(i,t.fields):!(t.name in i)&&"defaultValue"in t&&(i[t.name]=t.defaultValue)}import{EffectType as zs,ToastAppearance as qd}from"@devvit/protos";var et,Si,Vr,$s,qs=class{constructor(e){l(this,et,[]);l(this,Si);l(this,Vr);l(this,$s,(e,t)=>{let r=t!==void 0?e:"",s=t!==void 0?t:e;n(this,et).push({type:zs.EFFECT_WEB_VIEW,webView:{postMessage:{webViewId:r,app:{message:s}}}})});a(this,Si,e),a(this,Vr,{postMessage:n(this,$s)})}get webView(){return n(this,Vr)}showForm(e,t){return this.showFormInternal(e,t)}showFormInternal(e,t,r){let s=u.formDefinitions.get(e);if(!s&&n(this,Si)){let c=n(this,Si).forms.get(e);c&&(s={form:c,onSubmit:()=>{}})}if(!s)throw new Error("Form does not exist. Make sure you have added it using Devvit.createForm at the root of your app.");let o=r??(s.form instanceof Function?s.form(t??{}):s.form),d={fields:[],id:e,title:o.title,acceptLabel:o.acceptLabel,cancelLabel:o.cancelLabel,shortDescription:o.description};Rt(o.fields),d.fields=Le(o.fields),n(this,et).push({type:zs.EFFECT_SHOW_FORM,showForm:{form:d}})}showToast(e){let t;e instanceof Object?t={text:e.text,appearance:e.appearance==="success"?qd.SUCCESS:qd.NEUTRAL}:t={text:e},n(this,et).push({type:zs.EFFECT_SHOW_TOAST,showToast:{toast:t}})}navigateTo(e){let t=typeof e=="string"?e:e.url;if(!URL.canParse(t))throw new TypeError(`Invalid URL: ${t}`);let r=new URL(t).toString();n(this,et).push({type:zs.EFFECT_NAVIGATE_TO_URL,navigateToUrl:{url:r}})}get __effects(){return n(this,et)}};et=new WeakMap,Si=new WeakMap,Vr=new WeakMap,$s=new WeakMap;function Ce({metadata:i,ui:e,hooks:t,reconciler:r}){let s=new fi(i),o=new gi(i),d=new ki(i),c=Md(d,r?r.state:{}),m=new bi(i),y=new Ci(i),v=new Pi(i),f=e?new qs(r):void 0,S=new hi(i),b=new mi,_=new yi(i),A=t&&r?Cd(r):void 0,N=t&&r?kd(r):void 0,B=t&&r?vd(r):void 0,oi=t&&r?bd(r):void 0;return{modLog:s,kvStore:o,redis:d,reddit:m,scheduler:y,settings:v,media:S,assets:b,realtime:_,get useForm(){return B??(()=>{throw new Error("useForm() is unavailable")})},get cache(){return c??(()=>{throw new Error("cache() is unavailable")})},get useState(){return A??(()=>{throw new Error("useState() is unavailable")})},get useInterval(){return N??(()=>{throw new Error("useInterval() is unavailable")})},get useChannel(){return oi??(()=>{throw new Error("useChannel() is unavailable")})},get ui(){if(!f)throw new Error("ui client is not available");return f}}}import{DevvitPostData as ym}from"@devvit/protos";var $d={name:"@devvit/public-api",version:"0.11.20-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:min","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",clean:"rm -rf .turbo 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.11.20-dev","@devvit/protos":"0.11.20-dev","@devvit/shared":"0.11.20-dev","@devvit/shared-types":"0.11.20-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.11.20-dev","@devvit/tsconfig":"0.11.20-dev","@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.8.3",vitest:"1.6.1"},publishConfig:{directory:"dist"},filesize:{"dist/public-api.min.js":{gzip:"62 KB",none:"219 KB"}},source:"./src/index.ts"};function se(i,e,t){let r=i[P.Subreddit]?.values[0];p(r,"subreddit is missing from Context");let s=i[P.SubredditName]?.values[0],o,d=i[P.PostData]?.values[0];d&&(o=ym.fromJSON(JSON.parse(d)).developerData);let c=i[P.AppUser]?.values[0],m=i[P.App]?.values[0],y=i[P.Version]?.values[0],v=i[P.User]?.values[0],f=bm(i);return{get appAccountId(){return p(c,"appAccountId is missing from Context"),c},subredditId:r,subredditName:s,userId:v,postId:e,postData:o,commentId:t,appName:m,appVersion:y,debug:f,metadata:i,toJSON(){return{appAccountId:c,appName:m,appVersion:y,subredditId:r,subredditName:s,userId:v,postId:e,postData:o,commentId:t,debug:f,metadata:i}}}}function bm(i){let e={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},t={};for(let s in e)t[s.toLowerCase()]=s;let r={};for(let s of(i[P.Debug]?.values??[]).join().split(",")){let[o,d]=s.split("=");o&&(o=o.trim(),d=d?.trim(),o.toLowerCase()in t&&(o=t[o.toLowerCase()]),r[o]??(r[o]=d||"true"))}return i[P.Debug]&&console.info(`[api] @devvit/public-api v${$d.version} ${Object.entries(r).map(([s,o])=>`${s}=${o}`).join(" ")}`),{...r,metadata:i}}function Kd(i){return i.flatMap(e=>e.type==="group"?Kd(e.fields):e)}async function Ks(i,e,t){if(!e)throw new Error("Settings were not defined.");let r={success:!0,errors:{}},s=Xe(i.fieldValues),o=Kd(e);return await Promise.all(o.map(async d=>{let c=d.name;if(c&&d.onValidate){let m=s[c],y=d.onValidate,v=Object.assign(Ce({metadata:t}),se(t)),f=await y({value:m,isEditing:i.editing},v);f&&(r.success=!1,r.errors[c]=f)}})),vm.fromJSON(r)}async function Pm(){return Cm.fromJSON({fields:{fields:Le(u.appSettings??[])}})}async function Sm(i,e){return Ks(i,u.appSettings,e)}function Xd(i){i.provides(km),O("GetAppSettingsFields",Pm),O("ValidateAppForm",Sm)}import{CustomPostDefinition as Tm,RenderPostResponse as Rm}from"@devvit/protos";import{BlockRenderEventType as pa,EffectType as cl}from"@devvit/protos";function wi(i){return i.__effects}function Zd(){let i=new Set;return e=>{let t=e,r=1;for(;i.has(t);)t=`${e}.${r++}`;return i.add(t),t}}import{BlockActionType as ma,BlockAvatarBackground as al,BlockAvatarFacing as dl,BlockAvatarSize as tt,BlockBorderWidth as Ys,BlockButtonAppearance as it,BlockButtonSize as na,BlockGap as eo,BlockHorizontalAlignment as sa,BlockIconSize as to,BlockImageResizeMode as Wr,BlockPadding as Gr,BlockRadius as Jr,BlockSpacerShape as oa,BlockSpacerSize as io,BlockStackDirection as aa,BlockTextOutline as da,BlockTextOverflow as la,BlockTextSize as xi,BlockTextStyle as ua,BlockTextWeight as ll,BlockType as Re,BlockVerticalAlignment as ca}from"@devvit/protos";var ea={"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 Qd={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"},Yd=i=>!!i.match(/^(#[0-9a-fA-F]{3,8}).*/),el=i=>i in ea,ta=i=>i in Qd,tl=i=>!!i.match(/^rgba?\(.*/),il=i=>!!i.match(/^hsla?\(.*/),rl=(i,e="light")=>{if(ta(i))return Xs(i);let r=ea[i];return typeof r=="string"?r:r[e]},Xs=i=>Qd[i]??i,nl=i=>{let[e,t,r,s]=i.replace(/^rgba?\(|\s+|\)$/g,"").split(",");if(!e||!t||!r)return i;let d=[...[e,t,r].map(m=>parseFloat(m))];if(s){let m=parseFloat(s),y=Math.round(m*255);d.push(y)}return`#${d.map(m=>m.toString(16).padStart(2,"0")).join("")}`};import{BlockStackDirection as Zs}from"@devvit/protos";var ia={stackParentLayout:{hasHeight:!0,hasWidth:!0,direction:Zs.UNRECOGNIZED,alignment:void 0}};function ol(i,e,t){if(!e)return{hasHeight:!1,hasWidth:!1};let{growDirection:r,stretchDirection:s}=wm(i?.grow,e.direction,e.alignment),o=t?.height?.value?.value||t?.height?.min?.value||sl(2,r,s,e.hasHeight),d=t?.width?.value?.value||t?.width?.min?.value||sl(1,r,s,e.hasWidth);return{hasHeight:!!o,hasWidth:!!d}}function sl(i,e,t,r){return e===i&&r||t===i&&r}function wm(i,e,t){let r=e===Zs.STACK_VERTICAL||e===Zs.UNRECOGNIZED,s=e===Zs.STACK_HORIZONTAL,o=0;s&&i?o=1:r&&i&&(o=2);let d=t===void 0||t.horizontal===void 0,c=t===void 0||t.vertical===void 0,m=s?!!c:r?!!d:!1,y=0;return s&&m?y=2:r&&m&&(y=1),{growDirection:o,stretchDirection:y}}import{BlockSizeUnit as Ut,BlockStackDirection as Qs}from"@devvit/protos";function Fi(i){if(i==null)return;if(typeof i=="number")return{value:i,unit:Ut.SIZE_UNIT_PERCENT};let e=i.match(/^(\d+(?:\.\d+)?)(px|%)?$/);if(e==null)return;let t=Ut.SIZE_UNIT_PERCENT;return e.at(2)==="px"&&(t=Ut.SIZE_UNIT_PIXELS),{value:Number.parseFloat(e[1]),unit:t}}function Fm(i,e){return(i.width?.value?.unit===Ut.SIZE_UNIT_PERCENT||i.width?.min?.unit===Ut.SIZE_UNIT_PERCENT)&&(e.direction===Qs.STACK_HORIZONTAL||e.direction===Qs.STACK_DEPTH)&&(e.hasWidth||(i.width=void 0)),(i.height?.value?.unit===Ut.SIZE_UNIT_PERCENT||i.height?.min?.unit===Ut.SIZE_UNIT_PERCENT)&&(e.direction===Qs.STACK_VERTICAL||e.direction===Qs.STACK_DEPTH)&&(e.hasHeight||(i.height=void 0)),i}function ra(i,e){if(i){let t=i.width!=null||i.minWidth!=null||i.maxWidth!=null,r=i.height!=null||i.minHeight!=null||i.maxHeight!=null;if(t||r||i.grow!=null){let s={width:t?{value:Fi(i.width),min:Fi(i.minWidth),max:Fi(i.maxWidth)}:void 0,height:r?{value:Fi(i.height),min:Fi(i.minHeight),max:Fi(i.maxHeight)}:void 0,grow:i.grow};return e.stackParentLayout&&(s=Fm(s,e.stackParentLayout)),s}}}var ul="data-",xm=new Set(["onPress","onMessage"]),Am=new Map([["onPress",ma.ACTION_CLICK],["onMessage",ma.ACTION_WEBVIEW]]),zr,Ai=class{constructor(e=()=>{}){l(this,zr);a(this,zr,e)}createBlocksElementOrThrow({type:e,props:t,children:r}){let s=this.createBlocksElement({type:e,props:t,children:r},ia);if(!s)throw new Error(`Could not create block of type ${e}`);return s}createBlocksElement({type:e,props:t,children:r},s){switch(e){case"blocks":return this.makeRoot(t,...r);case"hstack":return this.makeHStack(t,s,...r);case"vstack":return this.makeVStack(t,s,...r);case"zstack":return this.makeZStack(t,s,...r);case"text":return this.makeText(t,s,...r);case"button":return this.makeButton(t,s,...r);case"image":return this.makeImage(t,s);case"spacer":return this.makeSpacer(t,s);case"icon":return this.makeIcon(t,s);case"avatar":return this.makeAvatar(t,s);case"webview":return this.makeWebView(t,s);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 Gr.PADDING_NONE;case"xsmall":return Gr.PADDING_XSMALL;case"small":return Gr.PADDING_SMALL;case"medium":return Gr.PADDING_MEDIUM;case"large":return Gr.PADDING_LARGE}}makeBlockRadius(e){switch(e){case"none":return Jr.RADIUS_NONE;case"small":return Jr.RADIUS_SMALL;case"medium":return Jr.RADIUS_MEDIUM;case"large":return Jr.RADIUS_LARGE;case"full":return Jr.RADIUS_FULL}}makeBlockGap(e){switch(e){case"none":return eo.GAP_NONE;case"small":return eo.GAP_SMALL;case"medium":return eo.GAP_MEDIUM;case"large":return eo.GAP_LARGE}}makeBlockAlignment(e){if(e===void 0)return;let t,r;if(e.includes("top")?t=ca.ALIGN_TOP:e.includes("middle")?t=ca.ALIGN_MIDDLE:e.includes("bottom")&&(t=ca.ALIGN_BOTTOM),e.includes("start")?r=sa.ALIGN_START:e.includes("center")?r=sa.ALIGN_CENTER:e.includes("end")&&(r=sa.ALIGN_END),t!==void 0||r!==void 0)return{vertical:t,horizontal:r}}makeBlockBorder(e,t,r,s){if(!e&&!t)return;let o;switch(e){case"none":o=Ys.BORDER_WIDTH_NONE;break;case"thin":o=Ys.BORDER_WIDTH_THIN;break;case"thick":o=Ys.BORDER_WIDTH_THICK;break;default:o=Ys.BORDER_WIDTH_THIN;break}let d=t??"neutral-border-weak",c=this.getThemedColors(d,r,s);return{width:o,color:c?.light,colors:c}}makeBlockTextSize(e){switch(e){case"xsmall":return xi.TEXT_SIZE_XSMALL;case"small":return xi.TEXT_SIZE_SMALL;case"medium":return xi.TEXT_SIZE_MEDIUM;case"large":return xi.TEXT_SIZE_LARGE;case"xlarge":return xi.TEXT_SIZE_XLARGE;case"xxlarge":return xi.TEXT_SIZE_XXLARGE}}makeBlockTextStyle(e){switch(e){case"body":return ua.TEXT_STYLE_BODY;case"metadata":return ua.TEXT_STYLE_METADATA;case"heading":return ua.TEXT_STYLE_HEADING}}makeBlockTextOutline(e){switch(e){case"none":return da.TEXT_OUTLINE_NONE;case"thin":return da.TEXT_OUTLINE_THIN;case"thick":return da.TEXT_OUTLINE_THICK}}makeBlockTextWeight(e){switch(e){case"regular":return ll.TEXT_WEIGHT_REGULAR;case"bold":return ll.TEXT_WEIGHT_BOLD}}makeBlockTextOverflow(e){switch(e){case"clip":return la.TEXT_OVERFLOW_CLIP;case"ellipsis":return la.TEXT_OVERFLOW_ELLIPSE}return la.TEXT_OVERFLOW_ELLIPSE}makeBlockButtonAppearance(e){switch(e){case"secondary":return it.BUTTON_APPEARANCE_SECONDARY;case"primary":return it.BUTTON_APPEARANCE_PRIMARY;case"plain":return it.BUTTON_APPEARANCE_PLAIN;case"bordered":return it.BUTTON_APPEARANCE_BORDERED;case"media":return it.BUTTON_APPEARANCE_MEDIA;case"destructive":return it.BUTTON_APPEARANCE_DESTRUCTIVE;case"caution":return it.BUTTON_APPEARANCE_CAUTION;case"success":return it.BUTTON_APPEARANCE_SUCCESS}}makeBlockButtonSize(e){switch(e){case"small":return na.BUTTON_SIZE_SMALL;case"medium":return na.BUTTON_SIZE_MEDIUM;case"large":return na.BUTTON_SIZE_LARGE}}makeBlockImageResizeMode(e){switch(e){case"none":return Wr.IMAGE_RESIZE_NONE;case"fit":return Wr.IMAGE_RESIZE_FIT;case"fill":return Wr.IMAGE_RESIZE_FILL;case"cover":return Wr.IMAGE_RESIZE_COVER;case"scale-down":return Wr.IMAGE_RESIZE_SCALE_DOWN}}makeBlockSpacerSize(e){switch(e){case"xsmall":return io.SPACER_XSMALL;case"small":return io.SPACER_SMALL;case"medium":return io.SPACER_MEDIUM;case"large":return io.SPACER_LARGE}}makeBlockSpacerShape(e){switch(e){case"invisible":return oa.SPACER_INVISIBLE;case"thin":return oa.SPACER_THIN;case"square":return oa.SPACER_SQUARE}}makeBlockIconSize(e){switch(e){case"xsmall":return to.ICON_SIZE_XSMALL;case"small":return to.ICON_SIZE_SMALL;case"medium":return to.ICON_SIZE_MEDIUM;case"large":return to.ICON_SIZE_LARGE}}makeBlockAvatarSize(e){switch(e){case"xxsmall":return tt.AVATAR_SIZE_XXSMALL;case"xsmall":return tt.AVATAR_SIZE_XSMALL;case"small":return tt.AVATAR_SIZE_SMALL;case"medium":return tt.AVATAR_SIZE_MEDIUM;case"large":return tt.AVATAR_SIZE_LARGE;case"xlarge":return tt.AVATAR_SIZE_XXLARGE;case"xxlarge":return tt.AVATAR_SIZE_XXLARGE;case"xxxlarge":return tt.AVATAR_SIZE_XXXLARGE}}makeBlockAvatarFacing(e){switch(e){case"left":return dl.AVATAR_FACING_LEFT;case"right":return dl.AVATAR_FACING_RIGHT}}makeBlockAvatarBackground(e){switch(e){case"dark":return al.AVATAR_BG_DARK;case"light":return al.AVATAR_BG_LIGHT}}getDataSet(e){return Object.keys(e).filter(t=>t.startsWith(ul)).reduce((t,r)=>(t[r.substring(ul.length)]=e[r],t),{})}makeActions(e,t){let r=[],s=this.getDataSet(t);return xm.forEach(o=>{if(o in t){let d=t[o];r.push({type:Am.get(o)??ma.UNRECOGNIZED,id:d.toString(),data:s})}}),r}blockColorToHex(e,t="light"){if(e)return e=e.toLowerCase(),Yd(e)?e:el(e)?rl(e,t):ta(e)?Xs(e):tl(e)?nl(e):il(e)?e:(console.warn(`Could not parse color: ${e}.`),Xs("red"))}childrenToBlocks(e,t){return e.flatMap(r=>(typeof r!="string"?this.createBlocksElement(r,t):void 0)??[])}getThemedColors(e,t,r){let s=this.blockColorToHex(t,"light"),o=this.blockColorToHex(r,"dark"),d=[];if(e&&(!s||!o)){let c=Array.from(e?.matchAll(/[\w#-]+(?:\([\w\t ,.#-]+\))?/g)??[]);d.push(...c.map(m=>m[0]))}return s||(s=this.blockColorToHex(d?.at(0),"light")),o||(o=this.blockColorToHex(d?.at(1)??d?.at(0),"dark")),s||o?{light:s,dark:o}:void 0}parsePixels(e){return typeof e=="string"?Number(e.slice(0,-2)):e}resolveAssetUrl(e,t){return n(this,zr).call(this)?.getURL(e,t)??e}childrenToString(e){return e.map(t=>t.toString()).join("")}makeRoot(e,...t){return this.wrapRoot(e,this.childrenToBlocks(t,ia))}wrapRoot(e,t){return this.makeBlock(Re.BLOCK_ROOT,{},{},{rootConfig:{children:t,height:this.makeRootHeight(u.customPostType?.height??e?.height??"regular")}})}makeStackBlock(e,t,r,s){let o=this.getThemedColors(t?.backgroundColor,t?.lightBackgroundColor,t?.darkBackgroundColor),d=this.makeBlockAlignment(t?.alignment),c=ra(t,r),m=ol(t,r.stackParentLayout,c);return this.makeBlock(Re.BLOCK_STACK,t,r,{stackConfig:{alignment:d,backgroundColor:o?.light,backgroundColors:o,border:this.makeBlockBorder(t?.border,t?.borderColor,t?.lightBorderColor,t?.darkBorderColor),children:this.childrenToBlocks(s,{stackParentLayout:{...m,direction:e,alignment:d}}),cornerRadius:this.makeBlockRadius(t?.cornerRadius),direction:e,gap:this.makeBlockGap(t?.gap),padding:this.makeBlockPadding(t?.padding),reverse:t?.reverse}})}makeHStack(e,t,...r){return this.makeStackBlock(aa.STACK_HORIZONTAL,e,t,r)}makeVStack(e,t,...r){return this.makeStackBlock(aa.STACK_VERTICAL,e,t,r)}makeZStack(e,t,...r){return this.makeStackBlock(aa.STACK_DEPTH,e,t,r)}makeText(e,t,...r){let s=this.getThemedColors(e?.color,e?.lightColor,e?.darkColor);return this.makeBlock(Re.BLOCK_TEXT,e,t,{textConfig:{alignment:this.makeBlockAlignment(e?.alignment),color:s?.light,colors:s,outline:this.makeBlockTextOutline(e?.outline),size:this.makeBlockTextSize(e?.size),style:this.makeBlockTextStyle(e?.style),text:this.childrenToString(r),weight:this.makeBlockTextWeight(e?.weight),selectable:e?.selectable,wrap:e?.wrap,overflow:this.makeBlockTextOverflow(e?.overflow)}})}makeButton(e,t,...r){let s=this.getThemedColors(e?.textColor,e?.lightTextColor,e?.darkTextColor);return this.makeBlock(Re.BLOCK_BUTTON,e,t,{buttonConfig:{buttonAppearance:this.makeBlockButtonAppearance(e?.appearance),icon:e?.icon,buttonSize:this.makeBlockButtonSize(e?.size),text:this.childrenToString(r),textColor:s?.light,textColors:s,disabled:e?.disabled}})}makeImage(e,t){return e&&this.makeBlock(Re.BLOCK_IMAGE,e,t,{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,t){return this.makeBlock(Re.BLOCK_SPACER,e,t,{spacerConfig:{size:this.makeBlockSpacerSize(e?.size),shape:this.makeBlockSpacerShape(e?.shape)}})}makeIcon(e,t){let r=this.getThemedColors(e?.color,e?.lightColor,e?.darkColor);return e&&this.makeBlock(Re.BLOCK_ICON,e,t,{iconConfig:{icon:e.name,color:r?.light,colors:r,size:this.makeBlockIconSize(e.size)}})}makeAvatar(e,t){return e&&this.makeBlock(Re.BLOCK_AVATAR,e,t,{avatarConfig:{thingId:e.thingId,size:this.makeBlockAvatarSize(e.size),facing:this.makeBlockAvatarFacing(e.facing),background:this.makeBlockAvatarBackground(e.background)}})}makeWebView(e,t){return e&&this.makeBlock(Re.BLOCK_WEBVIEW,e,t,{webviewConfig:{url:this.resolveAssetUrl(e.url,{webView:!0})}})}makeBlock(e,t,r,s){return{type:e,sizes:ra(t,r),config:s,actions:(t&&this.makeActions(e,t))??[],id:t?.id,key:t?.key}}ensureRootBlock(e){let t;if(e.type===Re.BLOCK_ROOT?(e.config?.rootConfig&&u.customPostType?.height&&(e.config.rootConfig.height=this.makeRootHeight(u.customPostType?.height)),t=e):t=this.wrapRoot(void 0,[e]),!t)throw new Error("Could not create root block");return t}};zr=new WeakMap;function ml(i){if(typeof i=="string")throw new Error("Root element cannot be a string")}var pl=i=>{let e="",t=i.props?Object.keys(i.props).map(r=>r==="onPress"?"":`${r}="${i.props[r]}"`).join(" "):"";e+=`<${i.type}${t?" "+t:""}>`;for(let r of i.children)typeof r=="string"?e+=r:e+=pl(r);return e+=`</${i.type}>`,e};function Im(i){return" ".repeat(i)}function Em(i){let e="",t=0,r=i.split(/>\s*</);for(let s=0;s<r.length;s++){let o=r[s];s===0&&(o=o.trim()),s===r.length-1&&(o=o.trim());let d=o.charAt(0)==="/";d&&t--,e+=Im(t),s!==0&&(e+="<"),e+=o,s!==r.length-1&&(e+=`>
2
- `),!d&&o.indexOf("</")===-1&&o.charAt(o.length-1)!=="/"&&t++}return e}var Pe,gl,qr,ga,$r,_e=class{constructor(e,t,r,s,o){l(this,Pe);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 Ai(()=>this.assets);this.effects=[];l(this,$r,!1);this.component=e,this.event=t,this.state={__renderState:{},...r},this.metadata=s,this.state.__realtimeChannels&&(this.realtimeChannels=this.state.__realtimeChannels);let d=Ce({reconciler:this,hooks:!0,ui:!0,metadata:s});this.cache=d.cache,this.modLog=d.modLog,this.reddit=d.reddit,this.kvStore=d.kvStore,this.redis=d.redis,this.settings=d.settings,this.scheduler=d.scheduler,this.media=d.media,this.assets=d.assets,this.realtime=d.realtime,this.dimensions=o,this.ui=d.ui,this.hooks={useState:d.useState,useInterval:d.useInterval,useForm:d.useForm,useChannel:d.useChannel}}emitEffect(e,t){this.effects.push(t)}async render(){await this.reconcile(),this.isRendering=!0;let e=await this.buildBlocksUI();return this.isRendering=!1,e}makeUniqueActionID(e){let t=e,r=1;for(;this.actions.has(t);)t=`${e}.${r++}`;return t}async reconcile(){let e=h(this,Pe,qr).call(this),t={type:this.component,props:e,children:[]},r=await this.processBlock(t);if(ml(r),this.transformer.createBlocksElementOrThrow(r),this.isUserActionRender&&this.blockRenderEventId){let s=this.actions.get(this.blockRenderEventId);s&&await s(this.event.data)}for(let s of this.pendingHooks)await s();this.buildNextState(),h(this,Pe,gl).call(this)}async buildBlocksUI(){let e=h(this,Pe,qr).call(this),t={type:this.component,props:e,children:[]},r=await this.renderElement(e,t);return this.transformer.ensureRootBlock(r)}async renderElement(e,t){let r=await this.processBlock(t);return ml(r),(u.debug.emitSnapshots||e.debug.emitSnapshots)&&console.debug(Em(pl(r))),(u.debug.emitState||e.debug.emitState)&&console.debug(JSON.stringify(this.state,void 0,2)),this.transformer.createBlocksElementOrThrow(r)}async processProps(e){let t=e.props??{},r=["onPress","onMessage"];for(let s of r)if(s in t){let o=t[s],d=o?.name,c=this.makeUniqueActionID(`${e.type}.${d??s}`);this.actions.set(c,o),t[s]=c}}async processBlock(e,t=Zd(),r=[]){let s=e;if(typeof s.type=="string"){let c=[];for(let f=0;f<s.children.length;f++){let S=s.children[f];S!=null&&c.push(await this.processBlock(S,t,[...r,`${s.type}.${f}`]))}let m=c.flat(),y=h(this,Pe,ga).call(this,m);return await this.processProps(s),{type:s.type,props:s.props,children:y}}if(typeof s.type=="function"){let c=t(`${r.length?r.join("."):"root"}.${s.type.name.length?s.type.name:"anonymous"}`);this.currentComponentKey.push(c),this.renderState[c]||(this.renderState[c]={});let m=s.children.flatMap(f=>f),y={...h(this,Pe,qr).call(this),...s.props,children:m},v;for(;v===void 0;)try{v=await s.type(y,h(this,Pe,qr).call(this))}catch(f){if(f instanceof Promise)v=await f;else throw f}if(!this.isInitialRender){let f=this.getPreviousComponentState();if(Object.keys(f).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 v=="object")return this.processBlock(v,t,[...r,s.type.name])}if(typeof s=="string")return s;if(typeof s=="number")return`${s}`;let o=[],d="";return Array.isArray(s)?o=s:typeof s.type>"u"&&s.children&&(o=s.children,d="fragmentChild."),{type:"__fragment",props:void 0,children:await Promise.all(o.flatMap(async(c,m)=>await this.processBlock(c,t,[...r,`${d}${m}`])))}}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===pa.RENDER_INITIAL:!1}get isUserActionRender(){return this.event?this.event.type===pa.RENDER_USER_ACTION:!1}get isEffectRender(){return this.event?this.event.type===pa.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){n(this,$r)||(a(this,$r,!0),this.effects.push({type:cl.EFFECT_RERENDER_UI,rerenderUi:{delaySeconds:e/1e3}}))}addRealtimeChannel(e){this.realtimeChannels.push(e),this.realtimeUpdated=!0}removeRealtimeChannel(e){this.realtimeChannels=this.realtimeChannels.filter(t=>t!==e),this.realtimeUpdated=!0}get realtimeEffect(){return this.realtimeUpdated&&this.realtimeChannels.length>0?[{type:cl.EFFECT_REALTIME_SUB,realtimeSubscriptions:{subscriptionIds:this.realtimeChannels}}]:[]}getEffects(){return[...wi(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}:{}}}};Pe=new WeakSet,gl=function(){this.actions.clear(),this.currentComponentKey=[],this.currentHookIndex=0,this.pendingHooks=[],this.realtimeChannels=[],this.realtimeUpdated=!1},qr=function(){let e={...se(this.metadata,this.state.__postData?.thingId),modLog:this.modLog,reddit:this.reddit,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[P.Timezone]?.values[0],locale:this.metadata[P.Language]?.values[0],dimensions:this.dimensions},...this.hooks};return e.debug.effects=this,e},ga=function(e){let t=[];for(let r of e)typeof r=="string"?t.push(r):r.type==="__fragment"?t.push(...h(this,Pe,ga).call(this,r.children)):t.push(r);return t},$r=new WeakMap;async function Om(i,e){let t=u.customPostType;if(!t)throw new Error("Custom post type not registered");let r=new _e((o,d)=>t.render(d),i.blocks,i.state,e,i.dimensions),s=await r.render();return Rm.fromJSON({state:r.state,blocks:{ui:s},effects:r.getEffects()})}function hl(i){i.provides(Tm),O("RenderPost",Om)}import{GetFieldsResponse as Mm,InstallationSettingsDefinition as Um}from"@devvit/protos";async function Bm(){return Mm.fromJSON({fields:{fields:Le(u.installationSettings??[])}})}async function Dm(i,e){return Ks(i,u.installationSettings,e)}function fl(i){i.provides(Um),O("GetSettingsFields",Bm),O("ValidateForm",Dm)}import{ContextActionDefinition as Nm,ContextActionList as Lm,ContextActionResponse as _m}from"@devvit/protos";function ha(i){let e=i.metadata[P.User].values[0];if(!e)throw new Error("User missing from context");return e}function fa(i){let e=i.metadata[P.Subreddit].values[0];if(!e)throw new Error("Subreddit missing from context");return e}async function yl(i,e){let t=ha(i),r=fa(i);if(!t||!r)throw new Error("User or subreddit missing from context");let s=e.comment?.id&&`t1_${e.comment.id}`,o=e.post?.id&&`t3_${e.post.id}`,d=e.subreddit?.id&&`t5_${e.subreddit.id}`,c=s||o||d;if(!c)throw new Error("targetId is missing from ContextActionRequest");if(s){let f=await i.reddit.getCommentById(s);if(!f)throw new Error(`Comment ${s} not found`);if(f.subredditId!==r)throw new Error("Comment does not belong to the subreddit")}if(o){let f=await i.reddit.getPostById(o);if(!f)throw new Error(`Post ${o} not found`);if(f.subredditId!==r)throw new Error("Post does not belong to the subreddit")}if(d&&d!==r)throw new Error(`Subreddit ${d} ${r} not found`);let m=Kr(e.actionId);if(!m)throw new Error("Action not found");let y=!!m.forUserType?.includes("moderator");if(y&&!bl(i))throw new Error("User is not a moderator");let v={needsModCheck:y};await i.redis.set(`${t}${r}${c}${e.actionId}`,JSON.stringify(v)),await i.redis.expire(`${t}${r}${c}${e.actionId}`,600)}async function bl(i){let e=ha(i),t=fa(i),r=await i.reddit.getSubredditInfoById(t);return!!(await i.reddit.getModerators({subredditName:r.name}).all()).find(o=>o.id===e)}async function vl(i,e){let t=ha(i),r=fa(i),{actionId:s,thingId:o}=e.state?.__contextAction??{},d=await i.redis.get(`${t}${r}${o}${s}`);if(!d)throw new Error("CSRF token not found");if(JSON.parse(d).needsModCheck&&!await bl(i))throw new Error("User is not a moderator: "+t+"; "+r)}var kl=i=>`menuItem.${i}`;function Kr(i){return u.menuItems.find((e,t)=>kl(t)===i)}function ya(i,e){return i?Array.isArray(i.location)?i.location.includes(e):i.location===e:!1}async function Hm(i,e){let r=u.menuItems.map((s,o)=>({actionId:kl(o),name:s.label,description:s.description,contexts:{subreddit:s.location.includes("subreddit"),post:s.location.includes("post"),comment:s.location.includes("comment")},users:{loggedOut:s.forUserType?.includes("loggedOut"),moderator:s.forUserType?.includes("moderator")},postFilters:s.postFilter==="currentApp"?{currentApp:!0}:void 0}));return Lm.fromJSON({actions:r})}async function jm(i,e){let t=Kr(i.actionId);if(!t)throw new Error(`MenuItem ${i.actionId} not found`);let r=i.comment?.id&&`t1_${i.comment.id}`,s=i.post?.id&&`t3_${i.post.id}`,o=i.subreddit?.id&&`t5_${i.subreddit.id}`,d=r||s||o;p(d,"targetId is missing from ContextActionRequest");let c={targetId:d,location:i.comment?"comment":i.post?"post":"subreddit"},m=Object.assign(Ce({ui:!0,metadata:e}),se(e,s,r),{uiEnvironment:{timezone:e[P.Timezone]?.values[0],locale:e[P.Language]?.values[0]}});return await yl(m,i),await t.onPress(c,m),_m.fromJSON({effects:wi(m.ui)})}function Cl(i){i.provides(Nm),O("GetActions",Hm),O("OnAction",jm)}function xe(i){return i?i===!0?!0:i.enabled:!1}import{SchedulerHandlerDefinition as Vm}from"@devvit/protos";async function Wm(i,e){let t=i.type,r=u.scheduledJobHandlers.get(t);if(!r)throw new Error(`Job ${t} not found`);let s={name:t,data:i.data},o=Object.assign(Ce({metadata:e}),se(e));return await r(s,o),{}}function Pl(i){i.provides(Vm),O("HandleScheduledAction",Wm)}import{OnAppInstallDefinition as Gm,OnAppUpgradeDefinition as Jm,OnAutomoderatorFilterCommentDefinition as zm,OnAutomoderatorFilterPostDefinition as qm,OnCommentCreateDefinition as $m,OnCommentDeleteDefinition as Km,OnCommentReportDefinition as Xm,OnCommentSubmitDefinition as Zm,OnCommentUpdateDefinition as Qm,OnModActionDefinition as Ym,OnModMailDefinition as ep,OnPostCreateDefinition as tp,OnPostDeleteDefinition as ip,OnPostFlairUpdateDefinition as rp,OnPostNsfwUpdateDefinition as np,OnPostReportDefinition as sp,OnPostSpoilerUpdateDefinition as op,OnPostSubmitDefinition as ap,OnPostUpdateDefinition as dp}from"@devvit/protos";var rt;(function(i){function e(d,c){return d.length<=c?d:`${d.slice(0,c-1)}\u2026`}i.ellipsize=e;function t(d){return d[0]==null?d:`${d[0].toLocaleUpperCase()}${d.slice(1)}`}i.capitalize=t;function r(d){return d==null||/^\s*$/.test(d)}i.isBlank=r;function s(d,c="stack"){return d instanceof Error?`${d[c]||d.stack||d.message||d.name}`:String(d)}i.caughtToString=s;function o(d,c="stack"){return d instanceof Error?`${d[c]||d.stack||d.message||d.name}`:String(d)}i.caughtToStringUntyped=o})(rt||(rt={}));function $(i,e){return p(e),async(t,r)=>{let s={...t,type:i},o=Object.assign(Ce({metadata:r}),se(r)),d=await Promise.allSettled(e.map(m=>m(s,o))),c=lp(d);if(c)throw c.err;return{}}}function Sl(i){for(let e of u.triggerOnEventHandlers.keys())switch(e){case"PostSubmit":i.provides(ap),O("OnPostSubmit",$("PostSubmit",u.triggerOnEventHandlers.get(e)));break;case"PostCreate":i.provides(tp),O("OnPostCreate",$("PostCreate",u.triggerOnEventHandlers.get(e)));break;case"PostUpdate":i.provides(dp),O("OnPostUpdate",$("PostUpdate",u.triggerOnEventHandlers.get(e)));break;case"PostReport":i.provides(sp),O("OnPostReport",$("PostReport",u.triggerOnEventHandlers.get(e)));break;case"PostDelete":i.provides(ip),O("OnPostDelete",$("PostDelete",u.triggerOnEventHandlers.get(e)));break;case"PostFlairUpdate":i.provides(rp),O("OnPostFlairUpdate",$("PostFlairUpdate",u.triggerOnEventHandlers.get(e)));break;case"CommentSubmit":i.provides(Zm),O("OnCommentSubmit",$("CommentSubmit",u.triggerOnEventHandlers.get(e)));break;case"CommentCreate":i.provides($m),O("OnCommentCreate",$("CommentCreate",u.triggerOnEventHandlers.get(e)));break;case"CommentUpdate":i.provides(Qm),O("OnCommentUpdate",$("CommentUpdate",u.triggerOnEventHandlers.get(e)));break;case"CommentReport":i.provides(Xm),O("OnCommentReport",$("CommentReport",u.triggerOnEventHandlers.get(e)));break;case"CommentDelete":i.provides(Km),O("OnCommentDelete",$("CommentDelete",u.triggerOnEventHandlers.get(e)));break;case"AppInstall":i.provides(Gm),O("OnAppInstall",$("AppInstall",u.triggerOnEventHandlers.get(e)));break;case"AppUpgrade":i.provides(Jm),O("OnAppUpgrade",$("AppUpgrade",u.triggerOnEventHandlers.get(e)));break;case"ModAction":i.provides(Ym),O("OnModAction",$("ModAction",u.triggerOnEventHandlers.get(e)));break;case"ModMail":i.provides(ep),O("OnModMail",$("ModMail",u.triggerOnEventHandlers.get(e)));break;case"PostNsfwUpdate":i.provides(np),O("OnPostNsfwUpdate",$("PostNsfwUpdate",u.triggerOnEventHandlers.get(e)));break;case"PostSpoilerUpdate":i.provides(op),O("OnPostSpoilerUpdate",$("PostSpoilerUpdate",u.triggerOnEventHandlers.get(e)));break;case"AutomoderatorFilterPost":i.provides(qm),O("OnAutomoderatorFilterPost",$("AutomoderatorFilterPost",u.triggerOnEventHandlers.get(e)));break;case"AutomoderatorFilterComment":i.provides(zm),O("OnAutomoderatorFilterComment",$("AutomoderatorFilterComment",u.triggerOnEventHandlers.get(e)));break;default:throw new Error(`Unknown trigger event: ${e}`)}}function lp(i){let e=i.reduce((t,r)=>r.status==="rejected"?[...t,r.reason]:t,[]);if(e.length!==0)return e.length===1?{err:e[0]}:{err:new Error(e.map(t=>rt.caughtToString(t)).join(`
3
- `))}}import{EffectType as Mp,HandleUIEventResponse as ka,UIEventHandlerDefinition as Up}from"@devvit/protos";var Hl=ld(Bl(),1);function Dl(i){return i?.constructor===Object}function Bt(i,e){return Object.is(i,e)?!0:typeof i!=typeof e?!1:Array.isArray(i)&&Array.isArray(e)?Nl(i,e):i instanceof Date&&e instanceof Date?i.getTime()===e.getTime():i instanceof RegExp&&e instanceof RegExp?i.toString()===e.toString():Dl(i)&&Dl(e)?Op(i,e):i instanceof ArrayBuffer&&e instanceof ArrayBuffer?Ll(new DataView(i),new DataView(e)):i instanceof DataView&&e instanceof DataView?Ll(i,e):_l(i)&&_l(e)?i.byteLength!==e.byteLength?!1:Nl(i,e):!1}function Op(i,e){let t=Object.keys(i),r=Object.keys(e);if(!Bt(t,r))return!1;for(let s of t)if(!Bt(i[s],e[s]))return!1;return!0}function Nl(i,e){return i.length!==e.length?!1:i.every((t,r)=>Bt(t,e[r]))}function Ll(i,e){if(i.byteLength!==e.byteLength)return!1;for(let t=0;t<i.byteLength;t++)if(i.getUint8(t)!==e.getUint8(t))return!1;return!0}function _l(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}async function Bp(i,e){let t=i.state??{},r=(0,Hl.default)(t),s=Ce({ui:!0,metadata:e});if(i.event?.formSubmitted&&i.event.formSubmitted.formId){let m=i.event.formSubmitted.formId;if(m.includes("form.hook.")&&u.customPostType){let b=new _e((_,A)=>u.customPostType?.render(A)??null,i.event,i.state,e,void 0);return await b.reconcile(),ka.fromJSON({state:b.state,effects:b.getEffects()})}let y=u.formDefinitions.get(m);if(!y)throw new Error(`Form with key ${m} not found`);let v,f;if(r.__contextAction){let{actionId:b,thingId:_}=r.__contextAction,A=Kr(b);ya(A,"post")?v=_:ya(A,"comment")&&(f=_)}let S=Object.assign(s,se(e,v,f),{uiEnvironment:{timezone:e[P.Timezone]?.values[0],locale:e[P.Language]?.values[0]}});await vl(S,i),await y.onSubmit({values:Xe(i.event.formSubmitted.results)},S)}else if(i.event?.realtimeEvent){if(u.customPostType){let m=new _e((y,v)=>u.customPostType?.render(v)??null,i.event,i.state,e,void 0);return await m.reconcile(),ka.fromJSON({state:m.state,effects:m.getEffects()})}}else if(i.event?.toastAction)throw new Error("Toast actions not yet implemented");let o=!Bt(t,r),d=wi(s.ui),c=o?[...d,{type:Mp.EFFECT_RERENDER_UI,rerenderUi:{delaySeconds:0}}]:d;return ka.fromJSON({state:r,effects:c})}function jl(i){i.provides(Up),O("HandleUIEvent",Bp)}import{CustomPostDefinition as yo,UIResponse as gu}from"@devvit/protos";import{UIEventScope as Wp}from"@devvit/protos";var Ca="ServerCallRequired";function ro(i){return i?.message===Ca}var Fa={now(){return new Date}};function Vl(i){return`__autocache__${i}`}function Wl(i){return`__lock__${i}`}var Dp=300,Np=1e3,no=5e3,Pa=3,Gl=.1,Jl=1e3,Lp=3e4;function zl(i){if(i.error)throw new Error(i.error);return i.value}var nt,st,Se,Ii,q,ql,$l,Kl,Sa,Xl,Zl,wa,Ql,so=class{constructor(e,t,r=Fa){l(this,q);l(this,nt);l(this,st,{});l(this,Se);l(this,Ii);a(this,nt,e),a(this,Ii,t),a(this,Se,r)}async cache(e,t){var d;(d=n(this,Ii)).__cache??(d.__cache={}),a(this,st,n(this,Ii).__cache),h(this,q,Ql).call(this,t);let r=h(this,q,ql).call(this,t.key);if(r!==void 0)return r;let s=await h(this,q,wa).call(this,t.key),o=await h(this,q,$l).call(this,t,s,e);return zl(o)}};nt=new WeakMap,st=new WeakMap,Se=new WeakMap,Ii=new WeakMap,q=new WeakSet,ql=function(e){let t=n(this,st)[e];if(t){let r=n(this,Se).now().getTime(),s=t?.error&&t?.errorTime&&t.errorCount<Pa&&Math.random()<Gl&&t.errorTime+Jl<r;if(t?.expires&&t.expires<r&&t.checkedAt+Jl<r||s){delete n(this,st)[e];return}else return zl(t)}},$l=async function(e,t,r){let s=t?.expires,o=s?h(this,q,Zl).call(this,s):1;return!t||t?.error&&t.errorCount<Pa&&Gl>Math.random()||o>Math.random()?h(this,q,Kl).call(this,e,t,r):t},Kl=async function(e,t,r){let s=Wl(e.key),o=n(this,Se).now().getTime(),d=new Date(o+e.ttl/2);if(await n(this,nt).set(s,"1",{expiration:d,nx:!0}))return h(this,q,Xl).call(this,e.key,t,r,e.ttl);if(t)return t;{let m=n(this,Se).now();return h(this,q,Sa).call(this,m,e.key,e.ttl)}},Sa=async function(e,t,r){let s=Math.min(r,Np),o=await h(this,q,wa).call(this,t);if(o)return o;if(n(this,Se).now().getTime()-e.getTime()>=s)throw new Error(`Cache request timed out trying to get data at key: ${t}`);return await new Promise(d=>setTimeout(d,Dp)),h(this,q,Sa).call(this,e,t,r)},Xl=async function(e,t,r,s){let o=n(this,Se).now().getTime()+s;t=t??{value:null,expires:o,errorCount:0,error:null,errorTime:null,checkedAt:0};try{t.value=await r(),t.error=null,t.errorCount=0,t.errorTime=null}catch(d){t.value=null,t.error=d.message??"Unknown error",t.errorTime=n(this,Se).now().getTime(),t.errorCount++}return n(this,st)[e]=t,await n(this,nt).set(Vl(e),JSON.stringify(t),{expiration:new Date(o+Lp)}),t.error&&t.errorCount<Pa&&await n(this,nt).del(Wl(e)),t},Zl=function(e){let t=n(this,Se).now().getTime(),r=e-t;return r<0?1:r<1e3?.1:r<2e3?.01:r<3e3?.001:0},wa=async function(e){let t=await n(this,nt).get(Vl(e));if(t){let r=JSON.parse(t);return r.checkedAt=n(this,Se).now().getTime(),n(this,st)[e]=r,r}},Ql=function(e){e.ttl<no&&(console.warn(`Cache TTL cannot be less than ${no} milliseconds! Updating ttl value of ${e.ttl} to ${no}.`),e.ttl=no)};function Yl(i,e,t=Fa){let r=new so(i,e,t);return r.cache.bind(r)}import{EffectType as oo,ToastAppearance as iu}from"@devvit/protos";function eu(i){let e=i.match(/form\.hook\.(.+)\.0/);if(e?.[1])return e[1]}var xa=class{constructor(e,t,r){this.state=null;this.hookId=e.hookId,this.form=t,this.onSubmit=r,this.onUIEvent=async s=>{s.formSubmitted&&await r(Xe(s.formSubmitted.results))}}};function Aa(i,e){let t=me({namespace:"useForm",initializer:r=>new xa(r,i,e)});return _p({id:t.hookId})}function _p(i){return`form.hook.${i.id}.0`}function tu(i,e){let t=eu(e);return i.getHook({id:t})}var He,lo,Xr,uo,ao=class{constructor(e){l(this,He);l(this,lo,0);l(this,Xr);l(this,uo,(e,t)=>{let r=t!==void 0?e:"",s=t!==void 0?t:e;n(this,He).emitEffect(`postMessage${ud(this,lo)._++}`,{type:oo.EFFECT_WEB_VIEW,webView:{postMessage:{webViewId:r,app:{message:s,jsonString:JSON.stringify(s)}}}})});a(this,He,e),a(this,Xr,{postMessage:n(this,uo)})}get webView(){return n(this,Xr)}showForm(e,t){return this.showFormInternal(e,t)}showFormInternal(e,t,r){let s=tu(n(this,He),e);if(!s)throw new Error("Form does not exist. Make sure you have added it using useForm.");let o=r??(s.form instanceof Function?s.form(t??{}):s.form),d={fields:[],id:e,title:o.title,acceptLabel:o.acceptLabel,cancelLabel:o.cancelLabel,shortDescription:o.description};Rt(o.fields),d.fields=Le(o.fields),n(this,He).emitEffect(e,{type:oo.EFFECT_SHOW_FORM,showForm:{form:d}})}showToast(e){let t;e instanceof Object?t={text:e.text,appearance:e.appearance==="success"?iu.SUCCESS:iu.NEUTRAL}:t={text:e},n(this,He).emitEffect(e.toString(),{type:oo.EFFECT_SHOW_TOAST,showToast:{toast:t}})}navigateTo(e){let t=typeof e=="string"?e:e.url;if(!URL.canParse(t))throw new TypeError(`Invalid URL: ${t}`);let r=new URL(t).toString();n(this,He).emitEffect(r,{type:oo.EFFECT_NAVIGATE_TO_URL,navigateToUrl:{url:r}})}};He=new WeakMap,lo=new WeakMap,Xr=new WeakMap,uo=new WeakMap;import{EffectType as Hp,RealtimeSubscriptionStatus as ru}from"@devvit/protos";var ot,Oe,at,Dt,Zr,Ea,co=class co{constructor(e,t){l(this,Zr);l(this,ot);l(this,Oe);l(this,at);l(this,Dt);a(this,ot,t.context),a(this,Oe,!!t.context._devvitContext?.debug.realtime),a(this,Dt,e),a(this,at,t.invalidate);let r=t.context.meta[P.App]?.values[0];if(!r)throw Error("useChannel missing app ID metadata");let s=t.context.meta[P.Installation]?.values[0];if(!s)throw Error("useChannel missing install ID from metadata");let o=`${r}:${s}:${e.name}`;if(Object.values(n(this,ot)._hooks).filter(c=>c instanceof co).some(c=>c.state.channel===o))throw Error(`useChannel channel names must be unique; "${o}" duplicated`);this.state={channel:o,connected:!1,subscribed:!1}}async onUIEvent(e){let t=e.realtimeEvent;if(!(!t||!this.state.subscribed))switch(t.status){case ru.REALTIME_SUBSCRIBED:n(this,Oe)&&console.debug(`[realtime] "${this.state.channel}" connected`),this.state.connected=!0,n(this,at).call(this),await n(this,Dt).onSubscribed?.();break;case ru.REALTIME_UNSUBSCRIBED:n(this,Oe)&&console.debug(`[realtime] "${this.state.channel}" disconnected`),this.state.connected=!1,n(this,at).call(this),await n(this,Dt).onUnsubscribed?.();break;default:n(this,Oe)&&console.debug(`[realtime] "${this.state.channel}" received message: ${JSON.stringify(e,void 0,2)}`),n(this,Dt).onMessage(t.event?.data?.msg);break}}async send(e){if(n(this,Oe)&&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 n(this,ot).devvitContext.realtime.send(this.state.channel,e)}get status(){return this.state.subscribed&&this.state.connected?2:this.state.subscribed&&!this.state.connected?1:!this.state.subscribed&&this.state.connected?3:4}subscribe(){this.state.subscribed||(n(this,Oe)&&console.debug(`[realtime] "${this.state.channel}" subscribed`),this.state.subscribed=!0,n(this,at).call(this),h(this,Zr,Ea).call(this))}unsubscribe(){this.state.subscribed&&(n(this,Oe)&&console.debug(`[realtime] "${this.state.channel}" unsubscribed`),this.state.subscribed=!1,n(this,at).call(this),h(this,Zr,Ea).call(this))}};ot=new WeakMap,Oe=new WeakMap,at=new WeakMap,Dt=new WeakMap,Zr=new WeakSet,Ea=function(){let e=Object.values(n(this,ot)._hooks).filter(t=>t instanceof co&&t.state.subscribed).map(t=>t.state.channel);n(this,ot).emitEffect(this.state.channel,{type:Hp.EFFECT_REALTIME_SUB,realtimeSubscriptions:{subscriptionIds:e}})};var Ia=co;function Ta(i){if(!i.name||/[^a-zA-Z0-9_]/.test(i.name))throw Error(`useChannel error: The name "${i.name}" you provided for the hook is invalid. Valid names can only contain letters, numbers, and underscores (_).`);let e=`useChannel:${i.name}`;return me({id:e,namespace:e,initializer:t=>new Ia(i,t)})}import{EffectType as Ra}from"@devvit/protos";function nu(i){return typeof i=="object"&&i!==null&&"__deleted"in i}var Nt,dt,Ei=class Ei{constructor(e,t){l(this,Nt);this._segments=[];l(this,dt,{});this._prevHooks={};this._prevHookId="";this._effects={};this._changed={};this._touched={};this._requeueEvents=[];this._rootProps={};this._generated={};this._undeliveredHandlers={};this.request=e,this.meta=t,a(this,Nt,e.state??{__cache:{}}),this._rootProps=e.props??{}}get devvitContext(){if(!this._devvitContext)throw new Error("Devvit context not available");return this._devvitContext}set devvitContext(e){this._devvitContext=e}get _changedState(){let e={__cache:n(this,Nt).__cache??{}};for(let r in this._changed)e[r]=this._state[r];let t=new Set(Object.keys(this._state));return Object.keys(n(this,dt)).forEach(r=>{r!=="__cache"&&t.delete(r)}),t.forEach(r=>{if(r==="__cache")return;let s={__deleted:!0};this._state[r]=e[r]=s}),e}get _hooks(){return n(this,dt)}set _hooks(e){this._prevHooks=n(this,dt),a(this,dt,e)}get _state(){return n(this,Nt)}set _state(e){a(this,Nt,e)}push(e){this._segments.push({...e,next:0})}pop(){this._segments.pop()}addUndeliveredEventHandler(e,t){this._undeliveredHandlers[e]=t}addGlobalUndeliveredEventHandler(e,t){Ei.addGlobalUndeliveredEventHandler(e,t)}getHook(e){return n(this,dt)[e.id]}static addGlobalUndeliveredEventHandler(e,t){Ei._staticUndeliveredHandlers[e]=t}async handleUndeliveredEvent(e){let t={...Ei._staticUndeliveredHandlers,...this._undeliveredHandlers};for(let[r,s]of Object.entries(t))await s(e,this)}emitEffect(e,t){this._effects[e]=t}addToRequeueEvents(...e){this._devvitContext?.debug.blocks&&console.debug("[blocks] requeueing events",e);let t=e.reduce((r,s)=>(s.retry?r.retry.push(s):r.normal.push(s),r),{retry:[],normal:[]});this._requeueEvents=[...t.retry,...this._requeueEvents,...t.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 t=[];for(let s=this._segments.length-1;s>=0;s--){let o=this._segments[s];if(o.id){t.unshift(o.id);break}let d=[];o.namespace&&d.push(o.namespace),o.key!==void 0&&o.key!==!1&&d.push(o.key),t.unshift(d.join("-"))}let r=t.join(".");if(this._generated[r]&&!e.shared)throw new Error(`Hook id ${r} already used, cannot register another hook with the same id`);return this._generated[r]=!0,this._prevHookId=r,r}finally{this.pop()}}};Nt=new WeakMap,dt=new WeakMap,Ei._staticUndeliveredHandlers={};var Ti=Ei;var lt={};Ti.addGlobalUndeliveredEventHandler("intervals",async(i,e)=>{i.timer&&i.hook&&(delete lt[i.hook],e.emitEffect("timers",{type:Ra.EFFECT_SET_INTERVALS,interval:{intervals:lt}}))});var ut,Ri,Qr,Oi,Oa=class{constructor(e,t,r){l(this,ut);l(this,Ri);l(this,Qr);l(this,Oi);this.state={duration:{seconds:0,nanos:0},running:!1};a(this,Ri,r.invalidate),a(this,ut,r.hookId),a(this,Qr,e),a(this,Oi,r.context);let s=Math.floor(t/1e3),o=t%1e3*1e6;this.state.duration={seconds:s,nanos:o}}onStateLoaded(){this.state.running?lt[n(this,ut)]={duration:this.state.duration}:delete lt[n(this,ut)]}async onUIEvent(e){await n(this,Qr).call(this)}start(){lt[n(this,ut)]={duration:this.state.duration},this.state.running=!0,n(this,Ri).call(this),n(this,Oi).emitEffect("timers",{type:Ra.EFFECT_SET_INTERVALS,interval:{intervals:lt}})}stop(){delete lt[n(this,ut)],this.state.running=!1,n(this,Ri).call(this),n(this,Oi).emitEffect("timers",{type:Ra.EFFECT_SET_INTERVALS,interval:{intervals:lt}})}};ut=new WeakMap,Ri=new WeakMap,Qr=new WeakMap,Oi=new WeakMap;function Ma(i,e){let t=me({namespace:"useInterval",initializer:r=>new Oa(i,e,r)});return{start:()=>t.start(),stop:()=>t.stop()}}import{UIEventScope as Vp}from"@devvit/protos";var Lt=class extends Error{};import{UIEventScope as su}from"@devvit/protos";function Ba(i){if(i instanceof Error){if(i.message===Ca)throw i;return console.error(i),{message:i.message,details:i.stack??""}}else return console.error(i),{message:"Unknown error",details:rt.caughtToString(i)}}var Ae,Me,Mi,Yr,Ui,Ua=class{constructor(e,t,r){l(this,Ae);l(this,Me);l(this,Mi);l(this,Yr);l(this,Ui);a(this,Ae,!!r.context.devvitContext.debug.useAsync),n(this,Ae)&&console.debug("[useAsync] v1",t),this.state={data:null,load_state:"initial",error:null,depends:null},a(this,Me,r.hookId),this.initializer=e,a(this,Mi,r.invalidate),a(this,Yr,r.context),this.localDepends=t.depends??null,a(this,Ui,t)}onStateLoaded(){if(n(this,Ae)&&console.debug("[useAsync] async onLoad ",n(this,Me),this.state),n(this,Ae)&&console.debug("[useAsync] async onLoad have ",this.localDepends,"and",this.state.depends),!Bt(this.localDepends,this.state.depends)||this.state.load_state==="initial"){n(this,Ae)&&console.debug("[useAsync] attempting to resolve for hookId",n(this,Me)),this.state.load_state="loading",this.state.depends=this.localDepends,n(this,Mi).call(this);let e={scope:su.ALL,hook:n(this,Me),async:!0,asyncRequest:{requestId:n(this,Me)+"-"+JSON.stringify(this.state.depends)}};n(this,Ae)&&console.debug("[useAsync] onLoad requeue"),n(this,Yr).addToRequeueEvents(e)}}async onUIEvent(e,t){if(e.asyncRequest){let r={requestId:e.asyncRequest.requestId};try{r.data={value:await this.initializer()}}catch(o){r.error=Ba(o)}let s={scope:su.ALL,asyncResponse:r,hook:n(this,Me)};n(this,Ae)&&console.debug("[useAsync] onReq requeue"),t.addToRequeueEvents(s)}else if(e.asyncResponse){let r=n(this,Me)+"-"+JSON.stringify(this.state.depends);e.asyncResponse.requestId===r?(this.state={...this.state,data:e.asyncResponse.data?.value??null,error:e.asyncResponse.error??null,load_state:e.asyncResponse.error?"error":"loaded"},n(this,Ui).finally&&await n(this,Ui).finally(this.state.data,this.state.error?new Error(this.state.error?.message??"Unknown error"):null),n(this,Mi).call(this)):n(this,Ae)&&console.debug("[useAsync] onResp skip, stale event",e.asyncResponse.requestId," !== ",r)}else throw new Error("Unknown event type")}};Ae=new WeakMap,Me=new WeakMap,Mi=new WeakMap,Yr=new WeakMap,Ui=new WeakMap;function jp(i,e={}){let t=me({namespace:"useAsync",initializer:r=>new Ua(i,e,r)});return{data:t.state.data,error:t.state.error,loading:t.state.load_state==="loading"}}var je,Bi,_t,ct,Da=class{constructor(e,t){this.state={value:null,load_state:"initial",error:null};l(this,je);l(this,Bi);l(this,_t);l(this,ct);a(this,_t,e),a(this,ct,t.hookId),a(this,je,t.invalidate),a(this,Bi,t.context)}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=Ba(e)}n(this,je).call(this)}else console.warn(`Invalid state for hook (${n(this,ct)}):`,this.state.load_state,this._promise)}setter(e){this.state.value=e instanceof Function?e(this.state.value):e,this.state.load_state="loaded",n(this,je).call(this)}onStateLoaded(){if(this._promise=n(this,Bi)._prevHooks[n(this,ct)]?._promise,this.state.load_state==="loading")throw new Lt;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=n(this,_t)instanceof Function?n(this,_t).call(this):n(this,_t)}catch(t){console.log("error in loading async",t),this.state.load_state="error",n(this,je).call(this);return}if(e instanceof Promise){this._promise=e,this.state.load_state="loading";let t={scope:Vp.ALL,asyncRequest:{requestId:n(this,ct)},hook:n(this,ct)};throw n(this,Bi).addToRequeueEvents(t),n(this,je).call(this),new Lt}else this.state.value=e,this.state.load_state="loaded";n(this,je).call(this)}}};je=new WeakMap,Bi=new WeakMap,_t=new WeakMap,ct=new WeakMap;function Na(i){let e=me({namespace:"useState",initializer:t=>new Da(i,t)});return[e.state.value,e.setter.bind(e)]}var mo=class{buildContext(e,t,r){let s=new fi(r),o=new gi(r),d=new ki(r),c=new bi(r),m=new Ci(r),y=new Pi(r),v=new ao(e),f=new hi(r),S=new mi,b=new yi(r),_=Yl(d,e._state),A={modLog:s,kvStore:o,redis:d,reddit:c,scheduler:m,settings:y,media:f,assets:S,realtime:b,ui:v,useState:Na,useChannel:Ta,useInterval:Ma,useForm:Aa,cache:_,dimensions:t.env?.dimensions,uiEnvironment:{timezone:r[P.Timezone]?.values[0],locale:r[P.Language]?.values[0],dimensions:t.env?.dimensions,colorScheme:t.env?.colorScheme}},N=se(r,t.props?.postId);return N.debug.effects=e,{...N,...A}}};var pe=null;function ou(i){return JSON.parse(JSON.stringify(i))}function Gp(i){if(!(i!==""&&!/[-.]/.test(i)))throw new Error(`Hook with namespace '${i}' 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 me({initializer:i,...e}){if(!pe)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.");Gp(e.namespace);let t=pe.nextHookId(e),r=pe,s={hookId:t,invalidate:()=>{r._changed[t]=!0,r._state[t]=r?._hooks[t]?.state},context:pe},o=pe._state[t]===void 0||nu(pe._state[t]);pe._hooks[t]=pe._hooks[t]??i(s);let d=pe._hooks[t];return o||(d.state=pe._state[t]),d.onStateLoaded?.(),o&&d.state!==void 0&&d.state!==null&&s.invalidate(),d}var Jp=null,po=128,Di,fo,en,F,oe,go,au,La,du,_a,Ha,ho,ja,lu,Ht=class{constructor(e){l(this,F);l(this,Di);l(this,fo,new mo);l(this,en,new Ai(()=>this._latestRenderContext?.devvitContext?.assets));this._latestRenderContext=null;n(this,F,oe)&&console.debug("[blocks] BlocksHandler v1"),a(this,Di,e),Jp=this}async handle(e,t){let r=new Ti(e,t),s=n(this,fo).buildContext(r,e,t);r.devvitContext=s;let o,d=e.events.length-po,c=e.events;if(d>0){c=[];{let A=0;for(let N of e.events)A<d&&N.realtimeEvent?A++:c.push(N)}for(;c.length>po;)c.shift();console.warn(`dropped ${d} events`)}let y=!c.length||c.some(A=>!A.async),v=c.some(A=>A.blocking),f,S,b=[...c];c.length===0&&c.push({scope:Wp.ALL}),n(this,F,oe)&&console.debug("[blocks] starting processing events");let _=0;for(;c.length>0;){if(_++>po)throw new Error(`Exceeded maximum iterations of ${po}`);n(this,F,oe)&&console.debug("[blocks] processing events loop iteration",c.length);let A=[];if(!c[0].async)A.push(c.shift());else for(;c[0]?.async;)A.push(c.shift());if(!A.length)throw Error("batch must have at least one event");try{if(A[0].async){let B=ou(r._state);await h(this,F,au).call(this,r,...A),r._state=B}else await h(this,F,du).call(this,r,...A)}catch(B){if(!ro(B))throw B;if(n(this,F,oe)&&console.debug("[blocks] caught in handler",B),r._latestRenderContent=void 0,S){r._state=S._state,r._changed=f,r._effects=S._effects;let oi=b.map(sd=>{let od={...sd};return od.retry=!0,od});r.addToRequeueEvents(...oi);break}else throw ro(B)||console.error("[blocks] unhandled error in handler",B),B}n(this,F,oe)&&console.debug("[blocks] remaining events",r._requeueEvents);let N=[];for(let B of r._requeueEvents){if(!y&&!B.async){n(this,F,oe)&&console.debug("[blocks] NOT reprocessing event in BlocksHandler, sync mismatch A",B),N.push(B);continue}if(y&&B.async&&!v){n(this,F,oe)&&console.debug("[blocks] NOT reprocessing event in BlocksHandler, sync mismatch B",B),N.push(B);continue}n(this,F,oe)&&console.debug("[blocks] reprocessing event in BlocksHandler",B),c.push(B)}r._requeueEvents=N,c.length>0&&(f={...r._changed},S={_state:ou(r._state),_effects:{...r._effects}},b=[...c])}if(y){r._latestRenderContent||(r._latestRenderContent=h(this,F,_a).call(this,n(this,Di),r.request.props??{},r));let A=r._latestRenderContent;A&&(o=n(this,en).createBlocksElementOrThrow(A),o=n(this,en).ensureRootBlock(o))}return{state:r._changedState,effects:r.effects,blocks:o,events:r._requeueEvents}}};Di=new WeakMap,fo=new WeakMap,en=new WeakMap,F=new WeakSet,oe=function(){return!!this._latestRenderContext?.devvitContext.debug.blocks},go=function(e,...t){e._hooks={},h(this,F,_a).call(this,n(this,Di),e.request.props??{},e)},au=async function(e,...t){h(this,F,go).call(this,e,...t),await Promise.all(t.map(async r=>{if(!r.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 h(this,F,La).call(this,e,r)}))},La=async function(e,t){let r=e._hooks[t.hook];if(r?.onUIEvent)try{await r.onUIEvent(t,e)}catch(s){throw ro(s)?n(this,F,oe)&&console.error("Server call required",s):console.error("Error in event handler",s),s}else await e.handleUndeliveredEvent(t)},du=async function(e,...t){for(let r of t)n(this,F,oe)&&console.log("[blocks] handling main queue event",r),n(this,F,oe)&&console.log("[blocks] before",e._state),h(this,F,go).call(this,e,r),await h(this,F,La).call(this,e,r),n(this,F,oe)&&console.log("[blocks] after",e._state);h(this,F,go).call(this,e)},_a=function(e,t,r){n(this,F,oe)&&console.debug("[blocks] renderRoot"),r._generated={},pe=r,this._latestRenderContext=r;try{let s=h(this,F,Ha).call(this,e,t,r);if(s.length!==1)throw new Error(`There can only be one root element, received: ${s.length}. Please wrap these elements in a <vstack></vstack> or <hstack></hstack> to continue. Fragments cannot be used as a root element.`);let o=s[0];if(o==="[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 o=="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 r._latestRenderContent=o,o}catch(s){if(s instanceof Lt)return;throw s}finally{pe=null}},Ha=function(e,t,r){r.push({namespace:e.name||"anonymous",...t});try{let s=e(t,r.devvitContext);if(s 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 h(this,F,ja).call(this,s,r)}finally{r.pop()}},ho=function(e,t){return e=e.flat(1/0),e.flatMap((r,s)=>(r&&typeof r=="object"&&"props"in r&&(r.props?.key||(r.props=r.props??{},r.props.key=`${s}`)),h(this,F,ja).call(this,r,t)))},ja=function(e,t){if(Array.isArray(e))return h(this,F,ho).call(this,e,t);if(zp(e))if(e.type===void 0)try{return t.push({namespace:"fragment",...e.props}),h(this,F,ho).call(this,e.children,t)}finally{t.pop()}else if(typeof e.type=="function"){let r={...e.props,children:e.children.flat(1/0)};return h(this,F,Ha).call(this,e.type,r,t)}else try{t.push({namespace:e.type,...e.props});let r=h(this,F,ho).call(this,e.children,t),s=h(this,F,lu).call(this,e.props??{});return[{type:e.type,children:r,props:s}]}finally{t.pop()}else return[(e??"").toString()]},lu=function(e){let t={};for(let r in e)if(!(typeof e[r]>"u"))if(typeof e[r]=="function"){let s=me({namespace:r,key:!1,initializer:({hookId:o})=>({hookId:o,state:null,onUIEvent:d=>{if(d.userAction)return e[r](d.userAction.data);if(d.webView?.postMessage){let c=d.webView.postMessage.jsonString?JSON.parse(d.webView.postMessage.jsonString):d.webView.postMessage.message;return e[r](c)}}})});t[r]=s.hookId,"captureHookRef"in e[r]&&e[r].captureHookRef()}else{let s=JSON.parse(JSON.stringify(e[r]));s!=null&&(t[r]=s)}return t};function zp(i){return typeof i=="object"&&i!=null&&"type"in i}var uu=i=>{let e=Number(i.trim().split(".").pop());return isNaN(e)?void 0:e},cu=i=>{let[e,t,r]=i.trim().split(";");if(!e||!t||!r){console.warn(`Received a malformed devvit-user-agent! Received: '${i}'`);return}if(e!=="Reddit"){console.warn(`Received unknown company name in user agent! Received: '${i}'`);return}if(t==="iOS"){let s=uu(r);if(s===void 0){console.warn(`Could not parse version number from user agent! Received: '${i}'`);return}return{company:"Reddit",platform:"iOS",rawVersion:r,versionNumber:s}}if(t==="Android"){let s=uu(r);if(s===void 0){console.warn(`Could not parse version number from user agent! Received: '${i}'`);return}return{company:"Reddit",platform:"Android",rawVersion:r,versionNumber:s}}if(t==="Shreddit")return{company:"Reddit",platform:"Shreddit",rawVersion:r};console.warn("Received unknown platform:",t)},mu=i=>i?i.platform==="Android"?i.versionNumber<1875012:i.platform==="iOS"?i.versionNumber<614973:!1:(console.warn(`Could not parse devvit-user-agent! Received: '${JSON.stringify(i)}'`),!1),qp=i=>{switch(i){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"Shreddit":break;default:console.error(`No upgrade link for platform: ${i}`)}},$p=({platform:i},e)=>u.createElement("blocks",null,u.createElement("vstack",{alignment:"middle center",height:100,width:100},u.createElement("vstack",{maxWidth:"300px",gap:"large",alignment:"middle center"},u.createElement("vstack",{gap:"medium",alignment:"middle center"},u.createElement("image",{imageHeight:100,imageWidth:100,url:"https://i.redd.it/p1vmc5ulmpib1.png"}),u.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.")),u.createElement("hstack",{alignment:"middle center"},u.createElement("button",{onPress:()=>{let t=qp(i);t?e.ui.navigateTo(t):console.warn("No upgrade link found for platform:",i)}},"Upgrade"))))),pu=i=>()=>u.createElement($p,{platform:i});var Kp=()=>u.createElement("vstack",{alignment:"center middle",width:"100%",height:"100%"},u.createElement("text",null,"This feature is not available yet")),Xp=[[yo,yo.methods.renderPostContent,(i,e)=>u.customPostType?.render(e)??null],[yo,yo.methods.renderPostComposer,(i,e)=>u.createElement(Kp,null)]];function Zp(i){return async(e,t)=>{let r=cu(t["devvit-user-agent"]?.values?.[0]??"");if(r&&mu(r)){let o=new Ht(pu(r.platform));return gu.fromJSON(await o.handle(e,t))}let s=new Ht(i);return gu.fromJSON(await s.handle(e,t))}}function hu(i){for(let[e,t,r]of Xp)i.provides(e),O(t.name,Zp(r))}var Ve,jt,Vt,Wt,We,Ni,Gt,mt,tn,Li,Jt,rn,zt,j,bo,fu,M=class M extends Hs{static configure(e){a(this,jt,{...n(this,jt),...e});let t=e.http,r=typeof t=="object"&&"domains"in t;xe(r?{enabled:!0}:t)&&(r&&(gd(t.domains),a(this,Li,hd(t.domains))),this.use(k.HTTPDefinition)),(e.redis===void 0||xe(e.kvStore)||xe(e.redis))&&(this.use(k.KVStoreDefinition),this.use(k.RedisAPIDefinition)),xe(e.media)&&this.use(k.MediaServiceDefinition),xe(e.modLog)&&this.use(k.ModlogDefinition),xe(e.redditAPI)&&(this.use(k.FlairDefinition),this.use(k.GraphQLDefinition),this.use(k.LinksAndCommentsDefinition),this.use(k.ListingsDefinition),this.use(k.ModerationDefinition),this.use(k.ModNoteDefinition),this.use(k.NewModmailDefinition),this.use(k.PrivateMessagesDefinition),this.use(k.SubredditsDefinition),this.use(k.UsersDefinition),this.use(k.WidgetsDefinition),this.use(k.WikiDefinition)),xe(e.realtime)&&this.use(k.RealtimeDefinition);let d=e.userActions,m=typeof d=="object"&&"scopes"in d?{enabled:!0}:d;if(xe(m)){this.use(k.UserActionsDefinition);let y=h(this,bo,fu).call(this,e);y.length>0&&a(this,Jt,y)}}static addMenuItem(e){n(this,Ni).push(e)}static addCustomPostType(e){a(this,Vt,e)}static createForm(e,t){let r=`form.${n(this,Wt).size}`;return n(this,Wt).set(r,{form:e,onSubmit:t}),r}static addSchedulerJob(e){if(n(this,j)[k.SchedulerDefinition.fullName]||this.use(k.SchedulerDefinition),n(this,Gt).has(e.name))throw new Error(`Job ${e.name} is already defined`);n(this,Gt).set(e.name,e.onRun)}static addSettings(e){var o;let t=Array.isArray(e)?e:[e],r=t.filter(d=>d.type==="group"||!d.scope||d.scope===$e.Installation),s=t.filter(d=>d.type!=="group"&&d.scope===$e.App);r.length>0&&(n(this,We)??a(this,We,[]),n(this,We).push(...r)),s.length>0&&(n(this,Ve)??a(this,Ve,[]),n(this,Ve).push(...s)),Rt([...n(this,We)??[],...n(this,Ve)??[]]),n(this,j)[k.SettingsDefinition.fullName]||this.use(k.SettingsDefinition),globalThis.devvit??(globalThis.devvit={}),(o=globalThis.devvit).settings??(o.settings={}),globalThis.devvit.settings.app=n(this,Ve),globalThis.devvit.settings.installation=n(this,We)}static addTrigger(e){if("events"in e){for(let t of e.events)this.addTrigger({event:t,onEvent:(r,s)=>e.onEvent(r,s)});return this}return n(this,mt).has(e.event)?n(this,mt).get(e.event)?.push(e.onEvent):n(this,mt).set(e.event,[e.onEvent]),M}static provide(e){n(this,rn).push(e)}static use(e){n(this,zt)[e.fullName]={def:e,handler:void 0};let t={};for(let r of Object.values(e.methods))t[r.name]=(s,o)=>n(this,zt)[e.fullName].handler?.[r.name]?.(r.requestType?.fromPartial(s??{}),o);return n(this,j)[e.fullName]=t,t}static get redditAPIPlugins(){if(!xe(n(this,jt).redditAPI))throw new Error("Reddit API is not enabled. You can enable it by passing `redditAPI: true` to `Devvit.configure`.");return{Flair:n(this,j)[k.FlairDefinition.fullName],GraphQL:n(this,j)[k.GraphQLDefinition.fullName],LinksAndComments:n(this,j)[k.LinksAndCommentsDefinition.fullName],Listings:n(this,j)[k.ListingsDefinition.fullName],Moderation:n(this,j)[k.ModerationDefinition.fullName],ModNote:n(this,j)[k.ModNoteDefinition.fullName],NewModmail:n(this,j)[k.NewModmailDefinition.fullName],PrivateMessages:n(this,j)[k.PrivateMessagesDefinition.fullName],Subreddits:n(this,j)[k.SubredditsDefinition.fullName],Users:n(this,j)[k.UsersDefinition.fullName],Widgets:n(this,j)[k.WidgetsDefinition.fullName],Wiki:n(this,j)[k.WikiDefinition.fullName]}}static get modLogPlugin(){let e=n(this,j)[k.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=n(this,j)[k.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=n(this,j)[k.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=n(this,j)[k.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=n(this,j)[k.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=n(this,j)[k.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=n(this,j)[k.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(!(n(this,Jt).length>0&&xe(n(this,jt).redditAPI)))throw new Error("UserActions is not enabled. You can enable it by passing scopes in `userActions: { scopes: [...scopes] }` and `redditAPI: true` to `Devvit.configure`");return n(this,j)[k.UserActionsDefinition.fullName]}static get menuItems(){return n(this,Ni)}static get customPostType(){return n(this,Vt)}static get formDefinitions(){return n(this,Wt)}static get scheduledJobHandlers(){return n(this,Gt)}static get installationSettings(){return n(this,We)}static get appSettings(){return n(this,Ve)}static get triggerOnEventHandlers(){return n(this,mt)}static get assets(){return globalThis.devvit?.assets??{}}static get webViewAssets(){return n(this,tn)}constructor(e){var t;super(e),globalThis.devvit??(globalThis.devvit={}),(t=globalThis.devvit).assets??(t.assets=e.assets),a(M,tn,e.webviewAssets??{});for(let r in n(M,zt)){let s=n(M,zt)[r];s.handler=e.use(s.def)}n(M,Ni).length>0&&Cl(e),n(M,Gt).size>0&&Pl(e),n(M,Vt)&&(hl(e),hu(e)),(n(M,Vt)||n(M,Wt).size>0)&&jl(e),n(M,We)&&fl(e),n(M,Ve)&&Xd(e),n(M,mt).size>0&&Sl(e);for(let r of n(M,rn))e.provides(r);(n(M,Li).length>0||n(M,Jt).length>0)&&e.addPermissions({requestedFetchDomains:n(M,Li),asUserScopes:n(M,Jt)})}};Ve=new WeakMap,jt=new WeakMap,Vt=new WeakMap,Wt=new WeakMap,We=new WeakMap,Ni=new WeakMap,Gt=new WeakMap,mt=new WeakMap,tn=new WeakMap,Li=new WeakMap,Jt=new WeakMap,rn=new WeakMap,zt=new WeakMap,j=new WeakMap,bo=new WeakSet,fu=function(e){let t=e.userActions;return t?typeof t=="object"&&"enabled"in t&&t.enabled?[]:typeof t=="object"&&"scopes"in t?t.scopes:[]:[]},l(M,bo),M.debug={},l(M,Ve),l(M,jt,{}),l(M,Vt),l(M,Wt,new Map),l(M,We),l(M,Ni,[]),l(M,Gt,new Map),l(M,mt,new Map),l(M,tn,{}),l(M,Li,[]),l(M,Jt,[]),l(M,rn,[]),l(M,zt,{}),l(M,j,{});var u=M;(e=>{function i(t,r,...s){return{type:t,props:r,children:s}}e.createElement=i})(u||(u={}));function X(i){let e=Object.getOwnPropertyDescriptors(i.constructor.prototype);for(let[t,r]of Object.entries(e))r.get&&Object.defineProperty(i,t,{...r,enumerable:!0})}var Va;(function(i){i[i.bold=1]="bold",i[i.italic=2]="italic",i[i.underline=4]="underline",i[i.strikethrough=8]="strikethrough",i[i.subscript=16]="subscript",i[i.superscript=32]="superscript",i[i.monospace=64]="monospace"})(Va||(Va={}));var yu="text",bu="raw",vu="br",ku="link",Cu="c/",Pu="p/",Su="r/",wu="u/",Fu="@",xu="spoilertext",Au="par",Iu="h",Eu="hr",Tu="blockquote",Ru="code",Ou="li",Mu="list",Uu="L",Bu="R",Du="C",Nu="table",Lu="embed",_u="img",Hu="gif",ju="video";function Vu(i){return{e:Hu,id:i.mediaId,...i.caption&&{c:i.caption},...i.blur&&{o:i.blur}}}function Wu(i,e){let t={},r=[];return Object.assign(t,nn(t,r),sn(t,r),on(t,r),ln(t,r),un(t,r),cn(t,r)),e(t),{e:Tu,c:r,...i.author&&{a:i.author}}}function Gu(i,e){let t={},r=[];return Object.assign(t,Ga(t,r)),e(t),{e:Ru,c:r,...i.language&&{l:i.language}}}function Ju(i){return{e:Cu,t:i.permalink}}function zu(i,e){let t={},r=[];return Object.assign(t,Ga(t,r),dn(t,r)),e(t),{e:Iu,l:i.level,c:r}}function qu(i){return{e:Lu,u:i.sourceUrl,c:i.contentUrl,x:i.width,y:i.height}}function $u(){return{e:Eu}}function Ku(i){return{e:_u,id:i.mediaId,...i.caption&&{c:i.caption},...i.blur&&{o:i.blur}}}function Xu(){return{e:vu}}function Zu(i){return{e:ku,t:i.text,u:i.url,...i.formatting&&{f:i.formatting},...i.tooltip&&{a:i.tooltip}}}function Qu(i,e){let t={},r=[];return Object.assign(t,gc(t,r)),e(t),{e:Mu,o:i.ordered,c:r}}function Yu(i){let e={},t=[];return Object.assign(e,nn(e,t),sn(e,t),on(e,t),vo(e,t),ln(e,t),un(e,t),cn(e,t)),i(e),{e:Ou,c:t}}function ec(i){let e={},t=[];return Object.assign(e,ko(e,t),dn(e,t),Wa(e,t),Ja(e,t),an(e,t)),i(e),{e:Au,c:t}}function tc(i){return{e:Pu,t:i.permalink}}function ic(i){return{e:bu,t:i}}function rc(i){let e={},t=[];return Object.assign(e,ko(e,t),dn(e,t),Wa(e,t)),i(e),{e:xu,c:t}}function nc(i){return{e:Su,t:i.subredditName,l:i.showPrefix}}function sc(i){let e={},t=[],r=[];return Object.assign(e,hc(e,t,r)),i(e),{e:Nu,h:t,c:r}}function oc(i){let[e,t]=pc();return i(e),{c:t}}function ac(i,e){let[t,r]=pc();e(t);let s;switch(i.columnAlignment){case"left":s=Uu;break;case"right":s=Bu;break;case"center":s=Du;break}return{...s&&{a:s},...r&&{c:r}}}function dc(i){let e={},t=[];return Object.assign(e,fc(e,t)),i(e),t}function lc(i){return{e:yu,t:i.text,...i.formatting&&{f:i.formatting}}}function uc(i){return{e:wu,t:i.username,l:i.showPrefix}}function cc(i){return{e:Fu,t:i.username,l:i.showPrefix}}function mc(i){return{e:ju,id:i.mediaId,...i.caption&&{c:i.caption},...i.blur&&{o:i.blur},...i.thumbnail&&{p:i.thumbnail},...i.convertToGif&&{gifify:i.convertToGif}}}function pc(){let i={},e=[];return Object.assign(i,ko(i,e),dn(i,e),Ja(i,e),an(i,e)),[i,e]}function nn(i,e){return{blockQuote(t,r){return e.push(Wu(t,r)),i}}}function sn(i,e){return{codeBlock(t,r){return e.push(Gu(t,r)),i}}}function yc(i,e){return{embed(t){return e.push(qu(t)),i}}}function on(i,e){return{heading(t,r){return e.push(zu(t,r)),i}}}function vo(i,e){return{horizontalRule(){return e.push($u()),i}}}function an(i,e){return{image(t){return e.push(Ku(t)),i},animatedImage(t){return e.push(Vu(t)),i}}}function Wa(i,e){return{linebreak(){return e.push(Xu()),i}}}function dn(i,e){return{link(t){return e.push(Zu(t)),i},commentLink(t){return e.push(Ju(t)),i},postLink(t){return e.push(tc(t)),i},subredditLink(t){return e.push(nc(t)),i},userLink(t){return e.push(uc(t)),i},userMention(t){return e.push(cc(t)),i}}}function ln(i,e){return{list(t,r){return e.push(Qu(t,r)),i}}}function gc(i,e){return{item(t){return e.push(Yu(t)),i}}}function un(i,e){return{paragraph(t){return e.push(ec(t)),i}}}function Ga(i,e){return{rawText(t){return e.push(ic(t)),i}}}function Ja(i,e){return{spoiler(t){return e.push(rc(t)),i}}}function hc(i,e,t){return{headerCell(r,s){return e.push(ac(r,s)),i},row(r){return t.push(dc(r)),i}}}function cn(i,e){return{table(t){return e.push(sc(t)),i}}}function fc(i,e){return{cell(t){return e.push(oc(t)),i}}}function ko(i,e){return{text(t){return e.push(lc(t)),i}}}function bc(i,e){return{video(t){return e.push(mc(t)),i}}}var Qp=function(i,e,t,r,s){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!s:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?s.call(i,t):s?s.value=t:e.set(i,t),t},Yp=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},Co,qt=class{constructor(){Co.set(this,void 0);let e=[];Object.assign(this,un(this,e),on(this,e),vo(this,e),nn(this,e),sn(this,e),yc(this,e),ln(this,e),cn(this,e),an(this,e),bc(this,e)),Qp(this,Co,{document:e},"f")}build(){return JSON.stringify(Yp(this,Co,"f"))}paragraph(e){return this}heading(e,t){return this}horizontalRule(){return this}blockQuote(e,t){return this}codeBlock(e,t){return this}embed(e){return this}list(e,t){return this}table(e){return this}image(e){return this}animatedImage(e){return this}video(e){return this}};Co=new WeakMap;function _i(i){let e;return i instanceof qt?e=i.build():typeof i=="object"?e=JSON.stringify(i):e=i,e}var vc=100,kc=1/0,$t,Kt,pt,Hi,ji,Po,W=class{constructor(e){l(this,ji);l(this,$t);l(this,Kt);l(this,pt);l(this,Hi,!1);this.pageSize=vc;this.limit=kc;this.children=[];X(this),this._fetch=e.fetch,this.pageSize=e.pageSize??vc,this.limit=e.limit??kc,a(this,Kt,e.after),a(this,$t,e.before),a(this,pt,e.more),e.children&&(this.children=e.children)}get hasMore(){return!n(this,Hi)||!!(n(this,Kt)||n(this,$t)||n(this,pt))}async*[Symbol.asyncIterator](){let e=0;for(;;){if(e===this.children.length)if(this.hasMore){if((await h(this,ji,Po).call(this)).length===0)break}else break;if(yield this.children[e],e++,e===this.limit)break}}setMore(e){a(this,pt,e)}preventInitialFetch(){a(this,Hi,!0)}async all(){for(;this.hasMore&&this.children.length<this.limit;)await h(this,ji,Po).call(this);return this.children.slice(0,this.limit)}async get(e){let t=e<=this.limit?e:this.limit;for(;this.hasMore&&this.children.length<t;)await h(this,ji,Po).call(this);return this.children.slice(0,t)}};$t=new WeakMap,Kt=new WeakMap,pt=new WeakMap,Hi=new WeakMap,ji=new WeakSet,Po=async function(){if(!this.hasMore)throw new Error("This listing does not have any more items to load.");let{children:e,before:t,after:r,more:s}=await this._fetch({before:n(this,$t),after:n(this,Kt),limit:this.pageSize,more:n(this,pt)});return this.children.push(...e),a(this,$t,t),a(this,Kt,r),a(this,pt,s),a(this,Hi,!0),e};var mn,za,ke=class{constructor(){}static get(e,t){let r=u.redditAPIPlugins.ModNote;return new W({hasMore:!0,before:e.before,limit:e.limit,pageSize:e.limit,fetch:async s=>{let o=await r.GetNotes({subreddit:e.subreddit,user:e.user,filter:e.filter,before:s.before,limit:s.limit},t);return{children:o.modNotes?.map(d=>h(this,mn,za).call(this,d))||[],before:o.hasNextPage?o.endCursor:void 0,hasMore:o.hasNextPage}}})}static async delete(e,t){let r=u.redditAPIPlugins.ModNote,{deleted:s}=await r.DeleteNotes(e,t);return!!s}static async add(e,t){let s=await u.redditAPIPlugins.ModNote.PostNotes(e,t);if(!s?.created)throw new Error("Failed to create mod note");return h(this,mn,za).call(this,s.created)}static async addRemovalNote(e,t){await u.redditAPIPlugins.ModNote.PostRemovalNote(e,t)}};mn=new WeakSet,za=function(e){return p(e.id,"Mod note ID is null or undefined"),p(e.createdAt,"Mod note createdAt is null or undefined"),p(e.type,"Mod note type is null or undefined"),p(e.subreddit,"Mod note subreddit is null or undefined"),p(e.subredditId,"Mod note subredditId is null or undefined"),p(e.operator,"Mod note operator is null or undefined"),p(e.operatorId,"Mod note operatorId is null or undefined"),p(e.user,"Mod note user is null or undefined"),p(e.userId,"Mod note userId is null or undefined"),p(e.userNoteData,"Mod note userNote is null or undefined"),p(e.modActionData,"Mod note modAction is null or undefined"),{id:e.id,user:{id:te(e.userId??""),name:e.user},subreddit:{id:K(e.subredditId??""),name:e.subreddit},operator:{id:te(e.operatorId??""),name:e.operator},createdAt:new Date(e.createdAt*1e3),userNote:{note:e.userNoteData?.note,redditId:e.userNoteData?.redditId?ye(e.userNoteData?.redditId):void 0,label:e.userNoteData?.label},type:e.type}},l(ke,mn);var Y=class{static queryWithQueryString(e,t){return u.redditAPIPlugins.GraphQL.Query({query:e},t)}static query(e,t,r,s){return u.redditAPIPlugins.GraphQL.PersistedQuery({operationName:e,id:t,variables:r},s)}};var Cc=["all","wiki","posts","access","mail","config","flair","channels","chat_config","chat_operator","community_chat"];function eg(i,e){return e.map(t=>(i.includes(t)?"+":"-")+t).join(",")}function qa(i){return eg(i,Cc)}function Pc(i){return i.filter(e=>Cc.includes(e))}import"@devvit/protos";var tg=(t=>(t.User="USER_FLAIR",t.Post="LINK_FLAIR",t))(tg||{}),Xt,Vi,Wi,Gi,Ji,zi,qi,$i,Ki,Xi,Zi,So,Ie=class Ie{constructor(e,t,r){l(this,Xt);l(this,Vi);l(this,Wi);l(this,Gi);l(this,Ji);l(this,zi);l(this,qi);l(this,$i);l(this,Ki);l(this,Xi);X(this),p(e.id),p(e.text),a(this,Xt,e.id),a(this,Vi,t),a(this,Wi,e.text),a(this,Gi,ig(e.textColor)),a(this,Ji,rg(e.backgroundColor)),a(this,zi,ng(e.allowableContent)),a(this,qi,e.modOnly),a(this,$i,e.maxEmojis),a(this,Ki,e.textEditable),a(this,Xi,r)}get id(){return n(this,Xt)}get text(){return n(this,Wi)}get textColor(){return n(this,Gi)}get backgroundColor(){return n(this,Ji)}get allowableContent(){return n(this,zi)}get modOnly(){return n(this,qi)}get maxEmojis(){return n(this,$i)}get allowUserEdits(){return n(this,Ki)}async delete(){return Ie.deleteFlairTemplate(n(this,Xt),n(this,Vi),n(this,Xi))}async edit(e){return Ie.editFlairTemplate({id:n(this,Xt),subredditName:n(this,Vi),text:e.text??n(this,Wi),allowableContent:e.allowableContent??n(this,zi),backgroundColor:e.backgroundColor??n(this,Ji),maxEmojis:e.maxEmojis??n(this,$i),modOnly:e.modOnly??n(this,qi),textColor:e.textColor??n(this,Gi),allowUserEdits:e.allowUserEdits??n(this,Ki)},n(this,Xi))}static async createPostFlairTemplate(e,t){var r;return h(r=Ie,Zi,So).call(r,{...e,flairType:"LINK_FLAIR"},t)}static async createUserFlairTemplate(e,t){var r;return h(r=Ie,Zi,So).call(r,{...e,flairType:"USER_FLAIR"},t)}static async editFlairTemplate(e,t){var r;return h(r=Ie,Zi,So).call(r,e,t)}static async getPostFlairTemplates(e,t){return(await u.redditAPIPlugins.Flair.LinkFlair({subreddit:e},t)).flair?.map(o=>new Ie(o,e,t))||[]}static async getUserFlairTemplates(e,t){return(await u.redditAPIPlugins.Flair.UserFlair({subreddit:e},t)).flair?.map(o=>new Ie(o,e,t))||[]}static async deleteFlairTemplate(e,t,r){await u.redditAPIPlugins.Flair.DeleteFlairTemplate({subreddit:e,flairTemplateId:t},r)}};Xt=new WeakMap,Vi=new WeakMap,Wi=new WeakMap,Gi=new WeakMap,Ji=new WeakMap,zi=new WeakMap,qi=new WeakMap,$i=new WeakMap,Ki=new WeakMap,Xi=new WeakMap,Zi=new WeakSet,So=async function(e,t){let{subredditName:r,allowableContent:s="all",backgroundColor:o="transparent",flairType:d="",maxEmojis:c=10,modOnly:m=!1,text:y,textColor:v="dark",allowUserEdits:f=!1,id:S=""}=e;if(m&&f)throw new Error("Cannot have a mod only flair that is editable by users");let _=await u.redditAPIPlugins.Flair.FlairTemplate({subreddit:r,allowableContent:s,backgroundColor:o,flairType:d,maxEmojis:c,modOnly:m,text:y,textColor:v,textEditable:f,flairTemplateId:S,cssClass:"",overrideCss:!1},t);return new Ie(_,r,t)},l(Ie,Zi);var ne=Ie;function pn(i){return{flairCssClass:i.flairCssClass,user:i.user,flairText:i.flairText}}var Ue,$a,Sc,Ka,gt=class gt{static async getUserFlairBySubreddit(e,t){return u.redditAPIPlugins.Flair.FlairList(e,t)}static setUserFlair(e,t){var r;return h(r=gt,Ue,$a).call(r,e,t)}static setUserFlairBatch(e,t,r){var s;return h(s=gt,Ue,Sc).call(s,e,t,r)}static setPostFlair(e,t){var r;return h(r=gt,Ue,$a).call(r,{...e,postId:de(e.postId)},t)}static async removePostFlair(e,t,r){var s;return h(s=gt,Ue,Ka).call(s,e,t,void 0,r)}static async removeUserFlair(e,t,r){var s;return h(s=gt,Ue,Ka).call(s,e,void 0,t,r)}};Ue=new WeakSet,$a=async function(e,t){await u.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"},t)},Sc=async function(e,t,r){if(!t.length)return[];if(t.length>100)throw new Error("Unexpected input: flairs array cannot be longer than 100 entries.");let o=",",d=t.map(y=>{for(let v in y)if(y[v]?.includes(o))throw new Error(`Unexpected input: ${v} cannot contain the "," character`);return[y.username,y.text||"",y.cssClass||""].join(o)}).join(`
4
- `);return(await u.redditAPIPlugins.Flair.FlairCsv({subreddit:e,flairCsv:d},r)).result},Ka=async function(e,t,r,s){await u.redditAPIPlugins.Flair.SelectFlair({subreddit:e,name:r??"",link:t??"",flairTemplateId:"",backgroundColor:"",text:"",textColor:"",cssClass:"",returnRtjson:"none"},s)},l(gt,Ue);var ce=gt;function ig(i){if(p(i,"Flair text color is required"),i==="light"||i==="dark")return i;throw new Error(`Invalid flair text color: ${i}`)}function rg(i){if(!i||i.length===0||i==="transparent")return"transparent";if(/^#([A-Fa-f0-9]{6})$/.test(i))return i;throw new Error(`Invalid flair background color: ${i}`)}function ng(i){if(i==="all"||i==="text"||i==="emoji")return i;throw new Error(`Invalid allowable content: ${i}`)}import{Block as Ac,UIResponse as pg}from"@devvit/protos";var Qa=ld(xc(),1);var Za=i=>"text"in i?i.text:mg(i.richtext),mg=i=>i instanceof qt?i.build():typeof i=="object"?JSON.stringify(i):i;var gg={NONE:0,BLOCKS:1,UNRECOGNIZED:-1},qC={UNKNOWN:0,VALID:1,FAILED:2},Qi,hn,Qt,fn,Yi,yn,bn,vn,Yt,kn,Cn,Pn,Sn,wn,Fn,ht,xn,An,ei,er,ft,tr,ir,rr,yt,bt,vt,nr,kt,Ct,Pt,Ge,In,En,sr,or,ar,U,D=class D{constructor(e,t){l(this,Qi);l(this,hn);l(this,Qt);l(this,fn);l(this,Yi);l(this,yn);l(this,bn);l(this,vn);l(this,Yt);l(this,kn);l(this,Cn);l(this,Pn);l(this,Sn);l(this,wn);l(this,Fn);l(this,ht);l(this,xn);l(this,An);l(this,ei);l(this,er);l(this,ft);l(this,tr);l(this,ir);l(this,rr);l(this,yt);l(this,bt);l(this,vt);l(this,nr);l(this,kt);l(this,Ct);l(this,Pt);l(this,Ge);l(this,In);l(this,En);l(this,sr);l(this,or);l(this,ar);l(this,U);X(this),p(e.id,"Post is missing id"),p(e.title,"Post is missing title"),p(e.createdUtc,"Post is missing created date"),p(e.author,"Post is missing author name"),p(e.subreddit,"Post is missing subreddit name"),p(e.subredditId,"Post is missing subreddit id"),p(e.url,"Post is missing url"),p(e.permalink,"Post is missing permalink"),a(this,Qi,de(`t3_${e.id}`)),a(this,Qt,e.author),a(this,hn,e.authorFullname?te(e.authorFullname):void 0),a(this,Yi,K(e.subredditId)),a(this,yn,e.subreddit),a(this,Pn,e.score??0),a(this,Sn,e.numComments??0),a(this,wn,e.numReports??0);let r=new Date(0);r.setUTCSeconds(e.createdUtc),a(this,fn,r),a(this,vn,e.title),a(this,Yt,e.selftext),a(this,kn,e.selftextHtml),a(this,Cn,e.url),a(this,bn,e.permalink),e.thumbnail&&e.thumbnail!=="self"&&e.thumbnail!=="nsfw"&&e.thumbnailHeight!=null&&e.thumbnailWidth!=null&&a(this,Fn,{url:e.thumbnail,height:e.thumbnailHeight,width:e.thumbnailWidth}),a(this,ht,e.approved??!1),a(this,xn,e.approvedAtUtc??0),a(this,An,e.bannedAtUtc??0),a(this,ft,e.removed??!1),a(this,tr,e.removedBy),a(this,ir,e.removedByCategory),a(this,ei,e.spam??!1),a(this,er,e.stickied??!1),a(this,rr,e.archived??!1),a(this,yt,e.edited??!1),a(this,bt,e.locked??!1),a(this,vt,e.over18??!1),a(this,nr,e.quarantine??!1),a(this,kt,e.spoiler),a(this,Ct,e.hidden??!1),a(this,Pt,e.ignoreReports??!1),a(this,Ge,e.distinguished),a(this,En,e.secureMedia),a(this,sr,(e.modReports??[]).map(([s])=>s)),a(this,or,(e.userReports??[]).map(([s])=>s)),a(this,U,t),(e.linkFlairBackgroundColor||e.linkFlairCssClass||e.linkFlairText||e.linkFlairType||e.linkFlairTemplateId||e.linkFlairRichtext||e.linkFlairTextColor)&&a(this,In,{backgroundColor:e.linkFlairBackgroundColor,cssClass:e.linkFlairCssClass,text:e.linkFlairText,type:e.linkFlairType,templateId:e.linkFlairTemplateId,richtext:(e.linkFlairRichtext??[]).map(({e:s,t:o,a:d,u:c})=>({elementType:s,text:o,emojiRef:d,url:c})),textColor:e.linkFlairTextColor}),e.gallery?a(this,ar,e.gallery.map(s=>({status:s.status,url:s.url,height:s.height,width:s.width}))):a(this,ar,[])}get id(){return n(this,Qi)}get authorId(){return n(this,hn)}get authorName(){return n(this,Qt)}get subredditId(){return n(this,Yi)}get subredditName(){return n(this,yn)}get permalink(){return n(this,bn)}get title(){return n(this,vn)}get body(){return n(this,Yt)}get bodyHtml(){return n(this,kn)}get url(){return n(this,Cn)}get thumbnail(){return n(this,Fn)}get createdAt(){return n(this,fn)}get score(){return n(this,Pn)}get numberOfComments(){return n(this,Sn)}get numberOfReports(){return n(this,wn)}get approved(){return n(this,ht)}get approvedAtUtc(){return n(this,xn)}get bannedAtUtc(){return n(this,An)}get spam(){return n(this,ei)}get stickied(){return n(this,er)}get removed(){return n(this,ft)}get removedBy(){return n(this,tr)}get removedByCategory(){return n(this,ir)}get archived(){return n(this,rr)}get edited(){return n(this,yt)}get locked(){return n(this,bt)}get nsfw(){return n(this,vt)}get quarantined(){return n(this,nr)}get spoiler(){return n(this,kt)}get hidden(){return n(this,Ct)}get ignoringReports(){return n(this,Pt)}get distinguishedBy(){return n(this,Ge)}get comments(){return Q.getComments({postId:this.id},n(this,U))}get flair(){return n(this,In)}get secureMedia(){return n(this,En)}get userReportReasons(){return n(this,or)}get modReportReasons(){return n(this,sr)}get gallery(){return n(this,ar)}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:n(this,tr),removedByCategory:n(this,ir),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:n(this,sr),userReportReasons:n(this,or)}}isApproved(){return n(this,ht)}isSpam(){return n(this,ei)}isStickied(){return n(this,er)}isRemoved(){return n(this,ft)}isArchived(){return n(this,rr)}isEdited(){return n(this,yt)}isLocked(){return n(this,bt)}isNsfw(){return n(this,vt)}isQuarantined(){return n(this,nr)}isSpoiler(){return n(this,kt)}isHidden(){return n(this,Ct)}isIgnoringReports(){return n(this,Pt)}isDistinguishedBy(){return n(this,Ge)}async edit(e){let t=await D.edit({id:this.id,...e},n(this,U));a(this,Yt,t.body),a(this,yt,t.edited)}async setSuggestedCommentSort(e){await D.setSuggestedCommentSort({id:this.id,subredditId:n(this,Yi),suggestedSort:e},n(this,U))}async setPostData(e){await D.setPostData({postId:this.id,postData:e},n(this,U))}async setCustomPostPreview(e){await D.setCustomPostPreview({id:this.id,ui:e},n(this,U))}async setTextFallback(e){let t=await D.setTextFallback(e,this.id,n(this,U));a(this,Yt,t.body),a(this,yt,t.edited)}async addComment(e){return Q.submit({id:this.id,...e},n(this,U))}async delete(){p(n(this,U));let e=n(this,U)?.[P.App]?.values[0];if(e!==n(this,Qt))throw new Error(`App '${e}' is not the author of Post ${this.id}, delete not allowed.`);return D.delete(this.id,n(this,U))}async approve(){await D.approve(this.id,n(this,U)),a(this,ht,!0),a(this,ft,!1)}async remove(e=!1){await D.remove(this.id,e,n(this,U)),a(this,ft,!0),a(this,ei,e),a(this,ht,!1)}async lock(){await D.lock(this.id,n(this,U)),a(this,bt,!0)}async unlock(){await D.unlock(this.id,n(this,U)),a(this,bt,!1)}async hide(){await D.hide(this.id,n(this,U)),a(this,Ct,!0)}async unhide(){await D.unhide(this.id,n(this,U)),a(this,Ct,!1)}async markAsNsfw(){await D.markAsNsfw(this.id,n(this,U)),a(this,vt,!0)}async unmarkAsNsfw(){await D.unmarkAsNsfw(this.id,n(this,U)),a(this,vt,!1)}async markAsSpoiler(){await D.markAsSpoiler(this.id,n(this,U)),a(this,kt,!0)}async unmarkAsSpoiler(){await D.unmarkAsSpoiler(this.id,n(this,U)),a(this,kt,!1)}async sticky(e){await D.sticky(this.id,e,n(this,U))}async unsticky(){await D.unsticky(this.id,n(this,U))}async distinguish(){let{distinguishedBy:e}=await D.distinguish(this.id,!1,n(this,U));a(this,Ge,e)}async distinguishAsAdmin(){let{distinguishedBy:e}=await D.distinguish(this.id,!0,n(this,U));a(this,Ge,e)}async undistinguish(){let{distinguishedBy:e}=await D.undistinguish(this.id,n(this,U));a(this,Ge,e)}async ignoreReports(){await D.ignoreReports(this.id,n(this,U)),a(this,Pt,!0)}async unignoreReports(){await D.unignoreReports(this.id,n(this,U)),a(this,Pt,!1)}async getAuthor(){return C.getByUsername(n(this,Qt),n(this,U))}async crosspost(e){return D.crosspost({...e,postId:this.id},n(this,U))}addRemovalNote(e){return ke.addRemovalNote({itemIds:[n(this,Qi)],...e},n(this,U))}async getEnrichedThumbnail(){return hg({id:this.id},n(this,U))}static async getById(e,t){let r=u.redditAPIPlugins.LinksAndComments,s=Tt(e)?e:`t3_${e}`,o=await r.Info({subreddits:[],thingIds:[s]},t);if(!o.data?.children?.length)throw new Error("could not find post");let d=o.data.children[0];if(!d?.data)throw new Error("could not find post");return new D(d.data,t)}static async submit(e,t){let{runAs:r="APP"}=e,s=fe[r],o=s===fe.USER?u.userActionsPlugin:u.redditAPIPlugins.LinksAndComments,d;if("preview"in e){p(t,"Missing metadata in `SubmitPostOptions`"),s===fe.USER&&p(e.userGeneratedContent,"userGeneratedContent must be set in `SubmitPostOptions` when RunAs=USER for experience posts");let y=await new _e(()=>e.preview,void 0,{},t,void 0).buildBlocksUI(),v=Ac.encode(y).finish(),{textFallback:f,...S}=e,b=f?Za(f):"",_=e.userGeneratedContent?{text:e.userGeneratedContent.text??"",imageUrls:e.userGeneratedContent.imageUrls??[]}:void 0,A=e.postData?{developerData:e.postData}:void 0,N={kind:"custom",sr:e.subredditName,richtextJson:(0,Qa.fromByteArray)(v),richtextFallback:b,...S,userGeneratedContent:_,runAs:s,postData:A};d=await o.SubmitCustomPost(N,t)}else d=await o.Submit({kind:"kind"in e?e.kind:"url"in e?"link":"self",sr:e.subredditName,richtextJson:"richtext"in e?_i(e.richtext):void 0,...e,runAs:s},t);if("kind"in e&&["image","video","videogif"].includes(e.kind)&&!d.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(!d.json?.data?.id||d.json?.errors?.length)throw new Error(`failed to submit post - either post ID is empty or request failed with errors: ${d.json?.errors}`);return D.getById(`t3_${d.json.data.id}`,t)}static async crosspost(e,t){let{runAs:r="APP"}=e,s=fe[r],o=s===fe.USER?u.userActionsPlugin:u.redditAPIPlugins.LinksAndComments,{postId:d,subredditName:c,...m}=e,y=await o.Submit({kind:"crosspost",sr:c,crosspostFullname:de(d),...m,runAs:s},t);if(!y.json?.data?.id||y.json?.errors?.length)throw new Error("failed to crosspost post");return D.getById(`t3_${y.json.data.id}`,t)}static async edit(e,t){let r=u.redditAPIPlugins.LinksAndComments,{id:s}=e,o;if("richtext"in e&&(o=_i(e.richtext)),(await r.EditUserText({thingId:s,text:"text"in e?e.text:"",richtextJson:o,runAs:fe.APP},t)).json?.errors?.length)throw new Error("Failed to edit post");return D.getById(s,t)}static async setSuggestedCommentSort(e,t){if(!(await Y.query("SetSuggestedSort","cf6052acc7fefaa65b710625b81dba8041f258313aafe9730e2a3dc855e5d10d",{input:{subredditId:e.subredditId,postId:e.id,sort:e.suggestedSort}},t)).data?.setSuggestedSort?.ok)throw new Error("Failed to set suggested sort")}static async setPostData(e,t){let r=e.postData?{developerData:e.postData}:void 0,s=await u.redditAPIPlugins.LinksAndComments.EditCustomPost({thingId:e.postId,postData:r},t);if(s.json?.errors?.length)throw new Error(`Failed to set post data, errors: ${s.json?.errors}`)}static async setCustomPostPreview(e,t){if(!t)throw new Error("Failed to set custom post preview. Metadata not found");let r=u.redditAPIPlugins.LinksAndComments,s=new Ht(e.ui),d=pg.fromJSON(await s.handle({events:[]},t)).blocks,c=(0,Qa.fromByteArray)(Ac.encode(d).finish());await r.SetCustomPostPreview({thingId:e.id,bodyType:gg.BLOCKS,blocksRenderContent:c},t)}static async setTextFallback(e,t,r){if(!("text"in e)&&!("richtext"in e))throw new Error(`No text fallback provided for post ${t}.`);let s=u.redditAPIPlugins.LinksAndComments,o=Za(e);if((await s.EditCustomPost({thingId:t,richtextFallback:o},r)).json?.errors?.length)throw new Error("Failed to set post text fallback");return D.getById(t,r)}static async delete(e,t){await u.redditAPIPlugins.LinksAndComments.Del({id:e},t)}static async approve(e,t){await u.redditAPIPlugins.Moderation.Approve({id:e},t)}static async remove(e,t=!1,r){await u.redditAPIPlugins.Moderation.Remove({id:e,spam:t},r)}static async hide(e,t){await u.redditAPIPlugins.LinksAndComments.Hide({id:e},t)}static async unhide(e,t){await u.redditAPIPlugins.LinksAndComments.Unhide({id:e},t)}static async markAsNsfw(e,t){await u.redditAPIPlugins.LinksAndComments.MarkNSFW({id:e},t)}static async unmarkAsNsfw(e,t){await u.redditAPIPlugins.LinksAndComments.UnmarkNSFW({id:e},t)}static async markAsSpoiler(e,t){await u.redditAPIPlugins.LinksAndComments.Spoiler({id:e},t)}static async unmarkAsSpoiler(e,t){await u.redditAPIPlugins.LinksAndComments.Unspoiler({id:e},t)}static async sticky(e,t,r){await u.redditAPIPlugins.LinksAndComments.SetSubredditSticky({id:e,state:!0,num:t},r)}static async unsticky(e,t){await u.redditAPIPlugins.LinksAndComments.SetSubredditSticky({id:e,state:!1},t)}static async lock(e,t){await u.redditAPIPlugins.LinksAndComments.Lock({id:e},t)}static async unlock(e,t){await u.redditAPIPlugins.LinksAndComments.Unlock({id:e},t)}static async distinguish(e,t,r){let d=(await u.redditAPIPlugins.Moderation.Distinguish({id:e,how:t?"admin":"yes",sticky:!1},r)).json?.data?.things?.[0]?.data;return p(d),{distinguishedBy:d.distinguished}}static async undistinguish(e,t){let o=(await u.redditAPIPlugins.Moderation.Distinguish({id:e,how:"no",sticky:!1},t)).json?.data?.things?.[0]?.data;return p(o),{distinguishedBy:o.distinguished}}static async ignoreReports(e,t){await u.redditAPIPlugins.Moderation.IgnoreReports({id:e},t)}static async unignoreReports(e,t){await u.redditAPIPlugins.Moderation.UnignoreReports({id:e},t)}static getControversialPosts(e={},t){return this.getSortedPosts({...e,sort:"controversial"},t)}static getTopPosts(e={},t){return this.getSortedPosts({...e,sort:"top"},t)}static getSortedPosts(e,t){let r=u.redditAPIPlugins.Listings;return new W({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,fetch:async s=>{let o=await r.Sort({show:"all",sort:e.sort,t:e.timeframe,subreddit:e.subredditName,...s},t);return gn(o,t)}})}static getHotPosts(e={location:"GLOBAL"},t){let r=u.redditAPIPlugins.Listings;return new W({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,fetch:async s=>{let o=await r.Hot({g:e.location,show:"all",subreddit:e.subredditName,...s},t);return gn(o,t)}})}static getNewPosts(e,t){let r=u.redditAPIPlugins.Listings;return new W({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,fetch:async s=>{let o=await r.New({show:"all",subreddit:e.subredditName,...s},t);return gn(o,t)}})}static getRisingPosts(e,t){let r=u.redditAPIPlugins.Listings;return new W({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,fetch:async s=>{let o=await r.Rising({show:"all",subreddit:e.subredditName,...s},t);return gn(o,t)}})}static getPostsByUser(e,t){let r=u.redditAPIPlugins.Users;return new W({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,async fetch(s){let o=await r.UserWhere({username:e.username,where:"submitted",...s},t);return gn(o,t)}})}};Qi=new WeakMap,hn=new WeakMap,Qt=new WeakMap,fn=new WeakMap,Yi=new WeakMap,yn=new WeakMap,bn=new WeakMap,vn=new WeakMap,Yt=new WeakMap,kn=new WeakMap,Cn=new WeakMap,Pn=new WeakMap,Sn=new WeakMap,wn=new WeakMap,Fn=new WeakMap,ht=new WeakMap,xn=new WeakMap,An=new WeakMap,ei=new WeakMap,er=new WeakMap,ft=new WeakMap,tr=new WeakMap,ir=new WeakMap,rr=new WeakMap,yt=new WeakMap,bt=new WeakMap,vt=new WeakMap,nr=new WeakMap,kt=new WeakMap,Ct=new WeakMap,Pt=new WeakMap,Ge=new WeakMap,In=new WeakMap,En=new WeakMap,sr=new WeakMap,or=new WeakMap,ar=new WeakMap,U=new WeakMap;var G=D;function gn(i,e){if(!i.data?.children)throw new Error("Listing response is missing children");return{children:i.data.children.map(r=>new G(r.data,e)),before:i.data.before,after:i.data.after}}async function hg(i,e){let o=(await Y.query("GetThumbnailV2","81580ce4e23d748c5a59a1618489b559bf4518b6a73af41f345d8d074c8b2ce9",{id:i.id},e)).data?.postInfoById?.thumbnailV2;if(o){if(!o.image)return}else throw new Error("Failed to get thumbnail");return{attribution:o.attribution,image:{url:o.image.url,width:o.image.dimensions.width,height:o.image.dimensions.height},isObfuscatedDefault:o.isObfuscatedDefault,...o.obfuscatedImage&&{obfuscatedImage:{url:o.obfuscatedImage.url,width:o.obfuscatedImage.dimensions.width,height:o.obfuscatedImage.dimensions.height}}}}var fg=(H=>(H.Custom="CUSTOM",H.Reddit="REDDIT",H.Instagram="INSTAGRAM",H.Twitter="TWITTER",H.Tiktok="TIKTOK",H.Twitch="TWITCH",H.Facebook="FACEBOOK",H.Youtube="YOUTUBE",H.Tumblr="TUMBLR",H.Spotify="SPOTIFY",H.Soundcloud="SOUNDCLOUD",H.Beacons="BEACONS",H.Linktree="LINKTREE",H.Discord="DISCORD",H.Venmo="VENMO",H.CashApp="CASH_APP",H.Patreon="PATREON",H.Kofi="KOFI",H.Paypal="PAYPAL",H.Cameo="CAMEO",H.Onlyfans="ONLYFANS",H.Substack="SUBSTACK",H.Kickstarter="KICKSTARTER",H.Indiegogo="INDIEGOGO",H.BuyMeACoffee="BUY_ME_A_COFFEE",H.Shopify="SHOPIFY",H))(fg||{}),Tn,dr,Rn,On,Mn,Un,Bn,St,Dn,Nn,Ln,De,ti=class ti{constructor(e,t){l(this,Tn);l(this,dr);l(this,Rn);l(this,On);l(this,Mn);l(this,Un);l(this,Bn);l(this,St,new Map);l(this,Dn);l(this,Nn);l(this,Ln);l(this,De);X(this),p(e.id,"User ID is missing or undefined"),p(e.name,"Username is missing or undefined"),p(e.createdUtc,"User is missing created date"),a(this,Tn,te(_s(e.id)?e.id:`t2_${e.id}`)),a(this,dr,e.name),a(this,Un,e.over18??!1),a(this,Bn,e.isEmployee??!1);let r=new Date(0);if(r.setUTCSeconds(e.createdUtc),a(this,Rn,r),a(this,On,e.linkKarma??0),a(this,Mn,e.commentKarma??0),e.modPermissions)for(let[s,o]of Object.entries(e.modPermissions))n(this,St).set(s,Pc(o));a(this,Dn,new URL(e.subreddit?.url??"","https://www.reddit.com").toString()),a(this,Nn,e.subreddit?.url??""),a(this,Ln,e.hasVerifiedEmail??!1),a(this,De,t)}get id(){return n(this,Tn)}get username(){return n(this,dr)}get createdAt(){return n(this,Rn)}get linkKarma(){return n(this,On)}get commentKarma(){return n(this,Mn)}get nsfw(){return n(this,Un)}get isAdmin(){return n(this,Bn)}get modPermissions(){return n(this,St)}get url(){return n(this,Dn)}get permalink(){return n(this,Nn)}get hasVerifiedEmail(){return n(this,Ln)}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(n(this,St).has(e))return n(this,St).get(e);let t=await ti.getSubredditUsersByType({subredditName:e,type:"moderators",username:this.username},n(this,De)).all();if(t.length===0)return[];let r=t[0].modPermissions.get(e)??[];return r.length>0&&n(this,St).set(e,r),r}getComments(e){return Q.getCommentsByUser({username:this.username,...e},n(this,De))}getPosts(e){return G.getPostsByUser({username:this.username,...e},n(this,De))}async getUserFlairBySubreddit(e){let t=await ce.getUserFlairBySubreddit({subreddit:e,name:n(this,dr)},n(this,De));return t.users[0]?pn(t.users[0]):void 0}getSnoovatarUrl(){return ti.getSnoovatarUrl(this.username,n(this,De))}async getSocialLinks(){let r=await Y.query("GetUserSocialLinks","2aca18ef5f4fc75fb91cdaace3e9aeeae2cb3843b5c26ad511e6f01b8521593a",{name:this.username},n(this,De));return r.data?.user?.profile?.socialLinks?r.data.user.profile.socialLinks.map(s=>({...s,handle:s.handle??void 0})):[]}static async getById(e,t){let r=await Ic(e,t);return r==null?void 0:ti.getByUsername(r,t)}static async getByUsername(e,t){let r=u.redditAPIPlugins.Users;try{let s=await r.UserAbout({username:e},t);if(s.data?.id)return new ti(s.data,t)}catch(s){if(s instanceof Error&&s.message.includes("404 Not Found"))return;throw s}}static async getFromMetadata(e,t){p(t);let r=t?.[e]?.values[0];return r?ti.getById(te(r),t):Promise.resolve(void 0)}static getSubredditUsersByType(e,t){let r=u.redditAPIPlugins.Subreddits;return new W({hasMore:!0,pageSize:e.pageSize,limit:e.limit,after:e.after,before:e.before,fetch:async s=>{let o=await r.AboutWhere({where:e.type,user:e.username,subreddit:e.subredditName,show:"all",...s},t);return bg(o,e.subredditName,t)}})}static async createRelationship(e,t){let r=u.redditAPIPlugins.Users,{type:s,subredditName:o,username:d,permissions:c,...m}=e,y=await r.Friend({type:s,subreddit:o,name:d,permissions:c?qa(c):void 0,...m},t);if(y.json?.errors?.length)throw new Error(y.json.errors.join(`
5
- `))}static async removeRelationship(e,t){await u.redditAPIPlugins.Users.Unfriend({type:e.type,subreddit:e.subredditName,name:e.username},t)}static async setModeratorPermissions(e,t,r,s){let d=await u.redditAPIPlugins.Users.SetPermissions({subreddit:t,name:e,type:"moderator",permissions:qa(r)},s);if(d.json?.errors?.length)throw new Error(d.json.errors.join(`
6
- `))}static async getSnoovatarUrl(e,t){return(await Y.query("GetSnoovatarUrlByName","c47fd42345af268616d2d8904b56856acdc05cf61d3650380f539ad7d596ac0c",{username:e},t)).data?.redditorInfoByName?.snoovatarIcon?.url}static getOverview(e,t){let r=u.redditAPIPlugins.Users;return new W({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,async fetch(s){let o=await r.UserWhere({username:e.username,where:"overview",...s},t);return yg(o,t)}})}};Tn=new WeakMap,dr=new WeakMap,Rn=new WeakMap,On=new WeakMap,Mn=new WeakMap,Un=new WeakMap,Bn=new WeakMap,St=new WeakMap,Dn=new WeakMap,Nn=new WeakMap,Ln=new WeakMap,De=new WeakMap;var C=ti;function yg(i,e){if(!i.data?.children)throw new Error("Listing response is missing children");return{children:i.data.children.map(r=>{if(r.kind==="t3")return new G(r.data,e);if(r.kind==="t1")return new Q(r.data,e);throw new Error(`Type ${r.kind} is not supported`)}),before:i.data.before,after:i.data.after}}async function bg(i,e,t){let r=u.redditAPIPlugins.Users;if(!i.data?.children)throw new Error("Listing response is missing children");let s=i.data.children.map(v=>(p(v.data?.id,"User id is still from listing data"),v.data.id)),o=100,d=[];for(let v=0;v<s.length;v+=o)d.push(s.slice(v,v+o));let m=(await Promise.all(d.map(v=>r.UserDataByAccountIds({ids:v.join(",")},t)))).reduce((v,f)=>({...v,...f.users}),{});return{children:i.data.children.map(v=>{let f=v.data?.id;p(f,"User id is missing from listing");let S=m[f];return p(S,"User data is missing from response"),new C({id:f,name:S.name,linkKarma:S.linkKarma,commentKarma:S.commentKarma,createdUtc:S.createdUtc,over18:S.profileOver18,snoovatarSize:[],modPermissions:{[e]:v.data?.modPermissions??[]}},t)}),before:i.data.before,after:i.data.after}}async function Ic(i,e){return(await u.redditAPIPlugins.Users.UserDataByAccountIds({ids:i},e))?.users?.[i]?.name}async function Nd(i){p(i);let e=i?.[P.Username]?.values[0];if(e)return e;let t=i?.[P.User]?.values[0];if(t)return Ic(t,i)}var ii,_n,lr,ur,Hn,jn,cr,Vn,Wn,mr,wt,Gn,Jn,ri,Ft,xt,Je,ni,ze,zn,qn,$n,Kn,Xn,Zn,Qn,At,Z,Ne,Fo,xo,V=class V{constructor(e,t){l(this,ii);l(this,_n);l(this,lr);l(this,ur);l(this,Hn);l(this,jn);l(this,cr);l(this,Vn);l(this,Wn);l(this,mr);l(this,wt);l(this,Gn);l(this,Jn);l(this,ri);l(this,Ft);l(this,xt);l(this,Je);l(this,ni);l(this,ze);l(this,zn);l(this,qn);l(this,$n);l(this,Kn);l(this,Xn);l(this,Zn);l(this,Qn);l(this,At);l(this,Z);var s;X(this),p(e.id,"Comment id is null or undefined"),p(e.body,"Comment body is null or undefined"),p(e.createdUtc,"Comment is missing created date"),p(e.author,"Comment author is null or undefined"),p(e.parentId,"Comment parentId is null or undefined"),p(e.linkId,"Comment linkId is null or undefined"),p(e.permalink,"Comment permalink is null or undefined"),p(e.subreddit,"Comment is missing subreddit name"),p(e.subredditId,"Comment is missing subreddit id"),a(this,ii,di(`t1_${e.id}`)),a(this,_n,e.authorFullname?te(e.authorFullname):void 0),a(this,lr,e.author),a(this,ur,e.body),a(this,Vn,K(e.subredditId)),a(this,Wn,e.subreddit),a(this,jn,Wo(e.parentId)?di(e.parentId):de(e.parentId)),a(this,cr,de(e.linkId)),a(this,ri,e.edited??!1),a(this,Ft,e.locked??!1),a(this,xt,e.removed??!1),a(this,Je,e.stickied??!1),a(this,wt,e.approved??!1),a(this,Gn,e.approvedAtUtc??0),a(this,Jn,e.bannedAtUtc??0),a(this,ni,e.spam??!1),a(this,ze,e.distinguished),a(this,zn,e.numReports??0),a(this,qn,e.collapsedBecauseCrowdControl??!1),a(this,$n,e.score??0),a(this,Kn,e.permalink),a(this,Qn,new URL(e.permalink??"","https://www.reddit.com/").toString()),a(this,At,e.ignoreReports??!1),a(this,Xn,(e.modReports??[]).map(([o])=>o)),a(this,Zn,(e.userReports??[]).map(([o])=>o));let r=new Date(0);r.setUTCSeconds(e.createdUtc),a(this,Hn,r),a(this,mr,h(s=V,Ne,Fo).call(s,{postId:n(this,cr),commentId:n(this,ii)},t)),a(this,Z,t)}get id(){return n(this,ii)}get authorId(){return n(this,_n)}get authorName(){return n(this,lr)}get subredditId(){return n(this,Vn)}get subredditName(){return n(this,Wn)}get body(){return n(this,ur)}get createdAt(){return n(this,Hn)}get parentId(){return n(this,jn)}get postId(){return n(this,cr)}get replies(){return n(this,mr)}get distinguishedBy(){return n(this,ze)}get locked(){return n(this,Ft)}get stickied(){return n(this,Je)}get removed(){return n(this,xt)}get approved(){return n(this,wt)}get approvedAtUtc(){return n(this,Gn)}get bannedAtUtc(){return n(this,Jn)}get spam(){return n(this,ni)}get edited(){return n(this,ri)}get numReports(){return n(this,zn)}get collapsedBecauseCrowdControl(){return n(this,qn)}get score(){return n(this,$n)}get permalink(){return n(this,Kn)}get userReportReasons(){return n(this,Zn)}get modReportReasons(){return n(this,Xn)}get url(){return n(this,Qn)}get ignoringReports(){return n(this,At)}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 n(this,Ft)}isApproved(){return n(this,wt)}isRemoved(){return n(this,xt)}isSpam(){return n(this,ni)}isStickied(){return n(this,Je)}isDistinguished(){return!!n(this,ze)}isEdited(){return n(this,ri)}isIgnoringReports(){return n(this,At)}async delete(){return V.delete(this.id,n(this,Z))}async edit(e){let t=await V.edit({id:this.id,...e},n(this,Z));return a(this,ur,t.body),a(this,ri,t.edited),this}async approve(){await V.approve(this.id,n(this,Z)),a(this,wt,!0),a(this,xt,!1)}async remove(e=!1){await V.remove(this.id,e,n(this,Z)),a(this,xt,!0),a(this,ni,e),a(this,wt,!1)}async lock(){await V.lock(this.id,n(this,Z)),a(this,Ft,!0)}async unlock(){await V.unlock(this.id,n(this,Z)),a(this,Ft,!1)}async reply(e){return V.submit({id:this.id,...e},n(this,Z))}async getAuthor(){return C.getByUsername(n(this,lr),n(this,Z))}async distinguish(e=!1){let{distinguishedBy:t,stickied:r}=await V.distinguish(this.id,e,!1,n(this,Z));a(this,ze,t),a(this,Je,r)}async distinguishAsAdmin(e=!1){let{distinguishedBy:t,stickied:r}=await V.distinguish(this.id,e,!0,n(this,Z));a(this,ze,t),a(this,Je,r)}async undistinguish(){let{distinguishedBy:e,stickied:t}=await V.undistinguish(this.id,n(this,Z));a(this,ze,e),a(this,Je,t)}async ignoreReports(){await V.ignoreReports(this.id,n(this,Z)),a(this,At,!0)}async unignoreReports(){await V.unignoreReports(this.id,n(this,Z)),a(this,At,!1)}addRemovalNote(e){return ke.addRemovalNote({itemIds:[n(this,ii)],...e},n(this,Z))}static async getById(e,t){let r=u.redditAPIPlugins.LinksAndComments,s=qe(e)?e:`t1_${e}`,o=await r.Info({subreddits:[],thingIds:[s]},t);if(!o.data?.children?.[0]?.data)throw new Error("not found");return new V(o.data.children[0].data,t)}static getComments(e,t){var d;let{postId:r,commentId:s,...o}=e;return h(d=V,Ne,Fo).call(d,{postId:de(r),commentId:s?di(s):void 0,...o},t)}static async edit(e,t){let r=u.redditAPIPlugins.LinksAndComments,{id:s}=e,o;"richtext"in e&&(o=_i(e.richtext));let d=await r.EditUserText({thingId:s,text:"text"in e?e.text:"",richtextJson:o,runAs:fe.APP},t);if(d.json?.errors?.length)throw new Error("Failed to edit comment");let c=d.json?.data?.things?.[0]?.data;return p(c),new V(c,t)}static async delete(e,t){await u.redditAPIPlugins.LinksAndComments.Del({id:e},t)}static async approve(e,t){await u.redditAPIPlugins.Moderation.Approve({id:e},t)}static async remove(e,t=!1,r){await u.redditAPIPlugins.Moderation.Remove({id:e,spam:t},r)}static async lock(e,t){await u.redditAPIPlugins.LinksAndComments.Lock({id:e},t)}static async unlock(e,t){await u.redditAPIPlugins.LinksAndComments.Unlock({id:e},t)}static async submit(e,t){let{runAs:r="APP"}=e,s=fe[r],o=s===fe.USER?u.userActionsPlugin:u.redditAPIPlugins.LinksAndComments,{id:d}=e,c;"richtext"in e&&(c=_i(e.richtext));let m=await o.Comment({thingId:d,text:"text"in e?e.text:"",richtextJson:c,runAs:s},t);if(m.json?.errors?.length)throw new Error("failed to reply to comment");let y=m.json?.data?.things?.[0]?.data;return p(y),new V(y,t)}static async distinguish(e,t,r,s){let c=(await u.redditAPIPlugins.Moderation.Distinguish({id:e,how:r?"admin":"yes",sticky:t},s)).json?.data?.things?.[0]?.data;return p(c),{distinguishedBy:c.distinguished,stickied:!!c.stickied}}static async undistinguish(e,t){let o=(await u.redditAPIPlugins.Moderation.Distinguish({id:e,how:"no",sticky:!1},t)).json?.data?.things?.[0]?.data;return p(o),{distinguishedBy:o.distinguished,stickied:!!o.stickied}}static getCommentsByUser(e,t){let r=u.redditAPIPlugins.Users;return new W({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,async fetch(s){let o=await r.UserWhere({username:e.username,where:"comments",...s},t);return p(o.data,"Failed to get comments for user"),{children:o.data.children?.map(c=>new V(c.data,t))||[],before:o.data.before,after:o.data.after}}})}static async ignoreReports(e,t){await u.redditAPIPlugins.Moderation.IgnoreReports({id:e},t)}static async unignoreReports(e,t){await u.redditAPIPlugins.Moderation.UnignoreReports({id:e},t)}};ii=new WeakMap,_n=new WeakMap,lr=new WeakMap,ur=new WeakMap,Hn=new WeakMap,jn=new WeakMap,cr=new WeakMap,Vn=new WeakMap,Wn=new WeakMap,mr=new WeakMap,wt=new WeakMap,Gn=new WeakMap,Jn=new WeakMap,ri=new WeakMap,Ft=new WeakMap,xt=new WeakMap,Je=new WeakMap,ni=new WeakMap,ze=new WeakMap,zn=new WeakMap,qn=new WeakMap,$n=new WeakMap,Kn=new WeakMap,Xn=new WeakMap,Zn=new WeakMap,Qn=new WeakMap,At=new WeakMap,Z=new WeakMap,Ne=new WeakSet,Fo=function(e,t,r=0){return new W({limit:e.limit,pageSize:e.pageSize,fetch:async s=>{var S,b;let o=s.limit,d=u.redditAPIPlugins.Listings,c=u.redditAPIPlugins.LinksAndComments,m=e.commentId;if(s.more)if(s.more.children.length){let _=s.more;(!o||o>100)&&(o=100);let A=_.children.splice(0,o),N=await c.MoreChildren({linkId:e.postId,children:A,sort:e.sort},t);if(!N.json?.data?.things?.length)return{children:[]};let{children:B}=h(S=V,Ne,xo).call(S,N.json.data.things,e.postId,e,t);return{children:B,more:_.children.length?_:void 0}}else m=s.more.parentId,r=r+s.more.depth;let v=(await d.Comments({article:e.postId.substring(3),comment:m?.substring(3),limit:o,depth:e.depth,sort:e.sort},t)).listings?.[1]?.data?.children??[],f=v[0];return m&&f?.data?.replyList?.data&&(v=f.data.replyList.data.children),h(b=V,Ne,xo).call(b,v,m??e.postId,e,t,r)}})},xo=function(e,t,r,s,o=0){var y,v;let d=[],c,m={};for(let f of e){if(!f.data||(f.data.depth!=null&&(f.data.depth=f.data.depth+o),f.data.depth!=null&&r.depth!=null&&f.data.depth>=r.depth))continue;let S=f.data.parentId?m[f.data.parentId]:void 0;if(f.kind==="t1"){if(f.data.name===t)continue;let b=new V(f.data,s);if(m[b.id]=b,a(b,mr,h(y=V,Ne,Fo).call(y,{...r,postId:b.postId,commentId:b.id},s,o)),"replyList"in f.data&&f.data.replyList?.data){let{children:_,more:A}=h(v=V,Ne,xo).call(v,f.data.replyList.data.children,b.id,r,s,o);_.length&&b.replies.children.push(..._),A&&b.replies.setMore(A)}b.replies.preventInitialFetch(),S?S.replies.children.push(b):d.push(b)}else if(f.kind==="more"&&f.data.parentId&&f.data.depth!=null){let b={parentId:Wo(f.data.parentId)?di(f.data.parentId):de(f.data.parentId),children:f.data.children??[],depth:f.data.depth};S?S.replies.setMore(b):b.parentId===t&&(c=b)}}return{children:d,more:c}},l(V,Ne);var Q=V;function Ws(i,e){let t=u.redditAPIPlugins.Moderation;return new W({hasMore:!0,after:i.after,before:i.before,limit:i.limit,pageSize:i.pageSize,fetch:async r=>{let s=await t.AboutLog({subreddit:i.subredditName,mod:i.moderatorUsernames?i.moderatorUsernames.join(","):void 0,type:i.type,...r},e);return vg(s)}})}function vg(i){if(!i.data?.children)throw new Error("AboutLogResponse is missing children");return{children:i.data.children.map(t=>{if(!t.data)throw new Error("ModAction from AboutLogResponse is missing or invalid");let{id:r,mod:s,modId36:o,createdUtc:d,subreddit:c,subredditNamePrefixed:m,action:y,srId36:v,description:f,details:S,targetAuthor:b,targetBody:_,targetFullname:A,targetPermalink:N,targetTitle:B}=t.data;p(r,"ModAction from AboutLogResponse is missing id"),p(s,"ModAction from AboutLogResponse is missing mod"),p(o,"ModAction from AboutLogResponse is missing modId36"),p(d,"ModAction from AboutLogResponse is missing createdUtc"),p(c,"ModAction from AboutLogResponse is missing subreddit"),p(m,"ModAction from AboutLogResponse is missing subredditNamePrefixed"),p(y,"ModAction from AboutLogResponse is missing action"),p(v,"ModAction from AboutLogResponse is missing srId36");let oi=new Date(0);return oi.setUTCSeconds(d),{id:r,type:y,moderatorName:s,moderatorId:`t2_${o}`,createdAt:oi,subredditName:c,subredditId:`t5_${v}`,description:f,details:S,target:A?{id:A,author:b,body:_,permalink:N,title:B}:void 0}}),after:i.data.after,before:i.data.before}}import"@devvit/protos";var kg=(d=>(d.New="New",d.InProgress="InProgress",d.Archived="Archived",d.Appeals="Appeals",d.JoinRequests="JoinRequests",d.Filtered="Filtered",d))(kg||{}),Cg={0:"New",1:"InProgress",2:"Archived",3:"Appeals",4:"JoinRequests",5:"Filtered"},Pg=(b=>(b.Highlighted="Highlighted",b.Unhighlighted="Unhighlighted",b.Archived="Archived",b.Unarchived="Unarchived",b.ReportedToAdmins="ReportedToAdmins",b.Muted="Muted",b.Unmuted="Unmuted",b.Banned="Banned",b.Unbanned="Unbanned",b.Approved="Approved",b.Disapproved="Disapproved",b.Filtered="Filtered",b.Unfiltered="Unfiltered",b))(Pg||{}),Sg={0:"Highlighted",1:"Unhighlighted",2:"Archived",3:"Unarchived",4:"ReportedToAdmins",5:"Muted",6:"Unmuted",7:"Banned",8:"Unbanned",9:"Approved",10:"Disapproved",11:"Filtered",12:"Unfiltered"},L,J,re,Ec,Tc,Gs=class{constructor(e){l(this,J);l(this,L);this.notificationSubjectPrefix="[notification]";a(this,L,e)}async bulkReadConversations(e,t){let r=u.redditAPIPlugins.NewModmail,{conversationIds:s}=await r.BulkReadConversations({entity:e.join(","),state:t},n(this,L));return s}async getConversations(e){let r=await u.redditAPIPlugins.NewModmail.GetConversations({after:e.after,entity:e.subreddits?e.subreddits.join(","):void 0,limit:e.limit,sort:e.sort,state:e.state},n(this,L)),s={};for(let o in r.conversations)s[o]=h(this,J,re).call(this,{protoConversation:r.conversations[o],protoMessages:r.messages,protoModActions:{}});return{conversations:s,viewerId:r.viewerId,conversationIds:r.conversationIds}}async getConversation(e){let r=await u.redditAPIPlugins.NewModmail.GetConversation({...e,markRead:!!e.markRead},n(this,L));return{participantSubreddit:r.participantSubreddit,conversation:h(this,J,re).call(this,{protoConversation:r.conversation,protoMessages:r.messages,protoModActions:r.modActions}),user:r.user}}async getSubreddits(){let e=u.redditAPIPlugins.NewModmail,{subreddits:t}=await e.Subreddits({},n(this,L));return t}async createConversation(e){let r=await u.redditAPIPlugins.NewModmail.CreateConversation({body:e.body,isAuthorHidden:e.isAuthorHidden??!1,srName:e.subredditName,subject:e.subject,to:e.to?e.to:void 0},n(this,L));return{conversation:h(this,J,re).call(this,{protoConversation:r.conversation,protoMessages:r.messages,protoModActions:r.modActions}),user:r.user}}async createModDiscussionConversation(e){return Ya({subject:e.subject,bodyMarkdown:e.bodyMarkdown,subredditId:K(e.subredditId),isInternal:!0,participantType:"MODERATOR",conversationType:"INTERNAL"},n(this,L))}async createModInboxConversation(e){return Ya({subject:e.subject,bodyMarkdown:e.bodyMarkdown,subredditId:K(e.subredditId),isInternal:!1,participantType:"PARTICIPANT_USER",conversationType:"SR_USER"},n(this,L))}async createModNotification(e){let t=e.subject;return e.subject.startsWith(this.notificationSubjectPrefix)||(t=`${this.notificationSubjectPrefix} ${e.subject}`),Ya({subject:t,bodyMarkdown:e.bodyMarkdown,subredditId:K(e.subredditId),isInternal:!1,participantType:"PARTICIPANT_USER",conversationType:"SR_USER"},n(this,L))}async reply(e){let r=await u.redditAPIPlugins.NewModmail.CreateConversationMessage({body:e.body,conversationId:e.conversationId,isAuthorHidden:e.isAuthorHidden??!1,isInternal:e.isInternal??!1},n(this,L));return{conversation:h(this,J,re).call(this,{protoConversation:r.conversation,protoMessages:r.messages,protoModActions:{}}),user:r.user}}async highlightConversation(e){let r=await u.redditAPIPlugins.NewModmail.HighlightConversation({conversationId:e},n(this,L));return{conversation:h(this,J,re).call(this,{protoConversation:r.conversation,protoMessages:r.messages,protoModActions:r.modActions})}}async unhighlightConversation(e){let r=await u.redditAPIPlugins.NewModmail.UnhighlightConversation({conversationId:e},n(this,L));return{conversation:h(this,J,re).call(this,{protoConversation:r.conversation,protoMessages:r.messages,protoModActions:r.modActions})}}async archiveConversation(e){let r=await u.redditAPIPlugins.NewModmail.ArchiveConversation({conversationId:e},n(this,L));return{conversation:h(this,J,re).call(this,{protoConversation:r.conversation,protoMessages:r.messages,protoModActions:r.modActions})}}async unarchiveConversation(e){let r=await u.redditAPIPlugins.NewModmail.UnarchiveConversation({conversationId:e},n(this,L));return{conversation:h(this,J,re).call(this,{protoConversation:r.conversation,protoMessages:r.messages,protoModActions:r.modActions})}}async muteConversation(e){let r=await u.redditAPIPlugins.NewModmail.MuteConversation({conversationId:e.conversationId,numHours:e.numHours},n(this,L));return{conversation:h(this,J,re).call(this,{protoConversation:r.conversations,protoMessages:r.messages,protoModActions:r.modActions}),user:r.user}}async unmuteConversation(e){let r=await u.redditAPIPlugins.NewModmail.UnmuteConversation({conversationId:e},n(this,L));return{conversation:h(this,J,re).call(this,{protoConversation:r.conversations,protoMessages:r.messages,protoModActions:r.modActions}),user:r.user}}async readConversations(e){await u.redditAPIPlugins.NewModmail.Read({conversationIds:e.join(",")},n(this,L))}async unreadConversations(e){await u.redditAPIPlugins.NewModmail.Unread({conversationIds:e.join(",")},n(this,L))}async approveConversation(e){let r=await u.redditAPIPlugins.NewModmail.ApproveConversation({conversationId:e},n(this,L));return{conversation:h(this,J,re).call(this,{protoConversation:r.conversations,protoMessages:r.messages,protoModActions:r.modActions}),user:r.user}}async disapproveConversation(e){let r=await u.redditAPIPlugins.NewModmail.DisapproveConversation({conversationId:e},n(this,L));return{conversation:h(this,J,re).call(this,{protoConversation:r.conversations,protoMessages:r.messages,protoModActions:r.modActions}),user:r.user}}async tempBanConversation(e){let r=await u.redditAPIPlugins.NewModmail.TempBan({...e},n(this,L));return{conversation:h(this,J,re).call(this,{protoConversation:r.conversations,protoMessages:r.messages,protoModActions:r.modActions}),user:r.user}}async unbanConversation(e){let r=await u.redditAPIPlugins.NewModmail.Unban({conversationId:e},n(this,L));return{conversation:h(this,J,re).call(this,{protoConversation:r.conversations,protoMessages:r.messages,protoModActions:r.modActions}),user:r.user}}async getUnreadCount(){return await u.redditAPIPlugins.NewModmail.UnreadCount({},n(this,L))}async getUserConversations(e){return await u.redditAPIPlugins.NewModmail.UserConversations({conversationId:e},n(this,L))}};L=new WeakMap,J=new WeakSet,re=function({protoConversation:e,protoMessages:t,protoModActions:r}){return{...e,state:Cg[e.state],messages:h(this,J,Ec).call(this,e,t),modActions:h(this,J,Tc).call(this,e,r)}},Ec=function(e,t){let r={},s=e.objIds.filter(o=>o.key==="messages").map(({id:o})=>o);for(let o of s){let d=t[o];d&&(r[o]=d)}return r},Tc=function(e,t){let r={},s=e.objIds.filter(o=>o.key==="modActions").map(({id:o})=>o);for(let o of s){let d=t[o];d&&(r[o]={...d,actionType:Sg[d.actionTypeId]})}return r};async function Ya(i,e){let t=e[P.AppUser]?.values[0],o=await Y.query("CreateModmailConversation","5f9ae20b0c7bdffcafb80241728a72e67cd4239bc09f67284b79d4aa706ee0e5",{subject:i.subject,bodyMarkdown:i.bodyMarkdown,subredditId:i.subredditId,authorId:t,isInternal:i.isInternal,participantType:i.participantType,conversationType:i.conversationType},e);if(o.data?.createModmailConversationV2?.ok)return o.data?.createModmailConversationV2?.conversationId;throw new Error("modmail conversation creation failed; ${response.data?.createModmailConversationV2?.errors[0].message}")}var pr,gr,Yn,es,ts,is,ed=class ed{constructor(e,t){l(this,pr);l(this,gr);l(this,Yn);l(this,es);l(this,ts);l(this,is);if(X(this),p(e.id,"PrivateMessage: Invalid data, no id"),p(e.name,"PrivateMessage: Invalid data, no name"),p(e.created,"PrivateMessage: Invalid data, no created date"),a(this,pr,ye(e.name)),e.author!=null)a(this,gr,{type:"user",username:e.author,id:e.authorFullname?te(e.authorFullname):void 0});else if(e.subreddit!=null)a(this,gr,{type:"subreddit",name:e.subreddit,id:e.subredditId?K(e.subredditId):void 0});else throw new Error("PrivateMessage: Invalid data, no author or subreddit");a(this,Yn,e.body??""),a(this,es,e.bodyHtml??"");let r=new Date(0);r.setUTCSeconds(e.createdUtc),a(this,ts,r),a(this,is,t)}static async getMessages(e,t){let r=u.redditAPIPlugins.PrivateMessages;return new W({...e,fetch:async s=>{let o=await r.MessageWhere({...s,where:e.type??"inbox"},t);return{after:o.data?.after,before:o.data?.before,children:o.data?.children?.map(d=>new ed(d.data,t)).filter(Boolean)||[]}}})}static async send({to:e,subject:t,text:r},s){await u.redditAPIPlugins.PrivateMessages.Compose({to:e,subject:t,text:r,fromSr:""},s)}static async sendAsSubreddit({to:e,fromSubredditName:t,subject:r,text:s},o){await u.redditAPIPlugins.PrivateMessages.Compose({to:e,fromSr:t,subject:r,text:s},o)}static async markAllAsRead(e){await u.redditAPIPlugins.PrivateMessages.ReadAllMessages({filterTypes:""},e)}get id(){return n(this,pr)}get from(){return n(this,gr)}get body(){return n(this,Yn)}get bodyHtml(){return n(this,es)}get created(){return n(this,ts)}async markAsRead(){await u.redditAPIPlugins.PrivateMessages.ReadMessage({id:n(this,pr)},n(this,is))}};pr=new WeakMap,gr=new WeakMap,Yn=new WeakMap,es=new WeakMap,ts=new WeakMap,is=new WeakMap;var Ot=ed;var Ld=(o=>(o.Reports="reports",o.Spam="spam",o.Modqueue="modqueue",o.Unmoderated="unmoderated",o.Edited="edited",o))(Ld||{}),Rc=class{},Oc=class{},Mc=class{},Uc=class{},hr,x,rs,ns,ss,os,as,ds,ls,us,cs,fr,R,Ee=class Ee{constructor(e,t){l(this,hr);l(this,x);l(this,rs);l(this,ns);l(this,ss);l(this,os);l(this,as);l(this,ds);l(this,ls);l(this,us);l(this,cs);l(this,fr);l(this,R);X(this),p(e.id,"Subreddit id is missing or undefined"),p(e.displayName,"Subreddit name is missing or undefined"),a(this,hr,K(`t5_${e.id}`)),a(this,x,e.displayName),p(e.createdUtc,"Subreddit is missing created date");let r=new Date(0);r.setUTCSeconds(e.createdUtc),a(this,rs,r),a(this,ns,wg(e.subredditType)),a(this,ss,e.title),a(this,os,e.description),p(e.lang,"Subreddit is missing language"),a(this,as,e.lang),a(this,ds,e.subscribers??0),a(this,ls,e.activeUserCount??0),a(this,us,e.over18??!1),a(this,fr,e.url??""),a(this,cs,{acceptFollowers:e.acceptFollowers??!1,allOriginalContent:e.allOriginalContent??!1,allowChatPostCreation:e.allowChatPostCreation??!1,allowDiscovery:e.allowDiscovery??!1,allowGalleries:e.allowGalleries??!1,allowImages:e.allowImages??!1,allowPolls:e.allowPolls??!1,allowPredictionContributors:e.allowPredictionContributors??!1,allowPredictions:e.allowPredictions??!1,allowPredictionsTournament:e.allowPredictionsTournament??!1,allowTalks:e.allowTalks??!1,allowVideoGifs:e.allowVideogifs??!1,allowVideos:e.allowVideos??!1,chatPostEnabled:e.isChatPostFeatureEnabled??!1,collectionsEnabled:e.collectionsEnabled??!1,crosspostable:e.isCrosspostableSubreddit??!1,emojisEnabled:e.emojisEnabled??!1,eventPostsEnabled:e.eventPostsEnabled??!1,linkFlairEnabled:e.linkFlairEnabled??!1,originalContentTagEnabled:e.originalContentTagEnabled??!1,restrictCommenting:e.restrictCommenting??!1,restrictPosting:e.restrictPosting??!1,shouldArchivePosts:e.shouldArchivePosts??!1,spoilersEnabled:e.spoilersEnabled??!1,wikiEnabled:e.wikiEnabled??!1,allowedPostType:Fg(e.submissionType),allowedMediaInComments:(e.allowedMediaInComments??[]).map(xg),bannerBackgroundColor:e.bannerBackgroundColor,bannerBackgroundImage:e.bannerBackgroundImage,bannerImage:e.bannerImg,communityIcon:e.communityIcon,headerTitle:e.headerTitle,keyColor:e.keyColor,mobileBannerImage:e.mobileBannerImage,primaryColor:e.primaryColor,userFlairs:{enabled:e.userFlairEnabledInSr??!1,usersCanAssign:e.canAssignUserFlair??!1,userFlairBackgroundColor:e.userFlairBackgroundColor,userFlairTextColor:e.userFlairTextColor},postFlairs:{enabled:e.linkFlairEnabled??!1,usersCanAssign:e.canAssignLinkFlair??!1},url:new URL(n(this,fr),"https://www.reddit.com").toString()}),a(this,R,t)}get id(){return n(this,hr)}get name(){return n(this,x)}get createdAt(){return n(this,rs)}get type(){return n(this,ns)}get title(){return n(this,ss)}get description(){return n(this,os)}get language(){return n(this,as)}get numberOfSubscribers(){return n(this,ds)}get numberOfActiveUsers(){return n(this,ls)}get nsfw(){return n(this,us)}get settings(){return n(this,cs)}get userFlairsEnabled(){return this.settings.userFlairs.enabled}get postFlairsEnabled(){return this.settings.postFlairs.enabled}get usersCanAssignUserFlairs(){return this.settings.userFlairs.usersCanAssign}get usersCanAssignPostFlairs(){return this.settings.postFlairs.usersCanAssign}get url(){return this.settings.url}get permalink(){return n(this,fr)}toJSON(){return{id:this.id,name:this.name,createdAt:this.createdAt,type:this.type,title:this.title,description:this.description,language:this.language,nsfw:this.nsfw,numberOfSubscribers:this.numberOfSubscribers,numberOfActiveUsers:this.numberOfActiveUsers,settings:this.settings}}async submitPost(e){let t={...e,subredditName:n(this,x)};return G.submit(t,n(this,R))}getControversialPosts(e={}){if(!n(this,x))throw new Error("subreddit missing displayName - it might not have been fetched");return G.getControversialPosts({...e,subredditName:n(this,x)},n(this,R))}getTopPosts(e={}){if(!n(this,x))throw new Error("subreddit missing displayName - it might not have been fetched");return G.getTopPosts({...e,subredditName:n(this,x)},n(this,R))}getApprovedUsers(e={}){return C.getSubredditUsersByType({type:"contributors",subredditName:n(this,x),...e},n(this,R))}approveUser(e){return C.createRelationship({username:e,subredditName:n(this,x),type:"contributor"},n(this,R))}removeUser(e){return C.removeRelationship({username:e,subredditName:n(this,x),type:"contributor"},n(this,R))}getWikiContributors(e={}){return C.getSubredditUsersByType({type:"wikicontributors",subredditName:n(this,x),...e},n(this,R))}addWikiContributor(e){return C.createRelationship({username:e,subredditName:n(this,x),type:"wikicontributor"},n(this,R))}removeWikiContributor(e){return C.removeRelationship({username:e,subredditName:n(this,x),type:"wikicontributor"},n(this,R))}getBannedUsers(e={}){return C.getSubredditUsersByType({type:"banned",subredditName:n(this,x),...e},n(this,R))}banUser(e){return C.createRelationship({username:e.username,subredditName:n(this,x),type:"banned",banReason:e.reason,banMessage:e.message,note:e.note,duration:e.duration,banContext:e.context},n(this,R))}unbanUser(e){return C.removeRelationship({username:e,subredditName:n(this,x),type:"banned"},n(this,R))}getBannedWikiContributors(e={}){return C.getSubredditUsersByType({type:"wikibanned",subredditName:n(this,x),...e},n(this,R))}banWikiContributor(e){return C.createRelationship({username:e.username,subredditName:n(this,x),type:"wikibanned",banReason:e.reason,note:e.note,duration:e.duration},n(this,R))}unbanWikiContributor(e){return C.removeRelationship({username:e,subredditName:n(this,x),type:"wikibanned"},n(this,R))}getModerators(e={}){return C.getSubredditUsersByType({type:"moderators",subredditName:n(this,x),...e},n(this,R))}inviteModerator(e,t){return C.createRelationship({type:"moderator_invite",subredditName:n(this,x),username:e,permissions:t??[]},n(this,R))}revokeModeratorInvite(e){return C.removeRelationship({username:e,subredditName:n(this,x),type:"moderator_invite"},n(this,R))}removeModerator(e){return C.removeRelationship({type:"moderator",subredditName:n(this,x),username:e},n(this,R))}setModeratorPermissions(e,t){return C.setModeratorPermissions(e,n(this,x),t,n(this,R))}getMutedUsers(e={}){return C.getSubredditUsersByType({type:"muted",subredditName:n(this,x),...e},n(this,R))}muteUser(e,t){return C.createRelationship({username:e,subredditName:n(this,x),type:"muted",note:t},n(this,R))}unmuteUser(e){return C.removeRelationship({username:e,subredditName:n(this,x),type:"muted"},n(this,R))}getModerationLog(e){return Ws({subredditName:n(this,x),...e},n(this,R))}getUserFlairTemplates(){return ne.getUserFlairTemplates(n(this,x),n(this,R))}getPostFlairTemplates(){return ne.getPostFlairTemplates(n(this,x),n(this,R))}createPostFlairTemplate(e){return ne.createPostFlairTemplate({subredditName:n(this,x),...e},n(this,R))}createUserFlairTemplate(e){return ne.createUserFlairTemplate({subredditName:n(this,x),...e},n(this,R))}async getUserFlair(e){if(e?.usernames!==void 0)return{users:await Promise.all(e.usernames.map(async r=>{let s=await ce.getUserFlairBySubreddit({subreddit:n(this,x),name:r},n(this,R));return pn(s.users[0])}))};{let t=await ce.getUserFlairBySubreddit({...e,subreddit:n(this,x)},n(this,R));return{next:t.next,prev:t.prev,users:t.users.map(r=>pn(r))}}}getModQueue(e={type:"all"}){return Ee.aboutLocation({...e,location:"modqueue",subreddit:n(this,x)},n(this,R))}getReports(e={type:"all"}){return Ee.aboutLocation({...e,location:"reports",subreddit:n(this,x)},n(this,R))}getSpam(e={type:"all"}){return Ee.aboutLocation({...e,location:"spam",subreddit:n(this,x)},n(this,R))}getUnmoderated(e={type:"all"}){return Ee.aboutLocation({...e,location:"unmoderated",subreddit:n(this,x)},n(this,R))}getEdited(e={type:"all"}){return Ee.aboutLocation({...e,location:"edited",subreddit:n(this,x)},n(this,R))}static aboutLocation(e,t){let r=u.redditAPIPlugins.Moderation,s;switch(e.type){case"post":s="links";break;case"comment":s="comments";break;default:s=void 0}return new W({...e,fetch:async o=>{let d=await r.AboutLocation({...o,...e,only:s},t);return Bc(d,t)}})}getCommentsAndPostsByIds(e){let t=u.redditAPIPlugins.LinksAndComments;return new W({fetch:async()=>{let r=await t.Info({thingIds:e,subreddits:[n(this,hr)]},n(this,R));return Bc(r,n(this,R))}})}static async addRemovalReason(e,t,r,s){return(await u.redditAPIPlugins.Subreddits.SubredditAddRemovalReason({title:t,message:r,subreddit:e},s)).id}static async getRemovalReasons(e,t){let s=await u.redditAPIPlugins.Subreddits.SubredditGetRemovalReasons({subreddit:e},t);return s.order.map(o=>({...s.data[o]}))}static async getFromMetadata(e){p(e);let t=e?.[P.SubredditName]?.values[0];if(t)return Ee.getByName(t,e);let r=e?.[P.Subreddit]?.values[0];return p(r),Ee.getById(K(r),e)}static async getById(e,t){let r=await Ko(e,t);if(r)return Ee.getByName(r,t)}static async getByName(e,t){let s=await u.redditAPIPlugins.Subreddits.SubredditAbout({subreddit:e},t);if(!s?.data)throw new Error("not found");return new Ee(s.data,t)}};hr=new WeakMap,x=new WeakMap,rs=new WeakMap,ns=new WeakMap,ss=new WeakMap,os=new WeakMap,as=new WeakMap,ds=new WeakMap,ls=new WeakMap,us=new WeakMap,cs=new WeakMap,fr=new WeakMap,R=new WeakMap;var le=Ee;async function _d(i,e){let o=(await Y.query("GetSubredditInfoById","315a9b75c22a017d526afdf2d274616946156451aacfd56dfb91e7ad3f7a2fde",{id:i},e)).data?.subredditInfoById;if(!o)throw new Error("subreddit info not found");return o}async function Hd(i,e){let o=(await Y.query("GetSubredditInfoByName","4aa69726c7e3f5d33ab2bee22b3d74fce645824fddd5ea3ec6dfe30bdb4295cb",{name:i},e)).data?.subredditInfoByName;if(!o)throw new Error("subreddit info not found");return o}async function jd(i,e){let o=(await Y.query("GetSubredditLeaderboard","18ead70c46b6446d45ecd8b679b16d9a929a933d6ef25d8262a459cb18b72848",{id:i},e)).data?.subredditInfoById?.leaderboard;if(!o)throw new Error("subreddit leaderboard not found");if(!o.summary)throw new Error("subreddit leaderboard summary not found");return{id:o.id,summary:o.summary}}async function Vd(i,e){let o=(await Y.query("GetSubredditStyles","d491d17ea8858f563ea578b26b9595d64adecf4bf34557d567c7e53c470f5f22",{id:i},e)).data?.subredditInfoById?.styles;if(!o)throw new Error("subreddit styles not found");return o}function wg(i){if(i==="public"||i==="private"||i==="restricted"||i==="employees_only"||i==="gold_only"||i==="gold_restricted"||i==="archived"||i==="user")return i;throw new Error(`invalid subreddit type: ${i}`)}function Fg(i){if(i==="any"||i==="link"||i==="self")return i;throw new Error(`invalid allowed post type: ${i}`)}function xg(i){if(i==="animated"||i==="giphy"||i==="static"||i==="expression")return i;throw new Error(`invalid comment media type: ${i}`)}function Bc(i,e){let r=(i.data?.children??[]).map(d=>{let c=s(d);if(c!=null)return c;let m=o(d);return m??null}).filter(Boolean);return{after:i.data?.after,before:i.data?.before,children:r};function s(d){try{return new G(d.data,e)}catch{return null}}function o(d){try{return new Q(d.data,e)}catch{return null}}}async function Ko(i,e){return(await u.redditAPIPlugins.LinksAndComments.Info({thingIds:[i],subreddits:[]},e)).data?.children[0]?.data?.displayName}async function Wd(i,e){return Dc("GetVaultContactByAddress","3e2f7966a5c120e64fd2795d06a46595c52d988185be98d3ed71c3f81ae80d2e",{provider:"ethereum",address:i},e)}async function Gd(i,e){return Dc("GetVaultContactByUserId","a854ddc19d0e22c4f36ed917fdbd568f299f3571427e393aee5e2972080fffe9",{provider:"ethereum",userId:i},e)}async function Dc(i,e,t,r){let o=(await Y.query(i,e,t,r))?.data?.vault?.contact;return{provider:o?.provider,userId:te(o?.userId),address:o?.address,createdAt:o?.createdAt,isActive:o?.isActive}}import{CommunityListWidget_CommunityData as Ag,GetWidgetsResponse_WidgetItem as ae}from"@devvit/protos";var ms,ps,gs,hs,id=class id{constructor(e,t,r){l(this,ms);l(this,ps);l(this,gs);l(this,hs);X(this),a(this,ms,e.id),a(this,ps,e.shortName),a(this,gs,t),a(this,hs,r)}get id(){return n(this,ms)}get name(){return n(this,ps)}get subredditName(){return n(this,gs)}toJSON(){return{id:this.id,name:this.name,subredditName:this.subredditName}}delete(){return id.delete(this.subredditName,this.id,n(this,hs))}static async getWidgets(e,t){let s=await u.redditAPIPlugins.Widgets.GetWidgets({subreddit:e},t);p(s.layout,"Failed to load widgets for subreddit");let o=s.items,d=[];for(let c of s.layout.sidebar?.order??[]){let m=o[c];switch(m?.kind){case"image":d.push(new Ao(m,e,t));break;case"calendar":d.push(new Io(m,e,t));break;case"textarea":d.push(new Eo(m,e,t));break;case"button":d.push(new To(m,e,t));break;case"community-list":d.push(new Ro(m,e,t));break;case"post-flair":d.push(new Oo(m,e,t));break;case"custom":d.push(new Mo(m,e,t));break;case"subreddit-rules":{let y=await u.redditAPIPlugins.Subreddits.SubredditAboutRules({subreddit:e},t);d.push(new td(y,m,e,t));break}default:throw new Error(`Unknown widget type: ${m.kind}`)}}return d}static async delete(e,t,r){await u.redditAPIPlugins.Widgets.DeleteWidget({subreddit:e,id:t},r)}static async reorder(e,t,r){await u.redditAPIPlugins.Widgets.OrderWidgets({subreddit:e,order:t},r)}static async add(e,t){switch(e?.type){case"image":return Ao.create(e,t);case"calendar":return Io.create(e,t);case"textarea":return Eo.create(e,t);case"button":return To.create(e,t);case"community-list":return Ro.create(e,t);case"post-flair":return Oo.create(e,t);case"custom":return Mo.create(e,t);default:throw new Error("Unknown widget type")}}};ms=new WeakMap,ps=new WeakMap,gs=new WeakMap,hs=new WeakMap;var ie=id,fs,Uo=class Uo extends ie{constructor(t,r,s){super(t,r,s);l(this,fs);a(this,fs,t.data.map(o=>(p(o.url,"Image widget data is missing url"),p(o.height,"Image widget data is missing height"),p(o.width,"Image widget data is missing width"),p(o.linkUrl,"Image widget data is missing linkUrl"),{url:o.url,height:o.height,width:o.width,linkUrl:o.linkUrl})))}get images(){return n(this,fs)}toJSON(){return{...super.toJSON(),images:this.images}}static async create(t,r){let o=await u.redditAPIPlugins.Widgets.AddImageWidget(t,r);return new Uo(ae.fromJSON(o),t.subreddit,r)}static async update(t,r){let o=await u.redditAPIPlugins.Widgets.UpdateImageWidget(t,r);return new Uo(ae.fromJSON(o),t.subreddit,r)}};fs=new WeakMap;var Ao=Uo,ys,bs,vs,Bo=class Bo extends ie{constructor(t,r,s){super(t,r,s);l(this,ys);l(this,bs);l(this,vs);p(t.googleCalendarId,"Calendar widget data is missing googleCalendarId"),p(t.configuration,"Calendar widget data is missing configuration"),p(t.styles,"Calendar widget data is missing styles"),a(this,ys,t.googleCalendarId),a(this,bs,t.configuration),a(this,vs,t.styles)}get googleCalendarId(){return n(this,ys)}get configuration(){return n(this,bs)}get styles(){return n(this,vs)}toJSON(){return{...super.toJSON(),googleCalendarId:this.googleCalendarId,configuration:this.configuration,styles:this.styles}}static async create(t,r){let o=await u.redditAPIPlugins.Widgets.AddCalendarWidget(t,r);return new Bo(ae.fromJSON(o),t.subreddit,r)}static async update(t,r){let o=await u.redditAPIPlugins.Widgets.UpdateCalendarWidget(t,r);return new Bo(ae.fromJSON(o),t.subreddit,r)}};ys=new WeakMap,bs=new WeakMap,vs=new WeakMap;var Io=Bo,ks,Cs,Do=class Do extends ie{constructor(t,r,s){super(t,r,s);l(this,ks);l(this,Cs);p(t.text,"Textarea widget data is missing text"),p(t.styles,"Textarea widget data is missing styles"),a(this,ks,t.text),a(this,Cs,t.styles)}get text(){return n(this,ks)}get styles(){return n(this,Cs)}toJSON(){return{...super.toJSON(),text:this.text,styles:this.styles}}static async create(t,r){let o=await u.redditAPIPlugins.Widgets.AddTextAreaWidget(t,r);return new Do(ae.fromJSON(o),t.subreddit,r)}static async update(t,r){let o=await u.redditAPIPlugins.Widgets.UpdateTextAreaWidget(t,r);return new Do(ae.fromJSON(o),t.subreddit,r)}};ks=new WeakMap,Cs=new WeakMap;var Eo=Do,Ps,Ss,ws,No=class No extends ie{constructor(t,r,s){super(t,r,s);l(this,Ps);l(this,Ss);l(this,ws);p(t.styles,"Button widget data is missing styles"),a(this,Ps,t.buttons),a(this,Ss,t.description??""),a(this,ws,t.styles)}get buttons(){return n(this,Ps)}get description(){return n(this,Ss)}get styles(){return n(this,ws)}toJSON(){return{...super.toJSON(),buttons:this.buttons,description:this.description,styles:this.styles}}static async create(t,r){let o=await u.redditAPIPlugins.Widgets.AddButtonWidget(t,r);return new No(ae.fromJSON(o),t.subreddit,r)}static async update(t,r){let o=await u.redditAPIPlugins.Widgets.UpdateButtonWidget(t,r);return new No(ae.fromJSON(o),t.subreddit,r)}};Ps=new WeakMap,Ss=new WeakMap,ws=new WeakMap;var To=No,Fs,xs,Lo=class Lo extends ie{constructor(t,r,s){super(t,r,s);l(this,Fs);l(this,xs);a(this,Fs,t.data.map(o=>Ag.fromJSON(o))),p(t.styles,"Community list widget data is missing styles"),a(this,xs,t.styles)}get communities(){return n(this,Fs)}get styles(){return n(this,xs)}toJSON(){return{...super.toJSON(),communities:this.communities,styles:this.styles}}static async create(t,r){let o=await u.redditAPIPlugins.Widgets.AddCommunityListWidget(t,r);return new Lo(ae.fromJSON(o),t.subreddit,r)}static async update(t,r){let o=await u.redditAPIPlugins.Widgets.UpdateCommunityListWidget(t,r);return new Lo(ae.fromJSON(o),t.subreddit,r)}};Fs=new WeakMap,xs=new WeakMap;var Ro=Lo,As,Is,Es,_o=class _o extends ie{constructor(t,r,s){super(t,r,s);l(this,As);l(this,Is);l(this,Es);if(p(t.styles,"Post flair widget data is missing styles"),a(this,As,t.styles),a(this,Is,t.order.map(o=>t.templates[o])),!(t.display&&t.display==="list"||t.display==="cloud"))throw new Error("Post flair widget data is missing display type");a(this,Es,t.display)}get styles(){return n(this,As)}get templates(){return n(this,Is)}get display(){return n(this,Es)}toJSON(){return{...super.toJSON(),styles:this.styles,templates:this.templates,display:this.display}}static async create(t,r){let o=await u.redditAPIPlugins.Widgets.AddPostFlairWidget(t,r);return new _o(ae.fromJSON(o),t.subreddit,r)}static async update(t,r){let o=await u.redditAPIPlugins.Widgets.UpdatePostFlairWidget(t,r);return new _o(ae.fromJSON(o),t.subreddit,r)}};As=new WeakMap,Is=new WeakMap,Es=new WeakMap;var Oo=_o,Ts,Rs,Os,Ms,Us,Ho=class Ho extends ie{constructor(t,r,s){super(t,r,s);l(this,Ts);l(this,Rs);l(this,Os);l(this,Ms);l(this,Us);p(t.stylesheetUrl,"Custom widget data is missing stylesheetUrl"),p(t.height,"Custom widget data is missing height"),p(t.css,"Custom widget data is missing css"),a(this,Ts,t.imageData??[]),a(this,Rs,t.text??""),a(this,Os,t.stylesheetUrl),a(this,Ms,t.height),a(this,Us,t.css)}get images(){return n(this,Ts)}get text(){return n(this,Rs)}get stylesheetUrl(){return n(this,Os)}get height(){return n(this,Ms)}get css(){return n(this,Us)}toJSON(){return{...super.toJSON(),images:this.images,text:this.text,stylesheetUrl:this.stylesheetUrl,height:this.height,css:this.css}}static async create(t,r){let o=await u.redditAPIPlugins.Widgets.AddCustomWidget(t,r);return new Ho(ae.fromJSON(o),t.subreddit,r)}static async update(t,r){let o=await u.redditAPIPlugins.Widgets.UpdateCustomWidget(t,r);return new Ho(ae.fromJSON(o),t.subreddit,r)}};Ts=new WeakMap,Rs=new WeakMap,Os=new WeakMap,Ms=new WeakMap,Us=new WeakMap;var Mo=Ho,Bs,td=class extends ie{constructor(t,r,s,o){super(r,s,o);l(this,Bs);let d=t.rules.map(({description:c,priority:m,shortName:y,violationReason:v})=>(p(c,"Subreddit rule is missing description"),p(m,"Subreddit rule is missing priority"),p(y,"Subreddit rule is missing shortName"),p(v,"Subreddit rule is missing violationReason"),{description:c,priority:m,shortName:y,violationReason:v}));a(this,Bs,d)}get rules(){return n(this,Bs)}toJSON(){return{...super.toJSON(),rules:this.rules}}};Bs=new WeakMap;var Ig=(r=>(r[r.SUBREDDIT_PERMISSIONS=0]="SUBREDDIT_PERMISSIONS",r[r.APPROVED_CONTRIBUTORS_ONLY=1]="APPROVED_CONTRIBUTORS_ONLY",r[r.MODS_ONLY=2]="MODS_ONLY",r))(Ig||{}),ge,he,yr,br,vr,kr,Cr,Pr,Te,Fe=class Fe{constructor(e,t,r,s){l(this,ge);l(this,he);l(this,yr);l(this,br);l(this,vr);l(this,kr);l(this,Cr);l(this,Pr);l(this,Te);X(this),a(this,ge,e),a(this,he,t),a(this,yr,r.contentMd),a(this,br,r.contentHtml),a(this,vr,r.revisionId),a(this,kr,new Date(r.revisionDate*1e3)),a(this,Cr,r.reason??""),a(this,Pr,r.revisionBy?.data?new C(r.revisionBy.data,s):void 0),a(this,Te,s)}get name(){return n(this,ge)}get subredditName(){return n(this,he)}get content(){return n(this,yr)}get contentHtml(){return n(this,br)}get revisionId(){return n(this,vr)}get revisionDate(){return n(this,kr)}get revisionReason(){return n(this,Cr)}get revisionAuthor(){return n(this,Pr)}toJSON(){return{name:n(this,ge),subredditName:n(this,he),content:n(this,yr),contentHtml:n(this,br),revisionId:n(this,vr),revisionDate:n(this,kr),revisionReason:n(this,Cr),revisionAuthor:n(this,Pr)?.toJSON()}}async update(e,t){return Fe.updatePage({subredditName:n(this,he),page:n(this,ge),content:e,reason:t},n(this,Te))}async getRevisions(e){return Fe.getPageRevisions({subredditName:n(this,he),page:n(this,ge),...e},n(this,Te))}async revertTo(e){return Fe.revertPage(n(this,he),n(this,ge),e,n(this,Te))}async getSettings(){return Fe.getPageSettings(n(this,he),n(this,ge),n(this,Te))}async updateSettings(e){return Fe.updatePageSettings({subredditName:n(this,he),page:n(this,ge),listed:e.listed,permLevel:e.permLevel},n(this,Te))}async addEditor(e){return Fe.addEditor(n(this,he),n(this,ge),e,n(this,Te))}async removeEditor(e){return Fe.removeEditor(n(this,he),n(this,ge),e,n(this,Te))}static async getPage(e,t,r){let o=await u.redditAPIPlugins.Wiki.GetWikiPage({subreddit:e,page:t},r);return p(o.data,"Failed to get wiki page"),new Fe(t,e,o.data,r)}static async getPages(e,t){return(await u.redditAPIPlugins.Wiki.GetWikiPages({subreddit:e},t)).data||[]}static async createPage(e,t){return Fe.updatePage(e,t)}static async updatePage(e,t){return await u.redditAPIPlugins.Wiki.EditWikiPage({subreddit:e.subredditName,page:e.page,content:e.content,reason:e.reason??""},t),Fe.getPage(e.subredditName,e.page,t)}static getPageRevisions(e,t){let r=u.redditAPIPlugins.Wiki;return new W({hasMore:!0,after:e.after,limit:e.limit,pageSize:e.pageSize,async fetch(s){let o=await r.GetWikiPageRevisions({subreddit:e.subredditName,page:e.page,limit:s.limit,after:s.after,before:s.before},t);return Eg(o,t)}})}static async revertPage(e,t,r,s){await u.redditAPIPlugins.Wiki.RevertWikiPage({subreddit:e,page:t,revision:r},s)}static async getPageSettings(e,t,r){let o=await u.redditAPIPlugins.Wiki.GetWikiPageSettings({subreddit:e,page:t},r);return p(o.data,"Failed to get wiki page settings"),new jo(o.data,r)}static async updatePageSettings(e,t){let s=await u.redditAPIPlugins.Wiki.UpdateWikiPageSettings({subreddit:e.subredditName,page:e.page,listed:e.listed?"on":"",permlevel:e.permLevel},t);return p(s.data,"Failed to update wiki page settings"),new jo(s.data,t)}static async addEditor(e,t,r,s){await u.redditAPIPlugins.Wiki.AllowEditor({act:"add",subreddit:e,page:t,username:r},s)}static async removeEditor(e,t,r,s){await u.redditAPIPlugins.Wiki.AllowEditor({act:"del",subreddit:e,page:t,username:r},s)}};ge=new WeakMap,he=new WeakMap,yr=new WeakMap,br=new WeakMap,vr=new WeakMap,kr=new WeakMap,Cr=new WeakMap,Pr=new WeakMap,Te=new WeakMap;var ue=Fe,Sr,wr,Fr,xr,Ar,Ir,rd=class{constructor(e,t){l(this,Sr);l(this,wr);l(this,Fr);l(this,xr);l(this,Ar);l(this,Ir);a(this,Sr,e.id),a(this,wr,e.page),a(this,Fr,new Date(e.timestamp)),p(e.author?.data,"Wiki page revision author details are missing"),a(this,xr,new C(e.author.data,t)),a(this,Ar,e.reason??""),a(this,Ir,e.revisionHidden??!1)}get id(){return n(this,Sr)}get page(){return n(this,wr)}get date(){return n(this,Fr)}get author(){return n(this,xr)}get reason(){return n(this,Ar)}get hidden(){return n(this,Ir)}toJSON(){return{id:n(this,Sr),page:n(this,wr),date:n(this,Fr),author:n(this,xr).toJSON(),reason:n(this,Ar),hidden:n(this,Ir)}}};Sr=new WeakMap,wr=new WeakMap,Fr=new WeakMap,xr=new WeakMap,Ar=new WeakMap,Ir=new WeakMap;var Er,Tr,Rr,jo=class{constructor(e,t){l(this,Er);l(this,Tr);l(this,Rr);a(this,Er,e.listed),a(this,Tr,e.permLevel),a(this,Rr,e.editors.map(r=>(p(r.data,"Wiki page editor details are missing"),new C(r.data,t))))}get listed(){return n(this,Er)}get permLevel(){return n(this,Tr)}get editors(){return n(this,Rr)}toJSON(){return{listed:n(this,Er),permLevel:n(this,Tr),editors:n(this,Rr).map(e=>e.toJSON())}}};Er=new WeakMap,Tr=new WeakMap,Rr=new WeakMap;function Eg(i,e){return p(i.data?.children,"Wiki page revision listing is missing children"),{children:i.data.children.map(r=>new rd(r,e)),before:i.data.before,after:i.data.after}}var Tg=["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"],Rg=["border-image","border-image-source","behavior","expression","list-style-image","cursor","content"],Og=["onload","onerror","onclick","onmouseover"];function Mg(i){return/xmlns=["']http:\/\/www\.w3\.org\/2000\/svg["']/.test(i)?i:i.replace(/<svg\b/,'<svg xmlns="http://www.w3.org/2000/svg"')}function Nc(i){if(i){if(!i.trim().startsWith("<svg")){console.log("The provided string is not a valid SVG.");return}try{let e=new RegExp(`<\\s*(${Tg.join("|")})\\b`,"gi"),t=new RegExp(`(${Rg.join("|")})\\s*:\\s*url\\s*\\((['"]?)(.*?)\\2\\)`,"gi"),r=new RegExp(`(${Og.join("|")})\\s*(=\\s*(['"]?)(.*?)\\3)?`,"gi");i=i.trim().replace(/\s+/g," "),i=Mg(i);let s=i.match(e)||[],o=i.match(t)||[],d=i.match(r)||[],c=!1;return s.length>0&&(c=!0,console.warn(`Disallowed elements detected in SVG: ${s.map(m=>m.replace("<","")).join(", ")}`)),o.length>0&&(c=!0,console.warn(`Disallowed styles detected in SVG: ${o.map(m=>m.split(":")[0]).join(", ")}`)),d.length>0&&(c=!0,console.warn(`Disallowed attributes detected in SVG: ${d.map(m=>m.split("=")[0]).join(", ")}`)),c?void 0:i}catch{return}}}function TS(i,...e){let t="";return i.forEach((r,s)=>{t+=r;let o=e[s];o!==void 0&&(t+=`${o}`)}),t=Nc(t),t===void 0?"":`data:image/svg+xml;charset=UTF-8,${encodeURIComponent(t)}`}import{EffectType as Hc}from"@devvit/protos";import{WebViewVisibility as Ug}from"@devvit/protos";var Lc="/api/";var _c=i=>i===null||typeof i!="object"?!1:"scope"in i&&i.scope===0&&"type"in i&&i.type==="devvit-internal";var Or,It,Ds,Mr,si,Ns,Ls,nd=class{constructor(e,t){this.state={messageCount:0,isMounted:!1};l(this,Or);l(this,It);l(this,Ds);l(this,Mr);l(this,si);l(this,Ns);this.postMessage=e=>{try{let t=JSON.stringify(e);n(this,si).emitEffect(`postMessage${this.state.messageCount++}`,{type:Hc.EFFECT_WEB_VIEW,webView:{postMessage:{webViewId:n(this,Or),app:{message:e,jsonString:t}}}})}catch(t){throw console.error(rt.caughtToString(t)),Error("Something went wrong. Please check the contents of your postMessage.")}};this.mount=()=>{if(this.state.isMounted){console.warn("Webview is already mounted!");return}let e=n(this,si)?.devvitContext?.assets,t;if(n(this,It).startsWith(Lc))t=n(this,It);else{let r=n(this,It).replace(/[#?].*/,"");t=`${e.getURL(r,{webView:!0})}${n(this,It).slice(r.length)}`}if(!t)throw Error("useWebView fullscreen request failed; web view asset could not be found");n(this,Ls).call(this,!0,t)};this.unmount=()=>{n(this,Ls).call(this,!1,"")};l(this,Ls,(e,t)=>{n(this,si).emitEffect("fullscreen",{type:Hc.EFFECT_WEB_VIEW,webView:{fullscreen:{id:n(this,Or),show:e,url:t}}})});a(this,It,t.url??"index.html"),a(this,Or,e.hookId),a(this,Ds,t.onMessage),a(this,Mr,t.onUnmount),a(this,si,e.context),a(this,Ns,e.invalidate)}onStateLoaded(){}async onUIEvent(e){if(e.webView?.fullScreen){let t=e.webView.fullScreen.visibility===Ug.WEBVIEW_VISIBLE;this.state.isMounted=t,n(this,Ns).call(this),!t&&n(this,Mr)&&await n(this,Mr).call(this,this)}else if(e.webView?.postMessage){let t=e.webView.postMessage.jsonString?JSON.parse(e.webView.postMessage.jsonString):e.webView.postMessage.message;if(_c(t))return;await n(this,Ds).call(this,t,this)}}};Or=new WeakMap,It=new WeakMap,Ds=new WeakMap,Mr=new WeakMap,si=new WeakMap,Ns=new WeakMap,Ls=new WeakMap;function Bg(i){let e=me({namespace:"useWebView",initializer:t=>new nd(t,i)});return{postMessage:e.postMessage,mount:e.mount,unmount:e.unmount}}export{gh as ALL_ICON_NAMES,Ld as AboutLocations,Mc as AuthorFlairSettings,To as ButtonWidget,Io as CalendarWidget,Q as Comment,Ro as CommunityListWidget,Mo as CustomWidget,bh as DeletionReason,u as Devvit,vh as EventSource,ce as Flair,ne as FlairTemplate,tg as FlairType,qC as GalleryMediaStatus,Ke as Hook,Ao as ImageWidget,W as Listing,Pg as ModMailActionType,kg as ModMailConversationState,Gs as ModMailService,ke as ModNote,G as Post,Uc as PostFlairSettings,Oo as PostFlairWidget,Ot as PrivateMessage,qt as RichTextBuilder,fe as RunAs,$e as SettingScope,fg as SocialLinkType,le as Subreddit,Rc as SubredditDescription,td as SubredditRulesWidget,Oc as SubredditWikiSettings,Eo as TextAreaWidget,C as User,ie as Widget,ue as WikiPage,Ig as WikiPagePermissionLevel,rd as WikiPageRevision,jo as WikiPageSettings,pn as convertUserFlairProtoToAPI,Nd as getCurrentUsernameFromMetadata,Ws as getModerationLog,_d as getSubredditInfoById,Hd as getSubredditInfoByName,jd as getSubredditLeaderboard,Ko as getSubredditNameById,Vd as getSubredditStyles,Wd as getVaultByAddress,Gd as getVaultByUserId,TS as svg,jp as useAsync,Ta as useChannel,Aa as useForm,Ma as useInterval,Na as useState,Bg as useWebView};
1
+ var Wc=Object.create;var od=Object.defineProperty;var Vc=Object.getOwnPropertyDescriptor;var Gc=Object.getOwnPropertyNames;var Jc=Object.getPrototypeOf,zc=Object.prototype.hasOwnProperty;var ad=i=>{throw TypeError(i)};var oi=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var $c=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Gc(e))!zc.call(i,s)&&s!==t&&od(i,s,{get:()=>e[s],enumerable:!(r=Vc(e,s))||r.enumerable});return i};var dd=(i,e,t)=>(t=i!=null?Wc(Jc(i)):{},$c(e||!i||!i.__esModule?od(t,"default",{value:i,enumerable:!0}):t,i));var jo=(i,e,t)=>e.has(i)||ad("Cannot "+t);var n=(i,e,t)=>(jo(i,e,"read from private field"),t?t.call(i):e.get(i)),l=(i,e,t)=>e.has(i)?ad("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),d=(i,e,t,r)=>(jo(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),h=(i,e,t)=>(jo(i,e,"access private method"),t);var ld=(i,e,t,r)=>({set _(s){d(i,e,s,t)},get _(){return n(i,e,r)}});var ya=oi((zb,xl)=>{var cp=Object.prototype.toString;xl.exports=function(e){if(e===void 0)return"undefined";if(e===null)return"null";var t=typeof e;if(t==="boolean")return"boolean";if(t==="string")return"string";if(t==="number")return"number";if(t==="symbol")return"symbol";if(t==="function")return fp(e)?"generatorfunction":"function";if(mp(e))return"array";if(vp(e))return"buffer";if(bp(e))return"arguments";if(gp(e))return"date";if(pp(e))return"error";if(hp(e))return"regexp";switch(Fl(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(yp(e))return"generator";switch(t=cp.call(e),t){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 t.slice(8,-1).toLowerCase().replace(/\s/g,"")};function Fl(i){return typeof i.constructor=="function"?i.constructor.name:null}function mp(i){return Array.isArray?Array.isArray(i):i instanceof Array}function pp(i){return i instanceof Error||typeof i.message=="string"&&i.constructor&&typeof i.constructor.stackTraceLimit=="number"}function gp(i){return i instanceof Date?!0:typeof i.toDateString=="function"&&typeof i.getDate=="function"&&typeof i.setDate=="function"}function hp(i){return i instanceof RegExp?!0:typeof i.flags=="string"&&typeof i.ignoreCase=="boolean"&&typeof i.multiline=="boolean"&&typeof i.global=="boolean"}function fp(i,e){return Fl(i)==="GeneratorFunction"}function yp(i){return typeof i.throw=="function"&&typeof i.return=="function"&&typeof i.next=="function"}function bp(i){try{if(typeof i.length=="number"&&typeof i.callee=="function")return!0}catch(e){if(e.message.indexOf("callee")!==-1)return!0}return!1}function vp(i){return i.constructor&&typeof i.constructor.isBuffer=="function"?i.constructor.isBuffer(i):!1}});var Tl=oi(($b,Al)=>{"use strict";var Il=Symbol.prototype.valueOf,kp=ya();function Cp(i,e){switch(kp(i)){case"array":return i.slice();case"object":return Object.assign({},i);case"date":return new i.constructor(Number(i));case"map":return new Map(i);case"set":return new Set(i);case"buffer":return Fp(i);case"symbol":return xp(i);case"arraybuffer":return Sp(i);case"float32array":case"float64array":case"int16array":case"int32array":case"int8array":case"uint16array":case"uint32array":case"uint8clampedarray":case"uint8array":return wp(i);case"regexp":return Pp(i);case"error":return Object.create(i);default:return i}}function Pp(i){let e=i.flags!==void 0?i.flags:/\w+$/.exec(i)||void 0,t=new i.constructor(i.source,e);return t.lastIndex=i.lastIndex,t}function Sp(i){let e=new i.constructor(i.byteLength);return new Uint8Array(e).set(new Uint8Array(i)),e}function wp(i,e){return new i.constructor(i.buffer,i.byteOffset,i.length)}function Fp(i){let e=i.length,t=Buffer.allocUnsafe?Buffer.allocUnsafe(e):Buffer.from(e);return i.copy(t),t}function xp(i){return Il?Object(Il.call(i)):{}}Al.exports=Cp});var Rl=oi((qb,El)=>{"use strict";El.exports=function(e){return e!=null&&typeof e=="object"&&Array.isArray(e)===!1}});var Ul=oi((Kb,Ml)=>{"use strict";var Ip=Rl();function Ol(i){return Ip(i)===!0&&Object.prototype.toString.call(i)==="[object Object]"}Ml.exports=function(e){var t,r;return!(Ol(e)===!1||(t=e.constructor,typeof t!="function")||(r=t.prototype,Ol(r)===!1)||r.hasOwnProperty("isPrototypeOf")===!1)}});var Bl=oi((Xb,Dl)=>{"use strict";var Ap=Tl(),Tp=ya(),Ep=Ul();function ba(i,e){switch(Tp(i)){case"object":return Rp(i,e);case"array":return Op(i,e);default:return Ap(i)}}function Rp(i,e){if(typeof e=="function")return e(i);if(e||Ep(i)){let t=new i.constructor;for(let r in i)t[r]=ba(i[r],e);return t}return i}function Op(i,e){let t=new i.constructor(i.length);for(let r=0;r<i.length;r++)t[r]=ba(i[r],e);return t}Dl.exports=ba});var Ic=oi(So=>{"use strict";So.byteLength=ag;So.toByteArray=lg;So.fromByteArray=mg;var Ue=[],Se=[],og=typeof Uint8Array<"u"?Uint8Array:Array,Ka="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Xt=0,Fc=Ka.length;Xt<Fc;++Xt)Ue[Xt]=Ka[Xt],Se[Ka.charCodeAt(Xt)]=Xt;var Xt,Fc;Se[45]=62;Se[95]=63;function xc(i){var e=i.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=i.indexOf("=");t===-1&&(t=e);var r=t===e?0:4-t%4;return[t,r]}function ag(i){var e=xc(i),t=e[0],r=e[1];return(t+r)*3/4-r}function dg(i,e,t){return(e+t)*3/4-t}function lg(i){var e,t=xc(i),r=t[0],s=t[1],o=new og(dg(i,r,s)),a=0,c=s>0?r-4:r,m;for(m=0;m<c;m+=4)e=Se[i.charCodeAt(m)]<<18|Se[i.charCodeAt(m+1)]<<12|Se[i.charCodeAt(m+2)]<<6|Se[i.charCodeAt(m+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=e&255;return s===2&&(e=Se[i.charCodeAt(m)]<<2|Se[i.charCodeAt(m+1)]>>4,o[a++]=e&255),s===1&&(e=Se[i.charCodeAt(m)]<<10|Se[i.charCodeAt(m+1)]<<4|Se[i.charCodeAt(m+2)]>>2,o[a++]=e>>8&255,o[a++]=e&255),o}function ug(i){return Ue[i>>18&63]+Ue[i>>12&63]+Ue[i>>6&63]+Ue[i&63]}function cg(i,e,t){for(var r,s=[],o=e;o<t;o+=3)r=(i[o]<<16&16711680)+(i[o+1]<<8&65280)+(i[o+2]&255),s.push(ug(r));return s.join("")}function mg(i){for(var e,t=i.length,r=t%3,s=[],o=16383,a=0,c=t-r;a<c;a+=o)s.push(cg(i,a,a+o>c?c:a+o));return r===1?(e=i[t-1],s.push(Ue[e>>2]+Ue[e<<4&63]+"==")):r===2&&(e=(i[t-2]<<8)+i[t-1],s.push(Ue[e>>10]+Ue[e>>4&63]+Ue[e<<2&63]+"=")),s.join("")}});var he={APP:0,USER:1,UNSPECIFIED:2};function p(i,e){if(i==null)throw Error(e??"Expected nonnullish value.")}import*as k from"@devvit/protos";var Ls=class{constructor(e){}};var qc=/\.[a-zA-Z]{2,}$/;function ud(i){if(i.length>25)throw new Error("The size of requestedFetchDomains is limited to 25 domains.")}function cd(i){let e=new Set;for(let t of i)try{if(!qc.test(t))throw new Error("The domain does not have a valid top-level domain.");t.includes("://")||(t="http://"+t);let s=new URL(t).hostname.replace(/^www\./,"");e.add(s)}catch(r){throw new Error(`Failed to determine hostname from requested domain: '${t}'. ${r}`)}return Array.from(e)}var ze;(function(i){i.Installation="installation",i.App="app"})(ze||(ze={}));import"@devvit/protos/json/devvit/events/v1alpha/events.js";import{DeletionReason as zg,EventSource as $g}from"@devvit/protos/json/devvit/events/v1alpha/events.js";import{CrowdControlLevel as Kg,DistinguishType as Xg}from"@devvit/protos/json/devvit/reddit/v2alpha/postv2.js";import{SubredditRating as Qg,SubredditType as Yg}from"@devvit/protos/json/devvit/reddit/v2alpha/subredditv2.js";function $e(i,e){if(!i)throw Error(e)}var md;(function(i){i.COMMENT="t1_",i.ACCOUNT="t2_",i.LINK="t3_",i.MESSAGE="t4_",i.SUBREDDIT="t5_",i.AWARD="t6_"})(md||(md={}));function Tt(i,e=new Set){for(let t of i){if(t.type==="group"){Tt(t.fields,e);continue}let r=t.name;if(e.has(r))throw new Error(`Duplicate field name: ${r}`);e.add(r)}Kc(i)}function Kc(i){for(let e of i)if(e.type==="string"&&e.isSecret&&e.scope!==ze.App)throw`Invalid setting: only app settings can be secrets. Add "scope: SettingScope.App" to field "${e.name}"`}var qe=Object.freeze({INTERVAL:0,FORM:1,STATE:2,CHANNEL:3,WEB_VIEW:4});var hh=["3rd-party","activity","add-emoji","add","add-media","add-to-feed","admin","ads","ai","align-center","align-left","align-right","all","ama","appearance","approve","archived","aspect-ratio","aspect-rectangle","attach","audience","audio","author","automod","avatar-style","award","back","backup","ban","best","block","blockchain","bold","boost","bot","bounce","brand-awareness","browse","browser","cake","calendar","camera","campaign","caret-down","caret-left","caret-right","caret-up","chat","chat-group","chat-new","chat-private","checkbox-dismiss","checkbox","checkmark","chrome","clear","client-list","close","closed-captioning","code-block","code-inline","coins-color-old","coins","collapse-left","collapse-right","collectible-expressions","collection","comment","comments","communities","community","confidence","contest","controversial","conversion","copy-clipboard","crop","crosspost","crowd-control","custom-feed","customize","dashboard","day","delete-column","delete","delete-row","devvit","discover","dismiss-all","distinguish","down-arrow","down","download","downvote","downvotes","drag","drugs","duplicate","edit","effect","embed","emoji","end-live-chat","error","expand-left","expand-right","external","feed-video","filter","format","forward","funnel","gif-post","gold","hashtag","heart","help","hide","history","home","hot","ignore-reports","image-post","inbox","info","insert-column-left","insert-column-right","insert-row-above","insert-row-below","internet","invite","italic","join","joined","jump-down","jump-up","karma","keyboard","kick","language","leave","left","link","link-post","list-bulleted","list-numbered","live-chat","live","load","location","lock","logout","loop","macro","mark-read","marketplace","mask","media-gallery","meme","menu","message","mic","mic-mute","mod","mod-mail","mod-mode","mod-mute","mod-overflow","mod-queue","mod-unmute","music","mute","new","night","no-internet","notification","notification-frequent","notification-off","nsfw","nsfw-language","nsfw-violence","official","original","overflow-caret","overflow-horizontal","overflow-vertical","pause","payment","peace","pending-posts","phone","pin","play","poll-post","popular","posts","powerup","predictions","premium","privacy","profile","qa","qr-code","quarantined","quote","r-slash","radar","radio-button","raise-hand","random","ratings-everyone","ratings-mature","ratings-nsfw","ratings-violence","recovery-phrase","refresh","removal-reasons","remove","reply","report","reverse","rich-text","right","rising","rotate","rotate-image","rpan","rules","safari","save","save-view","saved","saved-response","search","self","send","settings","severity","share","share-new","show","side-menu","skipback10","skipforward10","sort-az","sort","sort-price","sort-za","spam","spoiler","sponsored","spreadsheet","star","statistics","status-live","sticker","strikethrough","subtract","superscript","swap-camera","swipe-back","swipe-down","swipe","swipe-up","table","tag","tap","text","text-post","text-size","toggle","tools","top","topic-activism","topic-addictionsupport","topic-advice","topic-animals","topic-anime","topic-art","topic-beauty","topic-business","topic-careers","topic-cars","topic-celebrity","topic-craftsdiy","topic-crypto","topic-culture","topic-diy","topic-entertainment","topic-ethics","topic-family","topic-fashion","topic","topic-fitness","topic-food","topic-funny","topic-gender","topic-health","topic-help","topic-history","topic-hobbies","topic-homegarden","topic-internet","topic-law","topic-learning","topic-lifestyle","topic-marketplace","topic-mature","topic-mensfashion","topic-menshealth","topic-meta","topic-military","topic-movies","topic-music","topic-news","topic-other","topic-outdoors","topic-pets","topic-photography","topic-places","topic-podcasts","topic-politics","topic-programming","topic-reading","topic-religion","topic-science","topic-sexorientation","topic-sports","topic-style","topic-tabletop","topic-technology","topic-television","topic-traumasupport","topic-travel","topic-videogaming","topic-womensfashion","topic-womenshealth","translate","translation-off","trim","u-slash","unban","undo","unheart","unlock","unmod","unpin","unstar","unverified","up-arrow","up","upload","upvote","upvotes","user","user-note","users","vault","verified","video-camera","video-feed","video-post","video-thread","video-transcription","view-card","view-classic","view-compact","view-grid","view-sort","views","volume","wallet","warning","webhook","whale","wiki-ban","wiki","wiki-unban","world","coins-color","powerup-color","powerup-fill-color","share-android","share-ios","video-live-1","video-live-fill-1","video-live","volume-mute","binoculars","caret-updown","planet","telescope"];import{DeletionReason as vh,EventSource as kh}from"@devvit/protos";import{AppSettingsDefinition as Cm,GetFieldsResponse as Pm}from"@devvit/protos";import{FormFieldType as fe}from"@devvit/protos";function Ne(i){return i.map(e=>{switch(e.type){case"string":return Xc(e);case"image":return Zc(e);case"paragraph":return Qc(e);case"number":return Yc(e);case"select":return em(e);case"boolean":return tm(e);case"group":return im(e);default:throw new Error("Unknown field type.")}})}function Xc(i){return{defaultValue:{fieldType:fe.STRING,stringValue:i.defaultValue},disabled:i.disabled,fieldConfig:{stringConfig:{placeholder:i.placeholder}},fieldId:i.name,fieldType:fe.STRING,helpText:i.helpText,label:i.label,required:i.required,isSecret:i.isSecret}}function Zc(i){return{disabled:i.disabled,fieldId:i.name,fieldType:fe.IMAGE,helpText:i.helpText,label:i.label,required:i.required}}function Qc(i){return{defaultValue:{fieldType:fe.PARAGRAPH,stringValue:i.defaultValue},disabled:i.disabled,fieldConfig:{paragraphConfig:{lineHeight:i.lineHeight,placeholder:i.placeholder}},fieldId:i.name,fieldType:fe.PARAGRAPH,helpText:i.helpText,label:i.label,required:i.required}}function Yc(i){return{defaultValue:{fieldType:fe.NUMBER,numberValue:i.defaultValue},disabled:i.disabled,fieldConfig:{numberConfig:{}},fieldId:i.name,fieldType:fe.NUMBER,helpText:i.helpText,label:i.label,required:i.required}}function em(i){return{defaultValue:{fieldType:fe.SELECTION,selectionValue:{values:i.defaultValue??[]}},disabled:i.disabled,fieldConfig:{selectionConfig:{choices:i.options,multiSelect:i.multiSelect}},fieldId:i.name,fieldType:fe.SELECTION,helpText:i.helpText,label:i.label,required:i.required}}function tm(i){return{defaultValue:{fieldType:fe.BOOLEAN,boolValue:i.defaultValue},disabled:i.disabled,fieldId:i.name,fieldType:fe.BOOLEAN,helpText:i.helpText,label:i.label}}function im(i){return{fieldId:"",fieldType:fe.GROUP,fieldConfig:{groupConfig:{fields:Ne(i.fields)}},label:i.label,helpText:i.helpText}}function O(i,e){u.prototype[i]=e}import{ValidateFormResponse as km}from"@devvit/protos";import{RealtimeSubscriptionStatus as gd}from"@devvit/protos";var P=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",PostData:"devvit-post-data",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"});var pd;(function(i){i.Blocks="blocks",i.EmitSnapshots="emitSnapshots",i.EmitState="emitState",i.Realtime="realtime",i.Runtime="runtime",i.Surface="surface",i.UseAsync="useAsync",i.Payments="payments",i.Bootstrap="bootstrap",i.WebView="webView"})(pd||(pd={}));function hd(i){function e(t){let s=i.currentHookIndex,o=i.getCurrentComponentState(),a=i.getPreviousComponentState(),c=i.metadata[P.App]?.values[0];p(c,"useChannel - app is missing from Context");let m=i.metadata[P.Installation]?.values[0];p(m,"useChannel - installation is missing from Context");async function y(N){let D=o[s].channel;if(o[s].active)if(o[s].connected)await i.realtime.send(D,N);else throw Error(`Failed to send to channel '${D}'; it is active but not yet connected`);else throw Error(`Cannot send a message over inactive channel: ${D}`)}function v(){if(!o[s].active){let N=o[s].channel;o[s].active=!0,i.addRealtimeChannel(N)}}function f(){if(o[s].active){let N=o[s].channel;o[s].active=!1,i.removeRealtimeChannel(N)}}function S(N){return async()=>{let D;switch(N.status){case gd.REALTIME_SUBSCRIBED:o[s].connected=!0,D=t.onSubscribed?.();break;case gd.REALTIME_UNSUBSCRIBED:o[s].connected=!1,D=t.onUnsubscribed?.();break;default:D=t.onMessage(N.event?.data?.msg);break}await D}}let b={channel:`${c}:${m}:${t.name}`,active:!1,connected:!1,preventCallback:!1,type:qe.CHANNEL};s in o?b=o[s]:s in a&&(b=a[s]);let _=i.realtimeEvent;i.isInitialRender?b.active=!1:_&&b.active&&_.event.channel===b.channel&&(b.preventCallback||i.runHook(S(_)),i.rerenderIn(0)),o[s]=b,i.currentHookIndex++;let I=0;return b.active&&b.connected?I=2:b.active&&!b.connected?I=1:!b.active&&b.connected?I=3:!b.active&&!b.connected&&(I=4),{subscribe:v,unsubscribe:f,send:y,status:I}}return e}import{FormFieldType as ai}from"@devvit/protos";function Wo(i){switch(i.fieldType){case ai.STRING:return i.stringValue;case ai.IMAGE:return i.stringValue;case ai.PARAGRAPH:return i.stringValue;case ai.NUMBER:return i.numberValue;case ai.BOOLEAN:return i.boolValue;case ai.SELECTION:return i.selectionValue?.values??[];default:return}}function Ke(i){return Object.keys(i).reduce((e,t)=>{let r=Wo(i[t]);return r!==void 0&&(e[t]=r),e},{})}function fd(i){function e(t,r){let s=i.currentHookIndex,o=i.getCurrentComponentKey(),a=i.getCurrentComponentState(),c=i.getPreviousComponentState(),m=`form.hook.${o}.${s}`,y={formKey:m,preventSubmit:!1,type:qe.FORM};s in a?y=a[s]:s in c&&(y=c[s]),a[s]=y,i.forms.set(m,t);let v=i.formSubmittedEvent;return v&&!y.preventSubmit&&v.formId===m&&i.runHook(async()=>{let f=r(Ke(v.results));f&&f instanceof Promise&&await f,i.rerenderIn(0)}),a[s].preventSubmit=!1,i.currentHookIndex++,m}return e}function yd(i){function e(t,r){let s=i.currentHookIndex,o=i.getCurrentComponentState(),a=i.getPreviousComponentState(),c=100,m=Math.max(c,r),y={lastRun:void 0,running:!1,preventCallback:!1,type:qe.INTERVAL};s in o?y=o[s]:s in a&&(y=a[s]);function v(){r<c&&console.error(`useInterval delay must be at least ${c}ms. Your interval of ${r}ms was automatically extended.`);for(let[S,b]of Object.entries(o))if(S!==s.toString()&&b?.type===qe.INTERVAL&&b?.running)throw new Error("Only one useInterval hook may be running at a time");o[s]={running:!0,lastRun:o[s]?.lastRun??Date.now(),preventCallback:!1,type:qe.INTERVAL},i.rerenderIn(m)}function f(){o[s].running=!1,o[s].lastRun=void 0,o[s].preventCallback=!1}return i.isEffectRender&&y.running&&(y.preventCallback||(y.lastRun===void 0||y.lastRun+m<Date.now())&&i.runHook(async()=>{let S=t();S&&S instanceof Promise&&await S,y.lastRun=Date.now()}),i.rerenderIn(m)),y.preventCallback=!1,o[s]=y,i.currentHookIndex++,{start:v,stop:f}}return e}function bd(i){function e(t){let r=i.currentHookIndex,s=i.getCurrentComponentState(),o=i.getPreviousComponentState();if(r in s)return i.currentHookIndex++,[s[r],a];if(i.isInitialRender||!(r in o)){let c=t instanceof Function?t():t;if(c instanceof Promise)throw(async()=>{s[r]=await c,i.currentHookIndex=0})();s[r]=c}else s[r]=o[r];function a(c){if(i.isRendering)throw new Error("Cannot call setState while rendering.");s[r]=c instanceof Function?c(s[r]):c}return i.currentHookIndex++,[s[r],a]}return e}var zo={now(){return new Date}};function vd(i){return`__autocache__${i}`}function kd(i){return`__lock__${i}`}var nm=300,sm=1e3,_s=5e3,Vo=3,Cd=.1,Pd=1e3,om=3e4;function Sd(i){if(i.error)throw new Error(i.error);return i.value}var Xe,Ze,ye,di,z,wd,Fd,xd,Go,Id,Ad,Jo,Td,Hs=class{constructor(e,t,r=zo){l(this,z);l(this,Xe);l(this,Ze,{});l(this,ye);l(this,di);d(this,Xe,e),d(this,di,t),d(this,ye,r)}async cache(e,t){d(this,Ze,n(this,di).__cache=n(this,di).__cache??{}),h(this,z,Td).call(this,t);let r=h(this,z,wd).call(this,t.key);if(r!==void 0)return r;let s=await h(this,z,Jo).call(this,t.key),o=await h(this,z,Fd).call(this,t,s,e);return Sd(o)}};Xe=new WeakMap,Ze=new WeakMap,ye=new WeakMap,di=new WeakMap,z=new WeakSet,wd=function(e){let t=n(this,Ze)[e];if(t){let r=n(this,ye).now().getTime(),s=t?.error&&t?.errorTime&&t.errorCount<Vo&&Math.random()<Cd&&t.errorTime+Pd<r;if(t?.expires&&t.expires<r&&t.checkedAt+Pd<r||s){delete n(this,Ze)[e];return}else return Sd(t)}},Fd=async function(e,t,r){let s=t?.expires,o=s?h(this,z,Ad).call(this,s):1;return!t||t?.error&&t.errorCount<Vo&&Cd>Math.random()||o>Math.random()?h(this,z,xd).call(this,e,t,r):t},xd=async function(e,t,r){let s=kd(e.key),o=n(this,ye).now().getTime(),a=new Date(o+e.ttl/2);if(await n(this,Xe).set(s,"1",{expiration:a,nx:!0}))return h(this,z,Id).call(this,e.key,t,r,e.ttl);if(t)return t;{let m=n(this,ye).now();return h(this,z,Go).call(this,m,e.key,e.ttl)}},Go=async function(e,t,r){let s=Math.min(r,sm),o=await h(this,z,Jo).call(this,t);if(o)return o;if(n(this,ye).now().getTime()-e.getTime()>=s)throw new Error(`Cache request timed out trying to get data at key: ${t}`);return await new Promise(a=>setTimeout(a,nm)),h(this,z,Go).call(this,e,t,r)},Id=async function(e,t,r,s){let o=n(this,ye).now().getTime()+s;t=t??{value:null,expires:o,errorCount:0,error:null,errorTime:null,checkedAt:0};try{t.value=await r(),t.error=null,t.errorCount=0,t.errorTime=null}catch(a){t.value=null,t.error=a.message??"Unknown error",t.errorTime=n(this,ye).now().getTime(),t.errorCount++}return n(this,Ze)[e]=t,await n(this,Xe).set(vd(e),JSON.stringify(t),{expiration:new Date(o+om)}),t.error&&t.errorCount<Vo&&await n(this,Xe).del(kd(e)),t},Ad=function(e){let t=n(this,ye).now().getTime(),r=e-t;return r<0?1:r<1e3?.1:r<2e3?.01:r<3e3?.001:0},Jo=async function(e){let t=await n(this,Xe).get(vd(e));if(t){let r=JSON.parse(t);return r.checkedAt=n(this,ye).now().getTime(),n(this,Ze)[e]=r,r}},Td=function(e){e.ttl<_s&&(console.warn(`Cache TTL cannot be less than ${_s} milliseconds! Updating ttl value of ${e.ttl} to ${_s}.`),e.ttl=_s)};function Ed(i,e,t=zo){let r=new Hs(i,e,t);return r.cache.bind(r)}function Rd(i){new URL(i.slice(0,i.indexOf(",")))}var li,ci,Od,Md,ui=class{constructor(){l(this,ci);l(this,li,{});d(this,li,u.webViewAssets)}getURL(e,t){return typeof e=="string"?h(this,ci,Od).call(this,e,t??{webView:!1}):h(this,ci,Md).call(this,e,t??{webView:!1})}};li=new WeakMap,ci=new WeakSet,Od=function(e,t){let r=t.webView?n(this,li)[e]:u.assets[e];if(r)return r;try{return Rd(e),e}catch{return""}},Md=function(e,t){let r={},s=[],o=t.webView?n(this,li):u.assets;if(o)for(let a of e)if(o[a])r[a]=o[a];else try{Rd(a),r[a]=a}catch{s.push(a)}else s=e;if(s.length>0)throw new Error(`The following assets were missing from the assets list: ${s.join(", ")}`);return r};var Qe,mi=class{constructor(e){l(this,Qe);d(this,Qe,e)}async get(e){let{messages:t}=await u.kvStorePlugin.Get({keys:[e]},n(this,Qe));try{if(t[e])return JSON.parse(t[e])}catch{return}}async put(e,t){let r={};r[e]=JSON.stringify(t),await u.kvStorePlugin.Put({messages:r},n(this,Qe))}async delete(e){await u.kvStorePlugin.Del({keys:[e]},n(this,Qe))}async list(){let{keys:e}=await u.kvStorePlugin.List({filter:"*"},n(this,Qe));return e}};Qe=new WeakMap;var Mr,pi=class{constructor(e){l(this,Mr);d(this,Mr,e)}async upload(e){let t=await u.mediaPlugin.Upload(e,n(this,Mr));if(!t.mediaId)throw new Error("unable to get mediaId via uploads");return{mediaId:t.mediaId,mediaUrl:t.mediaUrl}}};Mr=new WeakMap;var Ur,gi=class{constructor(e){l(this,Ur);d(this,Ur,e)}async add(e){await u.modLogPlugin.Add(e,n(this,Ur))}};Ur=new WeakMap;var Dr,hi=class{constructor(e){l(this,Dr);d(this,Dr,e)}async send(e,t){await u.realtimePlugin.Send({channel:e,data:{msg:t}},n(this,Dr))}};Dr=new WeakMap;import"@devvit/protos";var Ud=(a=>(a.COMMENT="t1_",a.ACCOUNT="t2_",a.LINK="t3_",a.MESSAGE="t4_",a.SUBREDDIT="t5_",a.AWARD="t6_",a))(Ud||{});function Ye(i){return i.startsWith("t1_")}function js(i){return i.startsWith("t2_")}function Et(i){return i.startsWith("t3_")}function Dd(i){return i.startsWith("t4_")}function Bd(i){return i.startsWith("t5_")}function Nd(i){return i.startsWith("t6_")}function am(i){$e(Ye(i),`Expected comment id to start with t1_, got ${i}}`)}function dm(i){$e(js(i),`Expected account id to start with t2_, got ${i}}`)}function lm(i){$e(Et(i),`Expected link id to start with t3_, got ${i}}`)}function um(i){$e(Dd(i),`Expected message id to start with t4_, got ${i}}`)}function cm(i){$e(Bd(i),`Expected subreddit id to start with t5_, got ${i}}`)}function mm(i){$e(Nd(i),`Expected award id to start with t6_, got ${i}}`)}function fi(i){return am(i),i}function ee(i){return dm(i),i}function ae(i){return lm(i),i}function pm(i){return um(i),i}function K(i){return cm(i),i}function gm(i){return mm(i),i}function be(i){if(Ye(i))return fi(i);if(js(i))return ee(i);if(Et(i))return ae(i);if(Dd(i))return pm(i);if(Bd(i))return K(i);if(Nd(i))return gm(i);throw new Error(`Expected thing id to start with ${Object.values(Ud).join(", ")} got ${i}}`)}function $o(i){return Ye(i)}var g,Br,Nr,Lr,yi=class{constructor(e){l(this,g);l(this,Br);l(this,Nr);l(this,Lr);d(this,g,e),d(this,Br,new Vs(e))}get modMail(){return n(this,Br)}getSubredditById(e){return de.getById(be(e),n(this,g))}getSubredditInfoById(e){return Hd(e,n(this,g))}getSubredditByName(e){return de.getByName(e,n(this,g))}getSubredditInfoByName(e){return jd(e,n(this,g))}addSubredditRemovalReason(e,t){return de.addRemovalReason(e,t.title,t.message,n(this,g))}getSubredditRemovalReasons(e){return de.getRemovalReasons(e,n(this,g))}async getCurrentSubredditName(){let e=n(this,g)?.[P.SubredditName]?.values[0];if(e)return e;let t=n(this,g)?.[P.Subreddit]?.values[0],r=await qo(K(t),n(this,g));if(!r)throw new Error("Couldn't get current subreddit's name");return r}async getCurrentSubreddit(){let e=await de.getFromMetadata(n(this,g));if(!e)throw new Error("Couldn't get current subreddit");return e}getPostById(e){return G.getById(be(e),n(this,g))}submitPost(e){return G.submit(e,n(this,g))}crosspost(e){return G.crosspost(e,n(this,g))}getUserById(e){return C.getById(be(e),n(this,g))}getUserByUsername(e){return C.getByUsername(e,n(this,g))}async getCurrentUsername(){return n(this,Lr)??d(this,Lr,Ld(n(this,g))),n(this,Lr)}async getCurrentUser(){return n(this,Nr)??d(this,Nr,this.getCurrentUsername().then(e=>e?C.getByUsername(e,n(this,g)):void 0)),n(this,Nr)}getAppUser(){return C.getFromMetadata(P.AppUser,n(this,g))}async getSnoovatarUrl(e){let t=await this.getCurrentUsername();if(t&&e===t){let r=n(this,g)?.[P.UserSnoovatarUrl]?.values[0];if(r)return r}return C.getSnoovatarUrl(e,n(this,g))}getCommentById(e){return Q.getById(be(e),n(this,g))}getComments(e){return Q.getComments(e,n(this,g))}getCommentsByUser(e){return Q.getCommentsByUser(e,n(this,g))}submitComment(e){return Q.submit({...e,id:be(e.id)},n(this,g))}getControversialPosts(e){return G.getControversialPosts(e,n(this,g))}getTopPosts(e){return G.getTopPosts(e,n(this,g))}getHotPosts(e){return G.getHotPosts(e,n(this,g))}getNewPosts(e){return G.getNewPosts(e,n(this,g))}getRisingPosts(e){return G.getRisingPosts(e,n(this,g))}getPostsByUser(e){return G.getPostsByUser(e,n(this,g))}getCommentsAndPostsByUser(e){return C.getOverview(e,n(this,g))}getModerationLog(e){return Ws(e,n(this,g))}getApprovedUsers(e){return C.getSubredditUsersByType({type:"contributors",...e},n(this,g))}approveUser(e,t){return C.createRelationship({username:e,subredditName:t,type:"contributor"},n(this,g))}removeUser(e,t){return C.removeRelationship({username:e,subredditName:t,type:"contributor"},n(this,g))}getWikiContributors(e){return C.getSubredditUsersByType({type:"wikicontributors",...e},n(this,g))}addWikiContributor(e,t){return C.createRelationship({username:e,subredditName:t,type:"wikicontributor"},n(this,g))}removeWikiContributor(e,t){return C.removeRelationship({username:e,subredditName:t,type:"wikicontributor"},n(this,g))}getBannedUsers(e){return C.getSubredditUsersByType({type:"banned",...e},n(this,g))}banUser(e){return C.createRelationship({username:e.username,subredditName:e.subredditName,type:"banned",banReason:e.reason,banMessage:e.message,note:e.note,duration:e.duration,banContext:e.context},n(this,g))}unbanUser(e,t){return C.removeRelationship({username:e,subredditName:t,type:"banned"},n(this,g))}getBannedWikiContributors(e){return C.getSubredditUsersByType({type:"wikibanned",...e},n(this,g))}banWikiContributor(e){return C.createRelationship({...e,type:"wikibanned"},n(this,g))}unbanWikiContributor(e,t){return C.removeRelationship({username:e,subredditName:t,type:"wikibanned"},n(this,g))}getModerators(e){return C.getSubredditUsersByType({type:"moderators",...e},n(this,g))}inviteModerator(e){return C.createRelationship({type:"moderator_invite",subredditName:e.subredditName,username:e.username,permissions:e.permissions??[]},n(this,g))}revokeModeratorInvite(e,t){return C.removeRelationship({username:e,subredditName:t,type:"moderator_invite"},n(this,g))}removeModerator(e,t){return C.removeRelationship({type:"moderator",subredditName:t,username:e},n(this,g))}setModeratorPermissions(e,t,r){return C.setModeratorPermissions(e,t,r,n(this,g))}getMutedUsers(e){return C.getSubredditUsersByType({type:"muted",...e},n(this,g))}muteUser(e){return C.createRelationship({...e,type:"muted"},n(this,g))}unmuteUser(e,t){return C.removeRelationship({username:e,subredditName:t,type:"muted"},n(this,g))}getModNotes(e){return ve.get(e,n(this,g))}deleteModNote(e){return ve.delete(e,n(this,g))}addModNote(e){let t={...e,redditId:e.redditId?be(e.redditId):void 0};return ve.add(t,n(this,g))}addRemovalNote(e){return ve.addRemovalNote(e,n(this,g))}async sendPrivateMessage(e){return Rt.send(e,n(this,g))}async sendPrivateMessageAsSubreddit(e){return Rt.sendAsSubreddit(e,n(this,g))}async approve(e){if(Ye(e))return Q.approve(e,n(this,g));if(Et(e))return G.approve(e,n(this,g));throw new Error("id must start with either t1_ or t3_")}async remove(e,t){if(Ye(e))return Q.remove(e,t,n(this,g));if(Et(e))return G.remove(e,t,n(this,g));throw new Error("id must start with either t1_ or t3_")}async getPostFlairTemplates(e){return re.getPostFlairTemplates(e,n(this,g))}async getUserFlairTemplates(e){return re.getUserFlairTemplates(e,n(this,g))}async createPostFlairTemplate(e){return re.createPostFlairTemplate(e,n(this,g))}async createUserFlairTemplate(e){return re.createUserFlairTemplate(e,n(this,g))}async editFlairTemplate(e){return re.editFlairTemplate(e,n(this,g))}async deleteFlairTemplate(e,t){return re.deleteFlairTemplate(e,t,n(this,g))}async setUserFlair(e){return ue.setUserFlair(e,n(this,g))}async setUserFlairBatch(e,t){return ue.setUserFlairBatch(e,t,n(this,g))}async removeUserFlair(e,t){return ue.removeUserFlair(e,t,n(this,g))}async setPostFlair(e){return ue.setPostFlair(e,n(this,g))}async removePostFlair(e,t){return ue.removePostFlair(e,ae(t),n(this,g))}async getWidgets(e){return te.getWidgets(e,n(this,g))}async deleteWidget(e,t){return te.delete(e,t,n(this,g))}async addWidget(e){return te.add(e,n(this,g))}async reorderWidgets(e,t){return te.reorder(e,t,n(this,g))}async getWikiPage(e,t){return le.getPage(e,t,n(this,g))}async getWikiPages(e){return le.getPages(e,n(this,g))}async createWikiPage(e){return le.createPage(e,n(this,g))}async updateWikiPage(e){return le.updatePage(e,n(this,g))}getWikiPageRevisions(e){return le.getPageRevisions(e,n(this,g))}async revertWikiPage(e,t,r){return le.revertPage(e,t,r,n(this,g))}async getWikiPageSettings(e,t){return le.getPageSettings(e,t,n(this,g))}async updateWikiPageSettings(e){return le.updatePageSettings(e,n(this,g))}async addEditorToWikiPage(e,t,r){return le.addEditor(e,t,r,n(this,g))}async removeEditorFromWikiPage(e,t,r){return le.removeEditor(e,t,r,n(this,g))}getMessages(e){return Rt.getMessages(e,n(this,g))}markAllMessagesAsRead(){return Rt.markAllAsRead(n(this,g))}report(e,t){return u.redditAPIPlugins.LinksAndComments.Report({reason:t.reason,thingId:e.id,srName:e.subredditName,usernames:e.authorName},n(this,g))}getModQueue(e){return de.aboutLocation({...e,location:"modqueue"},n(this,g))}getReports(e){return de.aboutLocation({...e,location:"reports"},n(this,g))}getSpam(e){return de.aboutLocation({...e,location:"spam"},n(this,g))}getUnmoderated(e){return de.aboutLocation({...e,location:"unmoderated"},n(this,g))}getEdited(e){return de.aboutLocation({...e,location:"edited"},n(this,g))}getVaultByAddress(e){return Gd(e,n(this,g))}getVaultByUserId(e){return Jd(be(e),n(this,g))}getSubredditLeaderboard(e){return Wd(e,n(this,g))}getSubredditStyles(e){return Vd(e,n(this,g))}async subscribeToCurrentSubreddit(){let e=await this.getCurrentSubreddit();await u.redditAPIPlugins.Subreddits.Subscribe({action:"sub",actionSource:"",srName:e.name,sr:"",skipInitialDefaults:!0},n(this,g))}async unsubscribeFromCurrentSubreddit(){let e=await this.getCurrentSubreddit();await u.redditAPIPlugins.Subreddits.Subscribe({action:"unsub",actionSource:"",srName:e.name,sr:"",skipInitialDefaults:!1},n(this,g))}};g=new WeakMap,Br=new WeakMap,Nr=new WeakMap,Lr=new WeakMap;import{BitfieldOverflowBehavior as Ko,RedisKeyScope as Xo}from"@devvit/protos";function _r(i){return i&&typeof i=="object"&&"message"in i&&i.message!==void 0&&typeof i.message=="string"?i.message.includes("redis: nil"):!1}var A,T,E,Zo=class{constructor(e,t,r){l(this,A);l(this,T);l(this,E);d(this,A,e),d(this,T,t),d(this,E,r)}async get(e){return await n(this,A).Get({key:e,transactionId:n(this,T)},n(this,E)),this}async multi(){await n(this,A).Multi(n(this,T),n(this,E))}async set(e,t,r){let s;return r?.expiration&&(s=Math.floor((r.expiration.getTime()-Date.now())/1e3),s<1&&(s=1)),await n(this,A).Set({key:e,value:t,nx:r?.nx===!0,xx:r?.xx===!0,expiration:s||0,transactionId:n(this,T)},n(this,E)),this}async del(...e){return await n(this,A).Del({keys:e,transactionId:n(this,T)},n(this,E)),this}async type(e){return await n(this,A).Type({key:e,transactionId:n(this,T)},n(this,E)),this}async exec(){let e=await n(this,A).Exec(n(this,T),n(this,E)),t=[];for(let r of e.response)r.members?t.push(r.members):r.nil!==void 0?t.push(null):r.num!==void 0?t.push(r.num):r.values!==void 0?t.push(r.values.values):r.str!==void 0?t.push(r.str):r.dbl!==void 0?t.push(r.dbl):r.bool!==void 0&&t.push(r.bool);return t}async discard(){await n(this,A).Discard(n(this,T),n(this,E))}async watch(...e){return await n(this,A).Watch({keys:e,transactionId:n(this,T)},n(this,E)),this}async unwatch(){return await n(this,A).Unwatch(n(this,T),n(this,E)),this}async getRange(e,t,r){return await n(this,A).GetRange({key:e,start:t,end:r,transactionId:n(this,T)},n(this,E)),this}async setRange(e,t,r){return await n(this,A).SetRange({key:e,offset:t,value:r,transactionId:n(this,T)},n(this,E)),this}async strlen(e){return this.strLen(e)}async strLen(e){return await n(this,A).Strlen({key:e,transactionId:n(this,T)},n(this,E)),this}async mget(e){return this.mGet(e)}async mGet(e){return await n(this,A).MGet({keys:e,transactionId:n(this,T)},n(this,E)),this}async mset(e){return this.mSet(e)}async mSet(e){let t=Object.entries(e).map(([r,s])=>({key:r,value:s}));return await n(this,A).MSet({kv:t,transactionId:n(this,T)},n(this,E)),this}async incrBy(e,t){return await n(this,A).IncrBy({key:e,value:t,transactionId:n(this,T)},n(this,E)),this}async expire(e,t){return await n(this,A).Expire({key:e,seconds:t,transactionId:n(this,T)},n(this,E)),this}async expireTime(e){return await n(this,A).ExpireTime({key:e,transactionId:n(this,T)},n(this,E)),this}async zAdd(e,...t){return await n(this,A).ZAdd({key:e,members:t,transactionId:n(this,T)},n(this,E)),this}async zScore(e,t){return await n(this,A).ZScore({key:{key:e,transactionId:n(this,T)},member:t},n(this,E)),this}async zRank(e,t){return await n(this,A).ZRank({key:{key:e,transactionId:n(this,T)},member:t},n(this,E)),this}async zIncrBy(e,t,r){return await n(this,A).ZIncrBy({key:e,member:t,value:r,transactionId:n(this,T)},n(this,E)),this}async zScan(e,t,r,s){let o={key:e,cursor:t,pattern:r,count:s,transactionId:n(this,T)};return await n(this,A).ZScan(o,n(this,E)),this}async zCard(e){return await n(this,A).ZCard({key:e,transactionId:n(this,T)},n(this,E)),this}async zRange(e,t,r,s){let o={rev:!1,byLex:!1,byScore:!1,offset:0,count:1e3};if(s?.reverse&&(o.rev=s.reverse),s?.by==="lex"?o.byLex=!0:s?.by==="score"&&(o.byScore=!0),s?.limit)if(o.byLex||o.byScore)o.offset=s.limit.offset,o.count=s.limit.count;else throw new Error("zRange parsing error: 'limit' only allowed when 'options.by' is 'lex' or 'score'");return await n(this,A).ZRange({key:{key:e,transactionId:n(this,T)},start:t+"",stop:r+"",...o},n(this,E)),this}async zRem(e,t){return await n(this,A).ZRem({key:{key:e,transactionId:n(this,T)},members:t},n(this,E)),this}async zRemRangeByLex(e,t,r){return await n(this,A).ZRemRangeByLex({key:{key:e,transactionId:n(this,T)},min:t,max:r},n(this,E)),this}async zRemRangeByRank(e,t,r){return await n(this,A).ZRemRangeByRank({key:{key:e,transactionId:n(this,T)},start:t,stop:r},n(this,E)),this}async zRemRangeByScore(e,t,r){return await n(this,A).ZRemRangeByScore({key:{key:e,transactionId:n(this,T)},min:t,max:r},n(this,E)),this}async hgetall(e){return this.hGetAll(e)}async hGetAll(e){return await n(this,A).HGetAll({key:e,transactionId:n(this,T)},n(this,E)),this}async hget(e,t){return this.hGet(e,t)}async hGet(e,t){return await n(this,A).HGet({key:e,field:t,transactionId:n(this,T)},n(this,E)),this}async hMGet(e,t){return await n(this,A).HMGet({key:e,fields:t,transactionId:n(this,T)},n(this,E)),this}async hset(e,t){return this.hSet(e,t)}async hSet(e,t){let r=Object.entries(t).map(([s,o])=>({field:s,value:o}));return await n(this,A).HSet({key:e,fv:r,transactionId:n(this,T)},n(this,E)),this}async hincrby(e,t,r){return this.hIncrBy(e,t,r)}async hIncrBy(e,t,r){return await n(this,A).HIncrBy({key:e,field:t,value:r,transactionId:n(this,T)},n(this,E)),this}async hdel(e,t){return this.hDel(e,t)}async hDel(e,t){return await n(this,A).HDel({key:e,fields:t,transactionId:n(this,T)},n(this,E)),this}async hscan(e,t,r,s){return this.hScan(e,t,r,s)}async hScan(e,t,r,s){let o={key:e,cursor:t,pattern:r,count:s,transactionId:n(this,T)};return await n(this,A).HScan(o,n(this,E)),this}async hkeys(e){return this.hKeys(e)}async hKeys(e){return await n(this,A).HKeys({key:e,transactionId:n(this,T)},n(this,E)),this}async hlen(e){return this.hLen(e)}async hLen(e){return await n(this,A).HLen({key:e,transactionId:n(this,T)},n(this,E)),this}};A=new WeakMap,T=new WeakMap,E=new WeakMap;var w,bi,Qo=class Qo{constructor(e,t=void 0,r=Xo.INSTALLATION){l(this,w);l(this,bi);d(this,w,e),d(this,bi,t),this.scope=r,this.global=r===Xo.INSTALLATION?new Qo(n(this,w),n(this,bi),Xo.GLOBAL):this}get storage(){return n(this,bi)||u.redisPlugin}async watch(...e){let t=await this.storage.Watch({keys:e},n(this,w));return new Zo(this.storage,t,n(this,w))}async get(e){try{let t=await this.storage.Get({key:e,scope:this.scope},{...n(this,w),"throw-redis-nil":{values:["true"]}});return t!==null?t.value??void 0:t}catch(t){if(_r(t))return;throw t}}async getBuffer(e){try{let t=await this.storage.GetBytes({key:e,scope:this.scope},{...n(this,w),"throw-redis-nil":{values:["true"]}});return t!==null?Buffer.from(t.value):t}catch(t){if(_r(t))return;throw t}}async set(e,t,r){let s;return r?.expiration&&(s=Math.floor((r.expiration.getTime()-Date.now())/1e3),s<1&&(s=1)),(await this.storage.Set({key:e,value:t,nx:r?.nx===!0&&!r.xx,xx:r?.xx===!0&&!r.nx,expiration:s||0,scope:this.scope},n(this,w))).value}async exists(...e){return(await this.storage.Exists({keys:e,scope:this.scope},n(this,w))).existingKeys}async del(...e){await this.storage.Del({keys:e,scope:this.scope},n(this,w))}async incrBy(e,t){return(await this.storage.IncrBy({key:e,value:t,scope:this.scope},n(this,w))).value}async getRange(e,t,r){let s=await this.storage.GetRange({key:e,start:t,end:r,scope:this.scope},n(this,w));return s!==null?s.value:s}async setRange(e,t,r){return(await this.storage.SetRange({key:e,offset:t,value:r,scope:this.scope},n(this,w))).value}async strlen(e){return this.strLen(e)}async strLen(e){return(await this.storage.Strlen({key:e,scope:this.scope},n(this,w))).value}async expire(e,t){await this.storage.Expire({key:e,seconds:t,scope:this.scope},n(this,w))}async expireTime(e){return(await this.storage.ExpireTime({key:e,scope:this.scope},n(this,w))).value}async zAdd(e,...t){return(await this.storage.ZAdd({key:e,members:t,scope:this.scope},n(this,w))).value}async zRange(e,t,r,s){let o={rev:!1,byLex:!1,byScore:!1,offset:0,count:1e3};if(s?.reverse&&(o.rev=s.reverse),s?.by==="lex"?o.byLex=!0:s?.by==="score"?o.byScore=!0:(o.offset=0,o.count=0),s?.limit)if(o.byLex||o.byScore)o.offset=s.limit.offset,o.count=s.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:t+"",stop:r+"",...o,scope:this.scope},n(this,w))).members}async zRem(e,t){return(await this.storage.ZRem({key:{key:e},members:t,scope:this.scope},n(this,w))).value}async zRemRangeByLex(e,t,r){return(await this.storage.ZRemRangeByLex({key:{key:e},min:t,max:r,scope:this.scope},n(this,w))).value}async zRemRangeByRank(e,t,r){return(await this.storage.ZRemRangeByRank({key:{key:e},start:t,stop:r,scope:this.scope},n(this,w))).value}async zRemRangeByScore(e,t,r){return(await this.storage.ZRemRangeByScore({key:{key:e},min:t,max:r,scope:this.scope},n(this,w))).value}async zScore(e,t){try{let r=await this.storage.ZScore({key:{key:e},member:t,scope:this.scope},{...n(this,w),"throw-redis-nil":{values:["true"]}});return r!==null?r.value:r}catch(r){if(_r(r))return;throw r}}async zRank(e,t){try{let r=await this.storage.ZRank({key:{key:e},member:t,scope:this.scope},{...n(this,w),"throw-redis-nil":{values:["true"]}});return r!==null?r.value:r}catch(r){if(_r(r))return;throw r}}async zIncrBy(e,t,r){let s=await this.storage.ZIncrBy({key:e,member:t,value:r,scope:this.scope},n(this,w));return s!==null?s.value:s}async mget(e){return this.mGet(e)}async mGet(e){let t=await this.storage.MGet({keys:e,scope:this.scope},n(this,w));return t!==null?t.values.map(r=>r||null):t}async mset(e){return this.mSet(e)}async mSet(e){let t=Object.entries(e).map(([r,s])=>({key:r,value:s}));await this.storage.MSet({kv:t,scope:this.scope},n(this,w))}async zCard(e){let t=await this.storage.ZCard({key:e,scope:this.scope},n(this,w));return t!==null?t.value:t}async zScan(e,t,r,s){let o={key:e,cursor:t,pattern:r,count:s,scope:this.scope};return await this.storage.ZScan(o,n(this,w))}async type(e){let t=await this.storage.Type({key:e,scope:this.scope},n(this,w));return t!==null?t.value:t}async rename(e,t){return(await this.storage.Rename({key:e,newKey:t,scope:this.scope},n(this,w))).result}async hget(e,t){return this.hGet(e,t)}async hGet(e,t){try{let r=await this.storage.HGet({key:e,field:t,scope:this.scope},{...n(this,w),"throw-redis-nil":{values:["true"]}});return r!==null?r.value??void 0:r}catch(r){if(_r(r))return;throw r}}async hMGet(e,t){let r=await this.storage.HMGet({key:e,fields:t,scope:this.scope},n(this,w));return r!==null?r.values.map(s=>s||null):r}async hset(e,t){return this.hSet(e,t)}async hSet(e,t){let r=Object.entries(t).map(([o,a])=>({field:o,value:a}));return(await this.storage.HSet({key:e,fv:r,scope:this.scope},n(this,w))).value}async hSetNX(e,t,r){return(await this.storage.HSetNX({key:e,field:t,value:r,scope:this.scope},n(this,w))).success}async hgetall(e){return this.hGetAll(e)}async hGetAll(e){let t=await this.storage.HGetAll({key:e,scope:this.scope},n(this,w));return t!==null?t.fieldValues:t}async hdel(e,t){return this.hDel(e,t)}async hDel(e,t){return(await this.storage.HDel({key:e,fields:t,scope:this.scope},n(this,w))).value}async hscan(e,t,r,s){return this.hScan(e,t,r,s)}async hScan(e,t,r,s){let o={key:e,cursor:t,pattern:r,count:s,scope:this.scope};return await this.storage.HScan(o,n(this,w))}async hkeys(e){return this.hKeys(e)}async hKeys(e){let t=await this.storage.HKeys({key:e,scope:this.scope},n(this,w));return t!==null?t.keys:t}async hincrby(e,t,r){return this.hIncrBy(e,t,r)}async hIncrBy(e,t,r){return(await this.storage.HIncrBy({key:e,field:t,value:r,scope:this.scope},n(this,w))).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,...t){let r=[];for(let o=0;o<t.length;){let a=t[o],c={};switch(a){case"get":{if(o+2>=t.length)throw Error("bitfield command parse failed; not enough arguments for 'get' command");c.get={encoding:t[o+1],offset:t[o+2].toString()},o+=3;break}case"set":{if(o+3>=t.length)throw Error("bitfield command parse failed; not enough arguments for 'set' command");c.set={encoding:t[o+1],offset:t[o+2].toString(),value:t[o+3].toString()},o+=4;break}case"incrBy":{if(o+3>=t.length)throw Error("bitfield command parse failed; not enough arguments for 'incrBy' command");c.incrBy={encoding:t[o+1],offset:t[o+2].toString(),increment:t[o+3].toString()},o+=4;break}case"overflow":{if(o+1>=t.length)throw Error("bitfield command parse failed; not enough arguments for 'overflow' command");let m=t[o+1].toString();c.overflow={behavior:hm(m)},o+=2;break}default:throw Error(`bitfield command parse failed; ${a} unrecognized (must be 'get', 'set', 'incrBy', or 'overflow')`)}r.push(c)}return(await this.storage.Bitfield({key:e,commands:r})).results}};w=new WeakMap,bi=new WeakMap;var vi=Qo;function hm(i){let e=i.toLowerCase();switch(e){case"wrap":return Ko.BITFIELD_OVERFLOW_BEHAVIOR_WRAP;case"sat":return Ko.BITFIELD_OVERFLOW_BEHAVIOR_SAT;case"fail":return Ko.BITFIELD_OVERFLOW_BEHAVIOR_FAIL;default:throw Error(`unknown bitfield overflow behavior: ${e}`)}}var Ot,ki=class{constructor(e){l(this,Ot);d(this,Ot,e)}async runJob(e){return(await u.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},n(this,Ot))).id}async cancelJob(e){await u.schedulerPlugin.Cancel({id:e},n(this,Ot))}async listJobs(){return(await u.schedulerPlugin.List({after:new Date(0),before:new Date(Date.now()+31536e7)},n(this,Ot))).actions.map(t=>(p(t.request?.action,"Scheduled job is malformed"),"when"in t.request&&t.request.when!=null?{id:t.id,name:t.request.action.type,runAt:t.request.when,data:t.request.action.data}:{id:t.id,name:t.request.action.type,cron:t.request.cron??"",data:t.request.action.data}))}};Ot=new WeakMap;import{FormFieldType as Gs}from"@devvit/protos";var Hr,Ci=class{constructor(e){l(this,Hr);d(this,Hr,e)}async get(e){return(await this.getAll())[e]}async getAll(){let t=await u.settingsPlugin.GetSettings({},n(this,Hr));if(!t.installationSettings)throw new Error("Could not get installation settings");if(!t.appSettings)throw new Error("Could not get app settings");return fm(t),{...zd(t.installationSettings.settings,u.installationSettings),...zd(t.appSettings.settings,u.appSettings)}}};Hr=new WeakMap;function fm(i){if(!i.appSettings)throw new Error("Could not get app settings");for(let[e,t]of Object.entries(i.appSettings.settings)){let r=u.appSettings?.find(s=>s.type!=="group"&&s.name===e);r&&(r.type==="boolean"&&t.fieldType===Gs.STRING&&t.boolValue==null&&t.stringValue!=null?(t.fieldType=Gs.BOOLEAN,t.boolValue=!!t.stringValue,delete t.stringValue):r.type==="number"&&t.fieldType===Gs.STRING&&t.numberValue==null&&t.stringValue!=null&&(t.fieldType=Gs.NUMBER,t.numberValue=Number(t.stringValue),delete t.stringValue))}}function zd(i,e){let t=Object.keys(i).reduce((r,s)=>(r[s]=Wo(i[s]),r),{});return e&&$d(t,e),t}function $d(i,e){for(let t of e)t.type==="group"?$d(i,t.fields):!(t.name in i)&&"defaultValue"in t&&(i[t.name]=t.defaultValue)}import{EffectType as Js,ToastAppearance as qd}from"@devvit/protos";var et,Pi,jr,$s,zs=class{constructor(e){l(this,et,[]);l(this,Pi);l(this,jr);l(this,$s,(e,t)=>{let r=t!==void 0?e:"",s=t!==void 0?t:e;n(this,et).push({type:Js.EFFECT_WEB_VIEW,webView:{postMessage:{webViewId:r,app:{message:s}}}})});d(this,Pi,e),d(this,jr,{postMessage:n(this,$s)})}get webView(){return n(this,jr)}showForm(e,t){return this.showFormInternal(e,t)}showFormInternal(e,t,r){let s=u.formDefinitions.get(e);if(!s&&n(this,Pi)){let c=n(this,Pi).forms.get(e);c&&(s={form:c,onSubmit:()=>{}})}if(!s)throw new Error("Form does not exist. Make sure you have added it using Devvit.createForm at the root of your app.");let o=r??(s.form instanceof Function?s.form(t??{}):s.form),a={fields:[],id:e,title:o.title,acceptLabel:o.acceptLabel,cancelLabel:o.cancelLabel,shortDescription:o.description};Tt(o.fields),a.fields=Ne(o.fields),n(this,et).push({type:Js.EFFECT_SHOW_FORM,showForm:{form:a}})}showToast(e){let t;e instanceof Object?t={text:e.text,appearance:e.appearance==="success"?qd.SUCCESS:qd.NEUTRAL}:t={text:e},n(this,et).push({type:Js.EFFECT_SHOW_TOAST,showToast:{toast:t}})}navigateTo(e){let t=typeof e=="string"?e:e.url;if(!URL.canParse(t))throw new TypeError(`Invalid URL: ${t}`);let r=new URL(t).toString();n(this,et).push({type:Js.EFFECT_NAVIGATE_TO_URL,navigateToUrl:{url:r}})}get __effects(){return n(this,et)}};et=new WeakMap,Pi=new WeakMap,jr=new WeakMap,$s=new WeakMap;function ke({metadata:i,ui:e,hooks:t,reconciler:r}){let s=new gi(i),o=new mi(i),a=new vi(i),c=Ed(a,r?r.state:{}),m=new yi(i),y=new ki(i),v=new Ci(i),f=e?new zs(r):void 0,S=new pi(i),b=new ui,_=new hi(i),I=t&&r?bd(r):void 0,N=t&&r?yd(r):void 0,D=t&&r?fd(r):void 0,si=t&&r?hd(r):void 0;return{modLog:s,kvStore:o,redis:a,reddit:m,scheduler:y,settings:v,media:S,assets:b,realtime:_,get useForm(){return D??(()=>{throw new Error("useForm() is unavailable")})},get cache(){return c??(()=>{throw new Error("cache() is unavailable")})},get useState(){return I??(()=>{throw new Error("useState() is unavailable")})},get useInterval(){return N??(()=>{throw new Error("useInterval() is unavailable")})},get useChannel(){return si??(()=>{throw new Error("useChannel() is unavailable")})},get ui(){if(!f)throw new Error("ui client is not available");return f}}}import{DevvitPostData as bm}from"@devvit/protos";var Kd={name:"@devvit/public-api",version:"0.11.20-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:min","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",clean:"rm -rf .turbo 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.11.20-dev","@devvit/protos":"0.11.20-dev","@devvit/shared":"0.11.20-dev","@devvit/shared-types":"0.11.20-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.11.20-dev","@devvit/tsconfig":"0.11.20-dev","@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.8.3",vitest:"1.6.1"},publishConfig:{directory:"dist"},filesize:{"dist/public-api.min.js":{gzip:"62 KB",none:"219 KB"}},source:"./src/index.ts"};function ne(i,e,t){let r=i[P.Subreddit]?.values[0];p(r,"subreddit is missing from Context");let s=i[P.SubredditName]?.values[0],o,a=i[P.PostData]?.values[0];a&&(o=bm.fromJSON(JSON.parse(a)).developerData);let c=i[P.AppUser]?.values[0],m=i[P.App]?.values[0],y=i[P.Version]?.values[0],v=i[P.User]?.values[0],f=vm(i);return{get appAccountId(){return p(c,"appAccountId is missing from Context"),c},subredditId:r,subredditName:s,userId:v,postId:e,postData:o,commentId:t,appName:m,appVersion:y,debug:f,metadata:i,toJSON(){return{appAccountId:c,appName:m,appVersion:y,subredditId:r,subredditName:s,userId:v,postId:e,postData:o,commentId:t,debug:f,metadata:i}}}}function vm(i){let e={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},t={};for(let s in e)t[s.toLowerCase()]=s;let r={};for(let s of(i[P.Debug]?.values??[]).join().split(",")){let[o,a]=s.split("=");o&&(o=o.trim(),a=a?.trim(),o.toLowerCase()in t&&(o=t[o.toLowerCase()]),r[o]??(r[o]=a||"true"))}return i[P.Debug]&&console.info(`[api] @devvit/public-api v${Kd.version} ${Object.entries(r).map(([s,o])=>`${s}=${o}`).join(" ")}`),{...r,metadata:i}}function Xd(i){return i.flatMap(e=>e.type==="group"?Xd(e.fields):e)}async function qs(i,e,t){if(!e)throw new Error("Settings were not defined.");let r={success:!0,errors:{}},s=Ke(i.fieldValues),o=Xd(e);return await Promise.all(o.map(async a=>{let c=a.name;if(c&&a.onValidate){let m=s[c],y=a.onValidate,v=Object.assign(ke({metadata:t}),ne(t)),f=await y({value:m,isEditing:i.editing},v);f&&(r.success=!1,r.errors[c]=f)}})),km.fromJSON(r)}async function Sm(){return Pm.fromJSON({fields:{fields:Ne(u.appSettings??[])}})}async function wm(i,e){return qs(i,u.appSettings,e)}function Zd(i){i.provides(Cm),O("GetAppSettingsFields",Sm),O("ValidateAppForm",wm)}import{CustomPostDefinition as Rm,RenderPostResponse as Om}from"@devvit/protos";import{BlockRenderEventType as ma,EffectType as ml}from"@devvit/protos";function Si(i){return i.__effects}function Qd(){let i=new Set;return e=>{let t=e,r=1;for(;i.has(t);)t=`${e}.${r++}`;return i.add(t),t}}import{BlockActionType as ca,BlockAvatarBackground as dl,BlockAvatarFacing as ll,BlockAvatarSize as tt,BlockBorderWidth as Qs,BlockButtonAppearance as it,BlockButtonSize as ra,BlockGap as Ys,BlockHorizontalAlignment as na,BlockIconSize as eo,BlockImageResizeMode as Wr,BlockPadding as Vr,BlockRadius as Gr,BlockSpacerShape as sa,BlockSpacerSize as to,BlockStackDirection as oa,BlockTextOutline as aa,BlockTextOverflow as da,BlockTextSize as Fi,BlockTextStyle as la,BlockTextWeight as ul,BlockType as Ee,BlockVerticalAlignment as ua}from"@devvit/protos";var Yo={"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 Yd={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"},el=i=>!!i.match(/^(#[0-9a-fA-F]{3,8}).*/),tl=i=>i in Yo,ea=i=>i in Yd,il=i=>!!i.match(/^rgba?\(.*/),rl=i=>!!i.match(/^hsla?\(.*/),nl=(i,e="light")=>{if(ea(i))return Ks(i);let r=Yo[i];return typeof r=="string"?r:r[e]},Ks=i=>Yd[i]??i,sl=i=>{let[e,t,r,s]=i.replace(/^rgba?\(|\s+|\)$/g,"").split(",");if(!e||!t||!r)return i;let a=[...[e,t,r].map(m=>parseFloat(m))];if(s){let m=parseFloat(s),y=Math.round(m*255);a.push(y)}return`#${a.map(m=>m.toString(16).padStart(2,"0")).join("")}`};import{BlockStackDirection as Xs}from"@devvit/protos";var ta={stackParentLayout:{hasHeight:!0,hasWidth:!0,direction:Xs.UNRECOGNIZED,alignment:void 0}};function al(i,e,t){if(!e)return{hasHeight:!1,hasWidth:!1};let{growDirection:r,stretchDirection:s}=Fm(i?.grow,e.direction,e.alignment),o=t?.height?.value?.value||t?.height?.min?.value||ol(2,r,s,e.hasHeight),a=t?.width?.value?.value||t?.width?.min?.value||ol(1,r,s,e.hasWidth);return{hasHeight:!!o,hasWidth:!!a}}function ol(i,e,t,r){return e===i&&r||t===i&&r}function Fm(i,e,t){let r=e===Xs.STACK_VERTICAL||e===Xs.UNRECOGNIZED,s=e===Xs.STACK_HORIZONTAL,o=0;s&&i?o=1:r&&i&&(o=2);let a=t===void 0||t.horizontal===void 0,c=t===void 0||t.vertical===void 0,m=s?!!c:r?!!a:!1,y=0;return s&&m?y=2:r&&m&&(y=1),{growDirection:o,stretchDirection:y}}import{BlockSizeUnit as Mt,BlockStackDirection as Zs}from"@devvit/protos";function wi(i){if(i==null)return;if(typeof i=="number")return{value:i,unit:Mt.SIZE_UNIT_PERCENT};let e=i.match(/^(\d+(?:\.\d+)?)(px|%)?$/);if(e==null)return;let t=Mt.SIZE_UNIT_PERCENT;return e.at(2)==="px"&&(t=Mt.SIZE_UNIT_PIXELS),{value:Number.parseFloat(e[1]),unit:t}}function xm(i,e){return(i.width?.value?.unit===Mt.SIZE_UNIT_PERCENT||i.width?.min?.unit===Mt.SIZE_UNIT_PERCENT)&&(e.direction===Zs.STACK_HORIZONTAL||e.direction===Zs.STACK_DEPTH)&&(e.hasWidth||(i.width=void 0)),(i.height?.value?.unit===Mt.SIZE_UNIT_PERCENT||i.height?.min?.unit===Mt.SIZE_UNIT_PERCENT)&&(e.direction===Zs.STACK_VERTICAL||e.direction===Zs.STACK_DEPTH)&&(e.hasHeight||(i.height=void 0)),i}function ia(i,e){if(i){let t=i.width!=null||i.minWidth!=null||i.maxWidth!=null,r=i.height!=null||i.minHeight!=null||i.maxHeight!=null;if(t||r||i.grow!=null){let s={width:t?{value:wi(i.width),min:wi(i.minWidth),max:wi(i.maxWidth)}:void 0,height:r?{value:wi(i.height),min:wi(i.minHeight),max:wi(i.maxHeight)}:void 0,grow:i.grow};return e.stackParentLayout&&(s=xm(s,e.stackParentLayout)),s}}}var cl="data-",Im=new Set(["onPress","onMessage"]),Am=new Map([["onPress",ca.ACTION_CLICK],["onMessage",ca.ACTION_WEBVIEW]]),Jr,xi=class{constructor(e=()=>{}){l(this,Jr);d(this,Jr,e)}createBlocksElementOrThrow({type:e,props:t,children:r}){let s=this.createBlocksElement({type:e,props:t,children:r},ta);if(!s)throw new Error(`Could not create block of type ${e}`);return s}createBlocksElement({type:e,props:t,children:r},s){switch(e){case"blocks":return this.makeRoot(t,...r);case"hstack":return this.makeHStack(t,s,...r);case"vstack":return this.makeVStack(t,s,...r);case"zstack":return this.makeZStack(t,s,...r);case"text":return this.makeText(t,s,...r);case"button":return this.makeButton(t,s,...r);case"image":return this.makeImage(t,s);case"spacer":return this.makeSpacer(t,s);case"icon":return this.makeIcon(t,s);case"avatar":return this.makeAvatar(t,s);case"webview":return this.makeWebView(t,s);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 Vr.PADDING_NONE;case"xsmall":return Vr.PADDING_XSMALL;case"small":return Vr.PADDING_SMALL;case"medium":return Vr.PADDING_MEDIUM;case"large":return Vr.PADDING_LARGE}}makeBlockRadius(e){switch(e){case"none":return Gr.RADIUS_NONE;case"small":return Gr.RADIUS_SMALL;case"medium":return Gr.RADIUS_MEDIUM;case"large":return Gr.RADIUS_LARGE;case"full":return Gr.RADIUS_FULL}}makeBlockGap(e){switch(e){case"none":return Ys.GAP_NONE;case"small":return Ys.GAP_SMALL;case"medium":return Ys.GAP_MEDIUM;case"large":return Ys.GAP_LARGE}}makeBlockAlignment(e){if(e===void 0)return;let t,r;if(e.includes("top")?t=ua.ALIGN_TOP:e.includes("middle")?t=ua.ALIGN_MIDDLE:e.includes("bottom")&&(t=ua.ALIGN_BOTTOM),e.includes("start")?r=na.ALIGN_START:e.includes("center")?r=na.ALIGN_CENTER:e.includes("end")&&(r=na.ALIGN_END),t!==void 0||r!==void 0)return{vertical:t,horizontal:r}}makeBlockBorder(e,t,r,s){if(!e&&!t)return;let o;switch(e){case"none":o=Qs.BORDER_WIDTH_NONE;break;case"thin":o=Qs.BORDER_WIDTH_THIN;break;case"thick":o=Qs.BORDER_WIDTH_THICK;break;default:o=Qs.BORDER_WIDTH_THIN;break}let a=t??"neutral-border-weak",c=this.getThemedColors(a,r,s);return{width:o,color:c?.light,colors:c}}makeBlockTextSize(e){switch(e){case"xsmall":return Fi.TEXT_SIZE_XSMALL;case"small":return Fi.TEXT_SIZE_SMALL;case"medium":return Fi.TEXT_SIZE_MEDIUM;case"large":return Fi.TEXT_SIZE_LARGE;case"xlarge":return Fi.TEXT_SIZE_XLARGE;case"xxlarge":return Fi.TEXT_SIZE_XXLARGE}}makeBlockTextStyle(e){switch(e){case"body":return la.TEXT_STYLE_BODY;case"metadata":return la.TEXT_STYLE_METADATA;case"heading":return la.TEXT_STYLE_HEADING}}makeBlockTextOutline(e){switch(e){case"none":return aa.TEXT_OUTLINE_NONE;case"thin":return aa.TEXT_OUTLINE_THIN;case"thick":return aa.TEXT_OUTLINE_THICK}}makeBlockTextWeight(e){switch(e){case"regular":return ul.TEXT_WEIGHT_REGULAR;case"bold":return ul.TEXT_WEIGHT_BOLD}}makeBlockTextOverflow(e){switch(e){case"clip":return da.TEXT_OVERFLOW_CLIP;case"ellipsis":return da.TEXT_OVERFLOW_ELLIPSE}return da.TEXT_OVERFLOW_ELLIPSE}makeBlockButtonAppearance(e){switch(e){case"secondary":return it.BUTTON_APPEARANCE_SECONDARY;case"primary":return it.BUTTON_APPEARANCE_PRIMARY;case"plain":return it.BUTTON_APPEARANCE_PLAIN;case"bordered":return it.BUTTON_APPEARANCE_BORDERED;case"media":return it.BUTTON_APPEARANCE_MEDIA;case"destructive":return it.BUTTON_APPEARANCE_DESTRUCTIVE;case"caution":return it.BUTTON_APPEARANCE_CAUTION;case"success":return it.BUTTON_APPEARANCE_SUCCESS}}makeBlockButtonSize(e){switch(e){case"small":return ra.BUTTON_SIZE_SMALL;case"medium":return ra.BUTTON_SIZE_MEDIUM;case"large":return ra.BUTTON_SIZE_LARGE}}makeBlockImageResizeMode(e){switch(e){case"none":return Wr.IMAGE_RESIZE_NONE;case"fit":return Wr.IMAGE_RESIZE_FIT;case"fill":return Wr.IMAGE_RESIZE_FILL;case"cover":return Wr.IMAGE_RESIZE_COVER;case"scale-down":return Wr.IMAGE_RESIZE_SCALE_DOWN}}makeBlockSpacerSize(e){switch(e){case"xsmall":return to.SPACER_XSMALL;case"small":return to.SPACER_SMALL;case"medium":return to.SPACER_MEDIUM;case"large":return to.SPACER_LARGE}}makeBlockSpacerShape(e){switch(e){case"invisible":return sa.SPACER_INVISIBLE;case"thin":return sa.SPACER_THIN;case"square":return sa.SPACER_SQUARE}}makeBlockIconSize(e){switch(e){case"xsmall":return eo.ICON_SIZE_XSMALL;case"small":return eo.ICON_SIZE_SMALL;case"medium":return eo.ICON_SIZE_MEDIUM;case"large":return eo.ICON_SIZE_LARGE}}makeBlockAvatarSize(e){switch(e){case"xxsmall":return tt.AVATAR_SIZE_XXSMALL;case"xsmall":return tt.AVATAR_SIZE_XSMALL;case"small":return tt.AVATAR_SIZE_SMALL;case"medium":return tt.AVATAR_SIZE_MEDIUM;case"large":return tt.AVATAR_SIZE_LARGE;case"xlarge":return tt.AVATAR_SIZE_XXLARGE;case"xxlarge":return tt.AVATAR_SIZE_XXLARGE;case"xxxlarge":return tt.AVATAR_SIZE_XXXLARGE}}makeBlockAvatarFacing(e){switch(e){case"left":return ll.AVATAR_FACING_LEFT;case"right":return ll.AVATAR_FACING_RIGHT}}makeBlockAvatarBackground(e){switch(e){case"dark":return dl.AVATAR_BG_DARK;case"light":return dl.AVATAR_BG_LIGHT}}getDataSet(e){return Object.keys(e).filter(t=>t.startsWith(cl)).reduce((t,r)=>(t[r.substring(cl.length)]=e[r],t),{})}makeActions(e,t){let r=[],s=this.getDataSet(t);return Im.forEach(o=>{if(o in t){let a=t[o];r.push({type:Am.get(o)??ca.UNRECOGNIZED,id:a.toString(),data:s})}}),r}blockColorToHex(e,t="light"){if(e)return e=e.toLowerCase(),el(e)?e:tl(e)?nl(e,t):ea(e)?Ks(e):il(e)?sl(e):rl(e)?e:(console.warn(`Could not parse color: ${e}.`),Ks("red"))}childrenToBlocks(e,t){return e.flatMap(r=>(typeof r!="string"?this.createBlocksElement(r,t):void 0)??[])}getThemedColors(e,t,r){let s=this.blockColorToHex(t,"light"),o=this.blockColorToHex(r,"dark"),a=[];if(e&&(!s||!o)){let c=Array.from(e?.matchAll(/[\w#-]+(?:\([\w\t ,.#-]+\))?/g)??[]);a.push(...c.map(m=>m[0]))}return s||(s=this.blockColorToHex(a?.at(0),"light")),o||(o=this.blockColorToHex(a?.at(1)??a?.at(0),"dark")),s||o?{light:s,dark:o}:void 0}parsePixels(e){return typeof e=="string"?Number(e.slice(0,-2)):e}resolveAssetUrl(e,t){return n(this,Jr).call(this)?.getURL(e,t)??e}childrenToString(e){return e.map(t=>t.toString()).join("")}makeRoot(e,...t){return this.wrapRoot(e,this.childrenToBlocks(t,ta))}wrapRoot(e,t){return this.makeBlock(Ee.BLOCK_ROOT,{},{},{rootConfig:{children:t,height:this.makeRootHeight(u.customPostType?.height??e?.height??"regular")}})}makeStackBlock(e,t,r,s){let o=this.getThemedColors(t?.backgroundColor,t?.lightBackgroundColor,t?.darkBackgroundColor),a=this.makeBlockAlignment(t?.alignment),c=ia(t,r),m=al(t,r.stackParentLayout,c);return this.makeBlock(Ee.BLOCK_STACK,t,r,{stackConfig:{alignment:a,backgroundColor:o?.light,backgroundColors:o,border:this.makeBlockBorder(t?.border,t?.borderColor,t?.lightBorderColor,t?.darkBorderColor),children:this.childrenToBlocks(s,{stackParentLayout:{...m,direction:e,alignment:a}}),cornerRadius:this.makeBlockRadius(t?.cornerRadius),direction:e,gap:this.makeBlockGap(t?.gap),padding:this.makeBlockPadding(t?.padding),reverse:t?.reverse}})}makeHStack(e,t,...r){return this.makeStackBlock(oa.STACK_HORIZONTAL,e,t,r)}makeVStack(e,t,...r){return this.makeStackBlock(oa.STACK_VERTICAL,e,t,r)}makeZStack(e,t,...r){return this.makeStackBlock(oa.STACK_DEPTH,e,t,r)}makeText(e,t,...r){let s=this.getThemedColors(e?.color,e?.lightColor,e?.darkColor);return this.makeBlock(Ee.BLOCK_TEXT,e,t,{textConfig:{alignment:this.makeBlockAlignment(e?.alignment),color:s?.light,colors:s,outline:this.makeBlockTextOutline(e?.outline),size:this.makeBlockTextSize(e?.size),style:this.makeBlockTextStyle(e?.style),text:this.childrenToString(r),weight:this.makeBlockTextWeight(e?.weight),selectable:e?.selectable,wrap:e?.wrap,overflow:this.makeBlockTextOverflow(e?.overflow)}})}makeButton(e,t,...r){let s=this.getThemedColors(e?.textColor,e?.lightTextColor,e?.darkTextColor);return this.makeBlock(Ee.BLOCK_BUTTON,e,t,{buttonConfig:{buttonAppearance:this.makeBlockButtonAppearance(e?.appearance),icon:e?.icon,buttonSize:this.makeBlockButtonSize(e?.size),text:this.childrenToString(r),textColor:s?.light,textColors:s,disabled:e?.disabled}})}makeImage(e,t){return e&&this.makeBlock(Ee.BLOCK_IMAGE,e,t,{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,t){return this.makeBlock(Ee.BLOCK_SPACER,e,t,{spacerConfig:{size:this.makeBlockSpacerSize(e?.size),shape:this.makeBlockSpacerShape(e?.shape)}})}makeIcon(e,t){let r=this.getThemedColors(e?.color,e?.lightColor,e?.darkColor);return e&&this.makeBlock(Ee.BLOCK_ICON,e,t,{iconConfig:{icon:e.name,color:r?.light,colors:r,size:this.makeBlockIconSize(e.size)}})}makeAvatar(e,t){return e&&this.makeBlock(Ee.BLOCK_AVATAR,e,t,{avatarConfig:{thingId:e.thingId,size:this.makeBlockAvatarSize(e.size),facing:this.makeBlockAvatarFacing(e.facing),background:this.makeBlockAvatarBackground(e.background)}})}makeWebView(e,t){return e&&this.makeBlock(Ee.BLOCK_WEBVIEW,e,t,{webviewConfig:{url:this.resolveAssetUrl(e.url,{webView:!0})}})}makeBlock(e,t,r,s){return{type:e,sizes:ia(t,r),config:s,actions:(t&&this.makeActions(e,t))??[],id:t?.id,key:t?.key}}ensureRootBlock(e){let t;if(e.type===Ee.BLOCK_ROOT?(e.config?.rootConfig&&u.customPostType?.height&&(e.config.rootConfig.height=this.makeRootHeight(u.customPostType?.height)),t=e):t=this.wrapRoot(void 0,[e]),!t)throw new Error("Could not create root block");return t}};Jr=new WeakMap;function pl(i){if(typeof i=="string")throw new Error("Root element cannot be a string")}var gl=i=>{let e="",t=i.props?Object.keys(i.props).map(r=>r==="onPress"?"":`${r}="${i.props[r]}"`).join(" "):"";e+=`<${i.type}${t?" "+t:""}>`;for(let r of i.children)typeof r=="string"?e+=r:e+=gl(r);return e+=`</${i.type}>`,e};function Tm(i){return" ".repeat(i)}function Em(i){let e="",t=0,r=i.split(/>\s*</);for(let s=0;s<r.length;s++){let o=r[s];s===0&&(o=o.trim()),s===r.length-1&&(o=o.trim());let a=o.charAt(0)==="/";a&&t--,e+=Tm(t),s!==0&&(e+="<"),e+=o,s!==r.length-1&&(e+=`>
2
+ `),!a&&o.indexOf("</")===-1&&o.charAt(o.length-1)!=="/"&&t++}return e}var Ce,hl,zr,pa,$r,Le=class{constructor(e,t,r,s,o){l(this,Ce);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 xi(()=>this.assets);this.effects=[];l(this,$r,!1);this.component=e,this.event=t,this.state={__renderState:{},...r},this.metadata=s,this.state.__realtimeChannels&&(this.realtimeChannels=this.state.__realtimeChannels);let a=ke({reconciler:this,hooks:!0,ui:!0,metadata:s});this.cache=a.cache,this.modLog=a.modLog,this.reddit=a.reddit,this.kvStore=a.kvStore,this.redis=a.redis,this.settings=a.settings,this.scheduler=a.scheduler,this.media=a.media,this.assets=a.assets,this.realtime=a.realtime,this.dimensions=o,this.ui=a.ui,this.hooks={useState:a.useState,useInterval:a.useInterval,useForm:a.useForm,useChannel:a.useChannel}}emitEffect(e,t){this.effects.push(t)}async render(){await this.reconcile(),this.isRendering=!0;let e=await this.buildBlocksUI();return this.isRendering=!1,e}makeUniqueActionID(e){let t=e,r=1;for(;this.actions.has(t);)t=`${e}.${r++}`;return t}async reconcile(){let e=h(this,Ce,zr).call(this),t={type:this.component,props:e,children:[]},r=await this.processBlock(t);if(pl(r),this.transformer.createBlocksElementOrThrow(r),this.isUserActionRender&&this.blockRenderEventId){let s=this.actions.get(this.blockRenderEventId);s&&await s(this.event.data)}for(let s of this.pendingHooks)await s();this.buildNextState(),h(this,Ce,hl).call(this)}async buildBlocksUI(){let e=h(this,Ce,zr).call(this),t={type:this.component,props:e,children:[]},r=await this.renderElement(e,t);return this.transformer.ensureRootBlock(r)}async renderElement(e,t){let r=await this.processBlock(t);return pl(r),(u.debug.emitSnapshots||e.debug.emitSnapshots)&&console.debug(Em(gl(r))),(u.debug.emitState||e.debug.emitState)&&console.debug(JSON.stringify(this.state,void 0,2)),this.transformer.createBlocksElementOrThrow(r)}async processProps(e){let t=e.props??{},r=["onPress","onMessage"];for(let s of r)if(s in t){let o=t[s],a=o?.name,c=this.makeUniqueActionID(`${e.type}.${a??s}`);this.actions.set(c,o),t[s]=c}}async processBlock(e,t=Qd(),r=[]){let s=e;if(typeof s.type=="string"){let c=[];for(let f=0;f<s.children.length;f++){let S=s.children[f];S!=null&&c.push(await this.processBlock(S,t,[...r,`${s.type}.${f}`]))}let m=c.flat(),y=h(this,Ce,pa).call(this,m);return await this.processProps(s),{type:s.type,props:s.props,children:y}}if(typeof s.type=="function"){let c=t(`${r.length?r.join("."):"root"}.${s.type.name.length?s.type.name:"anonymous"}`);this.currentComponentKey.push(c),this.renderState[c]||(this.renderState[c]={});let m=s.children.flatMap(f=>f),y={...h(this,Ce,zr).call(this),...s.props,children:m},v;for(;v===void 0;)try{v=await s.type(y,h(this,Ce,zr).call(this))}catch(f){if(f instanceof Promise)v=await f;else throw f}if(!this.isInitialRender){let f=this.getPreviousComponentState();if(Object.keys(f).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 v=="object")return this.processBlock(v,t,[...r,s.type.name])}if(typeof s=="string")return s;if(typeof s=="number")return`${s}`;let o=[],a="";return Array.isArray(s)?o=s:typeof s.type>"u"&&s.children&&(o=s.children,a="fragmentChild."),{type:"__fragment",props:void 0,children:await Promise.all(o.flatMap(async(c,m)=>await this.processBlock(c,t,[...r,`${a}${m}`])))}}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===ma.RENDER_INITIAL:!1}get isUserActionRender(){return this.event?this.event.type===ma.RENDER_USER_ACTION:!1}get isEffectRender(){return this.event?this.event.type===ma.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){n(this,$r)||(d(this,$r,!0),this.effects.push({type:ml.EFFECT_RERENDER_UI,rerenderUi:{delaySeconds:e/1e3}}))}addRealtimeChannel(e){this.realtimeChannels.push(e),this.realtimeUpdated=!0}removeRealtimeChannel(e){this.realtimeChannels=this.realtimeChannels.filter(t=>t!==e),this.realtimeUpdated=!0}get realtimeEffect(){return this.realtimeUpdated&&this.realtimeChannels.length>0?[{type:ml.EFFECT_REALTIME_SUB,realtimeSubscriptions:{subscriptionIds:this.realtimeChannels}}]:[]}getEffects(){return[...Si(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}:{}}}};Ce=new WeakSet,hl=function(){this.actions.clear(),this.currentComponentKey=[],this.currentHookIndex=0,this.pendingHooks=[],this.realtimeChannels=[],this.realtimeUpdated=!1},zr=function(){let e={...ne(this.metadata,this.state.__postData?.thingId),modLog:this.modLog,reddit:this.reddit,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[P.Timezone]?.values[0],locale:this.metadata[P.Language]?.values[0],dimensions:this.dimensions},...this.hooks};return e.debug.effects=this,e},pa=function(e){let t=[];for(let r of e)typeof r=="string"?t.push(r):r.type==="__fragment"?t.push(...h(this,Ce,pa).call(this,r.children)):t.push(r);return t},$r=new WeakMap;async function Mm(i,e){let t=u.customPostType;if(!t)throw new Error("Custom post type not registered");let r=new Le((o,a)=>t.render(a),i.blocks,i.state,e,i.dimensions),s=await r.render();return Om.fromJSON({state:r.state,blocks:{ui:s},effects:r.getEffects()})}function fl(i){i.provides(Rm),O("RenderPost",Mm)}import{GetFieldsResponse as Um,InstallationSettingsDefinition as Dm}from"@devvit/protos";async function Bm(){return Um.fromJSON({fields:{fields:Ne(u.installationSettings??[])}})}async function Nm(i,e){return qs(i,u.installationSettings,e)}function yl(i){i.provides(Dm),O("GetSettingsFields",Bm),O("ValidateForm",Nm)}import{ContextActionDefinition as Lm,ContextActionList as _m,ContextActionResponse as Hm}from"@devvit/protos";function ga(i){let e=i.metadata[P.User].values[0];if(!e)throw new Error("User missing from context");return e}function ha(i){let e=i.metadata[P.Subreddit].values[0];if(!e)throw new Error("Subreddit missing from context");return e}async function bl(i,e){let t=ga(i),r=ha(i);if(!t||!r)throw new Error("User or subreddit missing from context");let s=e.comment?.id&&`t1_${e.comment.id}`,o=e.post?.id&&`t3_${e.post.id}`,a=e.subreddit?.id&&`t5_${e.subreddit.id}`,c=s||o||a;if(!c)throw new Error("targetId is missing from ContextActionRequest");if(s){let f=await i.reddit.getCommentById(s);if(!f)throw new Error(`Comment ${s} not found`);if(f.subredditId!==r)throw new Error("Comment does not belong to the subreddit")}if(o){let f=await i.reddit.getPostById(o);if(!f)throw new Error(`Post ${o} not found`);if(f.subredditId!==r)throw new Error("Post does not belong to the subreddit")}if(a&&a!==r)throw new Error(`Subreddit ${a} ${r} not found`);let m=qr(e.actionId);if(!m)throw new Error("Action not found");let y=!!m.forUserType?.includes("moderator");if(y&&!vl(i))throw new Error("User is not a moderator");let v={needsModCheck:y};await i.redis.set(`${t}${r}${c}${e.actionId}`,JSON.stringify(v)),await i.redis.expire(`${t}${r}${c}${e.actionId}`,600)}async function vl(i){let e=ga(i),t=ha(i),r=await i.reddit.getSubredditInfoById(t);return!!(await i.reddit.getModerators({subredditName:r.name}).all()).find(o=>o.id===e)}async function kl(i,e){let t=ga(i),r=ha(i),{actionId:s,thingId:o}=e.state?.__contextAction??{},a=await i.redis.get(`${t}${r}${o}${s}`);if(!a)throw new Error("CSRF token not found");if(JSON.parse(a).needsModCheck&&!await vl(i))throw new Error("User is not a moderator: "+t+"; "+r)}var Cl=i=>`menuItem.${i}`;function qr(i){return u.menuItems.find((e,t)=>Cl(t)===i)}function fa(i,e){return i?Array.isArray(i.location)?i.location.includes(e):i.location===e:!1}async function jm(i,e){let r=u.menuItems.map((s,o)=>({actionId:Cl(o),name:s.label,description:s.description,contexts:{subreddit:s.location.includes("subreddit"),post:s.location.includes("post"),comment:s.location.includes("comment")},users:{loggedOut:s.forUserType?.includes("loggedOut"),moderator:s.forUserType?.includes("moderator")},postFilters:s.postFilter==="currentApp"?{currentApp:!0}:void 0}));return _m.fromJSON({actions:r})}async function Wm(i,e){let t=qr(i.actionId);if(!t)throw new Error(`MenuItem ${i.actionId} not found`);let r=i.comment?.id&&`t1_${i.comment.id}`,s=i.post?.id&&`t3_${i.post.id}`,o=i.subreddit?.id&&`t5_${i.subreddit.id}`,a=r||s||o;p(a,"targetId is missing from ContextActionRequest");let c={targetId:a,location:i.comment?"comment":i.post?"post":"subreddit"},m=Object.assign(ke({ui:!0,metadata:e}),ne(e,s,r),{uiEnvironment:{timezone:e[P.Timezone]?.values[0],locale:e[P.Language]?.values[0]}});return await bl(m,i),await t.onPress(c,m),Hm.fromJSON({effects:Si(m.ui)})}function Pl(i){i.provides(Lm),O("GetActions",jm),O("OnAction",Wm)}function Fe(i){return i?i===!0?!0:i.enabled:!1}import{SchedulerHandlerDefinition as Vm}from"@devvit/protos";async function Gm(i,e){let t=i.type,r=u.scheduledJobHandlers.get(t);if(!r)throw new Error(`Job ${t} not found`);let s={name:t,data:i.data},o=Object.assign(ke({metadata:e}),ne(e));return await r(s,o),{}}function Sl(i){i.provides(Vm),O("HandleScheduledAction",Gm)}import{OnAppInstallDefinition as Jm,OnAppUpgradeDefinition as zm,OnAutomoderatorFilterCommentDefinition as $m,OnAutomoderatorFilterPostDefinition as qm,OnCommentCreateDefinition as Km,OnCommentDeleteDefinition as Xm,OnCommentReportDefinition as Zm,OnCommentSubmitDefinition as Qm,OnCommentUpdateDefinition as Ym,OnModActionDefinition as ep,OnModMailDefinition as tp,OnPostCreateDefinition as ip,OnPostDeleteDefinition as rp,OnPostFlairUpdateDefinition as np,OnPostNsfwUpdateDefinition as sp,OnPostReportDefinition as op,OnPostSpoilerUpdateDefinition as ap,OnPostSubmitDefinition as dp,OnPostUpdateDefinition as lp}from"@devvit/protos";var rt;(function(i){function e(a,c){return a.length<=c?a:`${a.slice(0,c-1)}\u2026`}i.ellipsize=e;function t(a){return a[0]==null?a:`${a[0].toLocaleUpperCase()}${a.slice(1)}`}i.capitalize=t;function r(a){return a==null||/^\s*$/.test(a)}i.isBlank=r;function s(a,c="stack"){return a instanceof Error?`${a[c]||a.stack||a.message||a.name}`:String(a)}i.caughtToString=s;function o(a,c="stack"){return a instanceof Error?`${a[c]||a.stack||a.message||a.name}`:String(a)}i.caughtToStringUntyped=o})(rt||(rt={}));function q(i,e){return p(e),async(t,r)=>{let s={...t,type:i},o=Object.assign(ke({metadata:r}),ne(r)),a=await Promise.allSettled(e.map(m=>m(s,o))),c=up(a);if(c)throw c.err;return{}}}function wl(i){for(let e of u.triggerOnEventHandlers.keys())switch(e){case"PostSubmit":i.provides(dp),O("OnPostSubmit",q("PostSubmit",u.triggerOnEventHandlers.get(e)));break;case"PostCreate":i.provides(ip),O("OnPostCreate",q("PostCreate",u.triggerOnEventHandlers.get(e)));break;case"PostUpdate":i.provides(lp),O("OnPostUpdate",q("PostUpdate",u.triggerOnEventHandlers.get(e)));break;case"PostReport":i.provides(op),O("OnPostReport",q("PostReport",u.triggerOnEventHandlers.get(e)));break;case"PostDelete":i.provides(rp),O("OnPostDelete",q("PostDelete",u.triggerOnEventHandlers.get(e)));break;case"PostFlairUpdate":i.provides(np),O("OnPostFlairUpdate",q("PostFlairUpdate",u.triggerOnEventHandlers.get(e)));break;case"CommentSubmit":i.provides(Qm),O("OnCommentSubmit",q("CommentSubmit",u.triggerOnEventHandlers.get(e)));break;case"CommentCreate":i.provides(Km),O("OnCommentCreate",q("CommentCreate",u.triggerOnEventHandlers.get(e)));break;case"CommentUpdate":i.provides(Ym),O("OnCommentUpdate",q("CommentUpdate",u.triggerOnEventHandlers.get(e)));break;case"CommentReport":i.provides(Zm),O("OnCommentReport",q("CommentReport",u.triggerOnEventHandlers.get(e)));break;case"CommentDelete":i.provides(Xm),O("OnCommentDelete",q("CommentDelete",u.triggerOnEventHandlers.get(e)));break;case"AppInstall":i.provides(Jm),O("OnAppInstall",q("AppInstall",u.triggerOnEventHandlers.get(e)));break;case"AppUpgrade":i.provides(zm),O("OnAppUpgrade",q("AppUpgrade",u.triggerOnEventHandlers.get(e)));break;case"ModAction":i.provides(ep),O("OnModAction",q("ModAction",u.triggerOnEventHandlers.get(e)));break;case"ModMail":i.provides(tp),O("OnModMail",q("ModMail",u.triggerOnEventHandlers.get(e)));break;case"PostNsfwUpdate":i.provides(sp),O("OnPostNsfwUpdate",q("PostNsfwUpdate",u.triggerOnEventHandlers.get(e)));break;case"PostSpoilerUpdate":i.provides(ap),O("OnPostSpoilerUpdate",q("PostSpoilerUpdate",u.triggerOnEventHandlers.get(e)));break;case"AutomoderatorFilterPost":i.provides(qm),O("OnAutomoderatorFilterPost",q("AutomoderatorFilterPost",u.triggerOnEventHandlers.get(e)));break;case"AutomoderatorFilterComment":i.provides($m),O("OnAutomoderatorFilterComment",q("AutomoderatorFilterComment",u.triggerOnEventHandlers.get(e)));break;default:throw new Error(`Unknown trigger event: ${e}`)}}function up(i){let e=i.reduce((t,r)=>r.status==="rejected"?[...t,r.reason]:t,[]);if(e.length!==0)return e.length===1?{err:e[0]}:{err:new Error(e.map(t=>rt.caughtToString(t)).join(`
3
+ `))}}import{EffectType as Up,HandleUIEventResponse as va,UIEventHandlerDefinition as Dp}from"@devvit/protos";var jl=dd(Bl(),1);function Nl(i){return i?.constructor===Object}function Ut(i,e){return Object.is(i,e)?!0:typeof i!=typeof e?!1:Array.isArray(i)&&Array.isArray(e)?Ll(i,e):i instanceof Date&&e instanceof Date?i.getTime()===e.getTime():i instanceof RegExp&&e instanceof RegExp?i.toString()===e.toString():Nl(i)&&Nl(e)?Mp(i,e):i instanceof ArrayBuffer&&e instanceof ArrayBuffer?_l(new DataView(i),new DataView(e)):i instanceof DataView&&e instanceof DataView?_l(i,e):Hl(i)&&Hl(e)?i.byteLength!==e.byteLength?!1:Ll(i,e):!1}function Mp(i,e){let t=Object.keys(i),r=Object.keys(e);if(!Ut(t,r))return!1;for(let s of t)if(!Ut(i[s],e[s]))return!1;return!0}function Ll(i,e){return i.length!==e.length?!1:i.every((t,r)=>Ut(t,e[r]))}function _l(i,e){if(i.byteLength!==e.byteLength)return!1;for(let t=0;t<i.byteLength;t++)if(i.getUint8(t)!==e.getUint8(t))return!1;return!0}function Hl(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}async function Bp(i,e){let t=i.state??{},r=(0,jl.default)(t),s=ke({ui:!0,metadata:e});if(i.event?.formSubmitted&&i.event.formSubmitted.formId){let m=i.event.formSubmitted.formId;if(m.includes("form.hook.")&&u.customPostType){let b=new Le((_,I)=>u.customPostType?.render(I)??null,i.event,i.state,e,void 0);return await b.reconcile(),va.fromJSON({state:b.state,effects:b.getEffects()})}let y=u.formDefinitions.get(m);if(!y)throw new Error(`Form with key ${m} not found`);let v,f;if(r.__contextAction){let{actionId:b,thingId:_}=r.__contextAction,I=qr(b);fa(I,"post")?v=_:fa(I,"comment")&&(f=_)}let S=Object.assign(s,ne(e,v,f),{uiEnvironment:{timezone:e[P.Timezone]?.values[0],locale:e[P.Language]?.values[0]}});await kl(S,i),await y.onSubmit({values:Ke(i.event.formSubmitted.results)},S)}else if(i.event?.realtimeEvent){if(u.customPostType){let m=new Le((y,v)=>u.customPostType?.render(v)??null,i.event,i.state,e,void 0);return await m.reconcile(),va.fromJSON({state:m.state,effects:m.getEffects()})}}else if(i.event?.toastAction)throw new Error("Toast actions not yet implemented");let o=!Ut(t,r),a=Si(s.ui),c=o?[...a,{type:Up.EFFECT_RERENDER_UI,rerenderUi:{delaySeconds:0}}]:a;return va.fromJSON({state:r,effects:c})}function Wl(i){i.provides(Dp),O("HandleUIEvent",Bp)}import{CustomPostDefinition as fo,UIResponse as hu}from"@devvit/protos";import{UIEventScope as Gp}from"@devvit/protos";var ka="ServerCallRequired";function io(i){return i?.message===ka}var wa={now(){return new Date}};function Vl(i){return`__autocache__${i}`}function Gl(i){return`__lock__${i}`}var Np=300,Lp=1e3,ro=5e3,Ca=3,Jl=.1,zl=1e3,_p=3e4;function $l(i){if(i.error)throw new Error(i.error);return i.value}var nt,st,Pe,Ii,$,ql,Kl,Xl,Pa,Zl,Ql,Sa,Yl,no=class{constructor(e,t,r=wa){l(this,$);l(this,nt);l(this,st,{});l(this,Pe);l(this,Ii);d(this,nt,e),d(this,Ii,t),d(this,Pe,r)}async cache(e,t){var a;(a=n(this,Ii)).__cache??(a.__cache={}),d(this,st,n(this,Ii).__cache),h(this,$,Yl).call(this,t);let r=h(this,$,ql).call(this,t.key);if(r!==void 0)return r;let s=await h(this,$,Sa).call(this,t.key),o=await h(this,$,Kl).call(this,t,s,e);return $l(o)}};nt=new WeakMap,st=new WeakMap,Pe=new WeakMap,Ii=new WeakMap,$=new WeakSet,ql=function(e){let t=n(this,st)[e];if(t){let r=n(this,Pe).now().getTime(),s=t?.error&&t?.errorTime&&t.errorCount<Ca&&Math.random()<Jl&&t.errorTime+zl<r;if(t?.expires&&t.expires<r&&t.checkedAt+zl<r||s){delete n(this,st)[e];return}else return $l(t)}},Kl=async function(e,t,r){let s=t?.expires,o=s?h(this,$,Ql).call(this,s):1;return!t||t?.error&&t.errorCount<Ca&&Jl>Math.random()||o>Math.random()?h(this,$,Xl).call(this,e,t,r):t},Xl=async function(e,t,r){let s=Gl(e.key),o=n(this,Pe).now().getTime(),a=new Date(o+e.ttl/2);if(await n(this,nt).set(s,"1",{expiration:a,nx:!0}))return h(this,$,Zl).call(this,e.key,t,r,e.ttl);if(t)return t;{let m=n(this,Pe).now();return h(this,$,Pa).call(this,m,e.key,e.ttl)}},Pa=async function(e,t,r){let s=Math.min(r,Lp),o=await h(this,$,Sa).call(this,t);if(o)return o;if(n(this,Pe).now().getTime()-e.getTime()>=s)throw new Error(`Cache request timed out trying to get data at key: ${t}`);return await new Promise(a=>setTimeout(a,Np)),h(this,$,Pa).call(this,e,t,r)},Zl=async function(e,t,r,s){let o=n(this,Pe).now().getTime()+s;t=t??{value:null,expires:o,errorCount:0,error:null,errorTime:null,checkedAt:0};try{t.value=await r(),t.error=null,t.errorCount=0,t.errorTime=null}catch(a){t.value=null,t.error=a.message??"Unknown error",t.errorTime=n(this,Pe).now().getTime(),t.errorCount++}return n(this,st)[e]=t,await n(this,nt).set(Vl(e),JSON.stringify(t),{expiration:new Date(o+_p)}),t.error&&t.errorCount<Ca&&await n(this,nt).del(Gl(e)),t},Ql=function(e){let t=n(this,Pe).now().getTime(),r=e-t;return r<0?1:r<1e3?.1:r<2e3?.01:r<3e3?.001:0},Sa=async function(e){let t=await n(this,nt).get(Vl(e));if(t){let r=JSON.parse(t);return r.checkedAt=n(this,Pe).now().getTime(),n(this,st)[e]=r,r}},Yl=function(e){e.ttl<ro&&(console.warn(`Cache TTL cannot be less than ${ro} milliseconds! Updating ttl value of ${e.ttl} to ${ro}.`),e.ttl=ro)};function eu(i,e,t=wa){let r=new no(i,e,t);return r.cache.bind(r)}import{EffectType as so,ToastAppearance as ru}from"@devvit/protos";function tu(i){let e=i.match(/form\.hook\.(.+)\.0/);if(e?.[1])return e[1]}var Fa=class{constructor(e,t,r){this.state=null;this.hookId=e.hookId,this.form=t,this.onSubmit=r,this.onUIEvent=async s=>{s.formSubmitted&&await r(Ke(s.formSubmitted.results))}}};function xa(i,e){let t=ce({namespace:"useForm",initializer:r=>new Fa(r,i,e)});return Hp({id:t.hookId})}function Hp(i){return`form.hook.${i.id}.0`}function iu(i,e){let t=tu(e);return i.getHook({id:t})}var _e,ao,Kr,lo,oo=class{constructor(e){l(this,_e);l(this,ao,0);l(this,Kr);l(this,lo,(e,t)=>{let r=t!==void 0?e:"",s=t!==void 0?t:e;n(this,_e).emitEffect(`postMessage${ld(this,ao)._++}`,{type:so.EFFECT_WEB_VIEW,webView:{postMessage:{webViewId:r,app:{message:s,jsonString:JSON.stringify(s)}}}})});d(this,_e,e),d(this,Kr,{postMessage:n(this,lo)})}get webView(){return n(this,Kr)}showForm(e,t){return this.showFormInternal(e,t)}showFormInternal(e,t,r){let s=iu(n(this,_e),e);if(!s)throw new Error("Form does not exist. Make sure you have added it using useForm.");let o=r??(s.form instanceof Function?s.form(t??{}):s.form),a={fields:[],id:e,title:o.title,acceptLabel:o.acceptLabel,cancelLabel:o.cancelLabel,shortDescription:o.description};Tt(o.fields),a.fields=Ne(o.fields),n(this,_e).emitEffect(e,{type:so.EFFECT_SHOW_FORM,showForm:{form:a}})}showToast(e){let t;e instanceof Object?t={text:e.text,appearance:e.appearance==="success"?ru.SUCCESS:ru.NEUTRAL}:t={text:e},n(this,_e).emitEffect(e.toString(),{type:so.EFFECT_SHOW_TOAST,showToast:{toast:t}})}navigateTo(e){let t=typeof e=="string"?e:e.url;if(!URL.canParse(t))throw new TypeError(`Invalid URL: ${t}`);let r=new URL(t).toString();n(this,_e).emitEffect(r,{type:so.EFFECT_NAVIGATE_TO_URL,navigateToUrl:{url:r}})}};_e=new WeakMap,ao=new WeakMap,Kr=new WeakMap,lo=new WeakMap;import{EffectType as jp,RealtimeSubscriptionStatus as nu}from"@devvit/protos";var ot,Re,at,Dt,Xr,Aa,uo=class uo{constructor(e,t){l(this,Xr);l(this,ot);l(this,Re);l(this,at);l(this,Dt);d(this,ot,t.context),d(this,Re,!!t.context._devvitContext?.debug.realtime),d(this,Dt,e),d(this,at,t.invalidate);let r=t.context.meta[P.App]?.values[0];if(!r)throw Error("useChannel missing app ID metadata");let s=t.context.meta[P.Installation]?.values[0];if(!s)throw Error("useChannel missing install ID from metadata");let o=`${r}:${s}:${e.name}`;if(Object.values(n(this,ot)._hooks).filter(c=>c instanceof uo).some(c=>c.state.channel===o))throw Error(`useChannel channel names must be unique; "${o}" duplicated`);this.state={channel:o,connected:!1,subscribed:!1}}async onUIEvent(e){let t=e.realtimeEvent;if(!(!t||!this.state.subscribed))switch(t.status){case nu.REALTIME_SUBSCRIBED:n(this,Re)&&console.debug(`[realtime] "${this.state.channel}" connected`),this.state.connected=!0,n(this,at).call(this),await n(this,Dt).onSubscribed?.();break;case nu.REALTIME_UNSUBSCRIBED:n(this,Re)&&console.debug(`[realtime] "${this.state.channel}" disconnected`),this.state.connected=!1,n(this,at).call(this),await n(this,Dt).onUnsubscribed?.();break;default:n(this,Re)&&console.debug(`[realtime] "${this.state.channel}" received message: ${JSON.stringify(e,void 0,2)}`),n(this,Dt).onMessage(t.event?.data?.msg);break}}async send(e){if(n(this,Re)&&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 n(this,ot).devvitContext.realtime.send(this.state.channel,e)}get status(){return this.state.subscribed&&this.state.connected?2:this.state.subscribed&&!this.state.connected?1:!this.state.subscribed&&this.state.connected?3:4}subscribe(){this.state.subscribed||(n(this,Re)&&console.debug(`[realtime] "${this.state.channel}" subscribed`),this.state.subscribed=!0,n(this,at).call(this),h(this,Xr,Aa).call(this))}unsubscribe(){this.state.subscribed&&(n(this,Re)&&console.debug(`[realtime] "${this.state.channel}" unsubscribed`),this.state.subscribed=!1,n(this,at).call(this),h(this,Xr,Aa).call(this))}};ot=new WeakMap,Re=new WeakMap,at=new WeakMap,Dt=new WeakMap,Xr=new WeakSet,Aa=function(){let e=Object.values(n(this,ot)._hooks).filter(t=>t instanceof uo&&t.state.subscribed).map(t=>t.state.channel);n(this,ot).emitEffect(this.state.channel,{type:jp.EFFECT_REALTIME_SUB,realtimeSubscriptions:{subscriptionIds:e}})};var Ia=uo;function Ta(i){if(!i.name||/[^a-zA-Z0-9_]/.test(i.name))throw Error(`useChannel error: The name "${i.name}" you provided for the hook is invalid. Valid names can only contain letters, numbers, and underscores (_).`);let e=`useChannel:${i.name}`;return ce({id:e,namespace:e,initializer:t=>new Ia(i,t)})}import{EffectType as Ea}from"@devvit/protos";function su(i){return typeof i=="object"&&i!==null&&"__deleted"in i}var Bt,dt,Ai=class Ai{constructor(e,t){l(this,Bt);this._segments=[];l(this,dt,{});this._prevHooks={};this._prevHookId="";this._effects={};this._changed={};this._touched={};this._requeueEvents=[];this._rootProps={};this._generated={};this._undeliveredHandlers={};this.request=e,this.meta=t,d(this,Bt,e.state??{__cache:{}}),this._rootProps=e.props??{}}get devvitContext(){if(!this._devvitContext)throw new Error("Devvit context not available");return this._devvitContext}set devvitContext(e){this._devvitContext=e}get _changedState(){let e={__cache:n(this,Bt).__cache??{}};for(let r in this._changed)e[r]=this._state[r];let t=new Set(Object.keys(this._state));return Object.keys(n(this,dt)).forEach(r=>{r!=="__cache"&&t.delete(r)}),t.forEach(r=>{if(r==="__cache")return;let s={__deleted:!0};this._state[r]=e[r]=s}),e}get _hooks(){return n(this,dt)}set _hooks(e){this._prevHooks=n(this,dt),d(this,dt,e)}get _state(){return n(this,Bt)}set _state(e){d(this,Bt,e)}push(e){this._segments.push({...e,next:0})}pop(){this._segments.pop()}addUndeliveredEventHandler(e,t){this._undeliveredHandlers[e]=t}addGlobalUndeliveredEventHandler(e,t){Ai.addGlobalUndeliveredEventHandler(e,t)}getHook(e){return n(this,dt)[e.id]}static addGlobalUndeliveredEventHandler(e,t){Ai._staticUndeliveredHandlers[e]=t}async handleUndeliveredEvent(e){let t={...Ai._staticUndeliveredHandlers,...this._undeliveredHandlers};for(let[r,s]of Object.entries(t))await s(e,this)}emitEffect(e,t){this._effects[e]=t}addToRequeueEvents(...e){this._devvitContext?.debug.blocks&&console.debug("[blocks] requeueing events",e);let t=e.reduce((r,s)=>(s.retry?r.retry.push(s):r.normal.push(s),r),{retry:[],normal:[]});this._requeueEvents=[...t.retry,...this._requeueEvents,...t.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 t=[];for(let s=this._segments.length-1;s>=0;s--){let o=this._segments[s];if(o.id){t.unshift(o.id);break}let a=[];o.namespace&&a.push(o.namespace),o.key!==void 0&&o.key!==!1&&a.push(o.key),t.unshift(a.join("-"))}let r=t.join(".");if(this._generated[r]&&!e.shared)throw new Error(`Hook id ${r} already used, cannot register another hook with the same id`);return this._generated[r]=!0,this._prevHookId=r,r}finally{this.pop()}}};Bt=new WeakMap,dt=new WeakMap,Ai._staticUndeliveredHandlers={};var Ti=Ai;var lt={};Ti.addGlobalUndeliveredEventHandler("intervals",async(i,e)=>{i.timer&&i.hook&&(delete lt[i.hook],e.emitEffect("timers",{type:Ea.EFFECT_SET_INTERVALS,interval:{intervals:lt}}))});var ut,Ei,Zr,Ri,Ra=class{constructor(e,t,r){l(this,ut);l(this,Ei);l(this,Zr);l(this,Ri);this.state={duration:{seconds:0,nanos:0},running:!1};d(this,Ei,r.invalidate),d(this,ut,r.hookId),d(this,Zr,e),d(this,Ri,r.context);let s=Math.floor(t/1e3),o=t%1e3*1e6;this.state.duration={seconds:s,nanos:o}}onStateLoaded(){this.state.running?lt[n(this,ut)]={duration:this.state.duration}:delete lt[n(this,ut)]}async onUIEvent(e){await n(this,Zr).call(this)}start(){lt[n(this,ut)]={duration:this.state.duration},this.state.running=!0,n(this,Ei).call(this),n(this,Ri).emitEffect("timers",{type:Ea.EFFECT_SET_INTERVALS,interval:{intervals:lt}})}stop(){delete lt[n(this,ut)],this.state.running=!1,n(this,Ei).call(this),n(this,Ri).emitEffect("timers",{type:Ea.EFFECT_SET_INTERVALS,interval:{intervals:lt}})}};ut=new WeakMap,Ei=new WeakMap,Zr=new WeakMap,Ri=new WeakMap;function Oa(i,e){let t=ce({namespace:"useInterval",initializer:r=>new Ra(i,e,r)});return{start:()=>t.start(),stop:()=>t.stop()}}import{UIEventScope as Vp}from"@devvit/protos";var Nt=class extends Error{};import{UIEventScope as ou}from"@devvit/protos";function Ua(i){if(i instanceof Error){if(i.message===ka)throw i;return console.error(i),{message:i.message,details:i.stack??""}}else return console.error(i),{message:"Unknown error",details:rt.caughtToString(i)}}var xe,Oe,Oi,Qr,Mi,Ma=class{constructor(e,t,r){l(this,xe);l(this,Oe);l(this,Oi);l(this,Qr);l(this,Mi);d(this,xe,!!r.context.devvitContext.debug.useAsync),n(this,xe)&&console.debug("[useAsync] v1",t),this.state={data:null,load_state:"initial",error:null,depends:null},d(this,Oe,r.hookId),this.initializer=e,d(this,Oi,r.invalidate),d(this,Qr,r.context),this.localDepends=t.depends??null,d(this,Mi,t)}onStateLoaded(){if(n(this,xe)&&console.debug("[useAsync] async onLoad ",n(this,Oe),this.state),n(this,xe)&&console.debug("[useAsync] async onLoad have ",this.localDepends,"and",this.state.depends),!Ut(this.localDepends,this.state.depends)||this.state.load_state==="initial"){n(this,xe)&&console.debug("[useAsync] attempting to resolve for hookId",n(this,Oe)),this.state.load_state="loading",this.state.depends=this.localDepends,n(this,Oi).call(this);let e={scope:ou.ALL,hook:n(this,Oe),async:!0,asyncRequest:{requestId:n(this,Oe)+"-"+JSON.stringify(this.state.depends)}};n(this,xe)&&console.debug("[useAsync] onLoad requeue"),n(this,Qr).addToRequeueEvents(e)}}async onUIEvent(e,t){if(e.asyncRequest){let r={requestId:e.asyncRequest.requestId};try{r.data={value:await this.initializer()}}catch(o){r.error=Ua(o)}let s={scope:ou.ALL,asyncResponse:r,hook:n(this,Oe)};n(this,xe)&&console.debug("[useAsync] onReq requeue"),t.addToRequeueEvents(s)}else if(e.asyncResponse){let r=n(this,Oe)+"-"+JSON.stringify(this.state.depends);e.asyncResponse.requestId===r?(this.state={...this.state,data:e.asyncResponse.data?.value??null,error:e.asyncResponse.error??null,load_state:e.asyncResponse.error?"error":"loaded"},n(this,Mi).finally&&await n(this,Mi).finally(this.state.data,this.state.error?new Error(this.state.error?.message??"Unknown error"):null),n(this,Oi).call(this)):n(this,xe)&&console.debug("[useAsync] onResp skip, stale event",e.asyncResponse.requestId," !== ",r)}else throw new Error("Unknown event type")}};xe=new WeakMap,Oe=new WeakMap,Oi=new WeakMap,Qr=new WeakMap,Mi=new WeakMap;function Wp(i,e={}){let t=ce({namespace:"useAsync",initializer:r=>new Ma(i,e,r)});return{data:t.state.data,error:t.state.error,loading:t.state.load_state==="loading"}}var He,Ui,Lt,ct,Da=class{constructor(e,t){this.state={value:null,load_state:"initial",error:null};l(this,He);l(this,Ui);l(this,Lt);l(this,ct);d(this,Lt,e),d(this,ct,t.hookId),d(this,He,t.invalidate),d(this,Ui,t.context)}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=Ua(e)}n(this,He).call(this)}else console.warn(`Invalid state for hook (${n(this,ct)}):`,this.state.load_state,this._promise)}setter(e){this.state.value=e instanceof Function?e(this.state.value):e,this.state.load_state="loaded",n(this,He).call(this)}onStateLoaded(){if(this._promise=n(this,Ui)._prevHooks[n(this,ct)]?._promise,this.state.load_state==="loading")throw new Nt;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=n(this,Lt)instanceof Function?n(this,Lt).call(this):n(this,Lt)}catch(t){console.log("error in loading async",t),this.state.load_state="error",n(this,He).call(this);return}if(e instanceof Promise){this._promise=e,this.state.load_state="loading";let t={scope:Vp.ALL,asyncRequest:{requestId:n(this,ct)},hook:n(this,ct)};throw n(this,Ui).addToRequeueEvents(t),n(this,He).call(this),new Nt}else this.state.value=e,this.state.load_state="loaded";n(this,He).call(this)}}};He=new WeakMap,Ui=new WeakMap,Lt=new WeakMap,ct=new WeakMap;function Ba(i){let e=ce({namespace:"useState",initializer:t=>new Da(i,t)});return[e.state.value,e.setter.bind(e)]}var co=class{buildContext(e,t,r){let s=new gi(r),o=new mi(r),a=new vi(r),c=new yi(r),m=new ki(r),y=new Ci(r),v=new oo(e),f=new pi(r),S=new ui,b=new hi(r),_=eu(a,e._state),I={modLog:s,kvStore:o,redis:a,reddit:c,scheduler:m,settings:y,media:f,assets:S,realtime:b,ui:v,useState:Ba,useChannel:Ta,useInterval:Oa,useForm:xa,cache:_,dimensions:t.env?.dimensions,uiEnvironment:{timezone:r[P.Timezone]?.values[0],locale:r[P.Language]?.values[0],dimensions:t.env?.dimensions,colorScheme:t.env?.colorScheme}},N=ne(r,t.props?.postId);return N.debug.effects=e,{...N,...I}}};var me=null;function au(i){return JSON.parse(JSON.stringify(i))}function Jp(i){if(!(i!==""&&!/[-.]/.test(i)))throw new Error(`Hook with namespace '${i}' 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 ce({initializer:i,...e}){if(!me)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.");Jp(e.namespace);let t=me.nextHookId(e),r=me,s={hookId:t,invalidate:()=>{r._changed[t]=!0,r._state[t]=r?._hooks[t]?.state},context:me},o=me._state[t]===void 0||su(me._state[t]);me._hooks[t]=me._hooks[t]??i(s);let a=me._hooks[t];return o||(a.state=me._state[t]),a.onStateLoaded?.(),o&&a.state!==void 0&&a.state!==null&&s.invalidate(),a}var zp=null,mo=128,Di,ho,Yr,F,se,po,du,Na,lu,La,_a,go,Ha,uu,_t=class{constructor(e){l(this,F);l(this,Di);l(this,ho,new co);l(this,Yr,new xi(()=>this._latestRenderContext?.devvitContext?.assets));this._latestRenderContext=null;n(this,F,se)&&console.debug("[blocks] BlocksHandler v1"),d(this,Di,e),zp=this}async handle(e,t){let r=new Ti(e,t),s=n(this,ho).buildContext(r,e,t);r.devvitContext=s;let o,a=e.events.length-mo,c=e.events;if(a>0){c=[];{let I=0;for(let N of e.events)I<a&&N.realtimeEvent?I++:c.push(N)}for(;c.length>mo;)c.shift();console.warn(`dropped ${a} events`)}let y=!c.length||c.some(I=>!I.async),v=c.some(I=>I.blocking),f,S,b=[...c];c.length===0&&c.push({scope:Gp.ALL}),n(this,F,se)&&console.debug("[blocks] starting processing events");let _=0;for(;c.length>0;){if(_++>mo)throw new Error(`Exceeded maximum iterations of ${mo}`);n(this,F,se)&&console.debug("[blocks] processing events loop iteration",c.length);let I=[];if(!c[0].async)I.push(c.shift());else for(;c[0]?.async;)I.push(c.shift());if(!I.length)throw Error("batch must have at least one event");try{if(I[0].async){let D=au(r._state);await h(this,F,du).call(this,r,...I),r._state=D}else await h(this,F,lu).call(this,r,...I)}catch(D){if(!io(D))throw D;if(n(this,F,se)&&console.debug("[blocks] caught in handler",D),r._latestRenderContent=void 0,S){r._state=S._state,r._changed=f,r._effects=S._effects;let si=b.map(nd=>{let sd={...nd};return sd.retry=!0,sd});r.addToRequeueEvents(...si);break}else throw io(D)||console.error("[blocks] unhandled error in handler",D),D}n(this,F,se)&&console.debug("[blocks] remaining events",r._requeueEvents);let N=[];for(let D of r._requeueEvents){if(!y&&!D.async){n(this,F,se)&&console.debug("[blocks] NOT reprocessing event in BlocksHandler, sync mismatch A",D),N.push(D);continue}if(y&&D.async&&!v){n(this,F,se)&&console.debug("[blocks] NOT reprocessing event in BlocksHandler, sync mismatch B",D),N.push(D);continue}n(this,F,se)&&console.debug("[blocks] reprocessing event in BlocksHandler",D),c.push(D)}r._requeueEvents=N,c.length>0&&(f={...r._changed},S={_state:au(r._state),_effects:{...r._effects}},b=[...c])}if(y){r._latestRenderContent||(r._latestRenderContent=h(this,F,La).call(this,n(this,Di),r.request.props??{},r));let I=r._latestRenderContent;I&&(o=n(this,Yr).createBlocksElementOrThrow(I),o=n(this,Yr).ensureRootBlock(o))}return{state:r._changedState,effects:r.effects,blocks:o,events:r._requeueEvents}}};Di=new WeakMap,ho=new WeakMap,Yr=new WeakMap,F=new WeakSet,se=function(){return!!this._latestRenderContext?.devvitContext.debug.blocks},po=function(e,...t){e._hooks={},h(this,F,La).call(this,n(this,Di),e.request.props??{},e)},du=async function(e,...t){h(this,F,po).call(this,e,...t),await Promise.all(t.map(async r=>{if(!r.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 h(this,F,Na).call(this,e,r)}))},Na=async function(e,t){let r=e._hooks[t.hook];if(r?.onUIEvent)try{await r.onUIEvent(t,e)}catch(s){throw io(s)?n(this,F,se)&&console.error("Server call required",s):console.error("Error in event handler",s),s}else await e.handleUndeliveredEvent(t)},lu=async function(e,...t){for(let r of t)n(this,F,se)&&console.log("[blocks] handling main queue event",r),n(this,F,se)&&console.log("[blocks] before",e._state),h(this,F,po).call(this,e,r),await h(this,F,Na).call(this,e,r),n(this,F,se)&&console.log("[blocks] after",e._state);h(this,F,po).call(this,e)},La=function(e,t,r){n(this,F,se)&&console.debug("[blocks] renderRoot"),r._generated={},me=r,this._latestRenderContext=r;try{let s=h(this,F,_a).call(this,e,t,r);if(s.length!==1)throw new Error(`There can only be one root element, received: ${s.length}. Please wrap these elements in a <vstack></vstack> or <hstack></hstack> to continue. Fragments cannot be used as a root element.`);let o=s[0];if(o==="[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 o=="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 r._latestRenderContent=o,o}catch(s){if(s instanceof Nt)return;throw s}finally{me=null}},_a=function(e,t,r){r.push({namespace:e.name||"anonymous",...t});try{let s=e(t,r.devvitContext);if(s 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 h(this,F,Ha).call(this,s,r)}finally{r.pop()}},go=function(e,t){return e=e.flat(1/0),e.flatMap((r,s)=>(r&&typeof r=="object"&&"props"in r&&(r.props?.key||(r.props=r.props??{},r.props.key=`${s}`)),h(this,F,Ha).call(this,r,t)))},Ha=function(e,t){if(Array.isArray(e))return h(this,F,go).call(this,e,t);if($p(e))if(e.type===void 0)try{return t.push({namespace:"fragment",...e.props}),h(this,F,go).call(this,e.children,t)}finally{t.pop()}else if(typeof e.type=="function"){let r={...e.props,children:e.children.flat(1/0)};return h(this,F,_a).call(this,e.type,r,t)}else try{t.push({namespace:e.type,...e.props});let r=h(this,F,go).call(this,e.children,t),s=h(this,F,uu).call(this,e.props??{});return[{type:e.type,children:r,props:s}]}finally{t.pop()}else return[(e??"").toString()]},uu=function(e){let t={};for(let r in e)if(!(typeof e[r]>"u"))if(typeof e[r]=="function"){let s=ce({namespace:r,key:!1,initializer:({hookId:o})=>({hookId:o,state:null,onUIEvent:a=>{if(a.userAction)return e[r](a.userAction.data);if(a.webView?.postMessage){let c=a.webView.postMessage.jsonString?JSON.parse(a.webView.postMessage.jsonString):a.webView.postMessage.message;return e[r](c)}}})});t[r]=s.hookId,"captureHookRef"in e[r]&&e[r].captureHookRef()}else{let s=JSON.parse(JSON.stringify(e[r]));s!=null&&(t[r]=s)}return t};function $p(i){return typeof i=="object"&&i!=null&&"type"in i}var cu=i=>{let e=Number(i.trim().split(".").pop());return isNaN(e)?void 0:e},mu=i=>{let[e,t,r]=i.trim().split(";");if(!e||!t||!r){console.warn(`Received a malformed devvit-user-agent! Received: '${i}'`);return}if(e!=="Reddit"){console.warn(`Received unknown company name in user agent! Received: '${i}'`);return}if(t==="iOS"){let s=cu(r);if(s===void 0){console.warn(`Could not parse version number from user agent! Received: '${i}'`);return}return{company:"Reddit",platform:"iOS",rawVersion:r,versionNumber:s}}if(t==="Android"){let s=cu(r);if(s===void 0){console.warn(`Could not parse version number from user agent! Received: '${i}'`);return}return{company:"Reddit",platform:"Android",rawVersion:r,versionNumber:s}}if(t==="Shreddit")return{company:"Reddit",platform:"Shreddit",rawVersion:r};console.warn("Received unknown platform:",t)},pu=i=>i?i.platform==="Android"?i.versionNumber<1875012:i.platform==="iOS"?i.versionNumber<614973:!1:(console.warn(`Could not parse devvit-user-agent! Received: '${JSON.stringify(i)}'`),!1),qp=i=>{switch(i){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"Shreddit":break;default:console.error(`No upgrade link for platform: ${i}`)}},Kp=({platform:i},e)=>u.createElement("blocks",null,u.createElement("vstack",{alignment:"middle center",height:100,width:100},u.createElement("vstack",{maxWidth:"300px",gap:"large",alignment:"middle center"},u.createElement("vstack",{gap:"medium",alignment:"middle center"},u.createElement("image",{imageHeight:100,imageWidth:100,url:"https://i.redd.it/p1vmc5ulmpib1.png"}),u.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.")),u.createElement("hstack",{alignment:"middle center"},u.createElement("button",{onPress:()=>{let t=qp(i);t?e.ui.navigateTo(t):console.warn("No upgrade link found for platform:",i)}},"Upgrade"))))),gu=i=>()=>u.createElement(Kp,{platform:i});var Xp=()=>u.createElement("vstack",{alignment:"center middle",width:"100%",height:"100%"},u.createElement("text",null,"This feature is not available yet")),Zp=[[fo,fo.methods.renderPostContent,(i,e)=>u.customPostType?.render(e)??null],[fo,fo.methods.renderPostComposer,(i,e)=>u.createElement(Xp,null)]];function Qp(i){return async(e,t)=>{let r=mu(t["devvit-user-agent"]?.values?.[0]??"");if(r&&pu(r)){let o=new _t(gu(r.platform));return hu.fromJSON(await o.handle(e,t))}let s=new _t(i);return hu.fromJSON(await s.handle(e,t))}}function fu(i){for(let[e,t,r]of Zp)i.provides(e),O(t.name,Qp(r))}var je,Ht,jt,Wt,We,Bi,Vt,mt,en,Ni,Gt,tn,Jt,j,yo,yu,M=class M extends Ls{static configure(e){d(this,Ht,{...n(this,Ht),...e});let t=e.http,r=typeof t=="object"&&"domains"in t;Fe(r?{enabled:!0}:t)&&(r&&(ud(t.domains),d(this,Ni,cd(t.domains))),this.use(k.HTTPDefinition)),(e.redis===void 0||Fe(e.kvStore)||Fe(e.redis))&&(this.use(k.KVStoreDefinition),this.use(k.RedisAPIDefinition)),Fe(e.media)&&this.use(k.MediaServiceDefinition),Fe(e.modLog)&&this.use(k.ModlogDefinition),Fe(e.redditAPI)&&(this.use(k.FlairDefinition),this.use(k.GraphQLDefinition),this.use(k.LinksAndCommentsDefinition),this.use(k.ListingsDefinition),this.use(k.ModerationDefinition),this.use(k.ModNoteDefinition),this.use(k.NewModmailDefinition),this.use(k.PrivateMessagesDefinition),this.use(k.SubredditsDefinition),this.use(k.UsersDefinition),this.use(k.WidgetsDefinition),this.use(k.WikiDefinition)),Fe(e.realtime)&&this.use(k.RealtimeDefinition);let a=e.userActions,m=typeof a=="object"&&"scopes"in a?{enabled:!0}:a;if(Fe(m)){this.use(k.UserActionsDefinition);let y=h(this,yo,yu).call(this,e);y.length>0&&d(this,Gt,y)}}static addMenuItem(e){n(this,Bi).push(e)}static addCustomPostType(e){d(this,jt,e)}static createForm(e,t){let r=`form.${n(this,Wt).size}`;return n(this,Wt).set(r,{form:e,onSubmit:t}),r}static addSchedulerJob(e){if(n(this,j)[k.SchedulerDefinition.fullName]||this.use(k.SchedulerDefinition),n(this,Vt).has(e.name))throw new Error(`Job ${e.name} is already defined`);n(this,Vt).set(e.name,e.onRun)}static addSettings(e){var o;let t=Array.isArray(e)?e:[e],r=t.filter(a=>a.type==="group"||!a.scope||a.scope===ze.Installation),s=t.filter(a=>a.type!=="group"&&a.scope===ze.App);r.length>0&&(n(this,We)??d(this,We,[]),n(this,We).push(...r)),s.length>0&&(n(this,je)??d(this,je,[]),n(this,je).push(...s)),Tt([...n(this,We)??[],...n(this,je)??[]]),n(this,j)[k.SettingsDefinition.fullName]||this.use(k.SettingsDefinition),globalThis.devvit??(globalThis.devvit={}),(o=globalThis.devvit).settings??(o.settings={}),globalThis.devvit.settings.app=n(this,je),globalThis.devvit.settings.installation=n(this,We)}static addTrigger(e){if("events"in e){for(let t of e.events)this.addTrigger({event:t,onEvent:(r,s)=>e.onEvent(r,s)});return this}return n(this,mt).has(e.event)?n(this,mt).get(e.event)?.push(e.onEvent):n(this,mt).set(e.event,[e.onEvent]),M}static provide(e){n(this,tn).push(e)}static use(e){n(this,Jt)[e.fullName]={def:e,handler:void 0};let t={};for(let r of Object.values(e.methods))t[r.name]=(s,o)=>n(this,Jt)[e.fullName].handler?.[r.name]?.(r.requestType?.fromPartial(s??{}),o);return n(this,j)[e.fullName]=t,t}static get redditAPIPlugins(){if(!Fe(n(this,Ht).redditAPI))throw new Error("Reddit API is not enabled. You can enable it by passing `redditAPI: true` to `Devvit.configure`.");return{Flair:n(this,j)[k.FlairDefinition.fullName],GraphQL:n(this,j)[k.GraphQLDefinition.fullName],LinksAndComments:n(this,j)[k.LinksAndCommentsDefinition.fullName],Listings:n(this,j)[k.ListingsDefinition.fullName],Moderation:n(this,j)[k.ModerationDefinition.fullName],ModNote:n(this,j)[k.ModNoteDefinition.fullName],NewModmail:n(this,j)[k.NewModmailDefinition.fullName],PrivateMessages:n(this,j)[k.PrivateMessagesDefinition.fullName],Subreddits:n(this,j)[k.SubredditsDefinition.fullName],Users:n(this,j)[k.UsersDefinition.fullName],Widgets:n(this,j)[k.WidgetsDefinition.fullName],Wiki:n(this,j)[k.WikiDefinition.fullName]}}static get modLogPlugin(){let e=n(this,j)[k.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=n(this,j)[k.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=n(this,j)[k.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=n(this,j)[k.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=n(this,j)[k.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=n(this,j)[k.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=n(this,j)[k.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(!(n(this,Gt).length>0&&Fe(n(this,Ht).redditAPI)))throw new Error("UserActions is not enabled. You can enable it by passing scopes in `userActions: { scopes: [...scopes] }` and `redditAPI: true` to `Devvit.configure`");return n(this,j)[k.UserActionsDefinition.fullName]}static get menuItems(){return n(this,Bi)}static get customPostType(){return n(this,jt)}static get formDefinitions(){return n(this,Wt)}static get scheduledJobHandlers(){return n(this,Vt)}static get installationSettings(){return n(this,We)}static get appSettings(){return n(this,je)}static get triggerOnEventHandlers(){return n(this,mt)}static get assets(){return globalThis.devvit?.assets??{}}static get webViewAssets(){return n(this,en)}constructor(e){var t;super(e),globalThis.devvit??(globalThis.devvit={}),(t=globalThis.devvit).assets??(t.assets=e.assets),d(M,en,e.webviewAssets??{});for(let r in n(M,Jt)){let s=n(M,Jt)[r];s.handler=e.use(s.def)}n(M,Bi).length>0&&Pl(e),n(M,Vt).size>0&&Sl(e),n(M,jt)&&(fl(e),fu(e)),(n(M,jt)||n(M,Wt).size>0)&&Wl(e),n(M,We)&&yl(e),n(M,je)&&Zd(e),n(M,mt).size>0&&wl(e);for(let r of n(M,tn))e.provides(r);(n(M,Ni).length>0||n(M,Gt).length>0)&&e.addPermissions({requestedFetchDomains:n(M,Ni),asUserScopes:n(M,Gt)})}};je=new WeakMap,Ht=new WeakMap,jt=new WeakMap,Wt=new WeakMap,We=new WeakMap,Bi=new WeakMap,Vt=new WeakMap,mt=new WeakMap,en=new WeakMap,Ni=new WeakMap,Gt=new WeakMap,tn=new WeakMap,Jt=new WeakMap,j=new WeakMap,yo=new WeakSet,yu=function(e){let t=e.userActions;return t?typeof t=="object"&&"enabled"in t&&t.enabled?[]:typeof t=="object"&&"scopes"in t?t.scopes:[]:[]},l(M,yo),M.debug={},l(M,je),l(M,Ht,{}),l(M,jt),l(M,Wt,new Map),l(M,We),l(M,Bi,[]),l(M,Vt,new Map),l(M,mt,new Map),l(M,en,{}),l(M,Ni,[]),l(M,Gt,[]),l(M,tn,[]),l(M,Jt,{}),l(M,j,{});var u=M;(e=>{function i(t,r,...s){return{type:t,props:r,children:s}}e.createElement=i})(u||(u={}));function X(i){let e=Object.getOwnPropertyDescriptors(i.constructor.prototype);for(let[t,r]of Object.entries(e))r.get&&Object.defineProperty(i,t,{...r,enumerable:!0})}var ja;(function(i){i[i.bold=1]="bold",i[i.italic=2]="italic",i[i.underline=4]="underline",i[i.strikethrough=8]="strikethrough",i[i.subscript=16]="subscript",i[i.superscript=32]="superscript",i[i.monospace=64]="monospace"})(ja||(ja={}));var bu="text",vu="raw",ku="br",Cu="link",Pu="c/",Su="p/",wu="r/",Fu="u/",xu="@",Iu="spoilertext",Au="par",Tu="h",Eu="hr",Ru="blockquote",Ou="code",Mu="li",Uu="list",Du="L",Bu="R",Nu="C",Lu="table",_u="embed",Hu="img",ju="gif",Wu="video";function Vu(i){return{e:ju,id:i.mediaId,...i.caption&&{c:i.caption},...i.blur&&{o:i.blur}}}function Gu(i,e){let t={},r=[];return Object.assign(t,rn(t,r),nn(t,r),sn(t,r),dn(t,r),ln(t,r),un(t,r)),e(t),{e:Ru,c:r,...i.author&&{a:i.author}}}function Ju(i,e){let t={},r=[];return Object.assign(t,Va(t,r)),e(t),{e:Ou,c:r,...i.language&&{l:i.language}}}function zu(i){return{e:Pu,t:i.permalink}}function $u(i,e){let t={},r=[];return Object.assign(t,Va(t,r),an(t,r)),e(t),{e:Tu,l:i.level,c:r}}function qu(i){return{e:_u,u:i.sourceUrl,c:i.contentUrl,x:i.width,y:i.height}}function Ku(){return{e:Eu}}function Xu(i){return{e:Hu,id:i.mediaId,...i.caption&&{c:i.caption},...i.blur&&{o:i.blur}}}function Zu(){return{e:ku}}function Qu(i){return{e:Cu,t:i.text,u:i.url,...i.formatting&&{f:i.formatting},...i.tooltip&&{a:i.tooltip}}}function Yu(i,e){let t={},r=[];return Object.assign(t,hc(t,r)),e(t),{e:Uu,o:i.ordered,c:r}}function ec(i){let e={},t=[];return Object.assign(e,rn(e,t),nn(e,t),sn(e,t),bo(e,t),dn(e,t),ln(e,t),un(e,t)),i(e),{e:Mu,c:t}}function tc(i){let e={},t=[];return Object.assign(e,vo(e,t),an(e,t),Wa(e,t),Ga(e,t),on(e,t)),i(e),{e:Au,c:t}}function ic(i){return{e:Su,t:i.permalink}}function rc(i){return{e:vu,t:i}}function nc(i){let e={},t=[];return Object.assign(e,vo(e,t),an(e,t),Wa(e,t)),i(e),{e:Iu,c:t}}function sc(i){return{e:wu,t:i.subredditName,l:i.showPrefix}}function oc(i){let e={},t=[],r=[];return Object.assign(e,fc(e,t,r)),i(e),{e:Lu,h:t,c:r}}function ac(i){let[e,t]=gc();return i(e),{c:t}}function dc(i,e){let[t,r]=gc();e(t);let s;switch(i.columnAlignment){case"left":s=Du;break;case"right":s=Bu;break;case"center":s=Nu;break}return{...s&&{a:s},...r&&{c:r}}}function lc(i){let e={},t=[];return Object.assign(e,yc(e,t)),i(e),t}function uc(i){return{e:bu,t:i.text,...i.formatting&&{f:i.formatting}}}function cc(i){return{e:Fu,t:i.username,l:i.showPrefix}}function mc(i){return{e:xu,t:i.username,l:i.showPrefix}}function pc(i){return{e:Wu,id:i.mediaId,...i.caption&&{c:i.caption},...i.blur&&{o:i.blur},...i.thumbnail&&{p:i.thumbnail},...i.convertToGif&&{gifify:i.convertToGif}}}function gc(){let i={},e=[];return Object.assign(i,vo(i,e),an(i,e),Ga(i,e),on(i,e)),[i,e]}function rn(i,e){return{blockQuote(t,r){return e.push(Gu(t,r)),i}}}function nn(i,e){return{codeBlock(t,r){return e.push(Ju(t,r)),i}}}function bc(i,e){return{embed(t){return e.push(qu(t)),i}}}function sn(i,e){return{heading(t,r){return e.push($u(t,r)),i}}}function bo(i,e){return{horizontalRule(){return e.push(Ku()),i}}}function on(i,e){return{image(t){return e.push(Xu(t)),i},animatedImage(t){return e.push(Vu(t)),i}}}function Wa(i,e){return{linebreak(){return e.push(Zu()),i}}}function an(i,e){return{link(t){return e.push(Qu(t)),i},commentLink(t){return e.push(zu(t)),i},postLink(t){return e.push(ic(t)),i},subredditLink(t){return e.push(sc(t)),i},userLink(t){return e.push(cc(t)),i},userMention(t){return e.push(mc(t)),i}}}function dn(i,e){return{list(t,r){return e.push(Yu(t,r)),i}}}function hc(i,e){return{item(t){return e.push(ec(t)),i}}}function ln(i,e){return{paragraph(t){return e.push(tc(t)),i}}}function Va(i,e){return{rawText(t){return e.push(rc(t)),i}}}function Ga(i,e){return{spoiler(t){return e.push(nc(t)),i}}}function fc(i,e,t){return{headerCell(r,s){return e.push(dc(r,s)),i},row(r){return t.push(lc(r)),i}}}function un(i,e){return{table(t){return e.push(oc(t)),i}}}function yc(i,e){return{cell(t){return e.push(ac(t)),i}}}function vo(i,e){return{text(t){return e.push(uc(t)),i}}}function vc(i,e){return{video(t){return e.push(pc(t)),i}}}var Yp=function(i,e,t,r,s){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!s:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?s.call(i,t):s?s.value=t:e.set(i,t),t},eg=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},ko,zt=class{constructor(){ko.set(this,void 0);let e=[];Object.assign(this,ln(this,e),sn(this,e),bo(this,e),rn(this,e),nn(this,e),bc(this,e),dn(this,e),un(this,e),on(this,e),vc(this,e)),Yp(this,ko,{document:e},"f")}build(){return JSON.stringify(eg(this,ko,"f"))}paragraph(e){return this}heading(e,t){return this}horizontalRule(){return this}blockQuote(e,t){return this}codeBlock(e,t){return this}embed(e){return this}list(e,t){return this}table(e){return this}image(e){return this}animatedImage(e){return this}video(e){return this}};ko=new WeakMap;function Li(i){let e;return i instanceof zt?e=i.build():typeof i=="object"?e=JSON.stringify(i):e=i,e}var kc=100,Cc=1/0,$t,qt,pt,_i,Hi,Co,V=class{constructor(e){l(this,Hi);l(this,$t);l(this,qt);l(this,pt);l(this,_i,!1);this.pageSize=kc;this.limit=Cc;this.children=[];X(this),this._fetch=e.fetch,this.pageSize=e.pageSize??kc,this.limit=e.limit??Cc,d(this,qt,e.after),d(this,$t,e.before),d(this,pt,e.more),e.children&&(this.children=e.children)}get hasMore(){return!n(this,_i)||!!(n(this,qt)||n(this,$t)||n(this,pt))}async*[Symbol.asyncIterator](){let e=0;for(;;){if(e===this.children.length)if(this.hasMore){if((await h(this,Hi,Co).call(this)).length===0)break}else break;if(yield this.children[e],e++,e===this.limit)break}}setMore(e){d(this,pt,e)}preventInitialFetch(){d(this,_i,!0)}async all(){for(;this.hasMore&&this.children.length<this.limit;)await h(this,Hi,Co).call(this);return this.children.slice(0,this.limit)}async get(e){let t=e<=this.limit?e:this.limit;for(;this.hasMore&&this.children.length<t;)await h(this,Hi,Co).call(this);return this.children.slice(0,t)}};$t=new WeakMap,qt=new WeakMap,pt=new WeakMap,_i=new WeakMap,Hi=new WeakSet,Co=async function(){if(!this.hasMore)throw new Error("This listing does not have any more items to load.");let{children:e,before:t,after:r,more:s}=await this._fetch({before:n(this,$t),after:n(this,qt),limit:this.pageSize,more:n(this,pt)});return this.children.push(...e),d(this,$t,t),d(this,qt,r),d(this,pt,s),d(this,_i,!0),e};var cn,Ja,ve=class{constructor(){}static get(e,t){let r=u.redditAPIPlugins.ModNote;return new V({hasMore:!0,before:e.before,limit:e.limit,pageSize:e.limit,fetch:async s=>{let o=await r.GetNotes({subreddit:e.subreddit,user:e.user,filter:e.filter,before:s.before,limit:s.limit},t);return{children:o.modNotes?.map(a=>h(this,cn,Ja).call(this,a))||[],before:o.hasNextPage?o.endCursor:void 0,hasMore:o.hasNextPage}}})}static async delete(e,t){let r=u.redditAPIPlugins.ModNote,{deleted:s}=await r.DeleteNotes(e,t);return!!s}static async add(e,t){let s=await u.redditAPIPlugins.ModNote.PostNotes(e,t);if(!s?.created)throw new Error("Failed to create mod note");return h(this,cn,Ja).call(this,s.created)}static async addRemovalNote(e,t){await u.redditAPIPlugins.ModNote.PostRemovalNote(e,t)}};cn=new WeakSet,Ja=function(e){return p(e.id,"Mod note ID is null or undefined"),p(e.createdAt,"Mod note createdAt is null or undefined"),p(e.type,"Mod note type is null or undefined"),p(e.subreddit,"Mod note subreddit is null or undefined"),p(e.subredditId,"Mod note subredditId is null or undefined"),p(e.operator,"Mod note operator is null or undefined"),p(e.operatorId,"Mod note operatorId is null or undefined"),p(e.user,"Mod note user is null or undefined"),p(e.userId,"Mod note userId is null or undefined"),p(e.userNoteData,"Mod note userNote is null or undefined"),p(e.modActionData,"Mod note modAction is null or undefined"),{id:e.id,user:{id:ee(e.userId??""),name:e.user},subreddit:{id:K(e.subredditId??""),name:e.subreddit},operator:{id:ee(e.operatorId??""),name:e.operator},createdAt:new Date(e.createdAt*1e3),userNote:{note:e.userNoteData?.note,redditId:e.userNoteData?.redditId?be(e.userNoteData?.redditId):void 0,label:e.userNoteData?.label},type:e.type}},l(ve,cn);var Y=class{static queryWithQueryString(e,t){return u.redditAPIPlugins.GraphQL.Query({query:e},t)}static query(e,t,r,s){return u.redditAPIPlugins.GraphQL.PersistedQuery({operationName:e,id:t,variables:r},s)}};var Pc=["all","wiki","posts","access","mail","config","flair","channels","chat_config","chat_operator","community_chat"];function tg(i,e){return e.map(t=>(i.includes(t)?"+":"-")+t).join(",")}function za(i){return tg(i,Pc)}function Sc(i){return i.filter(e=>Pc.includes(e))}import"@devvit/protos";var ig=(t=>(t.User="USER_FLAIR",t.Post="LINK_FLAIR",t))(ig||{}),Kt,ji,Wi,Vi,Gi,Ji,zi,$i,qi,Ki,Xi,Po,Ie=class Ie{constructor(e,t,r){l(this,Kt);l(this,ji);l(this,Wi);l(this,Vi);l(this,Gi);l(this,Ji);l(this,zi);l(this,$i);l(this,qi);l(this,Ki);X(this),p(e.id),p(e.text),d(this,Kt,e.id),d(this,ji,t),d(this,Wi,e.text),d(this,Vi,rg(e.textColor)),d(this,Gi,ng(e.backgroundColor)),d(this,Ji,sg(e.allowableContent)),d(this,zi,e.modOnly),d(this,$i,e.maxEmojis),d(this,qi,e.textEditable),d(this,Ki,r)}get id(){return n(this,Kt)}get text(){return n(this,Wi)}get textColor(){return n(this,Vi)}get backgroundColor(){return n(this,Gi)}get allowableContent(){return n(this,Ji)}get modOnly(){return n(this,zi)}get maxEmojis(){return n(this,$i)}get allowUserEdits(){return n(this,qi)}async delete(){return Ie.deleteFlairTemplate(n(this,Kt),n(this,ji),n(this,Ki))}async edit(e){return Ie.editFlairTemplate({id:n(this,Kt),subredditName:n(this,ji),text:e.text??n(this,Wi),allowableContent:e.allowableContent??n(this,Ji),backgroundColor:e.backgroundColor??n(this,Gi),maxEmojis:e.maxEmojis??n(this,$i),modOnly:e.modOnly??n(this,zi),textColor:e.textColor??n(this,Vi),allowUserEdits:e.allowUserEdits??n(this,qi)},n(this,Ki))}static async createPostFlairTemplate(e,t){var r;return h(r=Ie,Xi,Po).call(r,{...e,flairType:"LINK_FLAIR"},t)}static async createUserFlairTemplate(e,t){var r;return h(r=Ie,Xi,Po).call(r,{...e,flairType:"USER_FLAIR"},t)}static async editFlairTemplate(e,t){var r;return h(r=Ie,Xi,Po).call(r,e,t)}static async getPostFlairTemplates(e,t){return(await u.redditAPIPlugins.Flair.LinkFlair({subreddit:e},t)).flair?.map(o=>new Ie(o,e,t))||[]}static async getUserFlairTemplates(e,t){return(await u.redditAPIPlugins.Flair.UserFlair({subreddit:e},t)).flair?.map(o=>new Ie(o,e,t))||[]}static async deleteFlairTemplate(e,t,r){await u.redditAPIPlugins.Flair.DeleteFlairTemplate({subreddit:e,flairTemplateId:t},r)}};Kt=new WeakMap,ji=new WeakMap,Wi=new WeakMap,Vi=new WeakMap,Gi=new WeakMap,Ji=new WeakMap,zi=new WeakMap,$i=new WeakMap,qi=new WeakMap,Ki=new WeakMap,Xi=new WeakSet,Po=async function(e,t){let{subredditName:r,allowableContent:s="all",backgroundColor:o="transparent",flairType:a="",maxEmojis:c=10,modOnly:m=!1,text:y,textColor:v="dark",allowUserEdits:f=!1,id:S=""}=e;if(m&&f)throw new Error("Cannot have a mod only flair that is editable by users");let _=await u.redditAPIPlugins.Flair.FlairTemplate({subreddit:r,allowableContent:s,backgroundColor:o,flairType:a,maxEmojis:c,modOnly:m,text:y,textColor:v,textEditable:f,flairTemplateId:S,cssClass:"",overrideCss:!1},t);return new Ie(_,r,t)},l(Ie,Xi);var re=Ie;function mn(i){return{flairCssClass:i.flairCssClass,user:i.user,flairText:i.flairText}}var Me,$a,wc,qa,gt=class gt{static async getUserFlairBySubreddit(e,t){return u.redditAPIPlugins.Flair.FlairList(e,t)}static setUserFlair(e,t){var r;return h(r=gt,Me,$a).call(r,e,t)}static setUserFlairBatch(e,t,r){var s;return h(s=gt,Me,wc).call(s,e,t,r)}static setPostFlair(e,t){var r;return h(r=gt,Me,$a).call(r,{...e,postId:ae(e.postId)},t)}static async removePostFlair(e,t,r){var s;return h(s=gt,Me,qa).call(s,e,t,void 0,r)}static async removeUserFlair(e,t,r){var s;return h(s=gt,Me,qa).call(s,e,void 0,t,r)}};Me=new WeakSet,$a=async function(e,t){await u.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"},t)},wc=async function(e,t,r){if(!t.length)return[];if(t.length>100)throw new Error("Unexpected input: flairs array cannot be longer than 100 entries.");let o=",",a=t.map(y=>{for(let v in y)if(y[v]?.includes(o))throw new Error(`Unexpected input: ${v} cannot contain the "," character`);return[y.username,y.text||"",y.cssClass||""].join(o)}).join(`
4
+ `);return(await u.redditAPIPlugins.Flair.FlairCsv({subreddit:e,flairCsv:a},r)).result},qa=async function(e,t,r,s){await u.redditAPIPlugins.Flair.SelectFlair({subreddit:e,name:r??"",link:t??"",flairTemplateId:"",backgroundColor:"",text:"",textColor:"",cssClass:"",returnRtjson:"none"},s)},l(gt,Me);var ue=gt;function rg(i){if(p(i,"Flair text color is required"),i==="light"||i==="dark")return i;throw new Error(`Invalid flair text color: ${i}`)}function ng(i){if(!i||i.length===0||i==="transparent")return"transparent";if(/^#([A-Fa-f0-9]{6})$/.test(i))return i;throw new Error(`Invalid flair background color: ${i}`)}function sg(i){if(i==="all"||i==="text"||i==="emoji")return i;throw new Error(`Invalid allowable content: ${i}`)}import{Block as Ac,UIResponse as gg}from"@devvit/protos";var Za=dd(Ic(),1);var Xa=i=>"text"in i?i.text:pg(i.richtext),pg=i=>i instanceof zt?i.build():typeof i=="object"?JSON.stringify(i):i;var hg={NONE:0,BLOCKS:1,UNRECOGNIZED:-1},XC={UNKNOWN:0,VALID:1,FAILED:2},Zi,gn,Zt,hn,Qi,fn,yn,bn,Qt,vn,kn,Cn,Pn,Sn,wn,ht,Fn,xn,Yt,Yi,ft,er,tr,ir,yt,bt,vt,rr,kt,Ct,Pt,Ve,In,An,nr,sr,or,U,B=class B{constructor(e,t){l(this,Zi);l(this,gn);l(this,Zt);l(this,hn);l(this,Qi);l(this,fn);l(this,yn);l(this,bn);l(this,Qt);l(this,vn);l(this,kn);l(this,Cn);l(this,Pn);l(this,Sn);l(this,wn);l(this,ht);l(this,Fn);l(this,xn);l(this,Yt);l(this,Yi);l(this,ft);l(this,er);l(this,tr);l(this,ir);l(this,yt);l(this,bt);l(this,vt);l(this,rr);l(this,kt);l(this,Ct);l(this,Pt);l(this,Ve);l(this,In);l(this,An);l(this,nr);l(this,sr);l(this,or);l(this,U);X(this),p(e.id,"Post is missing id"),p(e.title,"Post is missing title"),p(e.createdUtc,"Post is missing created date"),p(e.author,"Post is missing author name"),p(e.subreddit,"Post is missing subreddit name"),p(e.subredditId,"Post is missing subreddit id"),p(e.url,"Post is missing url"),p(e.permalink,"Post is missing permalink"),d(this,Zi,ae(`t3_${e.id}`)),d(this,Zt,e.author),d(this,gn,e.authorFullname?ee(e.authorFullname):void 0),d(this,Qi,K(e.subredditId)),d(this,fn,e.subreddit),d(this,Cn,e.score??0),d(this,Pn,e.numComments??0),d(this,Sn,e.numReports??0);let r=new Date(0);r.setUTCSeconds(e.createdUtc),d(this,hn,r),d(this,bn,e.title),d(this,Qt,e.selftext),d(this,vn,e.selftextHtml),d(this,kn,e.url),d(this,yn,e.permalink),e.thumbnail&&e.thumbnail!=="self"&&e.thumbnail!=="nsfw"&&e.thumbnailHeight!=null&&e.thumbnailWidth!=null&&d(this,wn,{url:e.thumbnail,height:e.thumbnailHeight,width:e.thumbnailWidth}),d(this,ht,e.approved??!1),d(this,Fn,e.approvedAtUtc??0),d(this,xn,e.bannedAtUtc??0),d(this,ft,e.removed??!1),d(this,er,e.removedBy),d(this,tr,e.removedByCategory),d(this,Yt,e.spam??!1),d(this,Yi,e.stickied??!1),d(this,ir,e.archived??!1),d(this,yt,e.edited??!1),d(this,bt,e.locked??!1),d(this,vt,e.over18??!1),d(this,rr,e.quarantine??!1),d(this,kt,e.spoiler),d(this,Ct,e.hidden??!1),d(this,Pt,e.ignoreReports??!1),d(this,Ve,e.distinguished),d(this,An,e.secureMedia),d(this,nr,(e.modReports??[]).map(([s])=>s)),d(this,sr,(e.userReports??[]).map(([s])=>s)),d(this,U,t),(e.linkFlairBackgroundColor||e.linkFlairCssClass||e.linkFlairText||e.linkFlairType||e.linkFlairTemplateId||e.linkFlairRichtext||e.linkFlairTextColor)&&d(this,In,{backgroundColor:e.linkFlairBackgroundColor,cssClass:e.linkFlairCssClass,text:e.linkFlairText,type:e.linkFlairType,templateId:e.linkFlairTemplateId,richtext:(e.linkFlairRichtext??[]).map(({e:s,t:o,a,u:c})=>({elementType:s,text:o,emojiRef:a,url:c})),textColor:e.linkFlairTextColor}),e.gallery?d(this,or,e.gallery.map(s=>({status:s.status,url:s.url,height:s.height,width:s.width}))):d(this,or,[])}get id(){return n(this,Zi)}get authorId(){return n(this,gn)}get authorName(){return n(this,Zt)}get subredditId(){return n(this,Qi)}get subredditName(){return n(this,fn)}get permalink(){return n(this,yn)}get title(){return n(this,bn)}get body(){return n(this,Qt)}get bodyHtml(){return n(this,vn)}get url(){return n(this,kn)}get thumbnail(){return n(this,wn)}get createdAt(){return n(this,hn)}get score(){return n(this,Cn)}get numberOfComments(){return n(this,Pn)}get numberOfReports(){return n(this,Sn)}get approved(){return n(this,ht)}get approvedAtUtc(){return n(this,Fn)}get bannedAtUtc(){return n(this,xn)}get spam(){return n(this,Yt)}get stickied(){return n(this,Yi)}get removed(){return n(this,ft)}get removedBy(){return n(this,er)}get removedByCategory(){return n(this,tr)}get archived(){return n(this,ir)}get edited(){return n(this,yt)}get locked(){return n(this,bt)}get nsfw(){return n(this,vt)}get quarantined(){return n(this,rr)}get spoiler(){return n(this,kt)}get hidden(){return n(this,Ct)}get ignoringReports(){return n(this,Pt)}get distinguishedBy(){return n(this,Ve)}get comments(){return Q.getComments({postId:this.id},n(this,U))}get flair(){return n(this,In)}get secureMedia(){return n(this,An)}get userReportReasons(){return n(this,sr)}get modReportReasons(){return n(this,nr)}get gallery(){return n(this,or)}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:n(this,er),removedByCategory:n(this,tr),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:n(this,nr),userReportReasons:n(this,sr)}}isApproved(){return n(this,ht)}isSpam(){return n(this,Yt)}isStickied(){return n(this,Yi)}isRemoved(){return n(this,ft)}isArchived(){return n(this,ir)}isEdited(){return n(this,yt)}isLocked(){return n(this,bt)}isNsfw(){return n(this,vt)}isQuarantined(){return n(this,rr)}isSpoiler(){return n(this,kt)}isHidden(){return n(this,Ct)}isIgnoringReports(){return n(this,Pt)}isDistinguishedBy(){return n(this,Ve)}async edit(e){let t=await B.edit({id:this.id,...e},n(this,U));d(this,Qt,t.body),d(this,yt,t.edited)}async setSuggestedCommentSort(e){await B.setSuggestedCommentSort({id:this.id,subredditId:n(this,Qi),suggestedSort:e},n(this,U))}async setPostData(e){await B.setPostData({postId:this.id,postData:e},n(this,U))}async setCustomPostPreview(e){await B.setCustomPostPreview({id:this.id,ui:e},n(this,U))}async setTextFallback(e){let t=await B.setTextFallback(e,this.id,n(this,U));d(this,Qt,t.body),d(this,yt,t.edited)}async addComment(e){return Q.submit({id:this.id,...e},n(this,U))}async delete(){p(n(this,U));let e=n(this,U)?.[P.App]?.values[0];if(e!==n(this,Zt))throw new Error(`App '${e}' is not the author of Post ${this.id}, delete not allowed.`);return B.delete(this.id,n(this,U))}async approve(){await B.approve(this.id,n(this,U)),d(this,ht,!0),d(this,ft,!1)}async remove(e=!1){await B.remove(this.id,e,n(this,U)),d(this,ft,!0),d(this,Yt,e),d(this,ht,!1)}async lock(){await B.lock(this.id,n(this,U)),d(this,bt,!0)}async unlock(){await B.unlock(this.id,n(this,U)),d(this,bt,!1)}async hide(){await B.hide(this.id,n(this,U)),d(this,Ct,!0)}async unhide(){await B.unhide(this.id,n(this,U)),d(this,Ct,!1)}async markAsNsfw(){await B.markAsNsfw(this.id,n(this,U)),d(this,vt,!0)}async unmarkAsNsfw(){await B.unmarkAsNsfw(this.id,n(this,U)),d(this,vt,!1)}async markAsSpoiler(){await B.markAsSpoiler(this.id,n(this,U)),d(this,kt,!0)}async unmarkAsSpoiler(){await B.unmarkAsSpoiler(this.id,n(this,U)),d(this,kt,!1)}async sticky(e){await B.sticky(this.id,e,n(this,U))}async unsticky(){await B.unsticky(this.id,n(this,U))}async distinguish(){let{distinguishedBy:e}=await B.distinguish(this.id,!1,n(this,U));d(this,Ve,e)}async distinguishAsAdmin(){let{distinguishedBy:e}=await B.distinguish(this.id,!0,n(this,U));d(this,Ve,e)}async undistinguish(){let{distinguishedBy:e}=await B.undistinguish(this.id,n(this,U));d(this,Ve,e)}async ignoreReports(){await B.ignoreReports(this.id,n(this,U)),d(this,Pt,!0)}async unignoreReports(){await B.unignoreReports(this.id,n(this,U)),d(this,Pt,!1)}async getAuthor(){return C.getByUsername(n(this,Zt),n(this,U))}async crosspost(e){return B.crosspost({...e,postId:this.id},n(this,U))}addRemovalNote(e){return ve.addRemovalNote({itemIds:[n(this,Zi)],...e},n(this,U))}async getEnrichedThumbnail(){return fg({id:this.id},n(this,U))}static async getById(e,t){let r=u.redditAPIPlugins.LinksAndComments,s=Et(e)?e:`t3_${e}`,o=await r.Info({subreddits:[],thingIds:[s]},t);if(!o.data?.children?.length)throw new Error("could not find post");let a=o.data.children[0];if(!a?.data)throw new Error("could not find post");return new B(a.data,t)}static async submit(e,t){let{runAs:r="APP"}=e,s=he[r],o=s===he.USER?u.userActionsPlugin:u.redditAPIPlugins.LinksAndComments,a;if("preview"in e){p(t,"Missing metadata in `SubmitPostOptions`"),s===he.USER&&p(e.userGeneratedContent,"userGeneratedContent must be set in `SubmitPostOptions` when RunAs=USER for experience posts");let y=await new Le(()=>e.preview,void 0,{},t,void 0).buildBlocksUI(),v=Ac.encode(y).finish(),{textFallback:f,...S}=e,b=f?Xa(f):"",_=e.userGeneratedContent?{text:e.userGeneratedContent.text??"",imageUrls:e.userGeneratedContent.imageUrls??[]}:void 0,I=e.postData?{developerData:e.postData}:void 0,N={kind:"custom",sr:e.subredditName,richtextJson:(0,Za.fromByteArray)(v),richtextFallback:b,...S,userGeneratedContent:_,runAs:s,postData:I};a=await o.SubmitCustomPost(N,t)}else a=await o.Submit({kind:"kind"in e?e.kind:"url"in e?"link":"self",sr:e.subredditName,richtextJson:"richtext"in e?Li(e.richtext):void 0,...e,runAs:s},t);if("kind"in e&&["image","video","videogif"].includes(e.kind)&&!a.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(!a.json?.data?.id||a.json?.errors?.length)throw new Error(`failed to submit post - either post ID is empty or request failed with errors: ${a.json?.errors}`);return B.getById(`t3_${a.json.data.id}`,t)}static async crosspost(e,t){let{runAs:r="APP"}=e,s=he[r],o=s===he.USER?u.userActionsPlugin:u.redditAPIPlugins.LinksAndComments,{postId:a,subredditName:c,...m}=e,y=await o.Submit({kind:"crosspost",sr:c,crosspostFullname:ae(a),...m,runAs:s},t);if(!y.json?.data?.id||y.json?.errors?.length)throw new Error("failed to crosspost post");return B.getById(`t3_${y.json.data.id}`,t)}static async edit(e,t){let r=u.redditAPIPlugins.LinksAndComments,{id:s}=e,o;if("richtext"in e&&(o=Li(e.richtext)),(await r.EditUserText({thingId:s,text:"text"in e?e.text:"",richtextJson:o,runAs:he.APP},t)).json?.errors?.length)throw new Error("Failed to edit post");return B.getById(s,t)}static async setSuggestedCommentSort(e,t){if(!(await Y.query("SetSuggestedSort","cf6052acc7fefaa65b710625b81dba8041f258313aafe9730e2a3dc855e5d10d",{input:{subredditId:e.subredditId,postId:e.id,sort:e.suggestedSort}},t)).data?.setSuggestedSort?.ok)throw new Error("Failed to set suggested sort")}static async setPostData(e,t){let r=e.postData?{developerData:e.postData}:void 0,s=await u.redditAPIPlugins.LinksAndComments.EditCustomPost({thingId:e.postId,postData:r},t);if(s.json?.errors?.length)throw new Error(`Failed to set post data, errors: ${s.json?.errors}`)}static async setCustomPostPreview(e,t){if(!t)throw new Error("Failed to set custom post preview. Metadata not found");let r=u.redditAPIPlugins.LinksAndComments,s=new _t(e.ui),a=gg.fromJSON(await s.handle({events:[]},t)).blocks,c=(0,Za.fromByteArray)(Ac.encode(a).finish());await r.SetCustomPostPreview({thingId:e.id,bodyType:hg.BLOCKS,blocksRenderContent:c},t)}static async setTextFallback(e,t,r){if(!("text"in e)&&!("richtext"in e))throw new Error(`No text fallback provided for post ${t}.`);let s=u.redditAPIPlugins.LinksAndComments,o=Xa(e);if((await s.EditCustomPost({thingId:t,richtextFallback:o},r)).json?.errors?.length)throw new Error("Failed to set post text fallback");return B.getById(t,r)}static async delete(e,t){await u.redditAPIPlugins.LinksAndComments.Del({id:e},t)}static async approve(e,t){await u.redditAPIPlugins.Moderation.Approve({id:e},t)}static async remove(e,t=!1,r){await u.redditAPIPlugins.Moderation.Remove({id:e,spam:t},r)}static async hide(e,t){await u.redditAPIPlugins.LinksAndComments.Hide({id:e},t)}static async unhide(e,t){await u.redditAPIPlugins.LinksAndComments.Unhide({id:e},t)}static async markAsNsfw(e,t){await u.redditAPIPlugins.LinksAndComments.MarkNSFW({id:e},t)}static async unmarkAsNsfw(e,t){await u.redditAPIPlugins.LinksAndComments.UnmarkNSFW({id:e},t)}static async markAsSpoiler(e,t){await u.redditAPIPlugins.LinksAndComments.Spoiler({id:e},t)}static async unmarkAsSpoiler(e,t){await u.redditAPIPlugins.LinksAndComments.Unspoiler({id:e},t)}static async sticky(e,t,r){await u.redditAPIPlugins.LinksAndComments.SetSubredditSticky({id:e,state:!0,num:t},r)}static async unsticky(e,t){await u.redditAPIPlugins.LinksAndComments.SetSubredditSticky({id:e,state:!1},t)}static async lock(e,t){await u.redditAPIPlugins.LinksAndComments.Lock({id:e},t)}static async unlock(e,t){await u.redditAPIPlugins.LinksAndComments.Unlock({id:e},t)}static async distinguish(e,t,r){let a=(await u.redditAPIPlugins.Moderation.Distinguish({id:e,how:t?"admin":"yes",sticky:!1},r)).json?.data?.things?.[0]?.data;return p(a),{distinguishedBy:a.distinguished}}static async undistinguish(e,t){let o=(await u.redditAPIPlugins.Moderation.Distinguish({id:e,how:"no",sticky:!1},t)).json?.data?.things?.[0]?.data;return p(o),{distinguishedBy:o.distinguished}}static async ignoreReports(e,t){await u.redditAPIPlugins.Moderation.IgnoreReports({id:e},t)}static async unignoreReports(e,t){await u.redditAPIPlugins.Moderation.UnignoreReports({id:e},t)}static getControversialPosts(e={},t){return this.getSortedPosts({...e,sort:"controversial"},t)}static getTopPosts(e={},t){return this.getSortedPosts({...e,sort:"top"},t)}static getSortedPosts(e,t){let r=u.redditAPIPlugins.Listings;return new V({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,fetch:async s=>{let o=await r.Sort({show:"all",sort:e.sort,t:e.timeframe,subreddit:e.subredditName,...s},t);return pn(o,t)}})}static getHotPosts(e={location:"GLOBAL"},t){let r=u.redditAPIPlugins.Listings;return new V({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,fetch:async s=>{let o=await r.Hot({g:e.location,show:"all",subreddit:e.subredditName,...s},t);return pn(o,t)}})}static getNewPosts(e,t){let r=u.redditAPIPlugins.Listings;return new V({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,fetch:async s=>{let o=await r.New({show:"all",subreddit:e.subredditName,...s},t);return pn(o,t)}})}static getRisingPosts(e,t){let r=u.redditAPIPlugins.Listings;return new V({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,fetch:async s=>{let o=await r.Rising({show:"all",subreddit:e.subredditName,...s},t);return pn(o,t)}})}static getPostsByUser(e,t){let r=u.redditAPIPlugins.Users;return new V({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,async fetch(s){let o=await r.UserWhere({username:e.username,where:"submitted",...s},t);return pn(o,t)}})}};Zi=new WeakMap,gn=new WeakMap,Zt=new WeakMap,hn=new WeakMap,Qi=new WeakMap,fn=new WeakMap,yn=new WeakMap,bn=new WeakMap,Qt=new WeakMap,vn=new WeakMap,kn=new WeakMap,Cn=new WeakMap,Pn=new WeakMap,Sn=new WeakMap,wn=new WeakMap,ht=new WeakMap,Fn=new WeakMap,xn=new WeakMap,Yt=new WeakMap,Yi=new WeakMap,ft=new WeakMap,er=new WeakMap,tr=new WeakMap,ir=new WeakMap,yt=new WeakMap,bt=new WeakMap,vt=new WeakMap,rr=new WeakMap,kt=new WeakMap,Ct=new WeakMap,Pt=new WeakMap,Ve=new WeakMap,In=new WeakMap,An=new WeakMap,nr=new WeakMap,sr=new WeakMap,or=new WeakMap,U=new WeakMap;var G=B;function pn(i,e){if(!i.data?.children)throw new Error("Listing response is missing children");return{children:i.data.children.map(r=>new G(r.data,e)),before:i.data.before,after:i.data.after}}async function fg(i,e){let o=(await Y.query("GetThumbnailV2","81580ce4e23d748c5a59a1618489b559bf4518b6a73af41f345d8d074c8b2ce9",{id:i.id},e)).data?.postInfoById?.thumbnailV2;if(o){if(!o.image)return}else throw new Error("Failed to get thumbnail");return{attribution:o.attribution,image:{url:o.image.url,width:o.image.dimensions.width,height:o.image.dimensions.height},isObfuscatedDefault:o.isObfuscatedDefault,...o.obfuscatedImage&&{obfuscatedImage:{url:o.obfuscatedImage.url,width:o.obfuscatedImage.dimensions.width,height:o.obfuscatedImage.dimensions.height}}}}var yg=(H=>(H.Custom="CUSTOM",H.Reddit="REDDIT",H.Instagram="INSTAGRAM",H.Twitter="TWITTER",H.Tiktok="TIKTOK",H.Twitch="TWITCH",H.Facebook="FACEBOOK",H.Youtube="YOUTUBE",H.Tumblr="TUMBLR",H.Spotify="SPOTIFY",H.Soundcloud="SOUNDCLOUD",H.Beacons="BEACONS",H.Linktree="LINKTREE",H.Discord="DISCORD",H.Venmo="VENMO",H.CashApp="CASH_APP",H.Patreon="PATREON",H.Kofi="KOFI",H.Paypal="PAYPAL",H.Cameo="CAMEO",H.Onlyfans="ONLYFANS",H.Substack="SUBSTACK",H.Kickstarter="KICKSTARTER",H.Indiegogo="INDIEGOGO",H.BuyMeACoffee="BUY_ME_A_COFFEE",H.Shopify="SHOPIFY",H))(yg||{}),Tn,ar,En,Rn,On,Mn,Un,St,Dn,Bn,Nn,De,ei=class ei{constructor(e,t){l(this,Tn);l(this,ar);l(this,En);l(this,Rn);l(this,On);l(this,Mn);l(this,Un);l(this,St,new Map);l(this,Dn);l(this,Bn);l(this,Nn);l(this,De);X(this),p(e.id,"User ID is missing or undefined"),p(e.name,"Username is missing or undefined"),p(e.createdUtc,"User is missing created date"),d(this,Tn,ee(js(e.id)?e.id:`t2_${e.id}`)),d(this,ar,e.name),d(this,Mn,e.over18??!1),d(this,Un,e.isEmployee??!1);let r=new Date(0);if(r.setUTCSeconds(e.createdUtc),d(this,En,r),d(this,Rn,e.linkKarma??0),d(this,On,e.commentKarma??0),e.modPermissions)for(let[s,o]of Object.entries(e.modPermissions))n(this,St).set(s,Sc(o));d(this,Dn,new URL(e.subreddit?.url??"","https://www.reddit.com").toString()),d(this,Bn,e.subreddit?.url??""),d(this,Nn,e.hasVerifiedEmail??!1),d(this,De,t)}get id(){return n(this,Tn)}get username(){return n(this,ar)}get createdAt(){return n(this,En)}get linkKarma(){return n(this,Rn)}get commentKarma(){return n(this,On)}get nsfw(){return n(this,Mn)}get isAdmin(){return n(this,Un)}get modPermissions(){return n(this,St)}get url(){return n(this,Dn)}get permalink(){return n(this,Bn)}get hasVerifiedEmail(){return n(this,Nn)}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(n(this,St).has(e))return n(this,St).get(e);let t=await ei.getSubredditUsersByType({subredditName:e,type:"moderators",username:this.username},n(this,De)).all();if(t.length===0)return[];let r=t[0].modPermissions.get(e)??[];return r.length>0&&n(this,St).set(e,r),r}getComments(e){return Q.getCommentsByUser({username:this.username,...e},n(this,De))}getPosts(e){return G.getPostsByUser({username:this.username,...e},n(this,De))}async getUserFlairBySubreddit(e){let t=await ue.getUserFlairBySubreddit({subreddit:e,name:n(this,ar)},n(this,De));return t.users[0]?mn(t.users[0]):void 0}getSnoovatarUrl(){return ei.getSnoovatarUrl(this.username,n(this,De))}async getSocialLinks(){let r=await Y.query("GetUserSocialLinks","2aca18ef5f4fc75fb91cdaace3e9aeeae2cb3843b5c26ad511e6f01b8521593a",{name:this.username},n(this,De));return r.data?.user?.profile?.socialLinks?r.data.user.profile.socialLinks.map(s=>({...s,handle:s.handle??void 0})):[]}static async getById(e,t){let r=await Tc(e,t);return r==null?void 0:ei.getByUsername(r,t)}static async getByUsername(e,t){let r=u.redditAPIPlugins.Users;try{let s=await r.UserAbout({username:e},t);if(s.data?.id)return new ei(s.data,t)}catch(s){if(s instanceof Error&&s.message.includes("404 Not Found"))return;throw s}}static async getFromMetadata(e,t){p(t);let r=t?.[e]?.values[0];return r?ei.getById(ee(r),t):Promise.resolve(void 0)}static getSubredditUsersByType(e,t){let r=u.redditAPIPlugins.Subreddits;return new V({hasMore:!0,pageSize:e.pageSize,limit:e.limit,after:e.after,before:e.before,fetch:async s=>{let o=await r.AboutWhere({where:e.type,user:e.username,subreddit:e.subredditName,show:"all",...s},t);return vg(o,e.subredditName,t)}})}static async createRelationship(e,t){let r=u.redditAPIPlugins.Users,{type:s,subredditName:o,username:a,permissions:c,...m}=e,y=await r.Friend({type:s,subreddit:o,name:a,permissions:c?za(c):void 0,...m},t);if(y.json?.errors?.length)throw new Error(y.json.errors.join(`
5
+ `))}static async removeRelationship(e,t){await u.redditAPIPlugins.Users.Unfriend({type:e.type,subreddit:e.subredditName,name:e.username},t)}static async setModeratorPermissions(e,t,r,s){let a=await u.redditAPIPlugins.Users.SetPermissions({subreddit:t,name:e,type:"moderator",permissions:za(r)},s);if(a.json?.errors?.length)throw new Error(a.json.errors.join(`
6
+ `))}static async getSnoovatarUrl(e,t){return(await Y.query("GetSnoovatarUrlByName","c47fd42345af268616d2d8904b56856acdc05cf61d3650380f539ad7d596ac0c",{username:e},t)).data?.redditorInfoByName?.snoovatarIcon?.url}static getOverview(e,t){let r=u.redditAPIPlugins.Users;return new V({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,async fetch(s){let o=await r.UserWhere({username:e.username,where:"overview",...s},t);return bg(o,t)}})}};Tn=new WeakMap,ar=new WeakMap,En=new WeakMap,Rn=new WeakMap,On=new WeakMap,Mn=new WeakMap,Un=new WeakMap,St=new WeakMap,Dn=new WeakMap,Bn=new WeakMap,Nn=new WeakMap,De=new WeakMap;var C=ei;function bg(i,e){if(!i.data?.children)throw new Error("Listing response is missing children");return{children:i.data.children.map(r=>{if(r.kind==="t3")return new G(r.data,e);if(r.kind==="t1")return new Q(r.data,e);throw new Error(`Type ${r.kind} is not supported`)}),before:i.data.before,after:i.data.after}}async function vg(i,e,t){let r=u.redditAPIPlugins.Users;if(!i.data?.children)throw new Error("Listing response is missing children");let s=i.data.children.map(v=>(p(v.data?.id,"User id is still from listing data"),v.data.id)),o=100,a=[];for(let v=0;v<s.length;v+=o)a.push(s.slice(v,v+o));let m=(await Promise.all(a.map(v=>r.UserDataByAccountIds({ids:v.join(",")},t)))).reduce((v,f)=>({...v,...f.users}),{});return{children:i.data.children.map(v=>{let f=v.data?.id;p(f,"User id is missing from listing");let S=m[f];return p(S,"User data is missing from response"),new C({id:f,name:S.name,linkKarma:S.linkKarma,commentKarma:S.commentKarma,createdUtc:S.createdUtc,over18:S.profileOver18,snoovatarSize:[],modPermissions:{[e]:v.data?.modPermissions??[]}},t)}),before:i.data.before,after:i.data.after}}async function Tc(i,e){return(await u.redditAPIPlugins.Users.UserDataByAccountIds({ids:i},e))?.users?.[i]?.name}async function Ld(i){p(i);let e=i?.[P.Username]?.values[0];if(e)return e;let t=i?.[P.User]?.values[0];if(t)return Tc(t,i)}var ti,Ln,dr,lr,_n,Hn,ur,jn,Wn,cr,wt,Vn,Gn,ii,Ft,xt,Ge,ri,Je,Jn,zn,$n,qn,Kn,Xn,Zn,It,Z,Be,wo,Fo,W=class W{constructor(e,t){l(this,ti);l(this,Ln);l(this,dr);l(this,lr);l(this,_n);l(this,Hn);l(this,ur);l(this,jn);l(this,Wn);l(this,cr);l(this,wt);l(this,Vn);l(this,Gn);l(this,ii);l(this,Ft);l(this,xt);l(this,Ge);l(this,ri);l(this,Je);l(this,Jn);l(this,zn);l(this,$n);l(this,qn);l(this,Kn);l(this,Xn);l(this,Zn);l(this,It);l(this,Z);var s;X(this),p(e.id,"Comment id is null or undefined"),p(e.body,"Comment body is null or undefined"),p(e.createdUtc,"Comment is missing created date"),p(e.author,"Comment author is null or undefined"),p(e.parentId,"Comment parentId is null or undefined"),p(e.linkId,"Comment linkId is null or undefined"),p(e.permalink,"Comment permalink is null or undefined"),p(e.subreddit,"Comment is missing subreddit name"),p(e.subredditId,"Comment is missing subreddit id"),d(this,ti,fi(`t1_${e.id}`)),d(this,Ln,e.authorFullname?ee(e.authorFullname):void 0),d(this,dr,e.author),d(this,lr,e.body),d(this,jn,K(e.subredditId)),d(this,Wn,e.subreddit),d(this,Hn,$o(e.parentId)?fi(e.parentId):ae(e.parentId)),d(this,ur,ae(e.linkId)),d(this,ii,e.edited??!1),d(this,Ft,e.locked??!1),d(this,xt,e.removed??!1),d(this,Ge,e.stickied??!1),d(this,wt,e.approved??!1),d(this,Vn,e.approvedAtUtc??0),d(this,Gn,e.bannedAtUtc??0),d(this,ri,e.spam??!1),d(this,Je,e.distinguished),d(this,Jn,e.numReports??0),d(this,zn,e.collapsedBecauseCrowdControl??!1),d(this,$n,e.score??0),d(this,qn,e.permalink),d(this,Zn,new URL(e.permalink??"","https://www.reddit.com/").toString()),d(this,It,e.ignoreReports??!1),d(this,Kn,(e.modReports??[]).map(([o])=>o)),d(this,Xn,(e.userReports??[]).map(([o])=>o));let r=new Date(0);r.setUTCSeconds(e.createdUtc),d(this,_n,r),d(this,cr,h(s=W,Be,wo).call(s,{postId:n(this,ur),commentId:n(this,ti)},t)),d(this,Z,t)}get id(){return n(this,ti)}get authorId(){return n(this,Ln)}get authorName(){return n(this,dr)}get subredditId(){return n(this,jn)}get subredditName(){return n(this,Wn)}get body(){return n(this,lr)}get createdAt(){return n(this,_n)}get parentId(){return n(this,Hn)}get postId(){return n(this,ur)}get replies(){return n(this,cr)}get distinguishedBy(){return n(this,Je)}get locked(){return n(this,Ft)}get stickied(){return n(this,Ge)}get removed(){return n(this,xt)}get approved(){return n(this,wt)}get approvedAtUtc(){return n(this,Vn)}get bannedAtUtc(){return n(this,Gn)}get spam(){return n(this,ri)}get edited(){return n(this,ii)}get numReports(){return n(this,Jn)}get collapsedBecauseCrowdControl(){return n(this,zn)}get score(){return n(this,$n)}get permalink(){return n(this,qn)}get userReportReasons(){return n(this,Xn)}get modReportReasons(){return n(this,Kn)}get url(){return n(this,Zn)}get ignoringReports(){return n(this,It)}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 n(this,Ft)}isApproved(){return n(this,wt)}isRemoved(){return n(this,xt)}isSpam(){return n(this,ri)}isStickied(){return n(this,Ge)}isDistinguished(){return!!n(this,Je)}isEdited(){return n(this,ii)}isIgnoringReports(){return n(this,It)}async delete(){return W.delete(this.id,n(this,Z))}async edit(e){let t=await W.edit({id:this.id,...e},n(this,Z));return d(this,lr,t.body),d(this,ii,t.edited),this}async approve(){await W.approve(this.id,n(this,Z)),d(this,wt,!0),d(this,xt,!1)}async remove(e=!1){await W.remove(this.id,e,n(this,Z)),d(this,xt,!0),d(this,ri,e),d(this,wt,!1)}async lock(){await W.lock(this.id,n(this,Z)),d(this,Ft,!0)}async unlock(){await W.unlock(this.id,n(this,Z)),d(this,Ft,!1)}async reply(e){return W.submit({id:this.id,...e},n(this,Z))}async getAuthor(){return C.getByUsername(n(this,dr),n(this,Z))}async distinguish(e=!1){let{distinguishedBy:t,stickied:r}=await W.distinguish(this.id,e,!1,n(this,Z));d(this,Je,t),d(this,Ge,r)}async distinguishAsAdmin(e=!1){let{distinguishedBy:t,stickied:r}=await W.distinguish(this.id,e,!0,n(this,Z));d(this,Je,t),d(this,Ge,r)}async undistinguish(){let{distinguishedBy:e,stickied:t}=await W.undistinguish(this.id,n(this,Z));d(this,Je,e),d(this,Ge,t)}async ignoreReports(){await W.ignoreReports(this.id,n(this,Z)),d(this,It,!0)}async unignoreReports(){await W.unignoreReports(this.id,n(this,Z)),d(this,It,!1)}addRemovalNote(e){return ve.addRemovalNote({itemIds:[n(this,ti)],...e},n(this,Z))}static async getById(e,t){let r=u.redditAPIPlugins.LinksAndComments,s=Ye(e)?e:`t1_${e}`,o=await r.Info({subreddits:[],thingIds:[s]},t);if(!o.data?.children?.[0]?.data)throw new Error("not found");return new W(o.data.children[0].data,t)}static getComments(e,t){var a;let{postId:r,commentId:s,...o}=e;return h(a=W,Be,wo).call(a,{postId:ae(r),commentId:s?fi(s):void 0,...o},t)}static async edit(e,t){let r=u.redditAPIPlugins.LinksAndComments,{id:s}=e,o;"richtext"in e&&(o=Li(e.richtext));let a=await r.EditUserText({thingId:s,text:"text"in e?e.text:"",richtextJson:o,runAs:he.APP},t);if(a.json?.errors?.length)throw new Error("Failed to edit comment");let c=a.json?.data?.things?.[0]?.data;return p(c),new W(c,t)}static async delete(e,t){await u.redditAPIPlugins.LinksAndComments.Del({id:e},t)}static async approve(e,t){await u.redditAPIPlugins.Moderation.Approve({id:e},t)}static async remove(e,t=!1,r){await u.redditAPIPlugins.Moderation.Remove({id:e,spam:t},r)}static async lock(e,t){await u.redditAPIPlugins.LinksAndComments.Lock({id:e},t)}static async unlock(e,t){await u.redditAPIPlugins.LinksAndComments.Unlock({id:e},t)}static async submit(e,t){let{runAs:r="APP"}=e,s=he[r],o=s===he.USER?u.userActionsPlugin:u.redditAPIPlugins.LinksAndComments,{id:a}=e,c;"richtext"in e&&(c=Li(e.richtext));let m=await o.Comment({thingId:a,text:"text"in e?e.text:"",richtextJson:c,runAs:s},t);if(m.json?.errors?.length)throw new Error("failed to reply to comment");let y=m.json?.data?.things?.[0]?.data;return p(y),new W(y,t)}static async distinguish(e,t,r,s){let c=(await u.redditAPIPlugins.Moderation.Distinguish({id:e,how:r?"admin":"yes",sticky:t},s)).json?.data?.things?.[0]?.data;return p(c),{distinguishedBy:c.distinguished,stickied:!!c.stickied}}static async undistinguish(e,t){let o=(await u.redditAPIPlugins.Moderation.Distinguish({id:e,how:"no",sticky:!1},t)).json?.data?.things?.[0]?.data;return p(o),{distinguishedBy:o.distinguished,stickied:!!o.stickied}}static getCommentsByUser(e,t){let r=u.redditAPIPlugins.Users;return new V({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,async fetch(s){let o=await r.UserWhere({username:e.username,where:"comments",...s},t);return p(o.data,"Failed to get comments for user"),{children:o.data.children?.map(c=>new W(c.data,t))||[],before:o.data.before,after:o.data.after}}})}static async ignoreReports(e,t){await u.redditAPIPlugins.Moderation.IgnoreReports({id:e},t)}static async unignoreReports(e,t){await u.redditAPIPlugins.Moderation.UnignoreReports({id:e},t)}};ti=new WeakMap,Ln=new WeakMap,dr=new WeakMap,lr=new WeakMap,_n=new WeakMap,Hn=new WeakMap,ur=new WeakMap,jn=new WeakMap,Wn=new WeakMap,cr=new WeakMap,wt=new WeakMap,Vn=new WeakMap,Gn=new WeakMap,ii=new WeakMap,Ft=new WeakMap,xt=new WeakMap,Ge=new WeakMap,ri=new WeakMap,Je=new WeakMap,Jn=new WeakMap,zn=new WeakMap,$n=new WeakMap,qn=new WeakMap,Kn=new WeakMap,Xn=new WeakMap,Zn=new WeakMap,It=new WeakMap,Z=new WeakMap,Be=new WeakSet,wo=function(e,t,r=0){return new V({limit:e.limit,pageSize:e.pageSize,fetch:async s=>{var S,b;let o=s.limit,a=u.redditAPIPlugins.Listings,c=u.redditAPIPlugins.LinksAndComments,m=e.commentId;if(s.more)if(s.more.children.length){let _=s.more;(!o||o>100)&&(o=100);let I=_.children.splice(0,o),N=await c.MoreChildren({linkId:e.postId,children:I,sort:e.sort},t);if(!N.json?.data?.things?.length)return{children:[]};let{children:D}=h(S=W,Be,Fo).call(S,N.json.data.things,e.postId,e,t);return{children:D,more:_.children.length?_:void 0}}else m=s.more.parentId,r=r+s.more.depth;let v=(await a.Comments({article:e.postId.substring(3),comment:m?.substring(3),limit:o,depth:e.depth,sort:e.sort},t)).listings?.[1]?.data?.children??[],f=v[0];return m&&f?.data?.replyList?.data&&(v=f.data.replyList.data.children),h(b=W,Be,Fo).call(b,v,m??e.postId,e,t,r)}})},Fo=function(e,t,r,s,o=0){var y,v;let a=[],c,m={};for(let f of e){if(!f.data||(f.data.depth!=null&&(f.data.depth=f.data.depth+o),f.data.depth!=null&&r.depth!=null&&f.data.depth>=r.depth))continue;let S=f.data.parentId?m[f.data.parentId]:void 0;if(f.kind==="t1"){if(f.data.name===t)continue;let b=new W(f.data,s);if(m[b.id]=b,d(b,cr,h(y=W,Be,wo).call(y,{...r,postId:b.postId,commentId:b.id},s,o)),"replyList"in f.data&&f.data.replyList?.data){let{children:_,more:I}=h(v=W,Be,Fo).call(v,f.data.replyList.data.children,b.id,r,s,o);_.length&&b.replies.children.push(..._),I&&b.replies.setMore(I)}b.replies.preventInitialFetch(),S?S.replies.children.push(b):a.push(b)}else if(f.kind==="more"&&f.data.parentId&&f.data.depth!=null){let b={parentId:$o(f.data.parentId)?fi(f.data.parentId):ae(f.data.parentId),children:f.data.children??[],depth:f.data.depth};S?S.replies.setMore(b):b.parentId===t&&(c=b)}}return{children:a,more:c}},l(W,Be);var Q=W;function Ws(i,e){let t=u.redditAPIPlugins.Moderation;return new V({hasMore:!0,after:i.after,before:i.before,limit:i.limit,pageSize:i.pageSize,fetch:async r=>{let s=await t.AboutLog({subreddit:i.subredditName,mod:i.moderatorUsernames?i.moderatorUsernames.join(","):void 0,type:i.type,...r},e);return kg(s)}})}function kg(i){if(!i.data?.children)throw new Error("AboutLogResponse is missing children");return{children:i.data.children.map(t=>{if(!t.data)throw new Error("ModAction from AboutLogResponse is missing or invalid");let{id:r,mod:s,modId36:o,createdUtc:a,subreddit:c,subredditNamePrefixed:m,action:y,srId36:v,description:f,details:S,targetAuthor:b,targetBody:_,targetFullname:I,targetPermalink:N,targetTitle:D}=t.data;p(r,"ModAction from AboutLogResponse is missing id"),p(s,"ModAction from AboutLogResponse is missing mod"),p(o,"ModAction from AboutLogResponse is missing modId36"),p(a,"ModAction from AboutLogResponse is missing createdUtc"),p(c,"ModAction from AboutLogResponse is missing subreddit"),p(m,"ModAction from AboutLogResponse is missing subredditNamePrefixed"),p(y,"ModAction from AboutLogResponse is missing action"),p(v,"ModAction from AboutLogResponse is missing srId36");let si=new Date(0);return si.setUTCSeconds(a),{id:r,type:y,moderatorName:s,moderatorId:`t2_${o}`,createdAt:si,subredditName:c,subredditId:`t5_${v}`,description:f,details:S,target:I?{id:I,author:b,body:_,permalink:N,title:D}:void 0}}),after:i.data.after,before:i.data.before}}import"@devvit/protos";var Cg=(a=>(a.New="New",a.InProgress="InProgress",a.Archived="Archived",a.Appeals="Appeals",a.JoinRequests="JoinRequests",a.Filtered="Filtered",a))(Cg||{}),Pg={0:"New",1:"InProgress",2:"Archived",3:"Appeals",4:"JoinRequests",5:"Filtered"},Sg=(b=>(b.Highlighted="Highlighted",b.Unhighlighted="Unhighlighted",b.Archived="Archived",b.Unarchived="Unarchived",b.ReportedToAdmins="ReportedToAdmins",b.Muted="Muted",b.Unmuted="Unmuted",b.Banned="Banned",b.Unbanned="Unbanned",b.Approved="Approved",b.Disapproved="Disapproved",b.Filtered="Filtered",b.Unfiltered="Unfiltered",b))(Sg||{}),wg={0:"Highlighted",1:"Unhighlighted",2:"Archived",3:"Unarchived",4:"ReportedToAdmins",5:"Muted",6:"Unmuted",7:"Banned",8:"Unbanned",9:"Approved",10:"Disapproved",11:"Filtered",12:"Unfiltered"},L,J,ie,Ec,Rc,Vs=class{constructor(e){l(this,J);l(this,L);this.notificationSubjectPrefix="[notification]";d(this,L,e)}async bulkReadConversations(e,t){let r=u.redditAPIPlugins.NewModmail,{conversationIds:s}=await r.BulkReadConversations({entity:e.join(","),state:t},n(this,L));return s}async getConversations(e){let r=await u.redditAPIPlugins.NewModmail.GetConversations({after:e.after,entity:e.subreddits?e.subreddits.join(","):void 0,limit:e.limit,sort:e.sort,state:e.state},n(this,L)),s={};for(let o in r.conversations)s[o]=h(this,J,ie).call(this,{protoConversation:r.conversations[o],protoMessages:r.messages,protoModActions:{}});return{conversations:s,viewerId:r.viewerId,conversationIds:r.conversationIds}}async getConversation(e){let r=await u.redditAPIPlugins.NewModmail.GetConversation({...e,markRead:!!e.markRead},n(this,L));return{participantSubreddit:r.participantSubreddit,conversation:h(this,J,ie).call(this,{protoConversation:r.conversation,protoMessages:r.messages,protoModActions:r.modActions}),user:r.user}}async getSubreddits(){let e=u.redditAPIPlugins.NewModmail,{subreddits:t}=await e.Subreddits({},n(this,L));return t}async createConversation(e){let r=await u.redditAPIPlugins.NewModmail.CreateConversation({body:e.body,isAuthorHidden:e.isAuthorHidden??!1,srName:e.subredditName,subject:e.subject,to:e.to?e.to:void 0},n(this,L));return{conversation:h(this,J,ie).call(this,{protoConversation:r.conversation,protoMessages:r.messages,protoModActions:r.modActions}),user:r.user}}async createModDiscussionConversation(e){return Qa({subject:e.subject,bodyMarkdown:e.bodyMarkdown,subredditId:K(e.subredditId),isInternal:!0,participantType:"MODERATOR",conversationType:"INTERNAL"},n(this,L))}async createModInboxConversation(e){return Qa({subject:e.subject,bodyMarkdown:e.bodyMarkdown,subredditId:K(e.subredditId),isInternal:!1,participantType:"PARTICIPANT_USER",conversationType:"SR_USER"},n(this,L))}async createModNotification(e){let t=e.subject;return e.subject.startsWith(this.notificationSubjectPrefix)||(t=`${this.notificationSubjectPrefix} ${e.subject}`),Qa({subject:t,bodyMarkdown:e.bodyMarkdown,subredditId:K(e.subredditId),isInternal:!1,participantType:"PARTICIPANT_USER",conversationType:"SR_USER"},n(this,L))}async reply(e){let r=await u.redditAPIPlugins.NewModmail.CreateConversationMessage({body:e.body,conversationId:e.conversationId,isAuthorHidden:e.isAuthorHidden??!1,isInternal:e.isInternal??!1},n(this,L));return{conversation:h(this,J,ie).call(this,{protoConversation:r.conversation,protoMessages:r.messages,protoModActions:{}}),user:r.user}}async highlightConversation(e){let r=await u.redditAPIPlugins.NewModmail.HighlightConversation({conversationId:e},n(this,L));return{conversation:h(this,J,ie).call(this,{protoConversation:r.conversation,protoMessages:r.messages,protoModActions:r.modActions})}}async unhighlightConversation(e){let r=await u.redditAPIPlugins.NewModmail.UnhighlightConversation({conversationId:e},n(this,L));return{conversation:h(this,J,ie).call(this,{protoConversation:r.conversation,protoMessages:r.messages,protoModActions:r.modActions})}}async archiveConversation(e){let r=await u.redditAPIPlugins.NewModmail.ArchiveConversation({conversationId:e},n(this,L));return{conversation:h(this,J,ie).call(this,{protoConversation:r.conversation,protoMessages:r.messages,protoModActions:r.modActions})}}async unarchiveConversation(e){let r=await u.redditAPIPlugins.NewModmail.UnarchiveConversation({conversationId:e},n(this,L));return{conversation:h(this,J,ie).call(this,{protoConversation:r.conversation,protoMessages:r.messages,protoModActions:r.modActions})}}async muteConversation(e){let r=await u.redditAPIPlugins.NewModmail.MuteConversation({conversationId:e.conversationId,numHours:e.numHours},n(this,L));return{conversation:h(this,J,ie).call(this,{protoConversation:r.conversations,protoMessages:r.messages,protoModActions:r.modActions}),user:r.user}}async unmuteConversation(e){let r=await u.redditAPIPlugins.NewModmail.UnmuteConversation({conversationId:e},n(this,L));return{conversation:h(this,J,ie).call(this,{protoConversation:r.conversations,protoMessages:r.messages,protoModActions:r.modActions}),user:r.user}}async readConversations(e){await u.redditAPIPlugins.NewModmail.Read({conversationIds:e.join(",")},n(this,L))}async unreadConversations(e){await u.redditAPIPlugins.NewModmail.Unread({conversationIds:e.join(",")},n(this,L))}async approveConversation(e){let r=await u.redditAPIPlugins.NewModmail.ApproveConversation({conversationId:e},n(this,L));return{conversation:h(this,J,ie).call(this,{protoConversation:r.conversations,protoMessages:r.messages,protoModActions:r.modActions}),user:r.user}}async disapproveConversation(e){let r=await u.redditAPIPlugins.NewModmail.DisapproveConversation({conversationId:e},n(this,L));return{conversation:h(this,J,ie).call(this,{protoConversation:r.conversations,protoMessages:r.messages,protoModActions:r.modActions}),user:r.user}}async tempBanConversation(e){let r=await u.redditAPIPlugins.NewModmail.TempBan({...e},n(this,L));return{conversation:h(this,J,ie).call(this,{protoConversation:r.conversations,protoMessages:r.messages,protoModActions:r.modActions}),user:r.user}}async unbanConversation(e){let r=await u.redditAPIPlugins.NewModmail.Unban({conversationId:e},n(this,L));return{conversation:h(this,J,ie).call(this,{protoConversation:r.conversations,protoMessages:r.messages,protoModActions:r.modActions}),user:r.user}}async getUnreadCount(){return await u.redditAPIPlugins.NewModmail.UnreadCount({},n(this,L))}async getUserConversations(e){return await u.redditAPIPlugins.NewModmail.UserConversations({conversationId:e},n(this,L))}};L=new WeakMap,J=new WeakSet,ie=function({protoConversation:e,protoMessages:t,protoModActions:r}){return{...e,state:Pg[e.state],messages:h(this,J,Ec).call(this,e,t),modActions:h(this,J,Rc).call(this,e,r)}},Ec=function(e,t){let r={},s=e.objIds.filter(o=>o.key==="messages").map(({id:o})=>o);for(let o of s){let a=t[o];a&&(r[o]=a)}return r},Rc=function(e,t){let r={},s=e.objIds.filter(o=>o.key==="modActions").map(({id:o})=>o);for(let o of s){let a=t[o];a&&(r[o]={...a,actionType:wg[a.actionTypeId]})}return r};async function Qa(i,e){let t=e[P.AppUser]?.values[0],o=await Y.query("CreateModmailConversation","5f9ae20b0c7bdffcafb80241728a72e67cd4239bc09f67284b79d4aa706ee0e5",{subject:i.subject,bodyMarkdown:i.bodyMarkdown,subredditId:i.subredditId,authorId:t,isInternal:i.isInternal,participantType:i.participantType,conversationType:i.conversationType},e);if(o.data?.createModmailConversationV2?.ok)return o.data?.createModmailConversationV2?.conversationId;throw new Error("modmail conversation creation failed; ${response.data?.createModmailConversationV2?.errors[0].message}")}var mr,pr,Qn,Yn,es,ts,Ya=class Ya{constructor(e,t){l(this,mr);l(this,pr);l(this,Qn);l(this,Yn);l(this,es);l(this,ts);if(X(this),p(e.id,"PrivateMessage: Invalid data, no id"),p(e.name,"PrivateMessage: Invalid data, no name"),p(e.created,"PrivateMessage: Invalid data, no created date"),d(this,mr,be(e.name)),e.author!=null)d(this,pr,{type:"user",username:e.author,id:e.authorFullname?ee(e.authorFullname):void 0});else if(e.subreddit!=null)d(this,pr,{type:"subreddit",name:e.subreddit,id:e.subredditId?K(e.subredditId):void 0});else throw new Error("PrivateMessage: Invalid data, no author or subreddit");d(this,Qn,e.body??""),d(this,Yn,e.bodyHtml??"");let r=new Date(0);r.setUTCSeconds(e.createdUtc),d(this,es,r),d(this,ts,t)}static async getMessages(e,t){let r=u.redditAPIPlugins.PrivateMessages;return new V({...e,fetch:async s=>{let o=await r.MessageWhere({...s,where:e.type??"inbox"},t);return{after:o.data?.after,before:o.data?.before,children:o.data?.children?.map(a=>new Ya(a.data,t)).filter(Boolean)||[]}}})}static async send({to:e,subject:t,text:r},s){await u.redditAPIPlugins.PrivateMessages.Compose({to:e,subject:t,text:r,fromSr:""},s)}static async sendAsSubreddit({to:e,fromSubredditName:t,subject:r,text:s},o){await u.redditAPIPlugins.PrivateMessages.Compose({to:e,fromSr:t,subject:r,text:s},o)}static async markAllAsRead(e){await u.redditAPIPlugins.PrivateMessages.ReadAllMessages({filterTypes:""},e)}get id(){return n(this,mr)}get from(){return n(this,pr)}get body(){return n(this,Qn)}get bodyHtml(){return n(this,Yn)}get created(){return n(this,es)}async markAsRead(){await u.redditAPIPlugins.PrivateMessages.ReadMessage({id:n(this,mr)},n(this,ts))}};mr=new WeakMap,pr=new WeakMap,Qn=new WeakMap,Yn=new WeakMap,es=new WeakMap,ts=new WeakMap;var Rt=Ya;var _d=(o=>(o.Reports="reports",o.Spam="spam",o.Modqueue="modqueue",o.Unmoderated="unmoderated",o.Edited="edited",o))(_d||{}),Oc=class{},Mc=class{},Uc=class{},Dc=class{},gr,x,is,rs,ns,ss,os,as,ds,ls,us,hr,R,Ae=class Ae{constructor(e,t){l(this,gr);l(this,x);l(this,is);l(this,rs);l(this,ns);l(this,ss);l(this,os);l(this,as);l(this,ds);l(this,ls);l(this,us);l(this,hr);l(this,R);X(this),p(e.id,"Subreddit id is missing or undefined"),p(e.displayName,"Subreddit name is missing or undefined"),d(this,gr,K(`t5_${e.id}`)),d(this,x,e.displayName),p(e.createdUtc,"Subreddit is missing created date");let r=new Date(0);r.setUTCSeconds(e.createdUtc),d(this,is,r),d(this,rs,Fg(e.subredditType)),d(this,ns,e.title),d(this,ss,e.description),p(e.lang,"Subreddit is missing language"),d(this,os,e.lang),d(this,as,e.subscribers??0),d(this,ds,e.activeUserCount??0),d(this,ls,e.over18??!1),d(this,hr,e.url??""),d(this,us,{acceptFollowers:e.acceptFollowers??!1,allOriginalContent:e.allOriginalContent??!1,allowChatPostCreation:e.allowChatPostCreation??!1,allowDiscovery:e.allowDiscovery??!1,allowGalleries:e.allowGalleries??!1,allowImages:e.allowImages??!1,allowPolls:e.allowPolls??!1,allowPredictionContributors:e.allowPredictionContributors??!1,allowPredictions:e.allowPredictions??!1,allowPredictionsTournament:e.allowPredictionsTournament??!1,allowTalks:e.allowTalks??!1,allowVideoGifs:e.allowVideogifs??!1,allowVideos:e.allowVideos??!1,chatPostEnabled:e.isChatPostFeatureEnabled??!1,collectionsEnabled:e.collectionsEnabled??!1,crosspostable:e.isCrosspostableSubreddit??!1,emojisEnabled:e.emojisEnabled??!1,eventPostsEnabled:e.eventPostsEnabled??!1,linkFlairEnabled:e.linkFlairEnabled??!1,originalContentTagEnabled:e.originalContentTagEnabled??!1,restrictCommenting:e.restrictCommenting??!1,restrictPosting:e.restrictPosting??!1,shouldArchivePosts:e.shouldArchivePosts??!1,spoilersEnabled:e.spoilersEnabled??!1,wikiEnabled:e.wikiEnabled??!1,allowedPostType:xg(e.submissionType),allowedMediaInComments:(e.allowedMediaInComments??[]).map(Ig),bannerBackgroundColor:e.bannerBackgroundColor,bannerBackgroundImage:e.bannerBackgroundImage,bannerImage:e.bannerImg,communityIcon:e.communityIcon,headerTitle:e.headerTitle,keyColor:e.keyColor,mobileBannerImage:e.mobileBannerImage,primaryColor:e.primaryColor,userFlairs:{enabled:e.userFlairEnabledInSr??!1,usersCanAssign:e.canAssignUserFlair??!1,userFlairBackgroundColor:e.userFlairBackgroundColor,userFlairTextColor:e.userFlairTextColor},postFlairs:{enabled:e.linkFlairEnabled??!1,usersCanAssign:e.canAssignLinkFlair??!1},url:new URL(n(this,hr),"https://www.reddit.com").toString()}),d(this,R,t)}get id(){return n(this,gr)}get name(){return n(this,x)}get createdAt(){return n(this,is)}get type(){return n(this,rs)}get title(){return n(this,ns)}get description(){return n(this,ss)}get language(){return n(this,os)}get numberOfSubscribers(){return n(this,as)}get numberOfActiveUsers(){return n(this,ds)}get nsfw(){return n(this,ls)}get settings(){return n(this,us)}get userFlairsEnabled(){return this.settings.userFlairs.enabled}get postFlairsEnabled(){return this.settings.postFlairs.enabled}get usersCanAssignUserFlairs(){return this.settings.userFlairs.usersCanAssign}get usersCanAssignPostFlairs(){return this.settings.postFlairs.usersCanAssign}get url(){return this.settings.url}get permalink(){return n(this,hr)}toJSON(){return{id:this.id,name:this.name,createdAt:this.createdAt,type:this.type,title:this.title,description:this.description,language:this.language,nsfw:this.nsfw,numberOfSubscribers:this.numberOfSubscribers,numberOfActiveUsers:this.numberOfActiveUsers,settings:this.settings}}async submitPost(e){let t={...e,subredditName:n(this,x)};return G.submit(t,n(this,R))}getControversialPosts(e={}){if(!n(this,x))throw new Error("subreddit missing displayName - it might not have been fetched");return G.getControversialPosts({...e,subredditName:n(this,x)},n(this,R))}getTopPosts(e={}){if(!n(this,x))throw new Error("subreddit missing displayName - it might not have been fetched");return G.getTopPosts({...e,subredditName:n(this,x)},n(this,R))}getApprovedUsers(e={}){return C.getSubredditUsersByType({type:"contributors",subredditName:n(this,x),...e},n(this,R))}approveUser(e){return C.createRelationship({username:e,subredditName:n(this,x),type:"contributor"},n(this,R))}removeUser(e){return C.removeRelationship({username:e,subredditName:n(this,x),type:"contributor"},n(this,R))}getWikiContributors(e={}){return C.getSubredditUsersByType({type:"wikicontributors",subredditName:n(this,x),...e},n(this,R))}addWikiContributor(e){return C.createRelationship({username:e,subredditName:n(this,x),type:"wikicontributor"},n(this,R))}removeWikiContributor(e){return C.removeRelationship({username:e,subredditName:n(this,x),type:"wikicontributor"},n(this,R))}getBannedUsers(e={}){return C.getSubredditUsersByType({type:"banned",subredditName:n(this,x),...e},n(this,R))}banUser(e){return C.createRelationship({username:e.username,subredditName:n(this,x),type:"banned",banReason:e.reason,banMessage:e.message,note:e.note,duration:e.duration,banContext:e.context},n(this,R))}unbanUser(e){return C.removeRelationship({username:e,subredditName:n(this,x),type:"banned"},n(this,R))}getBannedWikiContributors(e={}){return C.getSubredditUsersByType({type:"wikibanned",subredditName:n(this,x),...e},n(this,R))}banWikiContributor(e){return C.createRelationship({username:e.username,subredditName:n(this,x),type:"wikibanned",banReason:e.reason,note:e.note,duration:e.duration},n(this,R))}unbanWikiContributor(e){return C.removeRelationship({username:e,subredditName:n(this,x),type:"wikibanned"},n(this,R))}getModerators(e={}){return C.getSubredditUsersByType({type:"moderators",subredditName:n(this,x),...e},n(this,R))}inviteModerator(e,t){return C.createRelationship({type:"moderator_invite",subredditName:n(this,x),username:e,permissions:t??[]},n(this,R))}revokeModeratorInvite(e){return C.removeRelationship({username:e,subredditName:n(this,x),type:"moderator_invite"},n(this,R))}removeModerator(e){return C.removeRelationship({type:"moderator",subredditName:n(this,x),username:e},n(this,R))}setModeratorPermissions(e,t){return C.setModeratorPermissions(e,n(this,x),t,n(this,R))}getMutedUsers(e={}){return C.getSubredditUsersByType({type:"muted",subredditName:n(this,x),...e},n(this,R))}muteUser(e,t){return C.createRelationship({username:e,subredditName:n(this,x),type:"muted",note:t},n(this,R))}unmuteUser(e){return C.removeRelationship({username:e,subredditName:n(this,x),type:"muted"},n(this,R))}getModerationLog(e){return Ws({subredditName:n(this,x),...e},n(this,R))}getUserFlairTemplates(){return re.getUserFlairTemplates(n(this,x),n(this,R))}getPostFlairTemplates(){return re.getPostFlairTemplates(n(this,x),n(this,R))}createPostFlairTemplate(e){return re.createPostFlairTemplate({subredditName:n(this,x),...e},n(this,R))}createUserFlairTemplate(e){return re.createUserFlairTemplate({subredditName:n(this,x),...e},n(this,R))}async getUserFlair(e){if(e?.usernames!==void 0)return{users:await Promise.all(e.usernames.map(async r=>{let s=await ue.getUserFlairBySubreddit({subreddit:n(this,x),name:r},n(this,R));return mn(s.users[0])}))};{let t=await ue.getUserFlairBySubreddit({...e,subreddit:n(this,x)},n(this,R));return{next:t.next,prev:t.prev,users:t.users.map(r=>mn(r))}}}getModQueue(e={type:"all"}){return Ae.aboutLocation({...e,location:"modqueue",subreddit:n(this,x)},n(this,R))}getReports(e={type:"all"}){return Ae.aboutLocation({...e,location:"reports",subreddit:n(this,x)},n(this,R))}getSpam(e={type:"all"}){return Ae.aboutLocation({...e,location:"spam",subreddit:n(this,x)},n(this,R))}getUnmoderated(e={type:"all"}){return Ae.aboutLocation({...e,location:"unmoderated",subreddit:n(this,x)},n(this,R))}getEdited(e={type:"all"}){return Ae.aboutLocation({...e,location:"edited",subreddit:n(this,x)},n(this,R))}static aboutLocation(e,t){let r=u.redditAPIPlugins.Moderation,s;switch(e.type){case"post":s="links";break;case"comment":s="comments";break;default:s=void 0}return new V({...e,fetch:async o=>{let a=await r.AboutLocation({...o,...e,only:s},t);return Bc(a,t)}})}getCommentsAndPostsByIds(e){let t=u.redditAPIPlugins.LinksAndComments;return new V({fetch:async()=>{let r=await t.Info({thingIds:e,subreddits:[n(this,gr)]},n(this,R));return Bc(r,n(this,R))}})}static async addRemovalReason(e,t,r,s){return(await u.redditAPIPlugins.Subreddits.SubredditAddRemovalReason({title:t,message:r,subreddit:e},s)).id}static async getRemovalReasons(e,t){let s=await u.redditAPIPlugins.Subreddits.SubredditGetRemovalReasons({subreddit:e},t);return s.order.map(o=>({...s.data[o]}))}static async getFromMetadata(e){p(e);let t=e?.[P.SubredditName]?.values[0];if(t)return Ae.getByName(t,e);let r=e?.[P.Subreddit]?.values[0];return p(r),Ae.getById(K(r),e)}static async getById(e,t){let r=await qo(e,t);if(r)return Ae.getByName(r,t)}static async getByName(e,t){let s=await u.redditAPIPlugins.Subreddits.SubredditAbout({subreddit:e},t);if(!s?.data)throw new Error("not found");return new Ae(s.data,t)}};gr=new WeakMap,x=new WeakMap,is=new WeakMap,rs=new WeakMap,ns=new WeakMap,ss=new WeakMap,os=new WeakMap,as=new WeakMap,ds=new WeakMap,ls=new WeakMap,us=new WeakMap,hr=new WeakMap,R=new WeakMap;var de=Ae;async function Hd(i,e){let o=(await Y.query("GetSubredditInfoById","315a9b75c22a017d526afdf2d274616946156451aacfd56dfb91e7ad3f7a2fde",{id:i},e)).data?.subredditInfoById;if(!o)throw new Error("subreddit info not found");return o}async function jd(i,e){let o=(await Y.query("GetSubredditInfoByName","4aa69726c7e3f5d33ab2bee22b3d74fce645824fddd5ea3ec6dfe30bdb4295cb",{name:i},e)).data?.subredditInfoByName;if(!o)throw new Error("subreddit info not found");return o}async function Wd(i,e){let o=(await Y.query("GetSubredditLeaderboard","18ead70c46b6446d45ecd8b679b16d9a929a933d6ef25d8262a459cb18b72848",{id:i},e)).data?.subredditInfoById?.leaderboard;if(!o)throw new Error("subreddit leaderboard not found");if(!o.summary)throw new Error("subreddit leaderboard summary not found");return{id:o.id,summary:o.summary}}async function Vd(i,e){let o=(await Y.query("GetSubredditStyles","d491d17ea8858f563ea578b26b9595d64adecf4bf34557d567c7e53c470f5f22",{id:i},e)).data?.subredditInfoById?.styles;if(!o)throw new Error("subreddit styles not found");return o}function Fg(i){if(i==="public"||i==="private"||i==="restricted"||i==="employees_only"||i==="gold_only"||i==="gold_restricted"||i==="archived"||i==="user")return i;throw new Error(`invalid subreddit type: ${i}`)}function xg(i){if(i==="any"||i==="link"||i==="self")return i;throw new Error(`invalid allowed post type: ${i}`)}function Ig(i){if(i==="animated"||i==="giphy"||i==="static"||i==="expression")return i;throw new Error(`invalid comment media type: ${i}`)}function Bc(i,e){let r=(i.data?.children??[]).map(a=>{let c=s(a);if(c!=null)return c;let m=o(a);return m??null}).filter(Boolean);return{after:i.data?.after,before:i.data?.before,children:r};function s(a){try{return new G(a.data,e)}catch{return null}}function o(a){try{return new Q(a.data,e)}catch{return null}}}async function qo(i,e){return(await u.redditAPIPlugins.LinksAndComments.Info({thingIds:[i],subreddits:[]},e)).data?.children[0]?.data?.displayName}async function Gd(i,e){return Nc("GetVaultContactByAddress","3e2f7966a5c120e64fd2795d06a46595c52d988185be98d3ed71c3f81ae80d2e",{provider:"ethereum",address:i},e)}async function Jd(i,e){return Nc("GetVaultContactByUserId","a854ddc19d0e22c4f36ed917fdbd568f299f3571427e393aee5e2972080fffe9",{provider:"ethereum",userId:i},e)}async function Nc(i,e,t,r){let o=(await Y.query(i,e,t,r))?.data?.vault?.contact;return{provider:o?.provider,userId:ee(o?.userId),address:o?.address,createdAt:o?.createdAt,isActive:o?.isActive}}import{CommunityListWidget_CommunityData as Ag,GetWidgetsResponse_WidgetItem as oe}from"@devvit/protos";var cs,ms,ps,gs,td=class td{constructor(e,t,r){l(this,cs);l(this,ms);l(this,ps);l(this,gs);X(this),d(this,cs,e.id),d(this,ms,e.shortName),d(this,ps,t),d(this,gs,r)}get id(){return n(this,cs)}get name(){return n(this,ms)}get subredditName(){return n(this,ps)}toJSON(){return{id:this.id,name:this.name,subredditName:this.subredditName}}delete(){return td.delete(this.subredditName,this.id,n(this,gs))}static async getWidgets(e,t){let s=await u.redditAPIPlugins.Widgets.GetWidgets({subreddit:e},t);p(s.layout,"Failed to load widgets for subreddit");let o=s.items,a=[];for(let c of s.layout.sidebar?.order??[]){let m=o[c];switch(m?.kind){case"image":a.push(new xo(m,e,t));break;case"calendar":a.push(new Io(m,e,t));break;case"textarea":a.push(new Ao(m,e,t));break;case"button":a.push(new To(m,e,t));break;case"community-list":a.push(new Eo(m,e,t));break;case"post-flair":a.push(new Ro(m,e,t));break;case"custom":a.push(new Oo(m,e,t));break;case"subreddit-rules":{let y=await u.redditAPIPlugins.Subreddits.SubredditAboutRules({subreddit:e},t);a.push(new ed(y,m,e,t));break}default:throw new Error(`Unknown widget type: ${m.kind}`)}}return a}static async delete(e,t,r){await u.redditAPIPlugins.Widgets.DeleteWidget({subreddit:e,id:t},r)}static async reorder(e,t,r){await u.redditAPIPlugins.Widgets.OrderWidgets({subreddit:e,order:t},r)}static async add(e,t){switch(e?.type){case"image":return xo.create(e,t);case"calendar":return Io.create(e,t);case"textarea":return Ao.create(e,t);case"button":return To.create(e,t);case"community-list":return Eo.create(e,t);case"post-flair":return Ro.create(e,t);case"custom":return Oo.create(e,t);default:throw new Error("Unknown widget type")}}};cs=new WeakMap,ms=new WeakMap,ps=new WeakMap,gs=new WeakMap;var te=td,hs,Mo=class Mo extends te{constructor(t,r,s){super(t,r,s);l(this,hs);d(this,hs,t.data.map(o=>(p(o.url,"Image widget data is missing url"),p(o.height,"Image widget data is missing height"),p(o.width,"Image widget data is missing width"),p(o.linkUrl,"Image widget data is missing linkUrl"),{url:o.url,height:o.height,width:o.width,linkUrl:o.linkUrl})))}get images(){return n(this,hs)}toJSON(){return{...super.toJSON(),images:this.images}}static async create(t,r){let o=await u.redditAPIPlugins.Widgets.AddImageWidget(t,r);return new Mo(oe.fromJSON(o),t.subreddit,r)}static async update(t,r){let o=await u.redditAPIPlugins.Widgets.UpdateImageWidget(t,r);return new Mo(oe.fromJSON(o),t.subreddit,r)}};hs=new WeakMap;var xo=Mo,fs,ys,bs,Uo=class Uo extends te{constructor(t,r,s){super(t,r,s);l(this,fs);l(this,ys);l(this,bs);p(t.googleCalendarId,"Calendar widget data is missing googleCalendarId"),p(t.configuration,"Calendar widget data is missing configuration"),p(t.styles,"Calendar widget data is missing styles"),d(this,fs,t.googleCalendarId),d(this,ys,t.configuration),d(this,bs,t.styles)}get googleCalendarId(){return n(this,fs)}get configuration(){return n(this,ys)}get styles(){return n(this,bs)}toJSON(){return{...super.toJSON(),googleCalendarId:this.googleCalendarId,configuration:this.configuration,styles:this.styles}}static async create(t,r){let o=await u.redditAPIPlugins.Widgets.AddCalendarWidget(t,r);return new Uo(oe.fromJSON(o),t.subreddit,r)}static async update(t,r){let o=await u.redditAPIPlugins.Widgets.UpdateCalendarWidget(t,r);return new Uo(oe.fromJSON(o),t.subreddit,r)}};fs=new WeakMap,ys=new WeakMap,bs=new WeakMap;var Io=Uo,vs,ks,Do=class Do extends te{constructor(t,r,s){super(t,r,s);l(this,vs);l(this,ks);p(t.text,"Textarea widget data is missing text"),p(t.styles,"Textarea widget data is missing styles"),d(this,vs,t.text),d(this,ks,t.styles)}get text(){return n(this,vs)}get styles(){return n(this,ks)}toJSON(){return{...super.toJSON(),text:this.text,styles:this.styles}}static async create(t,r){let o=await u.redditAPIPlugins.Widgets.AddTextAreaWidget(t,r);return new Do(oe.fromJSON(o),t.subreddit,r)}static async update(t,r){let o=await u.redditAPIPlugins.Widgets.UpdateTextAreaWidget(t,r);return new Do(oe.fromJSON(o),t.subreddit,r)}};vs=new WeakMap,ks=new WeakMap;var Ao=Do,Cs,Ps,Ss,Bo=class Bo extends te{constructor(t,r,s){super(t,r,s);l(this,Cs);l(this,Ps);l(this,Ss);p(t.styles,"Button widget data is missing styles"),d(this,Cs,t.buttons),d(this,Ps,t.description??""),d(this,Ss,t.styles)}get buttons(){return n(this,Cs)}get description(){return n(this,Ps)}get styles(){return n(this,Ss)}toJSON(){return{...super.toJSON(),buttons:this.buttons,description:this.description,styles:this.styles}}static async create(t,r){let o=await u.redditAPIPlugins.Widgets.AddButtonWidget(t,r);return new Bo(oe.fromJSON(o),t.subreddit,r)}static async update(t,r){let o=await u.redditAPIPlugins.Widgets.UpdateButtonWidget(t,r);return new Bo(oe.fromJSON(o),t.subreddit,r)}};Cs=new WeakMap,Ps=new WeakMap,Ss=new WeakMap;var To=Bo,ws,Fs,No=class No extends te{constructor(t,r,s){super(t,r,s);l(this,ws);l(this,Fs);d(this,ws,t.data.map(o=>Ag.fromJSON(o))),p(t.styles,"Community list widget data is missing styles"),d(this,Fs,t.styles)}get communities(){return n(this,ws)}get styles(){return n(this,Fs)}toJSON(){return{...super.toJSON(),communities:this.communities,styles:this.styles}}static async create(t,r){let o=await u.redditAPIPlugins.Widgets.AddCommunityListWidget(t,r);return new No(oe.fromJSON(o),t.subreddit,r)}static async update(t,r){let o=await u.redditAPIPlugins.Widgets.UpdateCommunityListWidget(t,r);return new No(oe.fromJSON(o),t.subreddit,r)}};ws=new WeakMap,Fs=new WeakMap;var Eo=No,xs,Is,As,Lo=class Lo extends te{constructor(t,r,s){super(t,r,s);l(this,xs);l(this,Is);l(this,As);if(p(t.styles,"Post flair widget data is missing styles"),d(this,xs,t.styles),d(this,Is,t.order.map(o=>t.templates[o])),!(t.display&&t.display==="list"||t.display==="cloud"))throw new Error("Post flair widget data is missing display type");d(this,As,t.display)}get styles(){return n(this,xs)}get templates(){return n(this,Is)}get display(){return n(this,As)}toJSON(){return{...super.toJSON(),styles:this.styles,templates:this.templates,display:this.display}}static async create(t,r){let o=await u.redditAPIPlugins.Widgets.AddPostFlairWidget(t,r);return new Lo(oe.fromJSON(o),t.subreddit,r)}static async update(t,r){let o=await u.redditAPIPlugins.Widgets.UpdatePostFlairWidget(t,r);return new Lo(oe.fromJSON(o),t.subreddit,r)}};xs=new WeakMap,Is=new WeakMap,As=new WeakMap;var Ro=Lo,Ts,Es,Rs,Os,Ms,_o=class _o extends te{constructor(t,r,s){super(t,r,s);l(this,Ts);l(this,Es);l(this,Rs);l(this,Os);l(this,Ms);p(t.stylesheetUrl,"Custom widget data is missing stylesheetUrl"),p(t.height,"Custom widget data is missing height"),p(t.css,"Custom widget data is missing css"),d(this,Ts,t.imageData??[]),d(this,Es,t.text??""),d(this,Rs,t.stylesheetUrl),d(this,Os,t.height),d(this,Ms,t.css)}get images(){return n(this,Ts)}get text(){return n(this,Es)}get stylesheetUrl(){return n(this,Rs)}get height(){return n(this,Os)}get css(){return n(this,Ms)}toJSON(){return{...super.toJSON(),images:this.images,text:this.text,stylesheetUrl:this.stylesheetUrl,height:this.height,css:this.css}}static async create(t,r){let o=await u.redditAPIPlugins.Widgets.AddCustomWidget(t,r);return new _o(oe.fromJSON(o),t.subreddit,r)}static async update(t,r){let o=await u.redditAPIPlugins.Widgets.UpdateCustomWidget(t,r);return new _o(oe.fromJSON(o),t.subreddit,r)}};Ts=new WeakMap,Es=new WeakMap,Rs=new WeakMap,Os=new WeakMap,Ms=new WeakMap;var Oo=_o,Us,ed=class extends te{constructor(t,r,s,o){super(r,s,o);l(this,Us);let a=t.rules.map(({description:c,priority:m,shortName:y,violationReason:v})=>(p(c,"Subreddit rule is missing description"),p(m,"Subreddit rule is missing priority"),p(y,"Subreddit rule is missing shortName"),p(v,"Subreddit rule is missing violationReason"),{description:c,priority:m,shortName:y,violationReason:v}));d(this,Us,a)}get rules(){return n(this,Us)}toJSON(){return{...super.toJSON(),rules:this.rules}}};Us=new WeakMap;var Tg=(r=>(r[r.SUBREDDIT_PERMISSIONS=0]="SUBREDDIT_PERMISSIONS",r[r.APPROVED_CONTRIBUTORS_ONLY=1]="APPROVED_CONTRIBUTORS_ONLY",r[r.MODS_ONLY=2]="MODS_ONLY",r))(Tg||{}),pe,ge,fr,yr,br,vr,kr,Cr,Te,we=class we{constructor(e,t,r,s){l(this,pe);l(this,ge);l(this,fr);l(this,yr);l(this,br);l(this,vr);l(this,kr);l(this,Cr);l(this,Te);X(this),d(this,pe,e),d(this,ge,t),d(this,fr,r.contentMd),d(this,yr,r.contentHtml),d(this,br,r.revisionId),d(this,vr,new Date(r.revisionDate*1e3)),d(this,kr,r.reason??""),d(this,Cr,r.revisionBy?.data?new C(r.revisionBy.data,s):void 0),d(this,Te,s)}get name(){return n(this,pe)}get subredditName(){return n(this,ge)}get content(){return n(this,fr)}get contentHtml(){return n(this,yr)}get revisionId(){return n(this,br)}get revisionDate(){return n(this,vr)}get revisionReason(){return n(this,kr)}get revisionAuthor(){return n(this,Cr)}toJSON(){return{name:n(this,pe),subredditName:n(this,ge),content:n(this,fr),contentHtml:n(this,yr),revisionId:n(this,br),revisionDate:n(this,vr),revisionReason:n(this,kr),revisionAuthor:n(this,Cr)?.toJSON()}}async update(e,t){return we.updatePage({subredditName:n(this,ge),page:n(this,pe),content:e,reason:t},n(this,Te))}async getRevisions(e){return we.getPageRevisions({subredditName:n(this,ge),page:n(this,pe),...e},n(this,Te))}async revertTo(e){return we.revertPage(n(this,ge),n(this,pe),e,n(this,Te))}async getSettings(){return we.getPageSettings(n(this,ge),n(this,pe),n(this,Te))}async updateSettings(e){return we.updatePageSettings({subredditName:n(this,ge),page:n(this,pe),listed:e.listed,permLevel:e.permLevel},n(this,Te))}async addEditor(e){return we.addEditor(n(this,ge),n(this,pe),e,n(this,Te))}async removeEditor(e){return we.removeEditor(n(this,ge),n(this,pe),e,n(this,Te))}static async getPage(e,t,r){let o=await u.redditAPIPlugins.Wiki.GetWikiPage({subreddit:e,page:t},r);return p(o.data,"Failed to get wiki page"),new we(t,e,o.data,r)}static async getPages(e,t){return(await u.redditAPIPlugins.Wiki.GetWikiPages({subreddit:e},t)).data||[]}static async createPage(e,t){return we.updatePage(e,t)}static async updatePage(e,t){return await u.redditAPIPlugins.Wiki.EditWikiPage({subreddit:e.subredditName,page:e.page,content:e.content,reason:e.reason??""},t),we.getPage(e.subredditName,e.page,t)}static getPageRevisions(e,t){let r=u.redditAPIPlugins.Wiki;return new V({hasMore:!0,after:e.after,limit:e.limit,pageSize:e.pageSize,async fetch(s){let o=await r.GetWikiPageRevisions({subreddit:e.subredditName,page:e.page,limit:s.limit,after:s.after,before:s.before},t);return Eg(o,t)}})}static async revertPage(e,t,r,s){await u.redditAPIPlugins.Wiki.RevertWikiPage({subreddit:e,page:t,revision:r},s)}static async getPageSettings(e,t,r){let o=await u.redditAPIPlugins.Wiki.GetWikiPageSettings({subreddit:e,page:t},r);return p(o.data,"Failed to get wiki page settings"),new Ho(o.data,r)}static async updatePageSettings(e,t){let s=await u.redditAPIPlugins.Wiki.UpdateWikiPageSettings({subreddit:e.subredditName,page:e.page,listed:e.listed?"on":"",permlevel:e.permLevel},t);return p(s.data,"Failed to update wiki page settings"),new Ho(s.data,t)}static async addEditor(e,t,r,s){await u.redditAPIPlugins.Wiki.AllowEditor({act:"add",subreddit:e,page:t,username:r},s)}static async removeEditor(e,t,r,s){await u.redditAPIPlugins.Wiki.AllowEditor({act:"del",subreddit:e,page:t,username:r},s)}};pe=new WeakMap,ge=new WeakMap,fr=new WeakMap,yr=new WeakMap,br=new WeakMap,vr=new WeakMap,kr=new WeakMap,Cr=new WeakMap,Te=new WeakMap;var le=we,Pr,Sr,wr,Fr,xr,Ir,id=class{constructor(e,t){l(this,Pr);l(this,Sr);l(this,wr);l(this,Fr);l(this,xr);l(this,Ir);d(this,Pr,e.id),d(this,Sr,e.page),d(this,wr,new Date(e.timestamp)),p(e.author?.data,"Wiki page revision author details are missing"),d(this,Fr,new C(e.author.data,t)),d(this,xr,e.reason??""),d(this,Ir,e.revisionHidden??!1)}get id(){return n(this,Pr)}get page(){return n(this,Sr)}get date(){return n(this,wr)}get author(){return n(this,Fr)}get reason(){return n(this,xr)}get hidden(){return n(this,Ir)}toJSON(){return{id:n(this,Pr),page:n(this,Sr),date:n(this,wr),author:n(this,Fr).toJSON(),reason:n(this,xr),hidden:n(this,Ir)}}};Pr=new WeakMap,Sr=new WeakMap,wr=new WeakMap,Fr=new WeakMap,xr=new WeakMap,Ir=new WeakMap;var Ar,Tr,Er,Ho=class{constructor(e,t){l(this,Ar);l(this,Tr);l(this,Er);d(this,Ar,e.listed),d(this,Tr,e.permLevel),d(this,Er,e.editors.map(r=>(p(r.data,"Wiki page editor details are missing"),new C(r.data,t))))}get listed(){return n(this,Ar)}get permLevel(){return n(this,Tr)}get editors(){return n(this,Er)}toJSON(){return{listed:n(this,Ar),permLevel:n(this,Tr),editors:n(this,Er).map(e=>e.toJSON())}}};Ar=new WeakMap,Tr=new WeakMap,Er=new WeakMap;function Eg(i,e){return p(i.data?.children,"Wiki page revision listing is missing children"),{children:i.data.children.map(r=>new id(r,e)),before:i.data.before,after:i.data.after}}var Rg=["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"],Og=["border-image","border-image-source","behavior","expression","list-style-image","cursor","content"],Mg=["onload","onerror","onclick","onmouseover"];function Ug(i){return/xmlns=["']http:\/\/www\.w3\.org\/2000\/svg["']/.test(i)?i:i.replace(/<svg\b/,'<svg xmlns="http://www.w3.org/2000/svg"')}function Lc(i){if(i){if(!i.trim().startsWith("<svg")){console.log("The provided string is not a valid SVG.");return}try{let e=new RegExp(`<\\s*(${Rg.join("|")})\\b`,"gi"),t=new RegExp(`(${Og.join("|")})\\s*:\\s*url\\s*\\((['"]?)(.*?)\\2\\)`,"gi"),r=new RegExp(`(${Mg.join("|")})\\s*(=\\s*(['"]?)(.*?)\\3)?`,"gi");i=i.trim().replace(/\s+/g," "),i=Ug(i);let s=i.match(e)||[],o=i.match(t)||[],a=i.match(r)||[],c=!1;return s.length>0&&(c=!0,console.warn(`Disallowed elements detected in SVG: ${s.map(m=>m.replace("<","")).join(", ")}`)),o.length>0&&(c=!0,console.warn(`Disallowed styles detected in SVG: ${o.map(m=>m.split(":")[0]).join(", ")}`)),a.length>0&&(c=!0,console.warn(`Disallowed attributes detected in SVG: ${a.map(m=>m.split("=")[0]).join(", ")}`)),c?void 0:i}catch{return}}}function MS(i,...e){let t="";return i.forEach((r,s)=>{t+=r;let o=e[s];o!==void 0&&(t+=`${o}`)}),t=Lc(t),t===void 0?"":`data:image/svg+xml;charset=UTF-8,${encodeURIComponent(t)}`}import{EffectType as jc}from"@devvit/protos";import{WebViewVisibility as Dg}from"@devvit/protos";var _c="/api/";var Hc=i=>i===null||typeof i!="object"?!1:"scope"in i&&i.scope===0&&"type"in i&&i.type==="devvit-internal";var Rr,At,Ds,Or,ni,Bs,Ns,rd=class{constructor(e,t){this.state={messageCount:0,isMounted:!1};l(this,Rr);l(this,At);l(this,Ds);l(this,Or);l(this,ni);l(this,Bs);this.postMessage=e=>{try{let t=JSON.stringify(e);n(this,ni).emitEffect(`postMessage${this.state.messageCount++}`,{type:jc.EFFECT_WEB_VIEW,webView:{postMessage:{webViewId:n(this,Rr),app:{message:e,jsonString:t}}}})}catch(t){throw console.error(rt.caughtToString(t)),Error("Something went wrong. Please check the contents of your postMessage.")}};this.mount=()=>{if(this.state.isMounted){console.warn("Webview is already mounted!");return}let e=n(this,ni)?.devvitContext?.assets,t;if(n(this,At).startsWith(_c))t=n(this,At);else{let r=n(this,At).replace(/[#?].*/,"");t=`${e.getURL(r,{webView:!0})}${n(this,At).slice(r.length)}`}if(!t)throw Error("useWebView fullscreen request failed; web view asset could not be found");n(this,Ns).call(this,!0,t)};this.unmount=()=>{n(this,Ns).call(this,!1,"")};l(this,Ns,(e,t)=>{n(this,ni).emitEffect("fullscreen",{type:jc.EFFECT_WEB_VIEW,webView:{fullscreen:{id:n(this,Rr),show:e,url:t}}})});d(this,At,t.url??"index.html"),d(this,Rr,e.hookId),d(this,Ds,t.onMessage),d(this,Or,t.onUnmount),d(this,ni,e.context),d(this,Bs,e.invalidate)}onStateLoaded(){}async onUIEvent(e){if(e.webView?.fullScreen){let t=e.webView.fullScreen.visibility===Dg.WEBVIEW_VISIBLE;this.state.isMounted=t,n(this,Bs).call(this),!t&&n(this,Or)&&await n(this,Or).call(this,this)}else if(e.webView?.postMessage){let t=e.webView.postMessage.jsonString?JSON.parse(e.webView.postMessage.jsonString):e.webView.postMessage.message;if(Hc(t))return;await n(this,Ds).call(this,t,this)}}};Rr=new WeakMap,At=new WeakMap,Ds=new WeakMap,Or=new WeakMap,ni=new WeakMap,Bs=new WeakMap,Ns=new WeakMap;function Bg(i){let e=ce({namespace:"useWebView",initializer:t=>new rd(t,i)});return{postMessage:e.postMessage,mount:e.mount,unmount:e.unmount}}export{hh as ALL_ICON_NAMES,_d as AboutLocations,Uc as AuthorFlairSettings,To as ButtonWidget,Io as CalendarWidget,Q as Comment,Eo as CommunityListWidget,Oo as CustomWidget,vh as DeletionReason,u as Devvit,kh as EventSource,ue as Flair,re as FlairTemplate,ig as FlairType,XC as GalleryMediaStatus,qe as Hook,xo as ImageWidget,V as Listing,Sg as ModMailActionType,Cg as ModMailConversationState,Vs as ModMailService,ve as ModNote,G as Post,Dc as PostFlairSettings,Ro as PostFlairWidget,Rt as PrivateMessage,zt as RichTextBuilder,he as RunAs,ze as SettingScope,yg as SocialLinkType,de as Subreddit,Oc as SubredditDescription,ed as SubredditRulesWidget,Mc as SubredditWikiSettings,Ao as TextAreaWidget,C as User,te as Widget,le as WikiPage,Tg as WikiPagePermissionLevel,id as WikiPageRevision,Ho as WikiPageSettings,mn as convertUserFlairProtoToAPI,Ld as getCurrentUsernameFromMetadata,Ws as getModerationLog,Hd as getSubredditInfoById,jd as getSubredditInfoByName,Wd as getSubredditLeaderboard,qo as getSubredditNameById,Vd as getSubredditStyles,Gd as getVaultByAddress,Jd as getVaultByUserId,MS as svg,Wp as useAsync,Ta as useChannel,xa as useForm,Oa as useInterval,Ba as useState,Bg as useWebView};
7
7
  /*! Bundled license information:
8
8
 
9
9
  shallow-clone/index.js: