@quranjs/api 3.3.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index-BZgqOfA4.d.mts → index-BgoJducH.d.mts} +64 -1
- package/dist/{index-BZgqOfA4.d.ts → index-BgoJducH.d.ts} +64 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.min.js.map +1 -1
- package/dist/index.min.mjs.map +1 -1
- package/dist/public.d.mts +5 -9
- package/dist/public.d.ts +5 -9
- package/dist/public.min.js +2 -2
- package/dist/public.min.js.map +1 -1
- package/dist/public.min.mjs +2 -2
- package/dist/public.min.mjs.map +1 -1
- package/dist/runtime-utils-CpHQzQN3.d.mts +44 -0
- package/dist/runtime-utils-XwV859WP.d.ts +44 -0
- package/dist/server.d.mts +5 -9
- package/dist/server.d.ts +5 -9
- package/dist/server.min.js +2 -2
- package/dist/server.min.js.map +1 -1
- package/dist/server.min.mjs +2 -2
- package/dist/server.min.mjs.map +1 -1
- package/dist/{verses-CMtdLtyF.d.mts → verses-C_LN5-Sn.d.mts} +1 -1
- package/dist/{verses-B89EinHG.d.ts → verses-Dw2mFuje.d.ts} +1 -1
- package/package.json +3 -3
- package/dist/runtime-utils-CxjOQDsB.d.mts +0 -3
- package/dist/runtime-utils-CxjOQDsB.d.ts +0 -3
package/dist/server.min.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import fe from'humps';var Q={auth:{v1:{operations:{getV1Collections:{auth:"user",method:"get",path:"/v1/collections"},postV1Collections:{auth:"user",method:"post",path:"/v1/collections"},postV1CollectionsByCollectionIdBookmarks:{auth:"user",method:"post",path:"/v1/collections/{collectionId}/bookmarks"},deleteV1CollectionsByCollectionIdBookmarks:{auth:"user",method:"delete",path:"/v1/collections/{collectionId}/bookmarks"},getV1CollectionsByCollectionId:{auth:"user",method:"get",path:"/v1/collections/{collectionId}"},postV1CollectionsByCollectionId:{auth:"user",method:"post",path:"/v1/collections/{collectionId}"},deleteV1CollectionsByCollectionId:{auth:"user",method:"delete",path:"/v1/collections/{collectionId}"},deleteV1CollectionsByCollectionIdBookmarksByBookmarkId:{auth:"user",method:"delete",path:"/v1/collections/{collectionId}/bookmarks/{bookmarkId}"},getV1CollectionsAll:{auth:"user",method:"get",path:"/v1/collections/all"},getV1Bookmarks:{auth:"user",method:"get",path:"/v1/bookmarks"},postV1Bookmarks:{auth:"user",method:"post",path:"/v1/bookmarks"},deleteV1BookmarksByBookmarkId:{auth:"user",method:"delete",path:"/v1/bookmarks/{bookmarkId}"},getV1BookmarksAyahsRange:{auth:"user",method:"get",path:"/v1/bookmarks/ayahs-range"},getV1BookmarksBookmark:{auth:"user",method:"get",path:"/v1/bookmarks/bookmark"},getV1BookmarksCollections:{auth:"user",method:"get",path:"/v1/bookmarks/collections"},getV1Preferences:{auth:"user",method:"get",path:"/v1/preferences"},postV1Preferences:{auth:"user",method:"post",path:"/v1/preferences"},postV1PreferencesBulk:{auth:"user",method:"post",path:"/v1/preferences/bulk"},getV1ReadingSessions:{auth:"user",method:"get",path:"/v1/reading-sessions"},postV1ReadingSessions:{auth:"user",method:"post",path:"/v1/reading-sessions"},getV1GoalsGetTodaysPlan:{auth:"user",method:"get",path:"/v1/goals/get-todays-plan"},putV1GoalsById:{auth:"user",method:"put",path:"/v1/goals/{id}"},deleteV1GoalsById:{auth:"user",method:"delete",path:"/v1/goals/{id}"},postV1Goals:{auth:"user",method:"post",path:"/v1/goals"},getV1GoalsEstimate:{auth:"user",method:"get",path:"/v1/goals/estimate"},getV1Streaks:{auth:"user",method:"get",path:"/v1/streaks"},getV1StreaksCurrentStreakDays:{auth:"user",method:"get",path:"/v1/streaks/current-streak-days"},getV1ActivityDays:{auth:"user",method:"get",path:"/v1/activity-days"},postV1ActivityDays:{auth:"user",method:"post",path:"/v1/activity-days"},getV1ActivityDaysEstimateReadingTime:{auth:"user",method:"get",path:"/v1/activity-days/estimate-reading-time"},getV1Notes:{auth:"user",method:"get",path:"/v1/notes"},postV1Notes:{auth:"user",method:"post",path:"/v1/notes"},getV1NotesByVerseByVerseKey:{auth:"user",method:"get",path:"/v1/notes/by-verse/{verseKey}"},getV1NotesByAttachedEntity:{auth:"user",method:"get",path:"/v1/notes/by-attached-entity"},getV1NotesCountWithinRange:{auth:"user",method:"get",path:"/v1/notes/count-within-range"},getV1NotesByRange:{auth:"user",method:"get",path:"/v1/notes/by-range"},getV1NotesByNoteId:{auth:"user",method:"get",path:"/v1/notes/{noteId}"},patchV1NotesByNoteId:{auth:"user",method:"patch",path:"/v1/notes/{noteId}"},deleteV1NotesByNoteId:{auth:"user",method:"delete",path:"/v1/notes/{noteId}"},postV1NotesByNoteIdPublish:{auth:"user",method:"post",path:"/v1/notes/{noteId}/publish"}},service:"auth",version:"v1"}},content:{v4:{operations:{audioReciterTimestamp:{auth:"app",method:"get",path:"/audio/reciters/{reciter_id}/timestamp"},audioReciterLookup:{auth:"app",method:"get",path:"/audio/reciters/{reciter_id}/lookup"},listChapters:{auth:"app",method:"get",path:"/chapters"},getChapter:{auth:"app",method:"get",path:"/chapters/{id}"},getChapterInfo:{auth:"app",method:"get",path:"/chapters/{id}/info"},hadithReferencesByAyah:{auth:"app",method:"get",path:"/hadith_references/by_ayah/{ayah_key}"},hadithsByAyah:{auth:"app",method:"get",path:"/hadith_references/by_ayah/{ayah_key}/hadiths"},hadithCountWithinRange:{auth:"app",method:"get",path:"/hadith_references/count_within_range"},listPages:{auth:"app",method:"get",path:"/pages"},getPagesLookup:{auth:"app",method:"get",path:"/pages/lookup"},getPagesPageNumber:{auth:"app",method:"get",path:"/pages/{page_number}"},versesByChapterNumber:{auth:"app",method:"get",path:"/verses/by_chapter/{chapter_number}"},versesByPageNumber:{auth:"app",method:"get",path:"/verses/by_page/{page_number}"},versesByJuzNumber:{auth:"app",method:"get",path:"/verses/by_juz/{juz_number}"},versesByHizbNumber:{auth:"app",method:"get",path:"/verses/by_hizb/{hizb_number}"},versesByRubElHizbNumber:{auth:"app",method:"get",path:"/verses/by_rub/{rub_el_hizb_number}"},versesByManzilNumber:{auth:"app",method:"get",path:"/verses/by_manzil/{manzil_number}"},versesByRukuNumber:{auth:"app",method:"get",path:"/verses/by_ruku/{ruku_number}"},versesByRange:{auth:"app",method:"get",path:"/verses/by_range"},versesByVerseKey:{auth:"app",method:"get",path:"/verses/by_key/{verse_key}"},randomVerse:{auth:"app",method:"get",path:"/verses/random"},listJuzs:{auth:"app",method:"get",path:"/juzs"},quranVersesByScript:{auth:"app",method:"get",path:"/quran/verses/{script}"},quranVersesIndopak:{auth:"app",method:"get",path:"/quran/verses/indopak"},quranVersesIndopakNastaleeq:{auth:"app",method:"get",path:"/quran/verses/indopak_nastaleeq"},quranVersesUthmaniTajweed:{auth:"app",method:"get",path:"/quran/verses/uthmani_tajweed"},quranVersesUthmani:{auth:"app",method:"get",path:"/quran/verses/uthmani"},quranVersesUthmaniSimple:{auth:"app",method:"get",path:"/quran/verses/uthmani_simple"},quranVersesImlaei:{auth:"app",method:"get",path:"/quran/verses/imlaei"},recitations:{auth:"app",method:"get",path:"/resources/recitations"},recitationAudioFiles:{auth:"app",method:"get",path:"/quran/recitations/{recitation_id}"},translation:{auth:"app",method:"get",path:"/quran/translations/{translation_id}"},chapterReciters:{auth:"app",method:"get",path:"/resources/chapter_reciters"},tafsir:{auth:"app",method:"get",path:"/quran/tafsirs/{tafsir_id}"},quranVersesCodeV1:{auth:"app",method:"get",path:"/quran/verses/code_v1"},quranVersesCodeV2:{auth:"app",method:"get",path:"/quran/verses/code_v2"},listSurahRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_chapter/{chapter_number}"},listJuzRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_juz/{juz_number}"},listPageRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_page/{page_number}"},listRubElHizbRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_rub/{rub_el_hizb_number}"},listHizbRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_hizb/{hizb_number}"},listAyahRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_ayah/{ayah_key}"},recitationInfo:{auth:"app",method:"get",path:"/resources/recitations/{recitation_id}/info"},translationInfo:{auth:"app",method:"get",path:"/resources/translations/{translation_id}/info"},translations:{auth:"app",method:"get",path:"/resources/translations"},tafsirs:{auth:"app",method:"get",path:"/resources/tafsirs"},tafsirInfo:{auth:"app",method:"get",path:"/resources/tafsirs/{tafsir_id}/info"},recitationStyles:{auth:"app",method:"get",path:"/resources/recitation_styles"},languages:{auth:"app",method:"get",path:"/resources/languages"},chapterInfo:{auth:"app",method:"get",path:"/resources/chapter_infos"},verseMedia:{auth:"app",method:"get",path:"/resources/verse_media"},listManzilRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_manzil/{manzil_number}"},listRukuRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_ruku/{ruku_number}"},listSurahTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_chapter/{chapter_number}"},listPageTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_page/{page_number}"},listJuzTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_juz/{juz_number}"},listRubElHizbTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_rub_el_hizb/{rub_el_hizb_number}"},listHizbTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_hizb/{hizb_number}"},listManzilTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_manzil/{manzil_number}"},listRukuTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_ruku/{ruku_number}"},listAyahTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_ayah/{ayah_key}"},listSurahTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_chapter/{chapter_number}"},listPageTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_page/{page_number}"},listJuzTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_juz/{juz_number}"},listRubElHizbTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_rub_el_hizb/{rub_el_hizb_number}"},listHizbTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_hizb/{hizb_number}"},listManzilTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_manzil/{manzil_number}"},listRukuTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_ruku/{ruku_number}"},listAyahTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_ayah/{ayah_key}"},getJuz:{auth:"app",method:"get",path:"/juzs/{id}"},listHizbs:{auth:"app",method:"get",path:"/hizbs"},getHizb:{auth:"app",method:"get",path:"/hizbs/{id}"},listRubElHizbs:{auth:"app",method:"get",path:"/rub_el_hizbs"},getRubElHizb:{auth:"app",method:"get",path:"/rub_el_hizbs/{id}"},listRukus:{auth:"app",method:"get",path:"/rukus"},getRuku:{auth:"app",method:"get",path:"/rukus/{id}"},listManzils:{auth:"app",method:"get",path:"/manzils"},getManzil:{auth:"app",method:"get",path:"/manzils/{id}"},getFootNote:{auth:"app",method:"get",path:"/foot_notes/{id}"},postsControllerFeed:{auth:"app",method:"get",path:"/quran-reflect/v1/posts/feed"},postsControllerFindOne:{auth:"app",method:"get",path:"/quran-reflect/v1/posts/{id}"},postsControllerGetUserPost:{auth:"app",method:"get",path:"/quran-reflect/v1/posts/user-posts/{id}"},postsControllerGetComments:{auth:"app",method:"get",path:"/quran-reflect/v1/posts/{id}/comments"},postsControllerGetAllComment:{auth:"app",method:"get",path:"/quran-reflect/v1/posts/{id}/all-comments"},chapterReciterAudioFiles:{auth:"app",method:"get",path:"/chapter_recitations/{reciter_id}"},chapterReciterAudioFile:{auth:"app",method:"get",path:"/chapter_recitations/{reciter_id}/{chapter_number}"},versesByRubElHizbNumberRubElHizb:{auth:"app",method:"get",path:"/verses/by_rub_el_hizb/{rub_el_hizb_number}"},listRubElHizbTranslationsRub:{auth:"app",method:"get",path:"/translations/{resource_id}/by_rub/{rub_el_hizb_number}"},listRubElHizbTafsirsRub:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_rub/{rub_el_hizb_number}"},listRubElHizbRecitationRubElHizb:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_rub_el_hizb/{rub_el_hizb_number}"},listAyahAnswers:{auth:"app",method:"get",path:"/answers/by_ayah/{ayah_key}"},getAnswerById:{auth:"app",method:"get",path:"/answers/{question_id}"},countAnswersWithinRange:{auth:"app",method:"get",path:"/answers/count_within_range"},resourcesSync:{auth:"app",method:"get",path:"/resources/sync"},resourcesSnapshot:{auth:"app",method:"get",path:"/resources/snapshots/{resource_group}/{id}"}},service:"content",version:"v4"}},oauth2:{v1:{operations:{oauth2TokenExchange:{auth:"none",method:"post",path:"/oauth2/token"},introspectOauth2Token:{auth:"none",method:"post",path:"/oauth2/introspect"},oAuth2Authorize:{auth:"none",method:"get",path:"/oauth2/auth"},getOidcUserInfo:{auth:"user",method:"get",path:"/userinfo"},revokeOidcSession:{auth:"none",method:"get",path:"/oauth2/sessions/logout"}},service:"oauth2",version:"v1"}},quranReflect:{v1:{operations:{usersControllerProfile:{auth:"user",method:"get",path:"/v1/users/profile"},usersControllerUpdateProfile:{auth:"user",method:"put",path:"/v1/users/profile"},usersControllerEditProfile:{auth:"user",method:"patch",path:"/v1/users/profile"},usersControllerRooms:{auth:"user",method:"get",path:"/v1/users/my-rooms"},usersControllerSearch:{auth:"user",method:"get",path:"/v1/users/search"},usersControllerToggleFollow:{auth:"user",method:"post",path:"/v1/users/{followeeId}/toggle-follow"},usersControllerRemoveFollower:{auth:"user",method:"post",path:"/v1/users/{followerId}/remove-follower"},usersControllerGetUserProfile:{auth:"user",method:"get",path:"/v1/users/{id}"},usersControllerGetUserProfile2:{auth:"user",method:"get",path:"/v1/users/{username}/profile"},usersControllerGetUserFollowers:{auth:"user",method:"get",path:"/v1/users/{id}/followers"},usersControllerGetUserFollowing:{auth:"user",method:"get",path:"/v1/users/{id}/following"},roomsControllerAdminsAccess:{auth:"user",method:"post",path:"/v1/rooms/admins-access"},roomsControllerCreateNewGroup:{auth:"user",method:"post",path:"/v1/rooms/groups"},roomsControllerUpdateGroup:{auth:"user",method:"patch",path:"/v1/rooms/groups"},roomsControllerCreateNewPage:{auth:"user",method:"post",path:"/v1/rooms/pages"},roomsControllerUpdatePage:{auth:"user",method:"patch",path:"/v1/rooms/pages"},roomsControllerGetRoomMembers:{auth:"user",method:"get",path:"/v1/rooms/{id}/members"},roomsControllerInviteUserToRoom:{auth:"user",method:"post",path:"/v1/rooms/{id}/invite"},roomsControllerAcceptInvite:{auth:"user",method:"get",path:"/v1/rooms/{id}/accept-invite"},roomsControllerRejectInvite:{auth:"user",method:"get",path:"/v1/rooms/{id}/reject-invite"},roomsControllerRemoveMember:{auth:"user",method:"delete",path:"/v1/rooms/{id}/members/{userId}"},roomsControllerGetRooms:{auth:"user",method:"get",path:"/v1/rooms/joined-rooms"},roomsControllerGetRooms2:{auth:"user",method:"get",path:"/v1/rooms/managed-rooms"},roomsControllerSearchRooms:{auth:"user",method:"get",path:"/v1/rooms/search"},roomsControllerGetRoomProfile:{auth:"user",method:"get",path:"/v1/rooms/group/{url}"},roomsControllerGetRoomProfile2:{auth:"user",method:"get",path:"/v1/rooms/page/{subdomain}"},roomsControllerAcceptByPrivateToken:{auth:"user",method:"get",path:"/v1/rooms/group/{url}/accept/{token}"},roomsControllerAcceptByPrivateToken2:{auth:"user",method:"get",path:"/v1/rooms/page/{subdomain}/accept/{token}"},roomsControllerGetRoomProfileById:{auth:"user",method:"get",path:"/v1/rooms/{id}"},roomsControllerGetRoomPosts:{auth:"user",method:"get",path:"/v1/rooms/{id}/posts"},roomsControllerJoinRoom:{auth:"user",method:"post",path:"/v1/rooms/{groupId}/join"},roomsControllerLeaveGroup:{auth:"user",method:"post",path:"/v1/rooms/{groupId}/leave"},roomsControllerFollowPage:{auth:"user",method:"post",path:"/v1/rooms/{pageId}/follow"},roomsControllerUnfollowPage:{auth:"user",method:"post",path:"/v1/rooms/{pageId}/unfollow"},roomsControllerUpdatePostPrivacy:{auth:"user",method:"patch",path:"/v1/rooms/{roomId}/posts/{postId}/privacy"},postsControllerFeed:{auth:"user",method:"get",path:"/v1/posts/feed"},postsControllerGetRelatedPosts:{auth:"user",method:"get",path:"/v1/posts/{postId}/related"},postsControllerGetLoggedinUserPosts:{auth:"user",method:"get",path:"/v1/posts/my-posts"},postsControllerGetLikedState:{auth:"user",method:"get",path:"/v1/posts/{id}/liked"},postsControllerFindOne:{auth:"user",method:"get",path:"/v1/posts/{id}"},postsControllerEdit:{auth:"user",method:"patch",path:"/v1/posts/{id}"},postsControllerDelete:{auth:"user",method:"delete",path:"/v1/posts/{id}"},postsControllerViewTracking:{auth:"user",method:"get",path:"/v1/posts/viewed/{id}"},postsControllerCreate:{auth:"user",method:"post",path:"/v1/posts"},postsControllerReportAbuse:{auth:"user",method:"post",path:"/v1/posts/{id}/report"},postsControllerGetUserPost:{auth:"user",method:"get",path:"/v1/posts/user-posts/{id}"},postsControllerToggleLike:{auth:"user",method:"post",path:"/v1/posts/{id}/toggle-like"},postsControllerToggleSave:{auth:"user",method:"post",path:"/v1/posts/{id}/toggle-save"},postsControllerGetComments:{auth:"user",method:"get",path:"/v1/posts/{id}/comments"},postsControllerGetAllComment:{auth:"user",method:"get",path:"/v1/posts/{id}/all-comments"},postsControllerExportMultiplePosts:{auth:"user",method:"post",path:"/v1/posts/export/pdf"},postsControllerGetMyPostsCountWithinRange:{auth:"user",method:"get",path:"/v1/posts/count-within-range"},postsControllerGetMyPostsByVerse:{auth:"user",method:"get",path:"/v1/posts/by-verse/{verseKey}"},tagsControllerFind:{auth:"user",method:"get",path:"/v1/tags"},commentsControllerCreate:{auth:"user",method:"post",path:"/v1/comments"},commentsControllerDeleteComment:{auth:"user",method:"get",path:"/v1/comments/{id}/delete"},commentsControllerToggleLike:{auth:"user",method:"post",path:"/v1/comments/{id}/toggle-like"},commentsControllerGet:{auth:"user",method:"get",path:"/v1/comments/{id}/replies"}},service:"quranReflect",version:"v1"}},search:{v1:{operations:{searchControllerSearch:{auth:"app",method:"get",path:"/v1/search"}},service:"search",version:"v1"}}};var d=Q,x=(o,e,t)=>({...t,operationName:t.operationName??e,service:t.service??o.service,tags:t.tags??[],version:t.version??o.version});var v=(o,e)=>{let t=`${o}:${e}`;if(typeof Buffer<"u")return Buffer.from(t).toString("base64");if(typeof globalThis.btoa=="function")return globalThis.btoa(t);throw new Error("No base64 encoder available for HTTP basic auth.")},J=(o,e)=>{if(!(o.body===void 0||o.body===null))return typeof o.body=="string"||o.body instanceof URLSearchParams?(o.contentType&&e.set("Content-Type",o.contentType),o.body):(e.set("Content-Type",o.contentType??"application/json"),JSON.stringify(o.body))},R=(o,e)=>{let t=o.expiresIn??o.expires_in,r=o.accessToken??o.access_token,s=o.idToken??o.id_token??e?.idToken,n=o.refreshToken??o.refresh_token??e?.refreshToken,i=o.tokenType??o.token_type??e?.tokenType,h=o.scope??e?.scope,a=t?Date.now()+t*1e3:e?.expiresAt;return {accessToken:r,expiresAt:a,idToken:s,refreshToken:n,scope:h,tokenType:i}};var Y={delete:"remove",get:"list",patch:"update",post:"create",put:"update"},A=o=>{let e=o.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[^A-Za-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean);return e.length===0?"misc":e.map((t,r)=>{let s=t.toLowerCase();return r===0?s:s.charAt(0).toUpperCase()+s.slice(1)}).join("")},de=o=>{let e=A(o);return e.charAt(0).toUpperCase()+e.slice(1)},b=o=>o.startsWith("{")&&o.endsWith("}"),Z=o=>{let e=o.split("/").filter(Boolean);return e[0]?.match(/^v\d+$/)?e.slice(1):e},me=o=>{let e=Z(o.path),t=e.at(-1),r=e.filter(i=>!b(i)),s=r.at(-1),n=r[0];return e.length===1?Y[o.method]:e.length===2&&t&&b(t)?o.method==="get"?"get":o.method==="delete"?"remove":"update":t&&!b(t)&&s?s===n?`${Y[o.method]}ById`:A(s):A(o.operationName)},f=(o,e)=>{let t={};for(let[r,s]of Object.entries(e.operations)){let n=x(e,r,s);t[r]=i=>o.requestOperation(n,i);}return t},G=(o,e)=>{let t={};for(let[r,s]of Object.entries(o.operations)){let n=x(o,r,s),i=Z(n.path).filter(l=>!b(l)),h=A(i[0]??"misc"),a=me(n),p=t[h]??{},c=a;p[c]&&(c=`${a}${de(r)}`),p[c]=e[r],t[h]=p;}return t};var{decamelize:U}=fe,y=o=>o.startsWith("/")?o:`/${o}`,g=o=>o.endsWith("/")?o.slice(0,-1):o;var C=(o,e)=>o.replace(/\{([^}]+)\}/g,(t,r)=>{let s=e?.[r];if(s===void 0)throw new Error(`Missing path parameter: ${r}`);return encodeURIComponent(String(s))}),P=o=>o.replace(/(^|\/):([A-Za-z0-9_]+)/g,"$1{$2}"),X=["wordFields","translationFields","fields"],L=new Set([...X,...X.map(o=>U(o))]),ge=new Set(["navigationalResultsNumber","pageSize","versesResultsNumber"]),ee=(o,e={})=>{if(!o)return "";let t=new URLSearchParams;for(let[r,s]of Object.entries(o)){if(s===void 0)continue;let n=e.preserveCase||ge.has(r)?r:U(r);if(L.has(r)||L.has(n)){let i=Object.entries(s).filter(([,h])=>h).map(([h])=>U(h));i.length>0&&t.set(n,i.join(","));continue}typeof s=="string"?t.set(n,s):typeof s=="number"||typeof s=="boolean"?t.set(n,s.toString()):Array.isArray(s)&&t.set(n,s.join(","));}return t.size===0?"":`?${t.toString()}`};var m=o=>{let e=typeof o=="number"?o:Number(o);return !(!e||e<=0||e>114)};var z=o=>{let e=typeof o=="number"?o:Number(o);return !(!e||e<=0||e>30)};var N=o=>{let e=typeof o=="number"?o:Number(o);return !(!e||e<=0||e>240)};var H=o=>{let e=typeof o=="number"?o:Number(o);return !(!e||e<=0||e>60)};var q=o=>{let e=typeof o=="number"?o:Number(o);return !(!e||e<=0||e>604)};var te={1:7,2:286,3:200,4:176,5:120,6:165,7:206,8:75,9:129,10:109,11:123,12:111,13:43,14:52,15:99,16:128,17:111,18:110,19:98,20:135,21:112,22:78,23:118,24:64,25:77,26:227,27:93,28:88,29:69,30:60,31:34,32:30,33:73,34:54,35:45,36:83,37:182,38:88,39:75,40:85,41:54,42:53,43:89,44:59,45:37,46:35,47:38,48:29,49:18,50:45,51:60,52:49,53:62,54:55,55:78,56:96,57:29,58:22,59:24,60:13,61:14,62:11,63:11,64:18,65:12,66:12,67:30,68:52,69:52,70:44,71:28,72:28,73:20,74:56,75:40,76:31,77:50,78:40,79:46,80:42,81:29,82:19,83:36,84:25,85:22,86:17,87:19,88:26,89:30,90:20,91:15,92:21,93:11,94:8,95:8,96:19,97:5,98:8,99:8,100:11,101:11,102:8,103:3,104:9,105:5,106:4,107:7,108:3,109:6,110:3,111:5,112:4,113:5,114:6};var u=o=>{let[e,t]=o.trim().split(":");if(!e||!t||!m(e))return false;let r=Number(t),s=te[e];return !(!r||r<=0||r>s)};var ye=o=>Object.fromEntries(Object.entries(o).map(([e,t])=>t.types?[e,{...t,types:Object.fromEntries(Object.entries(t.types).map(([r,s])=>[r.toUpperCase(),s]))}]:[e,t])),w=class{constructor(e){this.fetcher=e;}async findByAyah(e,t){if(!u(e))throw new Error("Invalid verse key");return this.fetcher.fetch(`/content/api/v4/answers/by_ayah/${e}`,t)}async findByQuestionId(e){return this.fetcher.fetch(`/content/api/v4/answers/${e}`)}async countWithinRange(e,t,r){if(!u(e)||!u(t))throw new Error("Invalid verse key");let s=await this.fetcher.fetch("/content/api/v4/answers/count_within_range",{...r,from:e,to:t});return ye(s)}};var ve="https://verses.quran.com";function re(o){return o.map(e=>{let t=e.url.startsWith("http://")||e.url.startsWith("https://")?e.url:`${ve}/${e.url.replace(/^\/+/,"")}`;return {...e,audioUrl:t}})}var S=class{constructor(e){this.fetcher=e;}async findAllChapterRecitations(e,t){let{audioFiles:r}=await this.fetcher.fetch(`/content/api/v4/chapter_recitations/${e}`,t);return r}async findChapterRecitationById(e,t,r){if(!m(t))throw new Error("Invalid chapter id");let{audioFile:s}=await this.fetcher.fetch(`/content/api/v4/chapter_recitations/${e}/${t}`,r);return s}async findVerseRecitationsByChapter(e,t,r){if(!m(e))throw new Error("Invalid chapter id");let s=await this.fetcher.fetch(`/content/api/v4/recitations/${t}/by_chapter/${e}`,r);return {...s,audioFiles:re(s.audioFiles)}}async findVerseRecitationsByKey(e,t,r){if(!u(e))throw new Error("Invalid verse key");let s=await this.fetcher.fetch(`/content/api/v4/recitations/${t}/by_ayah/${e}`,r);return {...s,audioFiles:re(s.audioFiles)}}};var k=class{constructor(e){this.fetcher=e;}async findAll(e){let{chapters:t}=await this.fetcher.fetch("/content/api/v4/chapters",e);return t}async findById(e,t){if(!m(e))throw new Error("Invalid chapter id");let{chapter:r}=await this.fetcher.fetch(`/content/api/v4/chapters/${e}`,t);return r}async findInfoById(e,t){let{chapterInfo:r}=await this.findInfoResponseById(e,t);return r}async findInfoResponseById(e,t){if(!m(e))throw new Error("Invalid chapter id");return this.fetcher.fetch(`/content/api/v4/chapters/${e}/info`,t)}};var F=async(o,e={retries:3})=>{let t;for(let r=0;r<=e.retries;r++)try{return await o()}catch(s){if(t=s,r===e.retries)throw t;await new Promise(n=>setTimeout(n,Math.pow(2,r)*1e3));}throw t};var se="https://apis.quran.foundation",_={auth:"https://apis.quran.foundation/auth",content:"https://apis.quran.foundation/content",oauth2:"https://oauth2.quran.foundation",quranReflect:"https://apis.quran.foundation/quran-reflect",search:"https://apis.quran.foundation/search"},oe={auth:"/v1",content:"/api/v4",oauth2:"",quranReflect:"/v1",search:"/v1"},M={auth:"/auth/v1",content:"/content/api/v4",oauth2:"",quranReflect:"/quran-reflect/v1",search:"/search/v1"},ae={auth:["/auth/v1","/v1"],content:["/content/api/v4","/api/v4"],oauth2:[],quranReflect:["/quran-reflect/v1","/v1"],search:["/search/v1","/v1"]};var{camelizeKeys:be}=fe,ne={content:"content",search:"search"},Ae="/quran-reflect/v1/posts/",Ce=["/comments","/all-comments"],Pe=["auth","content","quranReflect","search"],ie="User session expired. Sign in again.",we="invalid_grant",Se=6e4,ke=async o=>{try{return await o.text()}catch{return ""}},_e=(o,e)=>o.status<400||o.status>=500||o.status===429?false:e.toLowerCase().includes(we),Ie=(o,e)=>{let t=e.trim(),r=t?`: ${t}`:"";return `Token refresh failed: ${o.status} ${o.statusText}${r}`},I=class{constructor(e,t){this.mode=e;this.config=t;this.userSession=t.userSession;}appTokens=new Map;userSession;userSessionRefreshPromise=null;getFetch(){let e=this.config.fetch??globalThis.fetch;if(typeof e!="function")throw new Error("No fetch function available. Please provide a fetch implementation or ensure global fetch is available.");return e}clearCachedTokens(){this.appTokens.clear();}async getUserSession(){let e=await this.config.storage?.getSession?.();return e!==void 0?e:this.userSession??null}async setUserSession(e){if(!this.config.storage){this.userSession=e;return}if(!e){if(this.config.storage.clearSession){await this.config.storage.clearSession(),this.userSession=null;return}await this.config.storage.setSession?.(null),this.userSession=null;return}await this.config.storage.setSession?.(e),this.userSession=e;}buildServiceUrl(e,t,r){let s=this.isCrossServiceGatewayPath(e,t),{baseUrl:n,usesGateway:i}=this.resolveServiceBaseUrl(e,s),h=this.normalizeServicePath(e,t,i,s);return `${n}${h}${ee(r,{preserveCase:e==="auth"||e==="quranReflect"})}`}async requestOperation(e,t){return this.request(e.service,C(e.path,t?.path),t?.query,{...t,auth:t?.auth==="auto"||!t?.auth?e.auth:t.auth,method:t?.method??e.method.toUpperCase(),path:void 0})}async request(e,t,r,s={}){let n=this.resolveAuthMode(e,s.auth);if(this.mode==="public"&&n==="app")throw new Error("This API requires @quranjs/api/server or a backend. Content and search are server-side for confidential clients.");let i=this.buildServiceUrl(e,t,r),h=await this.getRequestUserSession(n,s),a=await this.performRequest(e,i,s,n,h?.accessToken);if(this.shouldRetryUserRequest(a,n,s,h)){let l=await this.refreshStoredUserSession();a=await this.performRequest(e,i,s,n,l.accessToken);}if(!a.ok)throw new Error(`${a.status} ${a.statusText}`);if(a.status===204)return;if(!(a.headers.get("content-type")??"").includes("application/json"))return await a.text();let c=await a.json();return be(c)}async fetch(e,t){let r=this.resolveLegacyRoute(e);return this.request(r.service,r.path,{...this.config.defaults,...t})}async performRequest(e,t,r,s,n){let i=new Headers(r.headers),h=J(r,i);return e!=="oauth2"&&i.set("x-client-id",this.config.clientId),await this.applyAuthenticationHeaders(e,s,i,{...r,accessToken:n??r.accessToken},t),this.getFetch()(t,{body:h,headers:i,method:r.method??"GET"})}resolveLegacyRoute(e){let t=y(P(e));if(t.startsWith("/content/api/v4")||t.startsWith("/api/v4"))return {path:t,service:"content"};if(t==="/v1/search"||t.startsWith("/search/v1"))return {path:t,service:"search"};if(t.startsWith("/auth/v1"))return {path:t,service:"auth"};if(t.startsWith("/quran-reflect/v1"))return {path:t,service:"quranReflect"};if(t.startsWith("/oauth2")||t.startsWith("/userinfo"))return {path:t,service:"oauth2"};throw new Error(`Unsupported SDK route: ${e}`)}resolveAuthMode(e,t="auto"){return t!=="auto"?t:e==="content"||e==="search"?"app":e==="auth"||e==="quranReflect"?"user":"none"}async getRequestUserSession(e,t){if(e!=="user"||t.accessToken||this.mode!=="server")return null;let r=await this.getUserSession();if(!r?.accessToken)throw new Error("This operation requires a user session. Sign in first or use @quranjs/api/server.");return this.shouldRefreshUserSession(r)?this.refreshStoredUserSession(r):r}shouldRefreshUserSession(e){return !e.refreshToken||!e.expiresAt?false:e.expiresAt<=Date.now()+Se}shouldRetryUserRequest(e,t,r,s){return e.status!==401||t!=="user"||r.accessToken||this.mode!=="server"?false:!!s?.refreshToken}async applyAuthenticationHeaders(e,t,r,s,n){if(s.basicAuth&&r.set("Authorization",`Basic ${v(s.basicAuth.username,s.basicAuth.password)}`),s.accessToken){this.setTokenHeaders(e,r,s.accessToken);return}if(t==="none")return;if(t==="app"){let h=await this.getAppAccessToken(e,n);this.setTokenHeaders(e,r,h);return}let i=await this.getUserSession();if(!i?.accessToken)throw new Error("This operation requires a user session. Sign in first or use @quranjs/api/server.");this.setTokenHeaders(e,r,i.accessToken);}async refreshStoredUserSession(e){if(this.userSessionRefreshPromise)return this.userSessionRefreshPromise;let t=this.executeUserSessionRefresh(e);this.userSessionRefreshPromise=t;try{return await t}finally{this.userSessionRefreshPromise===t&&(this.userSessionRefreshPromise=null);}}async executeUserSessionRefresh(e){if(this.mode!=="server"||!("clientSecret"in this.config))throw new Error("Automatic session refresh requires @quranjs/api/server or a backend.");let t=this.config.clientSecret,r=e??await this.getUserSession();if(!r?.refreshToken)throw new Error(ie);let s=`${g(this.config.services?.tokenHost??this.config.services?.oauth2BaseUrl??_.oauth2)}/oauth2/token`,n=new URLSearchParams({grant_type:"refresh_token",refresh_token:r.refreshToken}),i=await F(()=>this.getFetch()(s,{body:n,headers:{Accept:"application/json",Authorization:`Basic ${v(this.config.clientId,t)}`,"Content-Type":"application/x-www-form-urlencoded"},method:"POST"}),{retries:3});if(!i.ok){let p=await ke(i);throw _e(i,p)?(await this.setUserSession(null),new Error(ie)):new Error(Ie(i,p))}let h=await i.json(),a=R(h,r);return await this.setUserSession(a),a}setTokenHeaders(e,t,r){if(e==="oauth2"){t.set("Authorization",`Bearer ${r}`);return}t.set("x-auth-token",r);}async getAppAccessToken(e,t){if(this.mode!=="server")throw new Error("App-authenticated APIs require @quranjs/api/server or a backend.");let r=this.resolveAppScope(e,t);if(!r)throw new Error(`No client-credentials scope is configured for ${e}.`);let s=`${e}:${r}`,n=this.appTokens.get(s);if(n&&n.expiresAt>Date.now()+3e4)return n.value;if(!("clientSecret"in this.config))throw new Error("client_secret is server-only. Use @quranjs/api/server.");let i=this.config.clientSecret,h=`${g(this.config.services?.tokenHost??this.config.services?.oauth2BaseUrl??_.oauth2)}/oauth2/token`,a=new URLSearchParams({grant_type:"client_credentials",scope:r}),p=await F(()=>this.getFetch()(h,{body:a,headers:{Accept:"application/json",Authorization:`Basic ${v(this.config.clientId,i)}`,"Content-Type":"application/x-www-form-urlencoded"},method:"POST"}),{retries:3});if(!p.ok)throw new Error(`Token request failed: ${p.status} ${p.statusText}`);let c=await p.json(),l={expiresAt:Date.now()+c.expires_in*1e3,value:c.access_token};return this.appTokens.set(s,l),l.value}resolveAppScope(e,t){if(e!=="content"||!t)return ne[e];let r=new URL(t).pathname;return r.startsWith(Ae)?Ce.some(s=>r.endsWith(s))?"comment.read":"post.read":ne.content}resolveServiceBaseUrl(e,t=false){let{services:r}=this.config;if(t)return {baseUrl:g(r?.gatewayUrl??se),usesGateway:true};let s=e==="content"?r?.contentBaseUrl:e==="search"?r?.searchBaseUrl:e==="auth"?r?.authBaseUrl:e==="quranReflect"?r?.quranReflectBaseUrl:r?.oauth2BaseUrl??r?.tokenHost;return s?{baseUrl:g(s),usesGateway:false}:r?.gatewayUrl&&e!=="oauth2"?{baseUrl:g(r.gatewayUrl),usesGateway:true}:{baseUrl:_[e],usesGateway:false}}normalizeServicePath(e,t,r,s=false){let n=y(P(t));if(e==="oauth2"||s)return n;let i=n;for(let a of ae[e])if(i.startsWith(a)){i=y(i.slice(a.length));break}let h=r?M[e]:oe[e];return i.startsWith(h)?i:`${h}${i}`}isCrossServiceGatewayPath(e,t){let r=y(P(t)),s=Pe.find(n=>this.pathMatchesPrefix(r,M[n]));return !!(s&&s!==e)}pathMatchesPrefix(e,t){return t.length>0&&(e===t||e.startsWith(`${t}/`))}};var T=class{constructor(e){this.fetcher=e;}async findByAyah(e,t){if(!u(e))throw new Error("Invalid verse key");return this.fetcher.fetch(`/content/api/v4/hadith_references/by_ayah/${e}`,t)}async findHadithsByAyah(e,t){if(!u(e))throw new Error("Invalid verse key");return this.fetcher.fetch(`/content/api/v4/hadith_references/by_ayah/${e}/hadiths`,t)}async countWithinRange(e,t,r){if(!u(e)||!u(t))throw new Error("Invalid verse key");return this.fetcher.fetch("/content/api/v4/hadith_references/count_within_range",{...r,from:e,to:t})}};var E=class{constructor(e){this.fetcher=e;}async findAll(){let{juzs:e}=await this.fetcher.fetch("/content/api/v4/juzs");return e}};var V=class{constructor(e){this.fetcher=e;}async findAllRecitations(e){let{recitations:t}=await this.fetcher.fetch("/content/api/v4/resources/recitations",e);return t}async findAllTranslations(e){let{translations:t}=await this.fetcher.fetch("/content/api/v4/resources/translations",e);return t}async findAllTafsirs(e){let{tafsirs:t}=await this.fetcher.fetch("/content/api/v4/resources/tafsirs",e);return t}async findAllLanguages(e){let{languages:t}=await this.fetcher.fetch("/content/api/v4/resources/languages",e);return t}async findRecitationInfo(e,t){let{recitationInfo:r}=await this.fetcher.fetch(`/content/api/v4/resources/recitations/${e}/info`,t);return r}async findTranslationInfo(e,t){let{translationInfo:r}=await this.fetcher.fetch(`/content/api/v4/resources/translations/${e}/info`,t);return r}async findTafsirInfo(e,t){let{tafsirInfo:r}=await this.fetcher.fetch(`/content/api/v4/resources/tafsirs/${e}/info`,t);return r}async findAllChapterInfos(e){let{chapterInfos:t}=await this.fetcher.fetch("/content/api/v4/resources/chapter_infos",e);return t}async findAllChapterReciters(e){let{reciters:t}=await this.fetcher.fetch("/content/api/v4/resources/chapter_reciters",e);return t}async findAllRecitationStyles(e){let{recitationStyles:t}=await this.fetcher.fetch("/content/api/v4/resources/recitation_styles",e);return t}async findVerseMedia(e){let{verseMedia:t}=await this.fetcher.fetch("/content/api/v4/resources/verse_media",e);return t}async sync(e){return this.fetcher.fetch("/content/api/v4/resources/sync",e)}async findSnapshot(e,t,r){return this.fetcher.fetch(`/content/api/v4/resources/snapshots/${e}/${t}`,r)}};var O=class{constructor(e){this.fetcher=e;}async search(e,t){return this.fetcher.fetch("/v1/search",{query:e,size:30,...t})}};var B=class{constructor(e){this.fetcher=e;}async findByKey(e,t){if(!u(e))throw new Error("Invalid verse key");let{verse:r}=await this.fetcher.fetch(`/content/api/v4/verses/by_key/${e}`,{words:false,...t});return r}async findByRange(e,t,r){if(!u(e)||!u(t))throw new Error("Invalid verse key");let{verses:s}=await this.fetcher.fetch("/content/api/v4/verses/by_range",{words:false,...r,from:e,to:t});return s}async findByChapter(e,t){if(!m(e))throw new Error("Invalid chapter id");let{verses:r}=await this.fetcher.fetch(`/content/api/v4/verses/by_chapter/${e}`,{words:false,...t});return r}async findByPage(e,t){if(!q(e))throw new Error("Invalid page number");let{verses:r}=await this.fetcher.fetch(`/content/api/v4/verses/by_page/${e}`,{words:false,...t});return r}async findByJuz(e,t){if(!z(e))throw new Error("Invalid juz");let{verses:r}=await this.fetcher.fetch(`/content/api/v4/verses/by_juz/${e}`,{words:false,...t});return r}async findByHizb(e,t){if(!H(e))throw new Error("Invalid hizb");let{verses:r}=await this.fetcher.fetch(`/content/api/v4/verses/by_hizb/${e}`,{words:false,...t});return r}async findByRub(e,t){if(!N(e))throw new Error("Invalid rub");let{verses:r}=await this.fetcher.fetch(`/content/api/v4/verses/by_rub/${e}`,{words:false,...t});return r}async findRandom(e){let{verse:t}=await this.fetcher.fetch("/content/api/v4/verses/random",{words:false,...e});return t}};var Te="auth.bookmarks.get(bookmarkId) is not supported because /v1/bookmarks/bookmark expects bookmark detail query parameters. Pass a query object such as { mushafId, key, type, verseNumber } or { mushafId, isReading: true }.",Ee=(o,e)=>(t,r,s)=>o.request(e,C(r,s?.path),s?.query,{...s,auth:"user",method:t,path:void 0,query:void 0}),Ve=o=>{let e=f(o,d.auth.v1),t=G(d.auth.v1,e),r=Ee(o,"auth");return {...t,collections:{...t.collections,addBookmark:(s,n)=>r("POST","/v1/collections/{collectionId}/bookmarks",{body:n,path:{collectionId:s}}),create:s=>r("POST","/v1/collections",{body:s}),get:(s,n)=>r("GET","/v1/collections/{collectionId}",{path:{collectionId:s},query:n}),list:s=>r("GET","/v1/collections",{query:s}),listAll:s=>r("GET","/v1/collections/all",{query:s}),remove:s=>r("DELETE","/v1/collections/{collectionId}",{path:{collectionId:s}}),removeBookmark:(s,n)=>r("DELETE","/v1/collections/{collectionId}/bookmarks/{bookmarkId}",{path:{bookmarkId:n,collectionId:s}}),update:(s,n)=>r("POST","/v1/collections/{collectionId}",{body:n,path:{collectionId:s}})},bookmarks:{...t.bookmarks,create:s=>r("POST","/v1/bookmarks",{body:s}),get:async s=>{if(typeof s=="string")throw new Error(Te);return r("GET","/v1/bookmarks/bookmark",{query:s})},list:s=>r("GET","/v1/bookmarks",{query:s}),listCollections:s=>r("GET","/v1/bookmarks/collections",{query:s}),listRange:s=>r("GET","/v1/bookmarks/ayahs-range",{query:s}),remove:s=>r("DELETE","/v1/bookmarks/{bookmarkId}",{path:{bookmarkId:s}})},goals:{...t.goals,create:s=>r("POST","/v1/goals",{body:s}),estimate:s=>r("GET","/v1/goals/estimate",{query:s}),getTodaysPlan:s=>r("GET","/v1/goals/get-todays-plan",{query:s}),remove:s=>r("DELETE","/v1/goals/{id}",{path:{id:s}}),update:(s,n)=>r("PUT","/v1/goals/{id}",{body:n,path:{id:s}})},notes:{...t.notes,create:s=>r("POST","/v1/notes",{body:s}),get:s=>r("GET","/v1/notes/{noteId}",{path:{noteId:s}}),list:s=>r("GET","/v1/notes",{query:s}),listByAttachedEntity:s=>r("GET","/v1/notes/by-attached-entity",{query:s}),listByRange:s=>r("GET","/v1/notes/by-range",{query:s}),listByVerseKey:(s,n)=>r("GET","/v1/notes/by-verse/{verseKey}",{path:{verseKey:s},query:n}),publish:(s,n)=>r("POST","/v1/notes/{noteId}/publish",{body:n,path:{noteId:s}}),remove:s=>r("DELETE","/v1/notes/{noteId}",{path:{noteId:s}}),update:(s,n)=>r("PATCH","/v1/notes/{noteId}",{body:n,path:{noteId:s}})},preferences:{...t.preferences,bulkUpdate:s=>r("POST","/v1/preferences/bulk",{body:s}),get:s=>r("GET","/v1/preferences",{query:s}),update:s=>r("POST","/v1/preferences",{body:s})},raw:e,readingSessions:{...t.readingSessions,create:s=>r("POST","/v1/reading-sessions",{body:s}),list:s=>r("GET","/v1/reading-sessions",{query:s})}}},Oe=o=>{let e=f(o,d.quranReflect.v1),t=G(d.quranReflect.v1,e);return {comments:t.comments??{},posts:t.posts??{},raw:e,rooms:t.rooms??{},tags:t.tags??{},users:t.users??{}}},Be=(o,e,t)=>{let r=f(o,d.oauth2.v1),s=async(n,i={})=>{if(i.requiresRefreshToken&&!n.get("refresh_token"))throw new Error("Missing refresh token.");let h=n.get("refresh_token")??void 0,a=i.requiresRefreshToken?await o.getUserSession():null,p=i.requiresRefreshToken&&h?{...a??{},refreshToken:h}:a,c=await o.request("oauth2","/oauth2/token",void 0,{auth:"none",basicAuth:"clientSecret"in t?{password:t.clientSecret,username:t.clientId}:void 0,body:n,contentType:"application/x-www-form-urlencoded",method:"POST"});return await o.setUserSession(R(c,p)),c};return {authorizeUrl:n=>o.buildServiceUrl("oauth2","/oauth2/auth",n),exchangeCode:n=>{let i=new URLSearchParams({code:n.code,grant_type:"authorization_code",redirect_uri:n.redirectUri});return n.codeVerifier&&i.set("code_verifier",n.codeVerifier),n.scope&&i.set("scope",n.scope),s(i,{})},getUserInfo:n=>o.request("oauth2","/userinfo",void 0,{accessToken:n,auth:"user",method:"GET"}),introspect:n=>{if(!("clientSecret"in t))throw new Error("Token introspection requires @quranjs/api/server or a backend.");return o.request("oauth2","/oauth2/introspect",void 0,{auth:"none",basicAuth:{password:t.clientSecret,username:t.clientId},body:new URLSearchParams({token:n}),contentType:"application/x-www-form-urlencoded",method:"POST"})},logout:n=>o.request("oauth2","/oauth2/sessions/logout",n,{auth:"none",method:"GET"}),raw:r,refresh:async n=>{let i=await o.getUserSession(),h=new URLSearchParams({grant_type:"refresh_token",refresh_token:n??i?.refreshToken??""});return s(h,{requiresRefreshToken:true})}}},xe=(o,e,t,r,s,n,i,h)=>({answers:{byAyah:(a,p)=>o.findByAyah(a,p),countWithinRange:(a,p,c)=>o.countWithinRange(a,p,c),get:a=>o.findByQuestionId(a)},audio:{chapterRecitation:{get:(a,p,c)=>s.findChapterRecitationById(a,p,c),list:(a,p)=>s.findAllChapterRecitations(a,p)},verseRecitation:{byChapter:(a,p,c)=>s.findVerseRecitationsByChapter(a,p,c),byKey:(a,p,c)=>s.findVerseRecitationsByKey(a,p,c)}},chapters:{get:(a,p)=>e.findById(a,p),getInfo:(a,p)=>e.findInfoById(a,p),getInfoResponse:(a,p)=>e.findInfoResponseById(a,p),list:a=>e.findAll(a)},hadithReferences:{byAyah:(a,p)=>n.findByAyah(a,p),countWithinRange:(a,p,c)=>n.countWithinRange(a,p,c),hadithsByAyah:(a,p)=>n.findHadithsByAyah(a,p)},juzs:{list:()=>r.findAll()},raw:h,resources:{findSnapshot:(a,p,c)=>i.findSnapshot(a,p,c),chapterInfos:{list:a=>i.findAllChapterInfos(a)},chapterReciters:{list:a=>i.findAllChapterReciters(a)},languages:{list:a=>i.findAllLanguages(a)},recitationStyles:{list:a=>i.findAllRecitationStyles(a)},recitations:{getInfo:(a,p)=>i.findRecitationInfo(a,p),list:a=>i.findAllRecitations(a)},tafsirs:{getInfo:(a,p)=>i.findTafsirInfo(a,p),list:a=>i.findAllTafsirs(a)},translations:{getInfo:(a,p)=>i.findTranslationInfo(a,p),list:a=>i.findAllTranslations(a)},verseMedia:{list:a=>i.findVerseMedia(a)},sync:a=>i.sync(a)},verses:{byChapter:(a,p)=>t.findByChapter(a,p),byHizb:(a,p)=>t.findByHizb(a,p),byJuz:(a,p)=>t.findByJuz(a,p),byKey:(a,p)=>t.findByKey(a,p),byPage:(a,p)=>t.findByPage(a,p),byRange:(a,p,c)=>t.findByRange(a,p,c),byRub:(a,p)=>t.findByRub(a,p),random:a=>t.findRandom(a)}}),pe=(o,e)=>{let t=new I(o,e);t.getFetch();let r=new w(t),s=new k(t),n=new B(t),i=new E(t),h=new S(t),a=new T(t),p=new V(t),c=new O(t),l={auth:{v1:f(t,d.auth.v1)},content:{v4:f(t,d.content.v4)},oauth2:{v1:f(t,d.oauth2.v1)},quranReflect:{v1:f(t,d.quranReflect.v1)},search:{v1:f(t,d.search.v1)}},K=xe(r,s,n,i,h,a,p,l.content.v4),$=Ve(t),j=Oe(t),W=Be(t,o,e),D=({query:ce,...ue})=>c.search(ce,ue),he=Object.assign(c,{query:D,raw:l.search.v1,v1:{query:D,raw:l.search.v1}});return {answers:r,audio:h,auth:{...$,v1:$},chapters:s,clearCachedTokens:()=>t.clearCachedTokens(),content:{...K,v4:K},getUserSession:()=>t.getUserSession(),hadithReferences:a,juzs:i,oauth2:{...W,v1:W},quranReflect:{...j,v1:j},raw:l,resources:p,search:he,verses:n}};var wr=o=>pe("server",{...o,defaults:{language:"ar",...o.defaults}});
|
|
2
|
-
export{
|
|
1
|
+
import ye from'humps';var D={auth:{v1:{operations:{getV1Collections:{auth:"user",method:"get",path:"/v1/collections"},postV1Collections:{auth:"user",method:"post",path:"/v1/collections"},postV1CollectionsByCollectionIdBookmarks:{auth:"user",method:"post",path:"/v1/collections/{collectionId}/bookmarks"},deleteV1CollectionsByCollectionIdBookmarks:{auth:"user",method:"delete",path:"/v1/collections/{collectionId}/bookmarks"},getV1CollectionsByCollectionId:{auth:"user",method:"get",path:"/v1/collections/{collectionId}"},postV1CollectionsByCollectionId:{auth:"user",method:"post",path:"/v1/collections/{collectionId}"},deleteV1CollectionsByCollectionId:{auth:"user",method:"delete",path:"/v1/collections/{collectionId}"},deleteV1CollectionsByCollectionIdBookmarksByBookmarkId:{auth:"user",method:"delete",path:"/v1/collections/{collectionId}/bookmarks/{bookmarkId}"},getV1CollectionsAll:{auth:"user",method:"get",path:"/v1/collections/all"},getV1Bookmarks:{auth:"user",method:"get",path:"/v1/bookmarks"},postV1Bookmarks:{auth:"user",method:"post",path:"/v1/bookmarks"},deleteV1BookmarksByBookmarkId:{auth:"user",method:"delete",path:"/v1/bookmarks/{bookmarkId}"},getV1BookmarksAyahsRange:{auth:"user",method:"get",path:"/v1/bookmarks/ayahs-range"},getV1BookmarksBookmark:{auth:"user",method:"get",path:"/v1/bookmarks/bookmark"},getV1BookmarksCollections:{auth:"user",method:"get",path:"/v1/bookmarks/collections"},getV1Preferences:{auth:"user",method:"get",path:"/v1/preferences"},postV1Preferences:{auth:"user",method:"post",path:"/v1/preferences"},postV1PreferencesBulk:{auth:"user",method:"post",path:"/v1/preferences/bulk"},getV1ReadingSessions:{auth:"user",method:"get",path:"/v1/reading-sessions"},postV1ReadingSessions:{auth:"user",method:"post",path:"/v1/reading-sessions"},getV1GoalsGetTodaysPlan:{auth:"user",method:"get",path:"/v1/goals/get-todays-plan"},putV1GoalsById:{auth:"user",method:"put",path:"/v1/goals/{id}"},deleteV1GoalsById:{auth:"user",method:"delete",path:"/v1/goals/{id}"},postV1Goals:{auth:"user",method:"post",path:"/v1/goals"},getV1GoalsEstimate:{auth:"user",method:"get",path:"/v1/goals/estimate"},getV1Streaks:{auth:"user",method:"get",path:"/v1/streaks"},getV1StreaksCurrentStreakDays:{auth:"user",method:"get",path:"/v1/streaks/current-streak-days"},getV1ActivityDays:{auth:"user",method:"get",path:"/v1/activity-days"},postV1ActivityDays:{auth:"user",method:"post",path:"/v1/activity-days"},getV1ActivityDaysEstimateReadingTime:{auth:"user",method:"get",path:"/v1/activity-days/estimate-reading-time"},getV1Notes:{auth:"user",method:"get",path:"/v1/notes"},postV1Notes:{auth:"user",method:"post",path:"/v1/notes"},getV1NotesByVerseByVerseKey:{auth:"user",method:"get",path:"/v1/notes/by-verse/{verseKey}"},getV1NotesByAttachedEntity:{auth:"user",method:"get",path:"/v1/notes/by-attached-entity"},getV1NotesCountWithinRange:{auth:"user",method:"get",path:"/v1/notes/count-within-range"},getV1NotesByRange:{auth:"user",method:"get",path:"/v1/notes/by-range"},getV1NotesByNoteId:{auth:"user",method:"get",path:"/v1/notes/{noteId}"},patchV1NotesByNoteId:{auth:"user",method:"patch",path:"/v1/notes/{noteId}"},deleteV1NotesByNoteId:{auth:"user",method:"delete",path:"/v1/notes/{noteId}"},postV1NotesByNoteIdPublish:{auth:"user",method:"post",path:"/v1/notes/{noteId}/publish"}},service:"auth",version:"v1"}},content:{v4:{operations:{audioReciterTimestamp:{auth:"app",method:"get",path:"/audio/reciters/{reciter_id}/timestamp"},audioReciterLookup:{auth:"app",method:"get",path:"/audio/reciters/{reciter_id}/lookup"},listChapters:{auth:"app",method:"get",path:"/chapters"},getChapter:{auth:"app",method:"get",path:"/chapters/{id}"},getChapterInfo:{auth:"app",method:"get",path:"/chapters/{id}/info"},hadithReferencesByAyah:{auth:"app",method:"get",path:"/hadith_references/by_ayah/{ayah_key}"},hadithsByAyah:{auth:"app",method:"get",path:"/hadith_references/by_ayah/{ayah_key}/hadiths"},hadithCountWithinRange:{auth:"app",method:"get",path:"/hadith_references/count_within_range"},listPages:{auth:"app",method:"get",path:"/pages"},getPagesLookup:{auth:"app",method:"get",path:"/pages/lookup"},getPagesPageNumber:{auth:"app",method:"get",path:"/pages/{page_number}"},versesByChapterNumber:{auth:"app",method:"get",path:"/verses/by_chapter/{chapter_number}"},versesByPageNumber:{auth:"app",method:"get",path:"/verses/by_page/{page_number}"},versesByJuzNumber:{auth:"app",method:"get",path:"/verses/by_juz/{juz_number}"},versesByHizbNumber:{auth:"app",method:"get",path:"/verses/by_hizb/{hizb_number}"},versesByRubElHizbNumber:{auth:"app",method:"get",path:"/verses/by_rub/{rub_el_hizb_number}"},versesByManzilNumber:{auth:"app",method:"get",path:"/verses/by_manzil/{manzil_number}"},versesByRukuNumber:{auth:"app",method:"get",path:"/verses/by_ruku/{ruku_number}"},versesByRange:{auth:"app",method:"get",path:"/verses/by_range"},versesByVerseKey:{auth:"app",method:"get",path:"/verses/by_key/{verse_key}"},randomVerse:{auth:"app",method:"get",path:"/verses/random"},listJuzs:{auth:"app",method:"get",path:"/juzs"},quranVersesByScript:{auth:"app",method:"get",path:"/quran/verses/{script}"},quranVersesIndopak:{auth:"app",method:"get",path:"/quran/verses/indopak"},quranVersesIndopakNastaleeq:{auth:"app",method:"get",path:"/quran/verses/indopak_nastaleeq"},quranVersesUthmaniTajweed:{auth:"app",method:"get",path:"/quran/verses/uthmani_tajweed"},quranVersesUthmani:{auth:"app",method:"get",path:"/quran/verses/uthmani"},quranVersesUthmaniSimple:{auth:"app",method:"get",path:"/quran/verses/uthmani_simple"},quranVersesImlaei:{auth:"app",method:"get",path:"/quran/verses/imlaei"},recitations:{auth:"app",method:"get",path:"/resources/recitations"},recitationAudioFiles:{auth:"app",method:"get",path:"/quran/recitations/{recitation_id}"},translation:{auth:"app",method:"get",path:"/quran/translations/{translation_id}"},chapterReciters:{auth:"app",method:"get",path:"/resources/chapter_reciters"},tafsir:{auth:"app",method:"get",path:"/quran/tafsirs/{tafsir_id}"},quranVersesCodeV1:{auth:"app",method:"get",path:"/quran/verses/code_v1"},quranVersesCodeV2:{auth:"app",method:"get",path:"/quran/verses/code_v2"},listSurahRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_chapter/{chapter_number}"},listJuzRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_juz/{juz_number}"},listPageRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_page/{page_number}"},listRubElHizbRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_rub/{rub_el_hizb_number}"},listHizbRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_hizb/{hizb_number}"},listAyahRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_ayah/{ayah_key}"},recitationInfo:{auth:"app",method:"get",path:"/resources/recitations/{recitation_id}/info"},translationInfo:{auth:"app",method:"get",path:"/resources/translations/{translation_id}/info"},translations:{auth:"app",method:"get",path:"/resources/translations"},tafsirs:{auth:"app",method:"get",path:"/resources/tafsirs"},tafsirInfo:{auth:"app",method:"get",path:"/resources/tafsirs/{tafsir_id}/info"},recitationStyles:{auth:"app",method:"get",path:"/resources/recitation_styles"},languages:{auth:"app",method:"get",path:"/resources/languages"},chapterInfo:{auth:"app",method:"get",path:"/resources/chapter_infos"},verseMedia:{auth:"app",method:"get",path:"/resources/verse_media"},listManzilRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_manzil/{manzil_number}"},listRukuRecitation:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_ruku/{ruku_number}"},listSurahTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_chapter/{chapter_number}"},listPageTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_page/{page_number}"},listJuzTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_juz/{juz_number}"},listRubElHizbTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_rub_el_hizb/{rub_el_hizb_number}"},listHizbTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_hizb/{hizb_number}"},listManzilTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_manzil/{manzil_number}"},listRukuTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_ruku/{ruku_number}"},listAyahTranslations:{auth:"app",method:"get",path:"/translations/{resource_id}/by_ayah/{ayah_key}"},listSurahTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_chapter/{chapter_number}"},listPageTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_page/{page_number}"},listJuzTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_juz/{juz_number}"},listRubElHizbTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_rub_el_hizb/{rub_el_hizb_number}"},listHizbTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_hizb/{hizb_number}"},listManzilTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_manzil/{manzil_number}"},listRukuTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_ruku/{ruku_number}"},listAyahTafsirs:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_ayah/{ayah_key}"},getJuz:{auth:"app",method:"get",path:"/juzs/{id}"},listHizbs:{auth:"app",method:"get",path:"/hizbs"},getHizb:{auth:"app",method:"get",path:"/hizbs/{id}"},listRubElHizbs:{auth:"app",method:"get",path:"/rub_el_hizbs"},getRubElHizb:{auth:"app",method:"get",path:"/rub_el_hizbs/{id}"},listRukus:{auth:"app",method:"get",path:"/rukus"},getRuku:{auth:"app",method:"get",path:"/rukus/{id}"},listManzils:{auth:"app",method:"get",path:"/manzils"},getManzil:{auth:"app",method:"get",path:"/manzils/{id}"},getFootNote:{auth:"app",method:"get",path:"/foot_notes/{id}"},postsControllerFeed:{auth:"app",method:"get",path:"/quran-reflect/v1/posts/feed"},postsControllerFindOne:{auth:"app",method:"get",path:"/quran-reflect/v1/posts/{id}"},postsControllerGetUserPost:{auth:"app",method:"get",path:"/quran-reflect/v1/posts/user-posts/{id}"},postsControllerGetComments:{auth:"app",method:"get",path:"/quran-reflect/v1/posts/{id}/comments"},postsControllerGetAllComment:{auth:"app",method:"get",path:"/quran-reflect/v1/posts/{id}/all-comments"},chapterReciterAudioFiles:{auth:"app",method:"get",path:"/chapter_recitations/{reciter_id}"},chapterReciterAudioFile:{auth:"app",method:"get",path:"/chapter_recitations/{reciter_id}/{chapter_number}"},versesByRubElHizbNumberRubElHizb:{auth:"app",method:"get",path:"/verses/by_rub_el_hizb/{rub_el_hizb_number}"},listRubElHizbTranslationsRub:{auth:"app",method:"get",path:"/translations/{resource_id}/by_rub/{rub_el_hizb_number}"},listRubElHizbTafsirsRub:{auth:"app",method:"get",path:"/tafsirs/{resource_id}/by_rub/{rub_el_hizb_number}"},listRubElHizbRecitationRubElHizb:{auth:"app",method:"get",path:"/recitations/{recitation_id}/by_rub_el_hizb/{rub_el_hizb_number}"},listAyahAnswers:{auth:"app",method:"get",path:"/answers/by_ayah/{ayah_key}"},getAnswerById:{auth:"app",method:"get",path:"/answers/{question_id}"},countAnswersWithinRange:{auth:"app",method:"get",path:"/answers/count_within_range"},resourcesSync:{auth:"app",method:"get",path:"/resources/sync"},resourcesSnapshot:{auth:"app",method:"get",path:"/resources/snapshots/{resource_group}/{id}"}},service:"content",version:"v4"}},oauth2:{v1:{operations:{oauth2TokenExchange:{auth:"none",method:"post",path:"/oauth2/token"},introspectOauth2Token:{auth:"none",method:"post",path:"/oauth2/introspect"},oAuth2Authorize:{auth:"none",method:"get",path:"/oauth2/auth"},getOidcUserInfo:{auth:"user",method:"get",path:"/userinfo"},revokeOidcSession:{auth:"none",method:"get",path:"/oauth2/sessions/logout"}},service:"oauth2",version:"v1"}},quranReflect:{v1:{operations:{usersControllerProfile:{auth:"user",method:"get",path:"/v1/users/profile"},usersControllerUpdateProfile:{auth:"user",method:"put",path:"/v1/users/profile"},usersControllerEditProfile:{auth:"user",method:"patch",path:"/v1/users/profile"},usersControllerRooms:{auth:"user",method:"get",path:"/v1/users/my-rooms"},usersControllerSearch:{auth:"user",method:"get",path:"/v1/users/search"},usersControllerToggleFollow:{auth:"user",method:"post",path:"/v1/users/{followeeId}/toggle-follow"},usersControllerRemoveFollower:{auth:"user",method:"post",path:"/v1/users/{followerId}/remove-follower"},usersControllerGetUserProfile:{auth:"user",method:"get",path:"/v1/users/{id}"},usersControllerGetUserProfile2:{auth:"user",method:"get",path:"/v1/users/{username}/profile"},usersControllerGetUserFollowers:{auth:"user",method:"get",path:"/v1/users/{id}/followers"},usersControllerGetUserFollowing:{auth:"user",method:"get",path:"/v1/users/{id}/following"},roomsControllerAdminsAccess:{auth:"user",method:"post",path:"/v1/rooms/admins-access"},roomsControllerCreateNewGroup:{auth:"user",method:"post",path:"/v1/rooms/groups"},roomsControllerUpdateGroup:{auth:"user",method:"patch",path:"/v1/rooms/groups"},roomsControllerCreateNewPage:{auth:"user",method:"post",path:"/v1/rooms/pages"},roomsControllerUpdatePage:{auth:"user",method:"patch",path:"/v1/rooms/pages"},roomsControllerGetRoomMembers:{auth:"user",method:"get",path:"/v1/rooms/{id}/members"},roomsControllerInviteUserToRoom:{auth:"user",method:"post",path:"/v1/rooms/{id}/invite"},roomsControllerAcceptInvite:{auth:"user",method:"get",path:"/v1/rooms/{id}/accept-invite"},roomsControllerRejectInvite:{auth:"user",method:"get",path:"/v1/rooms/{id}/reject-invite"},roomsControllerRemoveMember:{auth:"user",method:"delete",path:"/v1/rooms/{id}/members/{userId}"},roomsControllerGetRooms:{auth:"user",method:"get",path:"/v1/rooms/joined-rooms"},roomsControllerGetRooms2:{auth:"user",method:"get",path:"/v1/rooms/managed-rooms"},roomsControllerSearchRooms:{auth:"user",method:"get",path:"/v1/rooms/search"},roomsControllerGetRoomProfile:{auth:"user",method:"get",path:"/v1/rooms/group/{url}"},roomsControllerGetRoomProfile2:{auth:"user",method:"get",path:"/v1/rooms/page/{subdomain}"},roomsControllerAcceptByPrivateToken:{auth:"user",method:"get",path:"/v1/rooms/group/{url}/accept/{token}"},roomsControllerAcceptByPrivateToken2:{auth:"user",method:"get",path:"/v1/rooms/page/{subdomain}/accept/{token}"},roomsControllerGetRoomProfileById:{auth:"user",method:"get",path:"/v1/rooms/{id}"},roomsControllerGetRoomPosts:{auth:"user",method:"get",path:"/v1/rooms/{id}/posts"},roomsControllerJoinRoom:{auth:"user",method:"post",path:"/v1/rooms/{groupId}/join"},roomsControllerLeaveGroup:{auth:"user",method:"post",path:"/v1/rooms/{groupId}/leave"},roomsControllerFollowPage:{auth:"user",method:"post",path:"/v1/rooms/{pageId}/follow"},roomsControllerUnfollowPage:{auth:"user",method:"post",path:"/v1/rooms/{pageId}/unfollow"},roomsControllerUpdatePostPrivacy:{auth:"user",method:"patch",path:"/v1/rooms/{roomId}/posts/{postId}/privacy"},postsControllerFeed:{auth:"user",method:"get",path:"/v1/posts/feed"},postsControllerGetRelatedPosts:{auth:"user",method:"get",path:"/v1/posts/{postId}/related"},postsControllerGetLoggedinUserPosts:{auth:"user",method:"get",path:"/v1/posts/my-posts"},postsControllerGetLikedState:{auth:"user",method:"get",path:"/v1/posts/{id}/liked"},postsControllerFindOne:{auth:"user",method:"get",path:"/v1/posts/{id}"},postsControllerEdit:{auth:"user",method:"patch",path:"/v1/posts/{id}"},postsControllerDelete:{auth:"user",method:"delete",path:"/v1/posts/{id}"},postsControllerViewTracking:{auth:"user",method:"get",path:"/v1/posts/viewed/{id}"},postsControllerCreate:{auth:"user",method:"post",path:"/v1/posts"},postsControllerReportAbuse:{auth:"user",method:"post",path:"/v1/posts/{id}/report"},postsControllerGetUserPost:{auth:"user",method:"get",path:"/v1/posts/user-posts/{id}"},postsControllerToggleLike:{auth:"user",method:"post",path:"/v1/posts/{id}/toggle-like"},postsControllerToggleSave:{auth:"user",method:"post",path:"/v1/posts/{id}/toggle-save"},postsControllerGetComments:{auth:"user",method:"get",path:"/v1/posts/{id}/comments"},postsControllerGetAllComment:{auth:"user",method:"get",path:"/v1/posts/{id}/all-comments"},postsControllerExportMultiplePosts:{auth:"user",method:"post",path:"/v1/posts/export/pdf"},postsControllerGetMyPostsCountWithinRange:{auth:"user",method:"get",path:"/v1/posts/count-within-range"},postsControllerGetMyPostsByVerse:{auth:"user",method:"get",path:"/v1/posts/by-verse/{verseKey}"},tagsControllerFind:{auth:"user",method:"get",path:"/v1/tags"},commentsControllerCreate:{auth:"user",method:"post",path:"/v1/comments"},commentsControllerEdit:{auth:"user",method:"patch",path:"/v1/comments/{id}"},commentsControllerDeleteComment:{auth:"user",method:"get",path:"/v1/comments/{id}/delete"},commentsControllerToggleLike:{auth:"user",method:"post",path:"/v1/comments/{id}/toggle-like"},commentsControllerGet:{auth:"user",method:"get",path:"/v1/comments/{id}/replies"}},service:"quranReflect",version:"v1"}},search:{v1:{operations:{searchControllerSearch:{auth:"app",method:"get",path:"/v1/search"}},service:"search",version:"v1"}}};var d=D,G=(o,e,t)=>({...t,operationName:t.operationName??e,service:t.service??o.service,tags:t.tags??[],version:t.version??o.version});var R=(o,e)=>{let t=`${o}:${e}`;if(typeof Buffer<"u")return Buffer.from(t).toString("base64");if(typeof globalThis.btoa=="function")return globalThis.btoa(t);throw new Error("No base64 encoder available for HTTP basic auth.")},J=(o,e)=>{if(!(o.body===void 0||o.body===null))return typeof o.body=="string"||o.body instanceof URLSearchParams?(o.contentType&&e.set("Content-Type",o.contentType),o.body):(e.set("Content-Type",o.contentType??"application/json"),JSON.stringify(o.body))},v=(o,e)=>{let t=o.expiresIn??o.expires_in,r=o.accessToken??o.access_token,s=o.idToken??o.id_token??e?.idToken,n=o.refreshToken??o.refresh_token??e?.refreshToken,i=o.tokenType??o.token_type??e?.tokenType,h=o.scope??e?.scope,a=t?Date.now()+t*1e3:e?.expiresAt;return {accessToken:r,expiresAt:a,idToken:s,refreshToken:n,scope:h,tokenType:i}};var Y={delete:"remove",get:"list",patch:"update",post:"create",put:"update"},P=o=>{let e=o.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[^A-Za-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean);return e.length===0?"misc":e.map((t,r)=>{let s=t.toLowerCase();return r===0?s:s.charAt(0).toUpperCase()+s.slice(1)}).join("")},fe=o=>{let e=P(o);return e.charAt(0).toUpperCase()+e.slice(1)},b=o=>o.startsWith("{")&&o.endsWith("}"),Z=o=>{let e=o.split("/").filter(Boolean);return e[0]?.match(/^v\d+$/)?e.slice(1):e},ge=o=>{let e=Z(o.path),t=e.at(-1),r=e.filter(i=>!b(i)),s=r.at(-1),n=r[0];return e.length===1?Y[o.method]:e.length===2&&t&&b(t)?o.method==="get"?"get":o.method==="delete"?"remove":"update":t&&!b(t)&&s?s===n?`${Y[o.method]}ById`:P(s):P(o.operationName)},f=(o,e)=>{let t={};for(let[r,s]of Object.entries(e.operations)){let n=G(e,r,s);t[r]=i=>o.requestOperation(n,i);}return t},x=(o,e)=>{let t={};for(let[r,s]of Object.entries(o.operations)){let n=G(o,r,s),i=Z(n.path).filter(l=>!b(l)),h=P(i[0]??"misc"),a=ge(n),p=t[h]??{},u=a;p[u]&&(u=`${a}${fe(r)}`),p[u]=e[r],t[h]=p;}return t};var{decamelize:U}=ye,y=o=>o.startsWith("/")?o:`/${o}`,g=o=>o.endsWith("/")?o.slice(0,-1):o;var A=(o,e)=>o.replace(/\{([^}]+)\}/g,(t,r)=>{let s=e?.[r];if(s===void 0)throw new Error(`Missing path parameter: ${r}`);return encodeURIComponent(String(s))}),C=o=>o.replace(/(^|\/):([A-Za-z0-9_]+)/g,"$1{$2}"),X=["wordFields","translationFields","fields"],L=new Set([...X,...X.map(o=>U(o))]),Re=new Set(["navigationalResultsNumber","pageSize","versesResultsNumber"]),ee=(o,e={})=>{if(!o)return "";let t=new URLSearchParams;for(let[r,s]of Object.entries(o)){if(s===void 0)continue;let n=e.preserveCase||Re.has(r)?r:U(r);if(L.has(r)||L.has(n)){let i=Object.entries(s).filter(([,h])=>h).map(([h])=>U(h));i.length>0&&t.set(n,i.join(","));continue}typeof s=="string"?t.set(n,s):typeof s=="number"||typeof s=="boolean"?t.set(n,s.toString()):Array.isArray(s)&&t.set(n,s.join(","));}return t.size===0?"":`?${t.toString()}`};var ve=o=>!!o&&typeof o=="object"&&!Array.isArray(o),be=o=>ve(o)?typeof o.body=="string"&&typeof o.draft=="boolean"&&Array.isArray(o.references)&&Array.isArray(o.mentions):false,te=(o,e)=>({...o,create:n=>be(n)?e("POST","/v1/posts",{body:{post:n}}):e("POST","/v1/posts",n),get:(n,i)=>typeof n=="string"||typeof n=="number"?e("GET","/v1/posts/{id}",{path:{id:n},query:i}):e("GET","/v1/posts/{id}",n),update:(n,i)=>i!==void 0?e("PATCH","/v1/posts/{id}",{body:i,path:{id:n}}):e("PATCH","/v1/posts/{id}",n)});var m=o=>{let e=typeof o=="number"?o:Number(o);return !(!e||e<=0||e>114)};var z=o=>{let e=typeof o=="number"?o:Number(o);return !(!e||e<=0||e>30)};var N=o=>{let e=typeof o=="number"?o:Number(o);return !(!e||e<=0||e>240)};var q=o=>{let e=typeof o=="number"?o:Number(o);return !(!e||e<=0||e>60)};var H=o=>{let e=typeof o=="number"?o:Number(o);return !(!e||e<=0||e>604)};var re={1:7,2:286,3:200,4:176,5:120,6:165,7:206,8:75,9:129,10:109,11:123,12:111,13:43,14:52,15:99,16:128,17:111,18:110,19:98,20:135,21:112,22:78,23:118,24:64,25:77,26:227,27:93,28:88,29:69,30:60,31:34,32:30,33:73,34:54,35:45,36:83,37:182,38:88,39:75,40:85,41:54,42:53,43:89,44:59,45:37,46:35,47:38,48:29,49:18,50:45,51:60,52:49,53:62,54:55,55:78,56:96,57:29,58:22,59:24,60:13,61:14,62:11,63:11,64:18,65:12,66:12,67:30,68:52,69:52,70:44,71:28,72:28,73:20,74:56,75:40,76:31,77:50,78:40,79:46,80:42,81:29,82:19,83:36,84:25,85:22,86:17,87:19,88:26,89:30,90:20,91:15,92:21,93:11,94:8,95:8,96:19,97:5,98:8,99:8,100:11,101:11,102:8,103:3,104:9,105:5,106:4,107:7,108:3,109:6,110:3,111:5,112:4,113:5,114:6};var c=o=>{let[e,t]=o.trim().split(":");if(!e||!t||!m(e))return false;let r=Number(t),s=re[e];return !(!r||r<=0||r>s)};var Pe=o=>Object.fromEntries(Object.entries(o).map(([e,t])=>t.types?[e,{...t,types:Object.fromEntries(Object.entries(t.types).map(([r,s])=>[r.toUpperCase(),s]))}]:[e,t])),w=class{constructor(e){this.fetcher=e;}async findByAyah(e,t){if(!c(e))throw new Error("Invalid verse key");return this.fetcher.fetch(`/content/api/v4/answers/by_ayah/${e}`,t)}async findByQuestionId(e){return this.fetcher.fetch(`/content/api/v4/answers/${e}`)}async countWithinRange(e,t,r){if(!c(e)||!c(t))throw new Error("Invalid verse key");let s=await this.fetcher.fetch("/content/api/v4/answers/count_within_range",{...r,from:e,to:t});return Pe(s)}};var Ae="https://verses.quran.com";function se(o){return o.map(e=>{let t=e.url.startsWith("http://")||e.url.startsWith("https://")?e.url:`${Ae}/${e.url.replace(/^\/+/,"")}`;return {...e,audioUrl:t}})}var S=class{constructor(e){this.fetcher=e;}async findAllChapterRecitations(e,t){let{audioFiles:r}=await this.fetcher.fetch(`/content/api/v4/chapter_recitations/${e}`,t);return r}async findChapterRecitationById(e,t,r){if(!m(t))throw new Error("Invalid chapter id");let{audioFile:s}=await this.fetcher.fetch(`/content/api/v4/chapter_recitations/${e}/${t}`,r);return s}async findVerseRecitationsByChapter(e,t,r){if(!m(e))throw new Error("Invalid chapter id");let s=await this.fetcher.fetch(`/content/api/v4/recitations/${t}/by_chapter/${e}`,r);return {...s,audioFiles:se(s.audioFiles)}}async findVerseRecitationsByKey(e,t,r){if(!c(e))throw new Error("Invalid verse key");let s=await this.fetcher.fetch(`/content/api/v4/recitations/${t}/by_ayah/${e}`,r);return {...s,audioFiles:se(s.audioFiles)}}};var k=class{constructor(e){this.fetcher=e;}async findAll(e){let{chapters:t}=await this.fetcher.fetch("/content/api/v4/chapters",e);return t}async findById(e,t){if(!m(e))throw new Error("Invalid chapter id");let{chapter:r}=await this.fetcher.fetch(`/content/api/v4/chapters/${e}`,t);return r}async findInfoById(e,t){let{chapterInfo:r}=await this.findInfoResponseById(e,t);return r}async findInfoResponseById(e,t){if(!m(e))throw new Error("Invalid chapter id");return this.fetcher.fetch(`/content/api/v4/chapters/${e}/info`,t)}};var F=async(o,e={retries:3})=>{let t;for(let r=0;r<=e.retries;r++)try{return await o()}catch(s){if(t=s,r===e.retries)throw t;await new Promise(n=>setTimeout(n,Math.pow(2,r)*1e3));}throw t};var oe="https://apis.quran.foundation",_={auth:"https://apis.quran.foundation/auth",content:"https://apis.quran.foundation/content",oauth2:"https://oauth2.quran.foundation",quranReflect:"https://apis.quran.foundation/quran-reflect",search:"https://apis.quran.foundation/search"},ae={auth:"/v1",content:"/api/v4",oauth2:"",quranReflect:"/v1",search:"/v1"},Q={auth:"/auth/v1",content:"/content/api/v4",oauth2:"",quranReflect:"/quran-reflect/v1",search:"/search/v1"},ne={auth:["/auth/v1","/v1"],content:["/content/api/v4","/api/v4"],oauth2:[],quranReflect:["/quran-reflect/v1","/v1"],search:["/search/v1","/v1"]};var{camelizeKeys:we}=ye,ie={content:"content",search:"search"},Se="/quran-reflect/v1/posts/",ke=["/comments","/all-comments"],_e=["auth","content","quranReflect","search"],pe="User session expired. Sign in again.",Te="invalid_grant",Ie=6e4,Ee=async o=>{try{return await o.text()}catch{return ""}},Oe=(o,e)=>o.status<400||o.status>=500||o.status===429?false:e.toLowerCase().includes(Te),Ve=(o,e)=>{let t=e.trim(),r=t?`: ${t}`:"";return `Token refresh failed: ${o.status} ${o.statusText}${r}`},T=class{constructor(e,t){this.mode=e;this.config=t;this.userSession=t.userSession;}appTokens=new Map;userSession;userSessionRefreshPromise=null;getFetch(){let e=this.config.fetch??globalThis.fetch;if(typeof e!="function")throw new Error("No fetch function available. Please provide a fetch implementation or ensure global fetch is available.");return e}clearCachedTokens(){this.appTokens.clear();}async getUserSession(){let e=await this.config.storage?.getSession?.();return e!==void 0?e:this.userSession??null}async setUserSession(e){if(!this.config.storage){this.userSession=e;return}if(!e){if(this.config.storage.clearSession){await this.config.storage.clearSession(),this.userSession=null;return}await this.config.storage.setSession?.(null),this.userSession=null;return}await this.config.storage.setSession?.(e),this.userSession=e;}buildServiceUrl(e,t,r){let s=this.isCrossServiceGatewayPath(e,t),{baseUrl:n,usesGateway:i}=this.resolveServiceBaseUrl(e,s),h=this.normalizeServicePath(e,t,i,s);return `${n}${h}${ee(r,{preserveCase:e==="auth"||e==="quranReflect"})}`}async requestOperation(e,t){return this.request(e.service,A(e.path,t?.path),t?.query,{...t,auth:t?.auth==="auto"||!t?.auth?e.auth:t.auth,method:t?.method??e.method.toUpperCase(),path:void 0})}async request(e,t,r,s={}){let n=this.resolveAuthMode(e,s.auth);if(this.mode==="public"&&n==="app")throw new Error("This API requires @quranjs/api/server or a backend. Content and search are server-side for confidential clients.");let i=this.buildServiceUrl(e,t,r),h=await this.getRequestUserSession(n,s),a=await this.performRequest(e,i,s,n,h?.accessToken);if(this.shouldRetryUserRequest(a,n,s,h)){let l=await this.refreshStoredUserSession();a=await this.performRequest(e,i,s,n,l.accessToken);}if(!a.ok)throw new Error(`${a.status} ${a.statusText}`);if(a.status===204)return;if(!(a.headers.get("content-type")??"").includes("application/json"))return await a.text();let u=await a.json();return we(u)}async fetch(e,t){let r=this.resolveLegacyRoute(e);return this.request(r.service,r.path,{...this.config.defaults,...t})}async performRequest(e,t,r,s,n){let i=new Headers(r.headers),h=J(r,i);return e!=="oauth2"&&i.set("x-client-id",this.config.clientId),await this.applyAuthenticationHeaders(e,s,i,{...r,accessToken:n??r.accessToken},t),this.getFetch()(t,{body:h,headers:i,method:r.method??"GET"})}resolveLegacyRoute(e){let t=y(C(e));if(t.startsWith("/content/api/v4")||t.startsWith("/api/v4"))return {path:t,service:"content"};if(t==="/v1/search"||t.startsWith("/search/v1"))return {path:t,service:"search"};if(t.startsWith("/auth/v1"))return {path:t,service:"auth"};if(t.startsWith("/quran-reflect/v1"))return {path:t,service:"quranReflect"};if(t.startsWith("/oauth2")||t.startsWith("/userinfo"))return {path:t,service:"oauth2"};throw new Error(`Unsupported SDK route: ${e}`)}resolveAuthMode(e,t="auto"){return t!=="auto"?t:e==="content"||e==="search"?"app":e==="auth"||e==="quranReflect"?"user":"none"}async getRequestUserSession(e,t){if(e!=="user"||t.accessToken||this.mode!=="server")return null;let r=await this.getUserSession();if(!r?.accessToken)throw new Error("This operation requires a user session. Sign in first or use @quranjs/api/server.");return this.shouldRefreshUserSession(r)?this.refreshStoredUserSession(r):r}shouldRefreshUserSession(e){return !e.refreshToken||!e.expiresAt?false:e.expiresAt<=Date.now()+Ie}shouldRetryUserRequest(e,t,r,s){return e.status!==401||t!=="user"||r.accessToken||this.mode!=="server"?false:!!s?.refreshToken}async applyAuthenticationHeaders(e,t,r,s,n){if(s.basicAuth&&r.set("Authorization",`Basic ${R(s.basicAuth.username,s.basicAuth.password)}`),s.accessToken){this.setTokenHeaders(e,r,s.accessToken);return}if(t==="none")return;if(t==="app"){let h=await this.getAppAccessToken(e,n);this.setTokenHeaders(e,r,h);return}let i=await this.getUserSession();if(!i?.accessToken)throw new Error("This operation requires a user session. Sign in first or use @quranjs/api/server.");this.setTokenHeaders(e,r,i.accessToken);}async refreshStoredUserSession(e){if(this.userSessionRefreshPromise)return this.userSessionRefreshPromise;let t=this.executeUserSessionRefresh(e);this.userSessionRefreshPromise=t;try{return await t}finally{this.userSessionRefreshPromise===t&&(this.userSessionRefreshPromise=null);}}async executeUserSessionRefresh(e){if(this.mode!=="server"||!("clientSecret"in this.config))throw new Error("Automatic session refresh requires @quranjs/api/server or a backend.");let t=this.config.clientSecret,r=e??await this.getUserSession();if(!r?.refreshToken)throw new Error(pe);let s=`${g(this.config.services?.tokenHost??this.config.services?.oauth2BaseUrl??_.oauth2)}/oauth2/token`,n=new URLSearchParams({grant_type:"refresh_token",refresh_token:r.refreshToken}),i=await F(()=>this.getFetch()(s,{body:n,headers:{Accept:"application/json",Authorization:`Basic ${R(this.config.clientId,t)}`,"Content-Type":"application/x-www-form-urlencoded"},method:"POST"}),{retries:3});if(!i.ok){let p=await Ee(i);throw Oe(i,p)?(await this.setUserSession(null),new Error(pe)):new Error(Ve(i,p))}let h=await i.json(),a=v(h,r);return await this.setUserSession(a),a}setTokenHeaders(e,t,r){if(e==="oauth2"){t.set("Authorization",`Bearer ${r}`);return}t.set("x-auth-token",r);}async getAppAccessToken(e,t){if(this.mode!=="server")throw new Error("App-authenticated APIs require @quranjs/api/server or a backend.");let r=this.resolveAppScope(e,t);if(!r)throw new Error(`No client-credentials scope is configured for ${e}.`);let s=`${e}:${r}`,n=this.appTokens.get(s);if(n&&n.expiresAt>Date.now()+3e4)return n.value;if(!("clientSecret"in this.config))throw new Error("client_secret is server-only. Use @quranjs/api/server.");let i=this.config.clientSecret,h=`${g(this.config.services?.tokenHost??this.config.services?.oauth2BaseUrl??_.oauth2)}/oauth2/token`,a=new URLSearchParams({grant_type:"client_credentials",scope:r}),p=await F(()=>this.getFetch()(h,{body:a,headers:{Accept:"application/json",Authorization:`Basic ${R(this.config.clientId,i)}`,"Content-Type":"application/x-www-form-urlencoded"},method:"POST"}),{retries:3});if(!p.ok)throw new Error(`Token request failed: ${p.status} ${p.statusText}`);let u=await p.json(),l={expiresAt:Date.now()+u.expires_in*1e3,value:u.access_token};return this.appTokens.set(s,l),l.value}resolveAppScope(e,t){if(e!=="content"||!t)return ie[e];let r=new URL(t).pathname;return r.startsWith(Se)?ke.some(s=>r.endsWith(s))?"comment.read":"post.read":ie.content}resolveServiceBaseUrl(e,t=false){let{services:r}=this.config;if(t)return {baseUrl:g(r?.gatewayUrl??oe),usesGateway:true};let s=e==="content"?r?.contentBaseUrl:e==="search"?r?.searchBaseUrl:e==="auth"?r?.authBaseUrl:e==="quranReflect"?r?.quranReflectBaseUrl:r?.oauth2BaseUrl??r?.tokenHost;return s?{baseUrl:g(s),usesGateway:false}:r?.gatewayUrl&&e!=="oauth2"?{baseUrl:g(r.gatewayUrl),usesGateway:true}:{baseUrl:_[e],usesGateway:false}}normalizeServicePath(e,t,r,s=false){let n=y(C(t));if(e==="oauth2"||s)return n;let i=n;for(let a of ne[e])if(i.startsWith(a)){i=y(i.slice(a.length));break}let h=r?Q[e]:ae[e];return i.startsWith(h)?i:`${h}${i}`}isCrossServiceGatewayPath(e,t){let r=y(C(t)),s=_e.find(n=>this.pathMatchesPrefix(r,Q[n]));return !!(s&&s!==e)}pathMatchesPrefix(e,t){return t.length>0&&(e===t||e.startsWith(`${t}/`))}};var I=class{constructor(e){this.fetcher=e;}async findByAyah(e,t){if(!c(e))throw new Error("Invalid verse key");return this.fetcher.fetch(`/content/api/v4/hadith_references/by_ayah/${e}`,t)}async findHadithsByAyah(e,t){if(!c(e))throw new Error("Invalid verse key");return this.fetcher.fetch(`/content/api/v4/hadith_references/by_ayah/${e}/hadiths`,t)}async countWithinRange(e,t,r){if(!c(e)||!c(t))throw new Error("Invalid verse key");return this.fetcher.fetch("/content/api/v4/hadith_references/count_within_range",{...r,from:e,to:t})}};var E=class{constructor(e){this.fetcher=e;}async findAll(){let{juzs:e}=await this.fetcher.fetch("/content/api/v4/juzs");return e}};var O=class{constructor(e){this.fetcher=e;}async findAllRecitations(e){let{recitations:t}=await this.fetcher.fetch("/content/api/v4/resources/recitations",e);return t}async findAllTranslations(e){let{translations:t}=await this.fetcher.fetch("/content/api/v4/resources/translations",e);return t}async findAllTafsirs(e){let{tafsirs:t}=await this.fetcher.fetch("/content/api/v4/resources/tafsirs",e);return t}async findAllLanguages(e){let{languages:t}=await this.fetcher.fetch("/content/api/v4/resources/languages",e);return t}async findRecitationInfo(e,t){let{recitationInfo:r}=await this.fetcher.fetch(`/content/api/v4/resources/recitations/${e}/info`,t);return r}async findTranslationInfo(e,t){let{translationInfo:r}=await this.fetcher.fetch(`/content/api/v4/resources/translations/${e}/info`,t);return r}async findTafsirInfo(e,t){let{tafsirInfo:r}=await this.fetcher.fetch(`/content/api/v4/resources/tafsirs/${e}/info`,t);return r}async findAllChapterInfos(e){let{chapterInfos:t}=await this.fetcher.fetch("/content/api/v4/resources/chapter_infos",e);return t}async findAllChapterReciters(e){let{reciters:t}=await this.fetcher.fetch("/content/api/v4/resources/chapter_reciters",e);return t}async findAllRecitationStyles(e){let{recitationStyles:t}=await this.fetcher.fetch("/content/api/v4/resources/recitation_styles",e);return t}async findVerseMedia(e){let{verseMedia:t}=await this.fetcher.fetch("/content/api/v4/resources/verse_media",e);return t}async sync(e){return this.fetcher.fetch("/content/api/v4/resources/sync",e)}async findSnapshot(e,t,r){return this.fetcher.fetch(`/content/api/v4/resources/snapshots/${e}/${t}`,r)}};var V=class{constructor(e){this.fetcher=e;}async search(e,t){return this.fetcher.fetch("/v1/search",{query:e,size:30,...t})}};var B=class{constructor(e){this.fetcher=e;}async findByKey(e,t){if(!c(e))throw new Error("Invalid verse key");let{verse:r}=await this.fetcher.fetch(`/content/api/v4/verses/by_key/${e}`,{words:false,...t});return r}async findByRange(e,t,r){if(!c(e)||!c(t))throw new Error("Invalid verse key");let{verses:s}=await this.fetcher.fetch("/content/api/v4/verses/by_range",{words:false,...r,from:e,to:t});return s}async findByChapter(e,t){if(!m(e))throw new Error("Invalid chapter id");let{verses:r}=await this.fetcher.fetch(`/content/api/v4/verses/by_chapter/${e}`,{words:false,...t});return r}async findByPage(e,t){if(!H(e))throw new Error("Invalid page number");let{verses:r}=await this.fetcher.fetch(`/content/api/v4/verses/by_page/${e}`,{words:false,...t});return r}async findByJuz(e,t){if(!z(e))throw new Error("Invalid juz");let{verses:r}=await this.fetcher.fetch(`/content/api/v4/verses/by_juz/${e}`,{words:false,...t});return r}async findByHizb(e,t){if(!q(e))throw new Error("Invalid hizb");let{verses:r}=await this.fetcher.fetch(`/content/api/v4/verses/by_hizb/${e}`,{words:false,...t});return r}async findByRub(e,t){if(!N(e))throw new Error("Invalid rub");let{verses:r}=await this.fetcher.fetch(`/content/api/v4/verses/by_rub/${e}`,{words:false,...t});return r}async findRandom(e){let{verse:t}=await this.fetcher.fetch("/content/api/v4/verses/random",{words:false,...e});return t}};var Be="auth.bookmarks.get(bookmarkId) is not supported because /v1/bookmarks/bookmark expects bookmark detail query parameters. Pass a query object such as { mushafId, key, type, verseNumber } or { mushafId, isReading: true }.",he=(o,e)=>(t,r,s)=>o.request(e,A(r,s?.path),s?.query,{...s,auth:"user",method:t,path:void 0,query:void 0}),Ge=o=>{let e=f(o,d.auth.v1),t=x(d.auth.v1,e),r=he(o,"auth");return {...t,collections:{...t.collections,addBookmark:(s,n)=>r("POST","/v1/collections/{collectionId}/bookmarks",{body:n,path:{collectionId:s}}),create:s=>r("POST","/v1/collections",{body:s}),get:(s,n)=>r("GET","/v1/collections/{collectionId}",{path:{collectionId:s},query:n}),list:s=>r("GET","/v1/collections",{query:s}),listAll:s=>r("GET","/v1/collections/all",{query:s}),remove:s=>r("DELETE","/v1/collections/{collectionId}",{path:{collectionId:s}}),removeBookmark:(s,n)=>r("DELETE","/v1/collections/{collectionId}/bookmarks/{bookmarkId}",{path:{bookmarkId:n,collectionId:s}}),update:(s,n)=>r("POST","/v1/collections/{collectionId}",{body:n,path:{collectionId:s}})},bookmarks:{...t.bookmarks,create:s=>r("POST","/v1/bookmarks",{body:s}),get:async s=>{if(typeof s=="string")throw new Error(Be);return r("GET","/v1/bookmarks/bookmark",{query:s})},list:s=>r("GET","/v1/bookmarks",{query:s}),listCollections:s=>r("GET","/v1/bookmarks/collections",{query:s}),listRange:s=>r("GET","/v1/bookmarks/ayahs-range",{query:s}),remove:s=>r("DELETE","/v1/bookmarks/{bookmarkId}",{path:{bookmarkId:s}})},goals:{...t.goals,create:s=>r("POST","/v1/goals",{body:s}),estimate:s=>r("GET","/v1/goals/estimate",{query:s}),getTodaysPlan:s=>r("GET","/v1/goals/get-todays-plan",{query:s}),remove:s=>r("DELETE","/v1/goals/{id}",{path:{id:s}}),update:(s,n)=>r("PUT","/v1/goals/{id}",{body:n,path:{id:s}})},notes:{...t.notes,create:s=>r("POST","/v1/notes",{body:s}),get:s=>r("GET","/v1/notes/{noteId}",{path:{noteId:s}}),list:s=>r("GET","/v1/notes",{query:s}),listByAttachedEntity:s=>r("GET","/v1/notes/by-attached-entity",{query:s}),listByRange:s=>r("GET","/v1/notes/by-range",{query:s}),listByVerseKey:(s,n)=>r("GET","/v1/notes/by-verse/{verseKey}",{path:{verseKey:s},query:n}),publish:(s,n)=>r("POST","/v1/notes/{noteId}/publish",{body:n,path:{noteId:s}}),remove:s=>r("DELETE","/v1/notes/{noteId}",{path:{noteId:s}}),update:(s,n)=>r("PATCH","/v1/notes/{noteId}",{body:n,path:{noteId:s}})},preferences:{...t.preferences,bulkUpdate:s=>r("POST","/v1/preferences/bulk",{body:s}),get:s=>r("GET","/v1/preferences",{query:s}),update:s=>r("POST","/v1/preferences",{body:s})},raw:e,readingSessions:{...t.readingSessions,create:s=>r("POST","/v1/reading-sessions",{body:s}),list:s=>r("GET","/v1/reading-sessions",{query:s})}}},xe=o=>{let e=f(o,d.quranReflect.v1),t=x(d.quranReflect.v1,e);return {comments:t.comments??{},posts:te(t.posts??{},he(o,"quranReflect")),raw:e,rooms:t.rooms??{},tags:t.tags??{},users:t.users??{}}},Ue=(o,e,t)=>{let r=f(o,d.oauth2.v1),s=async(n,i={})=>{if(i.requiresRefreshToken&&!n.get("refresh_token"))throw new Error("Missing refresh token.");let h=n.get("refresh_token")??void 0,a=i.requiresRefreshToken?await o.getUserSession():null,p=i.requiresRefreshToken&&h?{...a??{},refreshToken:h}:a,u=await o.request("oauth2","/oauth2/token",void 0,{auth:"none",basicAuth:"clientSecret"in t?{password:t.clientSecret,username:t.clientId}:void 0,body:n,contentType:"application/x-www-form-urlencoded",method:"POST"});return await o.setUserSession(v(u,p)),u};return {authorizeUrl:n=>o.buildServiceUrl("oauth2","/oauth2/auth",n),exchangeCode:n=>{let i=new URLSearchParams({code:n.code,grant_type:"authorization_code",redirect_uri:n.redirectUri});return n.codeVerifier&&i.set("code_verifier",n.codeVerifier),n.scope&&i.set("scope",n.scope),s(i,{})},getUserInfo:n=>o.request("oauth2","/userinfo",void 0,{accessToken:n,auth:"user",method:"GET"}),introspect:n=>{if(!("clientSecret"in t))throw new Error("Token introspection requires @quranjs/api/server or a backend.");return o.request("oauth2","/oauth2/introspect",void 0,{auth:"none",basicAuth:{password:t.clientSecret,username:t.clientId},body:new URLSearchParams({token:n}),contentType:"application/x-www-form-urlencoded",method:"POST"})},logout:n=>o.request("oauth2","/oauth2/sessions/logout",n,{auth:"none",method:"GET"}),raw:r,refresh:async n=>{let i=await o.getUserSession(),h=new URLSearchParams({grant_type:"refresh_token",refresh_token:n??i?.refreshToken??""});return s(h,{requiresRefreshToken:true})}}},ze=(o,e,t,r,s,n,i,h)=>({answers:{byAyah:(a,p)=>o.findByAyah(a,p),countWithinRange:(a,p,u)=>o.countWithinRange(a,p,u),get:a=>o.findByQuestionId(a)},audio:{chapterRecitation:{get:(a,p,u)=>s.findChapterRecitationById(a,p,u),list:(a,p)=>s.findAllChapterRecitations(a,p)},verseRecitation:{byChapter:(a,p,u)=>s.findVerseRecitationsByChapter(a,p,u),byKey:(a,p,u)=>s.findVerseRecitationsByKey(a,p,u)}},chapters:{get:(a,p)=>e.findById(a,p),getInfo:(a,p)=>e.findInfoById(a,p),getInfoResponse:(a,p)=>e.findInfoResponseById(a,p),list:a=>e.findAll(a)},hadithReferences:{byAyah:(a,p)=>n.findByAyah(a,p),countWithinRange:(a,p,u)=>n.countWithinRange(a,p,u),hadithsByAyah:(a,p)=>n.findHadithsByAyah(a,p)},juzs:{list:()=>r.findAll()},raw:h,resources:{findSnapshot:(a,p,u)=>i.findSnapshot(a,p,u),chapterInfos:{list:a=>i.findAllChapterInfos(a)},chapterReciters:{list:a=>i.findAllChapterReciters(a)},languages:{list:a=>i.findAllLanguages(a)},recitationStyles:{list:a=>i.findAllRecitationStyles(a)},recitations:{getInfo:(a,p)=>i.findRecitationInfo(a,p),list:a=>i.findAllRecitations(a)},tafsirs:{getInfo:(a,p)=>i.findTafsirInfo(a,p),list:a=>i.findAllTafsirs(a)},translations:{getInfo:(a,p)=>i.findTranslationInfo(a,p),list:a=>i.findAllTranslations(a)},verseMedia:{list:a=>i.findVerseMedia(a)},sync:a=>i.sync(a)},verses:{byChapter:(a,p)=>t.findByChapter(a,p),byHizb:(a,p)=>t.findByHizb(a,p),byJuz:(a,p)=>t.findByJuz(a,p),byKey:(a,p)=>t.findByKey(a,p),byPage:(a,p)=>t.findByPage(a,p),byRange:(a,p,u)=>t.findByRange(a,p,u),byRub:(a,p)=>t.findByRub(a,p),random:a=>t.findRandom(a)}}),ue=(o,e)=>{let t=new T(o,e);t.getFetch();let r=new w(t),s=new k(t),n=new B(t),i=new E(t),h=new S(t),a=new I(t),p=new O(t),u=new V(t),l={auth:{v1:f(t,d.auth.v1)},content:{v4:f(t,d.content.v4)},oauth2:{v1:f(t,d.oauth2.v1)},quranReflect:{v1:f(t,d.quranReflect.v1)},search:{v1:f(t,d.search.v1)}},M=ze(r,s,n,i,h,a,p,l.content.v4),K=Ge(t),$=xe(t),j=Ue(t,o,e),W=({query:le,...de})=>u.search(le,de),ce=Object.assign(u,{query:W,raw:l.search.v1,v1:{query:W,raw:l.search.v1}});return {answers:r,audio:h,auth:{...K,v1:K},chapters:s,clearCachedTokens:()=>t.clearCachedTokens(),content:{...M,v4:M},getUserSession:()=>t.getUserSession(),hadithReferences:a,juzs:i,oauth2:{...j,v1:j},quranReflect:{...$,v1:$},raw:l,resources:p,search:ce,verses:n}};var Er=o=>ue("server",{...o,defaults:{language:"ar",...o.defaults}});
|
|
2
|
+
export{Er as createServerClient};//# sourceMappingURL=server.min.mjs.map
|
|
3
3
|
//# sourceMappingURL=server.min.mjs.map
|