@notionhq/custom-blocks-host 0.3.6 → 0.3.8
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/README.md +5 -0
- package/dist/browser.js +1 -1
- package/dist/dateValue.d.ts +11 -0
- package/dist/dateValue.d.ts.map +1 -0
- package/dist/dateValue.js +96 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/lifecycle/legacyPage.d.ts.map +1 -1
- package/dist/lifecycle/legacyPage.js +14 -62
- package/dist/protocol/dataSources/dateValue.d.ts +2 -2
- package/dist/protocol/dataSources/dateValue.js +9 -7
- package/dist/protocol/messages/createPage.d.ts +64 -2
- package/dist/protocol/messages/createPageResult.d.ts +192 -6
- package/dist/protocol/messages/getPage.d.ts +192 -6
- package/dist/protocol/messages/hostToSandbox.d.ts +704 -22
- package/dist/protocol/messages/queryDataSourceResult.d.ts +128 -4
- package/dist/protocol/messages/sandboxToHost.d.ts +128 -4
- package/dist/protocol/messages/updatePage.d.ts +64 -2
- package/dist/protocol/messages/updatePageResult.d.ts +192 -6
- package/dist/protocol/pages/page.d.ts +360 -12
- package/dist/protocol/pages/page.js +48 -2
- package/package.json +1 -1
- package/src/dateValue.ts +120 -0
- package/src/index.ts +5 -0
- package/src/lifecycle/legacyPage.ts +14 -73
package/README.md
CHANGED
|
@@ -244,6 +244,11 @@ Use the host APIs instead of posting bridge messages directly or importing proto
|
|
|
244
244
|
files. Runtime source imports schemas from the workspace protocol package; the publish build bundles
|
|
245
245
|
that dependency into the host package.
|
|
246
246
|
|
|
247
|
+
## Date conversion
|
|
248
|
+
|
|
249
|
+
`toNotionDateValue()` converts `NotionDateInput` into the four date variants in
|
|
250
|
+
`CustomBlockDateValue`, including reminders. Conversion failures throw `InvalidNotionDateError`.
|
|
251
|
+
|
|
247
252
|
## Other exports
|
|
248
253
|
|
|
249
254
|
- `LATEST_BRIDGE_PROTOCOL_VERSION`: the latest bridge protocol version bundled with this host
|
package/dist/browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var He=6,Ve=6;function ln(e){let{manifestProperties:t,propertySchemasById:o}=e,i=[];for(let[l,c]of Object.entries(t)){let p=pn({propertyKey:l,manifestProperty:c,propertySchemasById:o});p!==void 0&&i.push([l,p])}return Object.fromEntries(i)}function pn(e){let{propertyKey:t,manifestProperty:o,propertySchemasById:i}=e,l=ft(o.name),c=Object.entries(i).filter(([p,y])=>y.type===o.type&&(p===t||ft(y.name)===l));return c.length===1?c[0][0]:void 0}function ft(e){return e.trim().toLowerCase()}var De,fn={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function Ge(e){return!e&&!De?fn:{lang:e?.lang??De?.lang,message:e?.message,abortEarly:e?.abortEarly??De?.abortEarly,abortPipeEarly:e?.abortPipeEarly??De?.abortPipeEarly}}var mn;function yn(e){return mn?.get(e)}var vn;function dn(e){return vn?.get(e)}var hn;function gn(e,t){return hn?.get(e)?.get(t)}function Se(e){let t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function D(e,t,o,i,l){let c=l&&"input"in l?l.input:o.value,p=l?.expected??e.expects??null,y=l?.received??Se(c),m={kind:e.kind,type:e.type,input:c,expected:p,received:y,message:`Invalid ${t}: ${p?`Expected ${p} but r`:"R"}eceived ${y}`,requirement:e.requirement,path:l?.path,issues:l?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},_=e.kind==="schema",x=l?.message??e.message??gn(e.reference,m.lang)??(_?dn(m.lang):null)??i.message??yn(m.lang);x!==void 0&&(m.message=typeof x=="function"?x(m):x),_&&(o.typed=!1),o.issues?o.issues.push(m):o.issues=[m]}var mt=new WeakMap;function V(e){let t=mt.get(e);return t||(t={version:1,vendor:"valibot",validate(o){return e["~run"]({value:o},Ge())}},mt.set(e,t)),t}function bn(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function $e(e,t){let o=[...new Set(e)];return o.length>1?`(${o.join(` ${t} `)})`:o[0]??"never"}var Sn=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function ce(e){return{kind:"transformation",type:"brand",reference:ce,async:!1,name:e,"~run"(t){return t}}}function ke(e){return{kind:"validation",type:"finite",reference:ke,async:!1,expects:null,requirement:Number.isFinite,message:e,"~run"(t,o){return t.typed&&!this.requirement(t.value)&&D(this,"finite",t,o),t}}}function we(e,t){return{kind:"validation",type:"max_length",reference:we,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(o,i){return o.typed&&o.value.length>this.requirement&&D(this,"length",o,i,{received:`${o.value.length}`}),o}}}function Ie(e,t){return{kind:"validation",type:"min_length",reference:Ie,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(o,i){return o.typed&&o.value.length<this.requirement&&D(this,"length",o,i,{received:`${o.value.length}`}),o}}}function _e(e,t){return{kind:"validation",type:"min_value",reference:_e,async:!1,expects:`>=${e instanceof Date?e.toJSON():Se(e)}`,requirement:e,message:t,"~run"(o,i){return o.typed&&!(o.value>=this.requirement)&&D(this,"value",o,i,{received:o.value instanceof Date?o.value.toJSON():Se(o.value)}),o}}}function Qe(e,t){return{kind:"validation",type:"regex",reference:Qe,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(o,i){return o.typed&&!this.requirement.test(o.value)&&D(this,"format",o,i),o}}}function Xe(e){return{kind:"transformation",type:"transform",reference:Xe,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}var vt={abortEarly:!0};function dt(e,t,o){return typeof e.fallback=="function"?e.fallback(t,o):e.fallback}function qe(e,t,o){return typeof e.default=="function"?e.default(t,o):e.default}function ht(e,t){return!e["~run"]({value:t},vt).issues}function E(e,t){return{kind:"schema",type:"array",reference:E,expects:"Array",async:!1,item:e,message:t,get"~standard"(){return V(this)},"~run"(o,i){let l=o.value;if(Array.isArray(l)){o.typed=!0,o.value=[];for(let c=0;c<l.length;c++){let p=l[c],y=this.item["~run"]({value:p},i);if(y.issues){let m={type:"array",origin:"value",input:l,key:c,value:p};for(let _ of y.issues)_.path?_.path.unshift(m):_.path=[m],o.issues?.push(_);if(o.issues||(o.issues=y.issues),i.abortEarly){o.typed=!1;break}}y.typed||(o.typed=!1),o.value.push(y.value)}}else D(this,"type",o,i);return o}}}function h(e){return{kind:"schema",type:"boolean",reference:h,expects:"boolean",async:!1,message:e,get"~standard"(){return V(this)},"~run"(t,o){return typeof t.value=="boolean"?t.typed=!0:D(this,"type",t,o),t}}}function s(e,t){return{kind:"schema",type:"literal",reference:s,expects:Se(e),async:!1,literal:e,message:t,get"~standard"(){return V(this)},"~run"(o,i){return o.value===this.literal?o.typed=!0:D(this,"type",o,i),o}}}function We(e){return{kind:"schema",type:"nan",reference:We,expects:"NaN",async:!1,message:e,get"~standard"(){return V(this)},"~run"(t,o){return Number.isNaN(t.value)?t.typed=!0:D(this,"type",t,o),t}}}function A(e,t){return{kind:"schema",type:"nullable",reference:A,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,get"~standard"(){return V(this)},"~run"(o,i){return o.value===null&&(this.default!==void 0&&(o.value=qe(this,o,i)),o.value===null)?(o.typed=!0,o):this.wrapped["~run"](o,i)}}}function C(e){return{kind:"schema",type:"number",reference:C,expects:"number",async:!1,message:e,get"~standard"(){return V(this)},"~run"(t,o){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:D(this,"type",t,o),t}}}function n(e,t){return{kind:"schema",type:"object",reference:n,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return V(this)},"~run"(o,i){let l=o.value;if(l&&typeof l=="object"){o.typed=!0,o.value={};for(let c in this.entries){let p=this.entries[c];if(c in l||(p.type==="exact_optional"||p.type==="optional"||p.type==="nullish")&&p.default!==void 0){let y=c in l?l[c]:qe(p),m=p["~run"]({value:y},i);if(m.issues){let _={type:"object",origin:"value",input:l,key:c,value:y};for(let x of m.issues)x.path?x.path.unshift(_):x.path=[_],o.issues?.push(x);if(o.issues||(o.issues=m.issues),i.abortEarly){o.typed=!1;break}}m.typed||(o.typed=!1),o.value[c]=m.value}else if(p.fallback!==void 0)o.value[c]=dt(p);else if(p.type!=="exact_optional"&&p.type!=="optional"&&p.type!=="nullish"&&(D(this,"key",o,i,{input:void 0,expected:`"${c}"`,path:[{type:"object",origin:"key",input:l,key:c,value:l[c]}]}),i.abortEarly))break}}else D(this,"type",o,i);return o}}}function u(e,t){return{kind:"schema",type:"optional",reference:u,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return V(this)},"~run"(o,i){return o.value===void 0&&(this.default!==void 0&&(o.value=qe(this,o,i)),o.value===void 0)?(o.typed=!0,o):this.wrapped["~run"](o,i)}}}function w(e,t){return{kind:"schema",type:"picklist",reference:w,expects:$e(e.map(Se),"|"),async:!1,options:e,message:t,get"~standard"(){return V(this)},"~run"(o,i){return this.options.includes(o.value)?o.typed=!0:D(this,"type",o,i),o}}}function U(e,t,o){return{kind:"schema",type:"record",reference:U,expects:"Object",async:!1,key:e,value:t,message:o,get"~standard"(){return V(this)},"~run"(i,l){let c=i.value;if(c&&typeof c=="object"){i.typed=!0,i.value={};for(let p in c)if(bn(c,p)){let y=c[p],m=this.key["~run"]({value:p},l);if(m.issues){let x={type:"object",origin:"key",input:c,key:p,value:y};for(let P of m.issues)P.path=[x],i.issues?.push(P);if(i.issues||(i.issues=m.issues),l.abortEarly){i.typed=!1;break}}let _=this.value["~run"]({value:y},l);if(_.issues){let x={type:"object",origin:"value",input:c,key:p,value:y};for(let P of _.issues)P.path?P.path.unshift(x):P.path=[x],i.issues?.push(P);if(i.issues||(i.issues=_.issues),l.abortEarly){i.typed=!1;break}}(!m.typed||!_.typed)&&(i.typed=!1),m.typed&&(i.value[m.value]=_.value)}}else D(this,"type",i,l);return i}}}function f(e,t){return{kind:"schema",type:"strict_object",reference:f,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return V(this)},"~run"(o,i){let l=o.value;if(l&&typeof l=="object"){o.typed=!0,o.value={};for(let c in this.entries){let p=this.entries[c];if(c in l||(p.type==="exact_optional"||p.type==="optional"||p.type==="nullish")&&p.default!==void 0){let y=c in l?l[c]:qe(p),m=p["~run"]({value:y},i);if(m.issues){let _={type:"object",origin:"value",input:l,key:c,value:y};for(let x of m.issues)x.path?x.path.unshift(_):x.path=[_],o.issues?.push(x);if(o.issues||(o.issues=m.issues),i.abortEarly){o.typed=!1;break}}m.typed||(o.typed=!1),o.value[c]=m.value}else if(p.fallback!==void 0)o.value[c]=dt(p);else if(p.type!=="exact_optional"&&p.type!=="optional"&&p.type!=="nullish"&&(D(this,"key",o,i,{input:void 0,expected:`"${c}"`,path:[{type:"object",origin:"key",input:l,key:c,value:l[c]}]}),i.abortEarly))break}if(!o.issues||!i.abortEarly){for(let c in l)if(!(c in this.entries)){D(this,"key",o,i,{input:c,expected:"never",path:[{type:"object",origin:"key",input:l,key:c,value:l[c]}]});break}}}else D(this,"type",o,i);return o}}}function r(e){return{kind:"schema",type:"string",reference:r,expects:"string",async:!1,message:e,get"~standard"(){return V(this)},"~run"(t,o){return typeof t.value=="string"?t.typed=!0:D(this,"type",t,o),t}}}function yt(e){let t;if(e)for(let o of e)if(t)for(let i of o.issues)t.push(i);else t=o.issues;return t}function k(e,t){return{kind:"schema",type:"union",reference:k,expects:$e(e.map(o=>o.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return V(this)},"~run"(o,i){let l,c,p;for(let y of this.options){let m=y["~run"]({value:o.value},i);if(m.typed)if(m.issues)c?c.push(m):c=[m];else{l=m;break}else p?p.push(m):p=[m]}if(l)return l;if(c){if(c.length===1)return c[0];D(this,"type",o,i,{issues:yt(c)}),o.typed=!0}else{if(p?.length===1)return p[0];D(this,"type",o,i,{issues:yt(p)})}return o}}}function xe(){return{kind:"schema",type:"unknown",reference:xe,expects:"unknown",async:!1,get"~standard"(){return V(this)},"~run"(e){return e.typed=!0,e}}}function v(e,t,o){return{kind:"schema",type:"variant",reference:v,expects:"Object",async:!1,key:e,options:t,message:o,get"~standard"(){return V(this)},"~run"(i,l){let c=i.value;if(c&&typeof c=="object"){let p,y=0,m=this.key,_=[],x=(P,S)=>{for(let F of P.options){if(F.type==="variant")x(F,new Set(S).add(F.key));else{let G=!0,z=0;for(let R of S){let te=F.entries[R];if(R in c?te["~run"]({typed:!1,value:c[R]},vt).issues:te.type!=="exact_optional"&&te.type!=="optional"&&te.type!=="nullish"){G=!1,m!==R&&(y<z||y===z&&R in c&&!(m in c))&&(y=z,m=R,_=[]),m===R&&_.push(F.entries[R].expects);break}z++}if(G){let R=F["~run"]({value:c},l);(!p||!p.typed&&R.typed)&&(p=R)}}if(p&&!p.issues)break}};if(x(this,new Set([this.key])),p)return p;D(this,"type",i,l,{input:c[m],expected:$e(_,"|"),path:[{type:"object",origin:"value",input:c,key:m,value:c[m]}]})}else D(this,"type",i,l);return i}}}function ie(e,t,o){let i=e["~run"]({value:t},Ge(o));if(i.issues)throw new Sn(i.issues);return i.value}function H(...e){return{...e[0],pipe:e,get"~standard"(){return V(this)},"~run"(t,o){for(let i of e)if(i.kind!=="metadata"){if(t.issues&&(i.kind==="schema"||i.kind==="transformation")){t.typed=!1;break}(!t.issues||!o.abortEarly&&!o.abortPipeEarly)&&(t=i["~run"](t,o))}return t}}}function Ce(e,t,o){let i=e["~run"]({value:t},Ge(o));return{typed:i.typed,success:!i.issues,output:i.value,issues:i.issues}}var le=H(r(),ce("NotionBlockId")),X=H(r(),ce("NotionDataSourceId")),T=H(r(),ce("NotionPageId")),gt=H(r(),ce("NotionAgentId")),bt=H(r(),ce("NotionSpaceId"));var St=w(["default","gray","brown","orange","yellow","green","blue","purple","pink","red","gray_background","brown_background","orange_background","yellow_background","green_background","blue_background","purple_background","pink_background","red_background","default_background"]),Je=n({id:r(),name:r(),color:u(St),description:u(r())}),kn=n({id:r(),name:r(),color:u(St),option_ids:E(r())}),In=n({synced_property_id:r(),synced_property_name:r()}),j=n({name:r(),description:u(r())}),_n=["title","rich_text","number","checkbox","url","email","phone_number","select","multi_select","status","date","people","files","unique_id","relation","place","formula","rollup","button","verification","last_visited_time","location","created_time","last_edited_time","created_by","last_edited_by"],kt=w(_n),It=["title","rich_text","number","checkbox","url","email","phone_number","date","created_time","last_edited_time","people","created_by"],Ke=v("type",[n({...j.entries,type:s("title")}),n({...j.entries,type:s("rich_text")}),n({...j.entries,type:s("number")}),n({...j.entries,type:s("checkbox")}),n({...j.entries,type:s("url")}),n({...j.entries,type:s("email")}),n({...j.entries,type:s("phone_number")}),n({...j.entries,type:s("select"),options:E(Je)}),n({...j.entries,type:s("multi_select"),options:E(Je)}),n({...j.entries,type:s("status"),options:E(Je),groups:E(kn)}),n({...j.entries,type:s("date")}),n({...j.entries,type:s("people")}),n({...j.entries,type:s("files")}),n({...j.entries,type:s("unique_id")}),n({...j.entries,type:s("relation"),data_source_id:u(r()),dual_property:u(In)}),n({...j.entries,type:s("place")}),n({...j.entries,type:s("formula")}),n({...j.entries,type:s("rollup")}),n({...j.entries,type:s("button")}),n({...j.entries,type:s("verification")}),n({...j.entries,type:s("last_visited_time")}),n({...j.entries,type:s("location")}),n({...j.entries,type:s("created_time")}),n({...j.entries,type:s("last_edited_time")}),n({...j.entries,type:s("created_by")}),n({...j.entries,type:s("last_edited_by")})]);var _t=n({id:X,table:r(),spaceId:u(bt)}),xt=n({id:u(X),propertiesById:U(r(),Ke)}),Lo=n({key:r(),collectionPointer:u(_t),collectionSchema:u(xt),propertyIdsByKey:U(r(),u(r())),propertySchemasById:U(r(),Ke)}),xn=n({collectionPointer:u(_t),collectionSchema:u(xt),propertyIdsByKey:u(U(r(),u(r())))}),me=U(r(),xn);var de=w(["standard","high"]),Ct="standard";var Pt=n({type:s("contrastModeChanged"),contrastMode:de});var Te=n({id:r(),table:r()});var ae=v("type",[n({type:s("page_id"),page_id:T}),n({type:s("data_source_id"),data_source_id:X}),n({type:s("workspace"),workspace:s(!0)}),n({type:s("block_id"),block_id:le}),n({type:s("agent_id"),agent_id:gt}),n({type:s("unavailable")})]);var he=v("type",[n({type:s("unavailable")}),n({type:s("page"),id:T,parent:ae})]),Cn=n({type:s("emoji"),emoji:r()}),Pn=n({type:s("custom_emoji"),custom_emoji:n({id:r(),name:u(r()),url:u(r())})}),Ot=n({type:s("external"),external:n({url:r()})}),jt=n({type:s("file"),file:n({url:r(),expiry_time:u(r())})}),Ne=v("type",[Cn,Pn,Ot,jt]),Ue=v("type",[Ot,jt]),W=A(r()),Et=U(r(),xe()),Ye=k([n({id:r(),name:u(r()),color:u(r()),description:u(W)}),n({name:r(),id:u(r()),color:u(r()),description:u(W)})]),En=n({start:r(),end:u(W),time_zone:u(W)}),On=k([n({object:u(s("user")),id:r()}),n({object:s("group"),id:r(),name:u(W)})]),jn=n({id:r()}),Rn=k([n({type:s("external"),name:r(),external:n({url:r()})}),n({type:s("file"),name:r(),file:n({url:r(),expiry_time:u(r())})})]),Mn=n({lat:C(),lon:C(),name:u(W),address:u(W),aws_place_id:u(W),google_place_id:u(W)}),N={id:r()},Ae=A(n({...Te.entries,table:w(["notion_user","bot","organization_bot"]),spaceId:u(r())})),Rt=v("type",[n({...N,type:s("title"),title:E(Et)}),n({...N,type:s("rich_text"),rich_text:E(Et)}),n({...N,type:s("number"),number:A(C())}),n({...N,type:s("url"),url:W}),n({...N,type:s("email"),email:W}),n({...N,type:s("phone_number"),phone_number:W}),n({...N,type:s("checkbox"),checkbox:h()}),n({...N,type:s("select"),select:A(Ye)}),n({...N,type:s("status"),status:A(Ye)}),n({...N,type:s("multi_select"),multi_select:E(Ye)}),n({...N,type:s("date"),date:A(En)}),n({...N,type:s("people"),people:E(On)}),n({...N,type:s("relation"),has_more:u(h()),relation:E(jn)}),n({...N,type:s("files"),files:E(Rn)}),n({...N,type:s("place"),place:A(Mn)}),n({...N,type:s("created_time"),created_time:W}),n({...N,type:s("last_edited_time"),last_edited_time:W}),n({...N,type:s("created_by"),created_by:Ae}),n({...N,type:s("last_edited_by"),last_edited_by:Ae}),n({...N,type:s("last_visited_time"),last_visited_time:W})]),Pe=U(r(),Rt),Bn=U(r(),A(Rt)),re=n({object:s("page"),id:T,parent:ae,properties:Bn,created_by:u(Ae,null),last_edited_by:u(Ae,null),last_visited_time:u(A(r()),null),created_time:u(A(r()),null),last_edited_time:u(A(r()),null),icon:u(A(Ne),null),cover:u(A(Ue),null),url:u(A(r()),null),public_url:u(A(r()),null),is_archived:h(),in_trash:h()}),ge=n({object:s("page"),id:T,parent:ae,properties:Pe,created_time:u(r()),last_edited_time:u(r()),icon:u(Ne),cover:u(Ue),url:u(r()),public_url:u(r()),is_archived:h(),in_trash:h()});var Dn=r(),Mt=n({code:Dn,message:r(),isRetryable:h()}),Bt=v("status",[n({type:s("createPageResult"),requestId:r(),status:s("success"),page:re}),n({type:s("createPageResult"),requestId:r(),status:s("error"),error:Mt})]),Dt=v("status",[n({type:s("createPageResult"),requestId:r(),status:s("success"),page:k([re,ge])}),n({type:s("createPageResult"),requestId:r(),status:s("error"),error:Mt})]);var Ze=H(r(),ce("NotionUserId")),pe=n({object:s("user"),id:Ze,name:u(r()),avatar_url:A(r()),type:s("person"),person:n({email:r()})}),wt=n({object:s("list"),results:E(pe),next_cursor:A(r()),has_more:h(),type:s("user"),user:U(r(),xe())});var qt=n({type:s("currentUserChanged"),currentUser:pe});var Tt=n({type:s("dataSourcesChanged"),dataSources:n({bindings:me})});var wn=r(),At=n({code:wn,message:r(),isRetryable:h()}),Nt=n({type:s("getPage"),requestId:r(),pageId:T,dataSourceId:u(X)}),Ut=v("status",[n({type:s("getPageResult"),requestId:r(),status:s("success"),page:re}),n({type:s("getPageResult"),requestId:r(),status:s("error"),error:At})]),Ft=v("status",[n({type:s("getPageResult"),requestId:r(),status:s("success"),page:k([re,ge])}),n({type:s("getPageResult"),requestId:r(),status:s("error"),error:At})]);var qn=r(),Tn=n({code:qn,message:r(),isRetryable:h()}),zt=n({type:s("getUser"),requestId:r(),userId:Ze}),Lt=v("status",[n({type:s("getUserResult"),requestId:r(),status:s("success"),user:pe}),n({type:s("getUserResult"),requestId:r(),status:s("error"),error:Tn})]);var An=v("type",[n({type:s("emoji"),emoji:r()}),n({type:s("external"),url:r()})]),Nn=n({name:r(),description:u(r()),type:kt}),Un=n({name:r(),description:u(r()),icon:u(An),properties:u(U(r(),Nn),{})}),ye=n({version:s(1),name:u(r()),description:u(r()),slashCommand:u(r()),icon:u(n({type:s("emoji"),emoji:r()})),dataSources:u(U(r(),Un),{})});var be=w(["light","dark"]);var Fn=r(),zn=n({code:Fn,message:r(),isRetryable:h()});var Fe=v("status",[n({type:s("init"),initializationId:r(),status:s("success"),theme:be,contrastMode:de,blockId:le,parent:ae,page:he,manifest:ye,dataSources:n({bindings:me}),currentUser:pe}),n({type:s("init"),initializationId:r(),status:s("error"),error:zn})]);var Ht=n({type:s("invalidSandboxMessage"),reason:r()});var Ln=r(),Hn=n({code:Ln,message:r(),isRetryable:h()}),Vt=n({type:s("listUsers"),requestId:r(),startCursor:u(r()),pageSize:u(C())}),Gt=v("status",[n({type:s("listUsersResult"),requestId:r(),status:s("success"),list:wt}),n({type:s("listUsersResult"),requestId:r(),status:s("error"),error:Hn})]);var Vn=r(),Gn=n({code:Vn,message:r(),isRetryable:h()}),$t=n({type:s("openExternalUrl"),requestId:r(),url:r()}),Qt=v("status",[n({type:s("openExternalUrlResult"),requestId:r(),status:s("success")}),n({type:s("openExternalUrlResult"),requestId:r(),status:s("error"),error:Gn})]);var $n=w(["side_peek","center_peek"]),Qn=r(),Xn=n({code:Qn,message:r(),isRetryable:h()}),Xt=n({type:s("openPage"),requestId:r(),pageId:T,mode:$n}),Wt=v("status",[n({type:s("openPageResult"),requestId:r(),status:s("success"),pageId:T}),n({type:s("openPageResult"),requestId:r(),status:s("error"),error:Xn})]);var Jt=n({type:s("pageChanged"),page:he});var Kt=n({type:s("parentChanged"),parent:ae});var Yt=n({unit:w(["year","month","week","day"]),value:C(),time:r(),defaultTimeZone:u(r())}),Wn=n({unit:w(["hour","minute"]),value:C()}),Zt=n({unit:s("none")}),Jn=k([Yt,Wn]),er=u(k([Yt,Zt])),tr=u(k([Jn,Zt])),Kn=n({type:s("date"),start_date:r(),reminder:er}),Yn=n({type:s("daterange"),start_date:r(),end_date:r(),reminder:er}),Zn=n({type:s("datetime"),start_date:r(),start_time:r(),time_zone:u(r()),reminder:tr}),eo=n({type:s("datetimerange"),start_date:r(),start_time:r(),end_date:r(),end_time:r(),time_zone:u(r()),reminder:tr}),rr=v("type",[Kn,Yn,Zn,eo]);var nr=k([r(),C(),h(),rr,E(r()),E(Te)]);var or=n({id:T,is_archived:h(),in_trash:h(),propertiesById:U(r(),u(nr))});var to=r(),sr=n({code:to,message:r(),isRetryable:h()}),ir=v("status",[n({type:s("queryDataSourceResult"),subscriptionId:r(),status:s("success"),items:E(re),hasMore:h()}),n({type:s("queryDataSourceResult"),subscriptionId:r(),status:s("error"),error:sr})]),ar=v("status",[n({type:s("queryDataSourceResult"),subscriptionId:r(),status:s("success"),items:E(k([re,or])),hasMore:h()}),n({type:s("queryDataSourceResult"),subscriptionId:r(),status:s("error"),error:sr})]);var ur=n({type:s("themeChanged"),theme:be});var ro=r(),cr=n({code:ro,message:r(),isRetryable:h()}),lr=v("status",[n({type:s("updatePageResult"),requestId:r(),status:s("success"),page:re}),n({type:s("updatePageResult"),requestId:r(),status:s("error"),error:cr})]),pr=v("status",[n({type:s("updatePageResult"),requestId:r(),status:s("success"),page:k([re,ge])}),n({type:s("updatePageResult"),requestId:r(),status:s("error"),error:cr})]);var fr=v("type",[Fe,ur,Pt,Kt,Jt,qt,Tt,Lt,Gt,Wt,Qt,Ht]),mr=v("type",[...fr.options,ir,Ut,Bt,lr]),li=v("type",[...fr.options,ar,Ft,Dt,pr]);function yr(){return{code:"no_connect",message:"Sandbox did not send a connect message.",isRetryable:!0}}function vr(){return{code:"invalid_connect_payload",message:"Sandbox sent an invalid connect message.",isRetryable:!1}}function et(e){let{currentBridgeProtocolVersion:t}=e;return{code:"invalid_protocol_version",message:`Sandbox reported an invalid bridge protocol version: ${t}`,isRetryable:!1}}function tt(e){let{currentBridgeProtocolVersion:t,minBridgeProtocolVersion:o}=e;return{code:"unsupported_protocol_version",message:`Sandbox bridge protocol version ${t} is not supported. Minimum supported version is ${o}.`,isRetryable:!1}}function rt(){return{code:"context_unavailable",message:"Host page context is unavailable.",isRetryable:!0}}function dr(){return{code:"initial_state_timeout",message:"Host did not prepare initial state before the timeout.",isRetryable:!0}}function hr(){return{code:"missing_data_source_binding",message:"A required data source is not mapped.",isRetryable:!1}}function gr(){return{code:"missing_property_binding",message:"A required data source property is not mapped.",isRetryable:!1}}function br(){return{code:"invalid_property_binding",message:"A mapped data source property is missing or incompatible.",isRetryable:!1}}function Sr(){return{code:"no_init_result",message:"Sandbox did not acknowledge initialization.",isRetryable:!0}}function kr(){return{code:"invalid_init_result_payload",message:"Sandbox sent an invalid initialization result.",isRetryable:!1}}function Ee(){return{code:"unknown_error",message:"Unexpected error while initializing custom block.",isRetryable:!1}}function ee(e){throw new Error(`[custom-blocks-host] Unexpected value encountered: ${JSON.stringify(e)}`)}function nt(e){return Number.isFinite(e)&&Number.isInteger(e)&&e>=1}var no=5e3,oo=5e3,so=5e3;function Ir(e){let{prepareInit:t,sendInitMessage:o,warn:i,flushPendingHostStateChanges:l,minBridgeProtocolVersion:c,noConnectTimeoutMs:p=no,initialStateTimeoutMs:y=oo,noInitResultTimeoutMs:m=so,stopHostWithFailure:_,onInitResult:x,onConnectionFailure:P}=e,S="waitingForConnect",F,G,z,R,te=!1,ne=!1;function K(){F!==void 0&&(window.clearTimeout(F),F=void 0)}function ue(){G!==void 0&&(window.clearTimeout(G),G=void 0)}function $(){z!==void 0&&(window.clearTimeout(z),z=void 0)}function M(g){let{initializationId:I,error:Q,phase:oe,source:q}=g;switch(S){case"waitingForConnect":case"preparingInit":break;case"waitingForInitResult":case"initialized":case"error":case"stopped":return;default:return ee(S)}S="error",R=I,K(),ue(),o({type:"init",initializationId:I,status:"error",error:Q}),P?.({...Q,phase:oe,source:q})}async function L(g){if(S==="waitingForConnect"){S="preparingInit",R=g.initializationId,K(),G=window.setTimeout(()=>{if(S!=="preparingInit")return;let I=dr();i({...I,initializationId:g.initializationId}),M({initializationId:g.initializationId,error:I,phase:"init",source:"host"})},y);try{let I=await t(g);if(S!=="preparingInit")return;if(ue(),I.status==="error"){M({initializationId:g.initializationId,error:I.error,phase:"init",source:"host"});return}S="waitingForInitResult";let Q={type:"init",initializationId:g.initializationId,status:"success",theme:I.initialState.theme,contrastMode:I.initialState.contrastMode??Ct,blockId:I.initialState.blockId,parent:I.initialState.parent,page:I.initialState.page,currentUser:I.initialState.currentUser,manifest:I.initialState.manifest,dataSources:I.initialState.dataSources};o(Q),z=window.setTimeout(()=>{if(S!=="waitingForInitResult")return;S="error";let oe=Sr();P?.({...oe,phase:"initResult",source:"host"}),i({...oe,initializationId:g.initializationId})},m)}catch(I){if(S!=="preparingInit")return;i({message:"Failed to prepare custom block initialization",error:I}),M({initializationId:g.initializationId,error:Ee(),phase:"init",source:"host"})}}}function Y(g){if(S!=="stopped"&&S==="waitingForConnect"){if(!nt(g.bridgeProtocolVersion)){let I=et({currentBridgeProtocolVersion:g.bridgeProtocolVersion});M({initializationId:g.initializationId,error:I,phase:"connect",source:"host"});return}if(g.bridgeProtocolVersion<c){let I=tt({currentBridgeProtocolVersion:g.bridgeProtocolVersion,minBridgeProtocolVersion:c});M({initializationId:g.initializationId,error:I,phase:"connect",source:"host"});return}if(g.status==="error"){M({initializationId:g.initializationId,error:g.error,phase:"connect",source:"sandbox"});return}ne=!0,L(g)}}function se(g){if(S==="stopped"||S!=="waitingForConnect")return"handled";let{initializationId:I,bridgeProtocolVersion:Q}=g;if(I===void 0)return"nack";let oe=g.error;return Q!==void 0&&(nt(Q)?Q<c&&(oe=tt({currentBridgeProtocolVersion:Q,minBridgeProtocolVersion:c})):oe=et({currentBridgeProtocolVersion:Q})),M({initializationId:I,error:oe,phase:"connect",source:"host"}),"handled"}function B(g){let{initializationId:I,error:Q}=g;S!=="waitingForInitResult"||I===void 0||I!==R||(K(),$(),S="error",i(Q),P?.({...Q,phase:"initResult",source:"host"}))}function Z(){if(S!=="stopped"){if(te){_({phase:"runtime",source:"host",code:"iframe_reloaded",message:"The iframe reloaded. Create a new host and iframe to reconnect.",isRetryable:!0});return}te=!0,K(),S==="waitingForConnect"&&(F=window.setTimeout(()=>{if(S!=="waitingForConnect")return;S="error";let g=yr();i(g),P?.({...g,phase:"connect",source:"host"})},p))}}function fe(g){if(S!=="waitingForInitResult"||g.initializationId!==R){i({message:"Ignored stale or unexpected initResult",payload:g});return}$(),S=g.status==="success"?"initialized":"error",g.status==="success"?l():P?.({...g.error,phase:"initResult",source:"sandbox"}),x?.(g)}function Be(){S="stopped",K(),ue(),$()}return{get status(){return S},get hasConnectedSandbox(){return ne},handleConnect:Y,handleInitResult:fe,handleInvalidConnect:se,handleInvalidInitResult:B,onIframeLoad:Z,stop:Be}}function ot({url:e,hostOrigin:t}){return typeof t=="string"&&t!==""&&e.origin!==t&&(e.protocol==="http:"||e.protocol==="https:")&&(e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname.endsWith(".localhost"))&&e.username===""&&e.password===""}async function _r(e){let t=new AbortController,o=()=>t.abort();e.signal.addEventListener("abort",o,{once:!0});let i=new Promise((c,p)=>{t.signal.addEventListener("abort",()=>p(t.signal.reason),{once:!0})});e.signal.aborted&&t.abort();let l=e.manifestSource==="local"?window.setTimeout(()=>{t.abort(new Error("Manifest loading timed out after 5000 ms."))},5e3):void 0;try{let c=await Promise.race([e.manifestSource==="local"?io(e.sandboxOrigin,t.signal):e.getPersistedManifest({signal:t.signal}),i]);if(t.signal.aborted)throw new Error("Manifest loading was cancelled.");return{status:"success",manifest:ie(ye,c)}}catch(c){return e.signal.aborted||e.onError(c),{status:"error",error:{code:"manifest_unavailable",message:"The custom block manifest is unavailable.",isRetryable:!0}}}finally{window.clearTimeout(l),e.signal.removeEventListener("abort",o)}}async function io(e,t){let o=new URL(e);if(!ot({url:o,hostOrigin:window.location.origin}))throw new Error("Preview requires a separate loopback origin.");let i=await fetch(new URL("/manifest",o),{credentials:"omit",redirect:"error",cache:"no-store",signal:t});if(!i.ok)throw new Error(`Manifest request failed: HTTP ${i.status}.`);return i.json()}function Cr(e){return{...e,properties:Object.fromEntries(Object.values(e.properties).flatMap(t=>t?[[t.id,t]]:[])),icon:e.icon??void 0,cover:e.cover??void 0,created_time:e.created_time??void 0,last_edited_time:e.last_edited_time??void 0,url:e.url??void 0,public_url:e.public_url??void 0}}function Pr(e){let t={};for(let o of Object.values(e.properties))o&&(t[o.id]=uo(o));return{id:e.id,is_archived:e.is_archived,in_trash:e.in_trash,propertiesById:t}}function xr(e){return e.map(t=>{if(typeof t.plain_text=="string")return t.plain_text;let o=t.text;return o&&typeof o=="object"&&"content"in o&&typeof o.content=="string"?o.content:""}).join("")}function st(e){if(e==null||e==="")return;let t=new Date(e);if(Number.isFinite(t.getTime()))return{type:"datetime",start_date:t.toISOString().slice(0,10),start_time:t.toISOString().slice(11,16),time_zone:"UTC"}}function ao(e){let t=e.start.includes("T")||e.time_zone!=null,o=e.start.match(/([+-])(\d{2}):(\d{2})$/),i=o?(Number(o[2])*60+Number(o[3]))*(o[1]==="-"?-1:1):0,l=m=>{if(!m.includes("T"))return{date:m,time:"00:00"};let _=m.match(/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})(?::\d{2}(?:\.\d+)?)?$/);if(_)return{date:_[1],time:_[2]};if(!e.time_zone){let S=new Date(new Date(m).getTime()+i*6e4).toISOString();return{date:S.slice(0,10),time:S.slice(11,16)}}let x=new Intl.DateTimeFormat("en-CA",{timeZone:e.time_zone,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(new Date(m)),P=S=>x.find(F=>F.type===S)?.value;return{date:`${P("year")}-${P("month")}-${P("day")}`,time:`${P("hour")}:${P("minute")}`}},c=l(e.start),p=e.end?l(e.end):void 0;if(!t)return p?{type:"daterange",start_date:c.date,end_date:p.date}:{type:"date",start_date:c.date};let y=e.time_zone??(i===0?"UTC":`UTC${i<0?"-":"+"}${Math.floor(Math.abs(i)/60)}${Math.abs(i)%60===0?"":`:${String(Math.abs(i)%60).padStart(2,"0")}`}`);return p?{type:"datetimerange",start_date:c.date,start_time:c.time,end_date:p.date,end_time:p.time,time_zone:y}:{type:"datetime",start_date:c.date,start_time:c.time,time_zone:y}}function uo(e){switch(e.type){case"title":return xr(e.title);case"rich_text":return xr(e.rich_text);case"number":return e.number??void 0;case"checkbox":return e.checkbox;case"url":return e.url??"";case"email":return e.email??"";case"phone_number":return e.phone_number??"";case"select":return e.select?.name;case"status":return e.status?.name;case"multi_select":return e.multi_select.flatMap(t=>t.name??[]);case"date":return e.date?ao(e.date):void 0;case"people":return e.people.map(t=>t.object==="group"?{id:t.id,table:"space_permission_group",spaceId:t.id.split("|")[1]}:{id:t.id,table:"notion_user"});case"relation":return e.relation.map(t=>({id:t.id,table:"block"}));case"files":return e.files.map(t=>t.name).join(",");case"place":return"";case"created_time":return st(e.created_time);case"last_edited_time":return st(e.last_edited_time);case"last_visited_time":return st(e.last_visited_time);case"created_by":return e.created_by?[e.created_by]:void 0;case"last_edited_by":return e.last_edited_by?[e.last_edited_by]:void 0;default:return ee(e)}}function Er(e,t){if(t>=6||e.status==="error")return e;switch(e.type){case"queryDataSourceResult":return{...e,items:e.items.map(Pr)};case"getPageResult":case"createPageResult":case"updatePageResult":return{...e,page:Cr(e.page)};default:return ee(e)}}function Or(e,t){return e.type!=="queryDataSourceResult"&&e.type!=="getPageResult"&&e.type!=="createPageResult"&&e.type!=="updatePageResult"?e:Er(e,t)}var jr=n({theme:be,contrastMode:u(de),blockId:le,parent:ae,page:he,manifest:ye,dataSources:n({bindings:me}),currentUser:pe});function Rr(e){if(e.length>2048||!URL.canParse(e))return;let t=new URL(e);if(!(t.protocol!=="http:"&&t.protocol!=="https:"||t.username!==""||t.password!==""||t.href.length>2048))return t.href}function Mr(e){switch(e.type){case"connect":case"init":case"initResult":return!0;default:return!1}}var Br=n({code:r(),message:r(),isRetryable:h()});var Dr={type:s("connect"),initializationId:r(),bridgeProtocolVersion:C(),sdkVersion:r()},wr=v("status",[n({status:s("success"),manifest:u(ye),...Dr}),n({status:s("error"),error:Br,...Dr})]);var co=v("type",[n({type:s("start")}),n({type:s("end")}),n({type:s("before"),blockId:le}),n({type:s("after"),blockId:le})]),lo=v("type",[n({type:s("page_id"),page_id:T}),n({type:s("data_source_id"),data_source_id:X})]),qr=n({type:s("createPage"),requestId:r(),parent:lo,properties:Pe,position:u(co)});var po=r(),fo=n({code:po,message:r(),isRetryable:h()}),Tr=v("status",[n({type:s("initResult"),initializationId:r(),status:s("success"),initialHeight:u(H(C(),ke(),_e(0)))}),n({type:s("initResult"),initializationId:r(),status:s("error"),error:fo})]);var Ar=n({type:s("invalidHostMessage"),reason:r()});var Nr=w(["ascending","descending"]);var Ur=H(T,Qe(/^(?:[0-9a-f]{32}|[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})$/i),Xe(e=>e.replaceAll("-","").toLowerCase().replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/,"$1-$2-$3-$4-$5"))),it=k([f({contains:Ur}),f({does_not_contain:Ur})]),Me=k([f({is_empty:s(!0)}),f({is_not_empty:s(!0)})]),Re=k([r(),E(r())]),Fr=f({object:w(["user","group"]),id:H(r(),Ie(1))}),mo=k([f({contains:Fr}),f({does_not_contain:Fr}),Me]),zr=f({object:s("user"),id:H(r(),Ie(1),we(2e3))}),yo=k([f({contains:zr}),f({does_not_contain:zr}),f({is_empty:s(!0)}),f({is_not_empty:s(!0)})]),Oe=k([f({equals:r()}),f({does_not_equal:r()}),f({contains:r()}),f({does_not_contain:r()}),f({starts_with:r()}),f({ends_with:r()}),Me]),vo=k([f({equals:C()}),f({does_not_equal:C()}),f({greater_than:C()}),f({less_than:C()}),f({greater_than_or_equal_to:C()}),f({less_than_or_equal_to:C()}),Me]),ho=k([f({equals:h()}),f({does_not_equal:h()})]),Gr=k([f({equals:Re}),f({does_not_equal:Re}),Me]),Lr=w(["To-do","In progress","Complete","Current","Future"]),Hr=k([Lr,H(E(Lr),Ie(1),we(5))]),go=k([f({group_equals:Hr}),f({group_does_not_equal:Hr})]),bo=k([Gr,go]),So=k([f({contains:Re}),f({contains_all:Re}),f({does_not_contain:Re}),Me]),J=w(["start_date","end_date"]),ko=w(["today","tomorrow","yesterday","one_week_ago","one_week_from_now","one_month_ago","one_month_from_now"]),je=k([ko,r()]),Io=k([f({target:u(J),equals:je}),f({target:u(J),before:je}),f({target:u(J),after:je}),f({target:u(J),on_or_before:je}),f({target:u(J),on_or_after:je}),f({target:u(J),this_week:f({})}),f({target:u(J),past_week:f({})}),f({target:u(J),past_month:f({})}),f({target:u(J),past_year:f({})}),f({target:u(J),next_week:f({})}),f({target:u(J),next_month:f({})}),f({target:u(J),next_year:f({})}),f({target:u(J),is_empty:s(!0)}),f({target:u(J),is_not_empty:s(!0)})]),Vr=k([f({propertyId:r(),relation:it}),f({propertyId:r(),created_by:yo}),f({propertyId:r(),title:Oe}),f({propertyId:r(),rich_text:Oe}),f({propertyId:r(),url:Oe}),f({propertyId:r(),email:Oe}),f({propertyId:r(),phone_number:Oe}),f({propertyId:r(),number:vo}),f({propertyId:r(),checkbox:ho}),f({propertyId:r(),select:Gr}),f({propertyId:r(),multi_select:So}),f({propertyId:r(),status:bo}),f({propertyId:r(),date:Io}),f({propertyId:r(),people:mo})]),_o=k([Vr,f({and:E(Vr)})]),at=10,xo=f({propertyId:r(),direction:Nr}),$r=n({type:s("queryDataSource"),subscriptionId:r(),dataSourceId:X,limit:C(),filter:u(_o),sorts:u(E(xo))});var Qr=n({type:s("resize"),height:H(C(),ke(),_e(0))});var Xr=n({type:s("unsubscribeDataSourceQuery"),subscriptionId:r()});var Wr=n({type:s("updatePage"),requestId:r(),pageId:T,dataSourceId:u(X),properties:u(Pe),icon:u(Ne),cover:u(Ue),archived:u(h())});var Jr=v("type",[wr,Tr,$r,Xr,qr,Nt,zt,Vt,Xt,$t,Wr,Qr,Ar]);function Kr(e){if(typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string")return e.type}function Yr(e){let t=Kr(e);return t==="invalidHostMessage"||t==="invalidSandboxMessage"?{incomingType:t}:{incomingType:t,nack:{type:"invalidSandboxMessage",reason:Co(t)}}}function Co(e){return e!==void 0?`Unsupported sandbox message of type "${e}"`:"Unsupported sandbox message (no `type` field or non-object payload)"}var Zr=n({initializationId:r()}),Po=n({bridgeProtocolVersion:k([C(),We()])});function en(e){let{iframe:t,sandboxOrigin:o,getInitStatus:i,emit:l,sendNack:c,onInvalidConnect:p,onInvalidInitResult:y,onConnect:m,onInitResult:_,onQueryDataSource:x,onUnsubscribeDataSourceQuery:P,onCreatePage:S,onGetPage:F,onOpenPage:G,onOpenExternalUrl:z,onGetUser:R,onListUsers:te,onUpdatePage:ne,onResize:K}=e;function ue($,M){l("warn",{message:"Ignored unsupported sandbox message",payload:ut($),issues:M});let L=Yr($);if(L.incomingType==="connect"){let Y=Ce(Zr,$),se=Ce(Po,$);if(p({initializationId:Y.success?Y.output.initializationId:void 0,error:vr(),bridgeProtocolVersion:se.success?se.output.bridgeProtocolVersion:void 0})==="handled")return}if(L.incomingType==="initResult"){let Y=Ce(Zr,$);y({initializationId:Y.success?Y.output.initializationId:void 0,error:kr()})}L.nack!==void 0&&i()!=="stopped"&&c(L.nack)}return function(M){let L=M.source===t.contentWindow,Y=M.origin===o;if(!L||!Y)return;let se=Ce(Jr,M.data);if(!se.success){ue(M.data,se.issues);return}let B=se.output;if(!Mr(B)&&i()!=="initialized"){l("warn",{message:`Ignored ${B.type} before initialization completed`,payload:ut(B)});return}switch(l("in",ut(B)),B.type){case"connect":m(B);return;case"initResult":_(B);return;case"queryDataSource":x(B);return;case"unsubscribeDataSourceQuery":P(B);return;case"createPage":S(B);return;case"openPage":G(B);return;case"openExternalUrl":z(B);return;case"getPage":F(B);return;case"getUser":R(B);return;case"listUsers":te(B);return;case"updatePage":ne(B);return;case"resize":K(B);return;case"invalidHostMessage":return;default:ee(B)}}}function ut(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="openExternalUrl"?{type:"openExternalUrl",..."requestId"in e?{requestId:e.requestId}:{}}:e}var ze=class{constructor(t){this.onUnsubscribe=t}onUnsubscribe;bySubscriptionId=new Map;subscribe(t){this.unsubscribe(t.subscriptionId);let o={_tag:"QuerySubscriptionToken"};return this.bySubscriptionId.set(t.subscriptionId,{message:t,token:o,isRefreshing:!0,shouldRefreshAgain:!1}),o}isCurrent(t,o){return this.bySubscriptionId.get(t)?.token===o}unsubscribe(t){this.bySubscriptionId.delete(t)&&this.onUnsubscribe(t)}refresh(t){let o=[],i=!1;for(let l of this.bySubscriptionId.values())if(l.message.dataSourceId===t){if(i=!0,l.isRefreshing){l.shouldRefreshAgain=!0;continue}l.isRefreshing=!0,o.push({message:l.message,token:l.token})}return i?o:void 0}finish(t,o){let i=this.bySubscriptionId.get(t);if(i?.token===o&&(i.isRefreshing=!1,!!i.shouldRefreshAgain))return i.shouldRefreshAgain=!1,i.isRefreshing=!0,{message:i.message,token:i.token}}unsubscribeAll(){for(let t of this.bySubscriptionId.keys())this.unsubscribe(t)}};function tn(e,t){if(e===void 0)return;let o="and"in e?e.and:[e];for(let i of o){let l=Eo(i,t);if(l!==void 0)return l}}function Eo(e,t){if(!Object.hasOwn(t.propertiesById,e.propertyId))return{code:"invalid_data_source_query_filter",message:`Data source query filter property ID "${e.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let o=t.propertiesById[e.propertyId],i=Object.keys(e).find(y=>y!=="propertyId");if(i!==o.type)return{code:"invalid_data_source_query_filter",message:`Data source query filter branch "${i}" does not match property type "${o.type}".`,isRetryable:!1};if("status"in e&&o.type==="status"){let y=e.status;if("group_equals"in y||"group_does_not_equal"in y){let m="group_equals"in y?y.group_equals:y.group_does_not_equal,x=(Array.isArray(m)?m:[m]).find(P=>!o.groups.some(S=>S.name===P));return x===void 0?void 0:{code:"invalid_data_source_query_filter",message:`Unknown status group "${x}".`,isRetryable:!1}}}if("relation"in e&&!ht(it,e.relation))return{code:"invalid_data_source_query_filter",message:"Relation filters require a page ID.",isRetryable:!1};let l=Oo(e);if(l===void 0||o.type!==l.propertyType)return;let c=new Set(o.options.map(y=>y.name)),p=jo(l.operator).find(y=>!c.has(y));if(p!==void 0)return{code:"invalid_data_source_query_filter",message:`Data source query filter option "${p}" is not defined for property "${e.propertyId}".`,isRetryable:!1}}function Oo(e){if("select"in e)return{propertyType:"select",operator:e.select};if("multi_select"in e)return{propertyType:"multi_select",operator:e.multi_select};if("status"in e){let t=e.status;return"group_equals"in t||"group_does_not_equal"in t?void 0:{propertyType:"status",operator:t}}}function jo(e){let t;if("equals"in e)t=e.equals;else if("does_not_equal"in e)t=e.does_not_equal;else if("contains"in e)t=e.contains;else if("contains_all"in e)t=e.contains_all;else if("does_not_contain"in e)t=e.does_not_contain;else return"is_empty"in e||"is_not_empty"in e?[]:ee(e);return Array.isArray(t)?t:[t]}var Ro=new Set(It);function rn(e,t){if(e===void 0)return;if(e.length>at)return{code:"invalid_data_source_query_sort",message:`Data source query sorts may contain at most ${at} entries.`,isRetryable:!1};let o=new Set;for(let i of e){if(o.has(i.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sorts cannot contain duplicate property ID "${i.propertyId}".`,isRetryable:!1};if(o.add(i.propertyId),!Object.hasOwn(t.propertiesById,i.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sort property ID "${i.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let l=t.propertiesById[i.propertyId];if(!Ro.has(l.type))return{code:"invalid_data_source_query_sort",message:`Data source query sorts do not yet support property type "${l.type}".`,isRetryable:!1}}}var on=5;function Mo(e){let{iframe:t,prepareInitialState:o,handlers:i,onInitialized:l,onConnectionFailure:c,onLog:p,onQueryUnsubscribed:y,sandboxOrigin:m,minBridgeProtocolVersion:_,noConnectTimeoutMs:x,initialStateTimeoutMs:P,noInitResultTimeoutMs:S}=e,F=Math.max(_??3,3),G=new AbortController,z,R={},te=!1,ne=new AbortController,K,ue,$=6,M=new ze(a=>{y?.(a)});function L(a,b){p?.(a,b)}function Y(a){let b=q.status;switch(b){case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"initialized":case"error":break;case"stopped":return;default:return ee(b)}let O=Or(a,$);L("out",O),t.contentWindow?.postMessage(O,m)}function se(a){Y(ie(Fe,a))}function B(a){Y(a)}function Z(a){let b=q.status;switch(b){case"initialized":Y(ie(mr,a));return;case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"error":case"stopped":return;default:ee(b)}}async function fe(a,b){if(b===void 0)return;let O=await b(a);Z({type:`${a.type}Result`,requestId:a.requestId,...O})}function Be(a){let b=a.response.status==="error"?{type:"queryDataSourceResult",subscriptionId:a.subscriptionId,status:"error",error:a.response.error}:{type:"queryDataSourceResult",subscriptionId:a.subscriptionId,status:"success",items:a.response.items,hasMore:a.response.hasMore};Z(b)}async function g(a,b=M.subscribe(a)){try{let O=Bo(ue,a.dataSourceId),ve=Do(a,O);if(ve!==void 0){M.isCurrent(a.subscriptionId,b)&&(M.unsubscribe(a.subscriptionId),Be({subscriptionId:a.subscriptionId,response:{status:"error",error:ve}}));return}let Le=await i.queryDataSource(a);if(!M.isCurrent(a.subscriptionId,b))return;Le.status==="error"&&!Le.error.isRetryable&&M.unsubscribe(a.subscriptionId),Be({subscriptionId:a.subscriptionId,response:Le})}finally{let O=M.finish(a.subscriptionId,b);O!==void 0&&g(O.message,O.token)}}function I(a){q.status==="stopped"||q.status==="error"||(Object.assign(R,a),oe())}async function Q(a){if(i.openExternalUrl===void 0||G.signal.aborted||z===a.requestId)return;if(z!==void 0){let O={type:"openExternalUrlResult",requestId:a.requestId,status:"error",error:{code:"pending_navigation",message:"Another external navigation request is pending.",isRetryable:!0}};Z(O);return}let b=Rr(a.url);if(b===void 0){let O={type:"openExternalUrlResult",requestId:a.requestId,status:"error",error:{code:"invalid_url",message:"Only valid HTTP or HTTPS URLs without credentials, up to 2,048 characters, can be opened.",isRetryable:!1}};Z(O);return}z=a.requestId;try{let O=await i.openExternalUrl({...a,url:b},{signal:G.signal});if(G.signal.aborted)return;let ve={type:"openExternalUrlResult",requestId:a.requestId,...O};Z(ve)}catch(O){if(!G.signal.aborted)throw O}finally{z===a.requestId&&(z=void 0)}}function oe(){if(q.status!=="initialized")return;let a=R;R={},a.theme!==void 0&&Z({type:"themeChanged",theme:a.theme}),a.contrastMode!==void 0&&Z({type:"contrastModeChanged",contrastMode:a.contrastMode}),a.parent!==void 0&&Z({type:"parentChanged",parent:a.parent}),a.page!==void 0&&Z({type:"pageChanged",page:a.page}),a.dataSources!==void 0&&Z({type:"dataSourcesChanged",dataSources:a.dataSources}),a.currentUser!==void 0&&Z({type:"currentUserChanged",currentUser:a.currentUser})}let q=Ir({async prepareInit(a){$=a.bridgeProtocolVersion;let b=await un;return q.status!=="preparingInit"?b:an(b)},sendInitMessage:se,warn:a=>L("warn",a),flushPendingHostStateChanges:oe,minBridgeProtocolVersion:F,noConnectTimeoutMs:x,initialStateTimeoutMs:P,noInitResultTimeoutMs:S,stopHostWithFailure:pt,onInitResult(a){a.status==="success"&&K!==void 0&&l?.({manifest:K,initialHeight:a.initialHeight})},onConnectionFailure:a=>{ne.abort(),c?.(a)}});function an(a){if(a.status==="error")return a;let b=ie(jr,{...a.initialState,...R});if(K=b.manifest,R={},$<on&&b.page.type==="unavailable")return{status:"error",error:rt()};let O=sn(b.manifest,b.dataSources);return O!==void 0?{status:"error",error:O}:(ue=b.dataSources,te=!0,{status:"success",initialState:b})}let un=cn().catch(a=>(ne.signal.aborted||L("warn",{message:"Failed to prepare custom block initialization",error:a}),{status:"error",error:Ee()}));async function cn(){let a=await _r({...e,sandboxOrigin:m,signal:ne.signal,onError:O=>{L("warn",{message:"Failed to load custom block manifest",error:O})}});if(a.status==="error")return a;if(ne.signal.aborted)return{status:"error",error:Ee()};let b=await o({manifest:a.manifest,signal:ne.signal});return b.status==="error"?b:{status:"success",initialState:{...b.initialState,manifest:a.manifest}}}let ct=en({iframe:t,sandboxOrigin:m,getInitStatus:()=>q.status,emit:L,sendNack:B,onInvalidConnect:q.handleInvalidConnect,onInvalidInitResult:q.handleInvalidInitResult,onConnect:q.handleConnect,onInitResult:q.handleInitResult,onQueryDataSource:g,onUnsubscribeDataSourceQuery:a=>M.unsubscribe(a.subscriptionId),onOpenExternalUrl:Q,onCreatePage:a=>fe(a,i.createPage),onGetPage:a=>fe(a,i.getPage),onOpenPage:a=>fe(a,i.openPage),onGetUser:a=>fe(a,i.getUser),onListUsers:a=>fe(a,i.listUsers),onUpdatePage:a=>fe(a,i.updatePage),onResize:a=>i.resize?.(a)});window.addEventListener("message",ct),t.addEventListener("load",q.onIframeLoad);function lt(){G.abort(),ne.abort(),window.removeEventListener("message",ct),t.removeEventListener("load",q.onIframeLoad),q.stop(),M.unsubscribeAll()}function pt(a){lt(),L("warn",a),c?.(a)}return{stop:lt,setTheme(a){I({theme:a})},setContrastMode(a){I({contrastMode:a})},setParent(a){I({parent:a})},setPage(a){if(a.type==="unavailable"&&$<on&&(q.status==="preparingInit"&&te||q.status==="waitingForInitResult"||q.status==="initialized")){pt({...rt(),phase:"runtime",source:"host"});return}I({page:a})},setCurrentUser(a){I({currentUser:a})},setDataSources(a){let b={bindings:ie(me,a.bindings)};if(q.hasConnectedSandbox&&K!==void 0&&sn(K,b)!==void 0){L("warn",{message:"Ignored invalid data source bindings update",payload:b});return}ue=b,I({dataSources:b})},refreshQuery({dataSourceId:a}){if(q.status!=="initialized")return;let b=ie(X,a),O=M.refresh(b);if(O===void 0){L("warn",`No active query exists for data source "${a}"`);return}for(let ve of O)g(ve.message,ve.token)}}}function Bo(e,t){return Object.values(e?.bindings??{}).find(o=>o.collectionPointer?.id===t)?.collectionSchema}function sn(e,t){for(let[o,i]of Object.entries(e.dataSources)){let l=t.bindings[o];if(l?.collectionPointer===void 0||l.collectionSchema===void 0)return hr();for(let[c,p]of Object.entries(i.properties??{})){let y=l.propertyIdsByKey?.[c];if(y===void 0)return gr();if(l.collectionSchema.propertiesById[y]?.type!==p.type)return br()}}}function Do(e,t){return t===void 0?e.filter===void 0&&(e.sorts?.length??0)===0?void 0:{code:"data_source_schema_unavailable",message:"You cannot query this data source with filters or sorts because its schema is unavailable.",isRetryable:!1}:tn(e.filter,t)??rn(e.sorts,t)}function wo(e){return ie(T,e)}export{He as LATEST_BRIDGE_PROTOCOL_VERSION,Ve as LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION,Mo as createCustomBlockHost,ln as getAutoBoundPropertyIdsByKey,ot as isLocalCustomBlockUrl,wo as toNotionPageId};
|
|
1
|
+
var $e=6,Qe=6;function vn(e){let{manifestProperties:t,propertySchemasById:s}=e,i=[];for(let[c,l]of Object.entries(t)){let p=dn({propertyKey:c,manifestProperty:l,propertySchemasById:s});p!==void 0&&i.push([c,p])}return Object.fromEntries(i)}function dn(e){let{propertyKey:t,manifestProperty:s,propertySchemasById:i}=e,c=bt(s.name),l=Object.entries(i).filter(([p,y])=>y.type===s.type&&(p===t||bt(y.name)===c));return l.length===1?l[0][0]:void 0}function bt(e){return e.trim().toLowerCase()}var qe,hn={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function Xe(e){return!e&&!qe?hn:{lang:e?.lang??qe?.lang,message:e?.message,abortEarly:e?.abortEarly??qe?.abortEarly,abortPipeEarly:e?.abortPipeEarly??qe?.abortPipeEarly}}var gn;function bn(e){return gn?.get(e)}var Sn;function kn(e){return Sn?.get(e)}var In;function _n(e,t){return In?.get(e)?.get(t)}function he(e){let t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function w(e,t,s,i,c){let l=c&&"input"in c?c.input:s.value,p=c?.expected??e.expects??null,y=c?.received??he(l),m={kind:e.kind,type:e.type,input:l,expected:p,received:y,message:`Invalid ${t}: ${p?`Expected ${p} but r`:"R"}eceived ${y}`,requirement:e.requirement,path:c?.path,issues:c?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},x=e.kind==="schema",_=c?.message??e.message??_n(e.reference,m.lang)??(x?kn(m.lang):null)??i.message??bn(m.lang);_!==void 0&&(m.message=typeof _=="function"?_(m):_),x&&(s.typed=!1),s.issues?s.issues.push(m):s.issues=[m]}var St=new WeakMap;function Q(e){let t=St.get(e);return t||(t={version:1,vendor:"valibot",validate(s){return e["~run"]({value:s},Xe())}},St.set(e,t)),t}function xn(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function We(e,t){let s=[...new Set(e)];return s.length>1?`(${s.join(` ${t} `)})`:s[0]??"never"}var Cn=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function ce(e){return{kind:"transformation",type:"brand",reference:ce,async:!1,name:e,"~run"(t){return t}}}function Ie(e){return{kind:"validation",type:"finite",reference:Ie,async:!1,expects:null,requirement:Number.isFinite,message:e,"~run"(t,s){return t.typed&&!this.requirement(t.value)&&w(this,"finite",t,s),t}}}function Je(e,t){let s=he(e);return{kind:"validation",type:"includes",reference:Je,async:!1,expects:s,requirement:e,message:t,"~run"(i,c){return i.typed&&!i.value.includes(this.requirement)&&w(this,"content",i,c,{received:`!${s}`}),i}}}function Te(e,t){return{kind:"validation",type:"max_length",reference:Te,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(s,i){return s.typed&&s.value.length>this.requirement&&w(this,"length",s,i,{received:`${s.value.length}`}),s}}}function _e(e,t){return{kind:"validation",type:"min_length",reference:_e,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(s,i){return s.typed&&s.value.length<this.requirement&&w(this,"length",s,i,{received:`${s.value.length}`}),s}}}function xe(e,t){return{kind:"validation",type:"min_value",reference:xe,async:!1,expects:`>=${e instanceof Date?e.toJSON():he(e)}`,requirement:e,message:t,"~run"(s,i){return s.typed&&!(s.value>=this.requirement)&&w(this,"value",s,i,{received:s.value instanceof Date?s.value.toJSON():he(s.value)}),s}}}function Ke(e,t){return{kind:"validation",type:"regex",reference:Ke,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(s,i){return s.typed&&!this.requirement.test(s.value)&&w(this,"format",s,i),s}}}function Ze(e){return{kind:"transformation",type:"transform",reference:Ze,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}var It={abortEarly:!0};function _t(e,t,s){return typeof e.fallback=="function"?e.fallback(t,s):e.fallback}function Ae(e,t,s){return typeof e.default=="function"?e.default(t,s):e.default}function xt(e,t){return!e["~run"]({value:t},It).issues}function E(e,t){return{kind:"schema",type:"array",reference:E,expects:"Array",async:!1,item:e,message:t,get"~standard"(){return Q(this)},"~run"(s,i){let c=s.value;if(Array.isArray(c)){s.typed=!0,s.value=[];for(let l=0;l<c.length;l++){let p=c[l],y=this.item["~run"]({value:p},i);if(y.issues){let m={type:"array",origin:"value",input:c,key:l,value:p};for(let x of y.issues)x.path?x.path.unshift(m):x.path=[m],s.issues?.push(x);if(s.issues||(s.issues=y.issues),i.abortEarly){s.typed=!1;break}}y.typed||(s.typed=!1),s.value.push(y.value)}}else w(this,"type",s,i);return s}}}function h(e){return{kind:"schema",type:"boolean",reference:h,expects:"boolean",async:!1,message:e,get"~standard"(){return Q(this)},"~run"(t,s){return typeof t.value=="boolean"?t.typed=!0:w(this,"type",t,s),t}}}function o(e,t){return{kind:"schema",type:"literal",reference:o,expects:he(e),async:!1,literal:e,message:t,get"~standard"(){return Q(this)},"~run"(s,i){return s.value===this.literal?s.typed=!0:w(this,"type",s,i),s}}}function Ye(e){return{kind:"schema",type:"nan",reference:Ye,expects:"NaN",async:!1,message:e,get"~standard"(){return Q(this)},"~run"(t,s){return Number.isNaN(t.value)?t.typed=!0:w(this,"type",t,s),t}}}function F(e,t){return{kind:"schema",type:"nullable",reference:F,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,get"~standard"(){return Q(this)},"~run"(s,i){return s.value===null&&(this.default!==void 0&&(s.value=Ae(this,s,i)),s.value===null)?(s.typed=!0,s):this.wrapped["~run"](s,i)}}}function P(e){return{kind:"schema",type:"number",reference:P,expects:"number",async:!1,message:e,get"~standard"(){return Q(this)},"~run"(t,s){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:w(this,"type",t,s),t}}}function n(e,t){return{kind:"schema",type:"object",reference:n,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return Q(this)},"~run"(s,i){let c=s.value;if(c&&typeof c=="object"){s.typed=!0,s.value={};for(let l in this.entries){let p=this.entries[l];if(l in c||(p.type==="exact_optional"||p.type==="optional"||p.type==="nullish")&&p.default!==void 0){let y=l in c?c[l]:Ae(p),m=p["~run"]({value:y},i);if(m.issues){let x={type:"object",origin:"value",input:c,key:l,value:y};for(let _ of m.issues)_.path?_.path.unshift(x):_.path=[x],s.issues?.push(_);if(s.issues||(s.issues=m.issues),i.abortEarly){s.typed=!1;break}}m.typed||(s.typed=!1),s.value[l]=m.value}else if(p.fallback!==void 0)s.value[l]=_t(p);else if(p.type!=="exact_optional"&&p.type!=="optional"&&p.type!=="nullish"&&(w(this,"key",s,i,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),i.abortEarly))break}}else w(this,"type",s,i);return s}}}function u(e,t){return{kind:"schema",type:"optional",reference:u,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return Q(this)},"~run"(s,i){return s.value===void 0&&(this.default!==void 0&&(s.value=Ae(this,s,i)),s.value===void 0)?(s.typed=!0,s):this.wrapped["~run"](s,i)}}}function T(e,t){return{kind:"schema",type:"picklist",reference:T,expects:We(e.map(he),"|"),async:!1,options:e,message:t,get"~standard"(){return Q(this)},"~run"(s,i){return this.options.includes(s.value)?s.typed=!0:w(this,"type",s,i),s}}}function V(e,t,s){return{kind:"schema",type:"record",reference:V,expects:"Object",async:!1,key:e,value:t,message:s,get"~standard"(){return Q(this)},"~run"(i,c){let l=i.value;if(l&&typeof l=="object"){i.typed=!0,i.value={};for(let p in l)if(xn(l,p)){let y=l[p],m=this.key["~run"]({value:p},c);if(m.issues){let _={type:"object",origin:"key",input:l,key:p,value:y};for(let C of m.issues)C.path=[_],i.issues?.push(C);if(i.issues||(i.issues=m.issues),c.abortEarly){i.typed=!1;break}}let x=this.value["~run"]({value:y},c);if(x.issues){let _={type:"object",origin:"value",input:l,key:p,value:y};for(let C of x.issues)C.path?C.path.unshift(_):C.path=[_],i.issues?.push(C);if(i.issues||(i.issues=x.issues),c.abortEarly){i.typed=!1;break}}(!m.typed||!x.typed)&&(i.typed=!1),m.typed&&(i.value[m.value]=x.value)}}else w(this,"type",i,c);return i}}}function f(e,t){return{kind:"schema",type:"strict_object",reference:f,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return Q(this)},"~run"(s,i){let c=s.value;if(c&&typeof c=="object"){s.typed=!0,s.value={};for(let l in this.entries){let p=this.entries[l];if(l in c||(p.type==="exact_optional"||p.type==="optional"||p.type==="nullish")&&p.default!==void 0){let y=l in c?c[l]:Ae(p),m=p["~run"]({value:y},i);if(m.issues){let x={type:"object",origin:"value",input:c,key:l,value:y};for(let _ of m.issues)_.path?_.path.unshift(x):_.path=[x],s.issues?.push(_);if(s.issues||(s.issues=m.issues),i.abortEarly){s.typed=!1;break}}m.typed||(s.typed=!1),s.value[l]=m.value}else if(p.fallback!==void 0)s.value[l]=_t(p);else if(p.type!=="exact_optional"&&p.type!=="optional"&&p.type!=="nullish"&&(w(this,"key",s,i,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),i.abortEarly))break}if(!s.issues||!i.abortEarly){for(let l in c)if(!(l in this.entries)){w(this,"key",s,i,{input:l,expected:"never",path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]});break}}}else w(this,"type",s,i);return s}}}function r(e){return{kind:"schema",type:"string",reference:r,expects:"string",async:!1,message:e,get"~standard"(){return Q(this)},"~run"(t,s){return typeof t.value=="string"?t.typed=!0:w(this,"type",t,s),t}}}function kt(e){let t;if(e)for(let s of e)if(t)for(let i of s.issues)t.push(i);else t=s.issues;return t}function g(e,t){return{kind:"schema",type:"union",reference:g,expects:We(e.map(s=>s.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return Q(this)},"~run"(s,i){let c,l,p;for(let y of this.options){let m=y["~run"]({value:s.value},i);if(m.typed)if(m.issues)l?l.push(m):l=[m];else{c=m;break}else p?p.push(m):p=[m]}if(c)return c;if(l){if(l.length===1)return l[0];w(this,"type",s,i,{issues:kt(l)}),s.typed=!0}else{if(p?.length===1)return p[0];w(this,"type",s,i,{issues:kt(p)})}return s}}}function Ce(){return{kind:"schema",type:"unknown",reference:Ce,expects:"unknown",async:!1,get"~standard"(){return Q(this)},"~run"(e){return e.typed=!0,e}}}function v(e,t,s){return{kind:"schema",type:"variant",reference:v,expects:"Object",async:!1,key:e,options:t,message:s,get"~standard"(){return Q(this)},"~run"(i,c){let l=i.value;if(l&&typeof l=="object"){let p,y=0,m=this.key,x=[],_=(C,b)=>{for(let L of C.options){if(L.type==="variant")_(L,new Set(b).add(L.key));else{let q=!0,A=0;for(let O of b){let H=L.entries[O];if(O in l?H["~run"]({typed:!1,value:l[O]},It).issues:H.type!=="exact_optional"&&H.type!=="optional"&&H.type!=="nullish"){q=!1,m!==O&&(y<A||y===A&&O in l&&!(m in l))&&(y=A,m=O,x=[]),m===O&&x.push(L.entries[O].expects);break}A++}if(q){let O=L["~run"]({value:l},c);(!p||!p.typed&&O.typed)&&(p=O)}}if(p&&!p.issues)break}};if(_(this,new Set([this.key])),p)return p;w(this,"type",i,c,{input:l[m],expected:We(x,"|"),path:[{type:"object",origin:"value",input:l,key:m,value:l[m]}]})}else w(this,"type",i,c);return i}}}function ie(e,t,s){let i=e["~run"]({value:t},Xe(s));if(i.issues)throw new Cn(i.issues);return i.value}function z(...e){return{...e[0],pipe:e,get"~standard"(){return Q(this)},"~run"(t,s){for(let i of e)if(i.kind!=="metadata"){if(t.issues&&(i.kind==="schema"||i.kind==="transformation")){t.typed=!1;break}(!t.issues||!s.abortEarly&&!s.abortPipeEarly)&&(t=i["~run"](t,s))}return t}}}function Pe(e,t,s){let i=e["~run"]({value:t},Xe(s));return{typed:i.typed,success:!i.issues,output:i.value,issues:i.issues}}var le=z(r(),ce("NotionBlockId")),K=z(r(),ce("NotionDataSourceId")),U=z(r(),ce("NotionPageId")),Ct=z(r(),ce("NotionAgentId")),Pt=z(r(),ce("NotionSpaceId"));var Et=T(["default","gray","brown","orange","yellow","green","blue","purple","pink","red","gray_background","brown_background","orange_background","yellow_background","green_background","blue_background","purple_background","pink_background","red_background","default_background"]),et=n({id:r(),name:r(),color:u(Et),description:u(r())}),Pn=n({id:r(),name:r(),color:u(Et),option_ids:E(r())}),En=n({synced_property_id:r(),synced_property_name:r()}),R=n({name:r(),description:u(r())}),On=["title","rich_text","number","checkbox","url","email","phone_number","select","multi_select","status","date","people","files","unique_id","relation","place","formula","rollup","button","verification","last_visited_time","location","created_time","last_edited_time","created_by","last_edited_by"],Ot=T(On),jt=["title","rich_text","number","checkbox","url","email","phone_number","date","created_time","last_edited_time","people","created_by"],tt=v("type",[n({...R.entries,type:o("title")}),n({...R.entries,type:o("rich_text")}),n({...R.entries,type:o("number")}),n({...R.entries,type:o("checkbox")}),n({...R.entries,type:o("url")}),n({...R.entries,type:o("email")}),n({...R.entries,type:o("phone_number")}),n({...R.entries,type:o("select"),options:E(et)}),n({...R.entries,type:o("multi_select"),options:E(et)}),n({...R.entries,type:o("status"),options:E(et),groups:E(Pn)}),n({...R.entries,type:o("date")}),n({...R.entries,type:o("people")}),n({...R.entries,type:o("files")}),n({...R.entries,type:o("unique_id")}),n({...R.entries,type:o("relation"),data_source_id:u(r()),dual_property:u(En)}),n({...R.entries,type:o("place")}),n({...R.entries,type:o("formula")}),n({...R.entries,type:o("rollup")}),n({...R.entries,type:o("button")}),n({...R.entries,type:o("verification")}),n({...R.entries,type:o("last_visited_time")}),n({...R.entries,type:o("location")}),n({...R.entries,type:o("created_time")}),n({...R.entries,type:o("last_edited_time")}),n({...R.entries,type:o("created_by")}),n({...R.entries,type:o("last_edited_by")})]);var Rt=n({id:K,table:r(),spaceId:u(Pt)}),Mt=n({id:u(K),propertiesById:V(r(),tt)}),$o=n({key:r(),collectionPointer:u(Rt),collectionSchema:u(Mt),propertyIdsByKey:V(r(),u(r())),propertySchemasById:V(r(),tt)}),jn=n({collectionPointer:u(Rt),collectionSchema:u(Mt),propertyIdsByKey:u(V(r(),u(r())))}),me=V(r(),jn);var ge=T(["standard","high"]),Bt="standard";var Dt=n({type:o("contrastModeChanged"),contrastMode:ge});var Ne=n({unit:T(["year","month","week","day"]),value:P(),time:r(),defaultTimeZone:u(r())}),Rn=n({unit:T(["hour","minute"]),value:P()}),Ee=n({unit:o("none")}),rt=g([Ne,Rn]),wt=u(g([Ne,Ee])),qt=u(g([rt,Ee])),Mn=n({type:o("date"),start_date:r(),reminder:wt}),Bn=n({type:o("daterange"),start_date:r(),end_date:r(),reminder:wt}),Dn=n({type:o("datetime"),start_date:r(),start_time:r(),time_zone:u(r()),reminder:qt}),wn=n({type:o("datetimerange"),start_date:r(),start_time:r(),end_date:r(),end_time:r(),time_zone:u(r()),reminder:qt}),Tt=v("type",[Mn,Bn,Dn,wn]);var Ue=n({id:r(),table:r()});var ae=v("type",[n({type:o("page_id"),page_id:U}),n({type:o("data_source_id"),data_source_id:K}),n({type:o("workspace"),workspace:o(!0)}),n({type:o("block_id"),block_id:le}),n({type:o("agent_id"),agent_id:Ct}),n({type:o("unavailable")})]);var be=v("type",[n({type:o("unavailable")}),n({type:o("page"),id:U,parent:ae})]),qn=n({type:o("emoji"),emoji:r()}),Tn=n({type:o("custom_emoji"),custom_emoji:n({id:r(),name:u(r()),url:u(r())})}),Nt=n({type:o("external"),external:n({url:r()})}),Ut=n({type:o("file"),file:n({url:r(),expiry_time:u(r())})}),ze=v("type",[qn,Tn,Nt,Ut]),Le=v("type",[Nt,Ut]),Z=F(r()),At=V(r(),Ce()),nt=g([n({id:r(),name:u(r()),color:u(r()),description:u(Z)}),n({name:r(),id:u(r()),color:u(r()),description:u(Z)})]),ot={start:r(),end:u(Z),time_zone:u(Z),reminder:u(g([rt,Ee]))},An=g([n({...ot,start:z(r(),Je("T"))}),n({...ot,time_zone:r()}),n({...ot,reminder:u(g([Ne,Ee]))})]),Nn=g([n({object:u(o("user")),id:r()}),n({object:o("group"),id:r(),name:u(Z)})]),Un=n({id:r()}),Fn=g([n({type:o("external"),name:r(),external:n({url:r()})}),n({type:o("file"),name:r(),file:n({url:r(),expiry_time:u(r())})})]),zn=n({lat:P(),lon:P(),name:u(Z),address:u(Z),aws_place_id:u(Z),google_place_id:u(Z)}),M={id:r()},Fe=F(n({...Ue.entries,table:T(["notion_user","bot","organization_bot"]),spaceId:u(r())})),Ft=v("type",[n({...M,type:o("title"),title:E(At)}),n({...M,type:o("rich_text"),rich_text:E(At)}),n({...M,type:o("number"),number:F(P())}),n({...M,type:o("url"),url:Z}),n({...M,type:o("email"),email:Z}),n({...M,type:o("phone_number"),phone_number:Z}),n({...M,type:o("checkbox"),checkbox:h()}),n({...M,type:o("select"),select:F(nt)}),n({...M,type:o("status"),status:F(nt)}),n({...M,type:o("multi_select"),multi_select:E(nt)}),n({...M,type:o("date"),date:F(An)}),n({...M,type:o("people"),people:E(Nn)}),n({...M,type:o("relation"),has_more:u(h()),relation:E(Un)}),n({...M,type:o("files"),files:E(Fn)}),n({...M,type:o("place"),place:F(zn)}),n({...M,type:o("created_time"),created_time:Z}),n({...M,type:o("last_edited_time"),last_edited_time:Z}),n({...M,type:o("created_by"),created_by:Fe}),n({...M,type:o("last_edited_by"),last_edited_by:Fe}),n({...M,type:o("last_visited_time"),last_visited_time:Z}),n({...M,type:o("unique_id"),unique_id:r()}),n({...M,type:o("button"),button:r()}),n({...M,type:o("formula"),formula:r()}),n({...M,type:o("location"),location:r()}),n({...M,type:o("rollup"),rollup:r()}),n({...M,type:o("verification"),verification:r()})]),Oe=V(r(),Ft),Ln=V(r(),F(Ft)),ne=n({object:o("page"),id:U,parent:ae,properties:Ln,created_by:u(Fe,null),last_edited_by:u(Fe,null),last_visited_time:u(F(r()),null),created_time:u(F(r()),null),last_edited_time:u(F(r()),null),icon:u(F(ze),null),cover:u(F(Le),null),url:u(F(r()),null),public_url:u(F(r()),null),is_archived:h(),in_trash:h()}),Se=n({object:o("page"),id:U,parent:ae,properties:Oe,created_time:u(r()),last_edited_time:u(r()),icon:u(ze),cover:u(Le),url:u(r()),public_url:u(r()),is_archived:h(),in_trash:h()});var Hn=r(),zt=n({code:Hn,message:r(),isRetryable:h()}),Lt=v("status",[n({type:o("createPageResult"),requestId:r(),status:o("success"),page:ne}),n({type:o("createPageResult"),requestId:r(),status:o("error"),error:zt})]),Ht=v("status",[n({type:o("createPageResult"),requestId:r(),status:o("success"),page:g([ne,Se])}),n({type:o("createPageResult"),requestId:r(),status:o("error"),error:zt})]);var st=z(r(),ce("NotionUserId")),pe=n({object:o("user"),id:st,name:u(r()),avatar_url:F(r()),type:o("person"),person:n({email:r()})}),Vt=n({object:o("list"),results:E(pe),next_cursor:F(r()),has_more:h(),type:o("user"),user:V(r(),Ce())});var Gt=n({type:o("currentUserChanged"),currentUser:pe});var $t=n({type:o("dataSourcesChanged"),dataSources:n({bindings:me})});var Vn=r(),Qt=n({code:Vn,message:r(),isRetryable:h()}),Xt=n({type:o("getPage"),requestId:r(),pageId:U,dataSourceId:u(K)}),Wt=v("status",[n({type:o("getPageResult"),requestId:r(),status:o("success"),page:ne}),n({type:o("getPageResult"),requestId:r(),status:o("error"),error:Qt})]),Jt=v("status",[n({type:o("getPageResult"),requestId:r(),status:o("success"),page:g([ne,Se])}),n({type:o("getPageResult"),requestId:r(),status:o("error"),error:Qt})]);var Gn=r(),$n=n({code:Gn,message:r(),isRetryable:h()}),Kt=n({type:o("getUser"),requestId:r(),userId:st}),Zt=v("status",[n({type:o("getUserResult"),requestId:r(),status:o("success"),user:pe}),n({type:o("getUserResult"),requestId:r(),status:o("error"),error:$n})]);var Qn=v("type",[n({type:o("emoji"),emoji:r()}),n({type:o("external"),url:r()})]),Xn=n({name:r(),description:u(r()),type:Ot}),Wn=n({name:r(),description:u(r()),icon:u(Qn),properties:u(V(r(),Xn),{})}),ye=n({version:o(1),name:u(r()),description:u(r()),slashCommand:u(r()),icon:u(n({type:o("emoji"),emoji:r()})),dataSources:u(V(r(),Wn),{})});var ke=T(["light","dark"]);var Jn=r(),Kn=n({code:Jn,message:r(),isRetryable:h()});var He=v("status",[n({type:o("init"),initializationId:r(),status:o("success"),theme:ke,contrastMode:ge,blockId:le,parent:ae,page:be,manifest:ye,dataSources:n({bindings:me}),currentUser:pe}),n({type:o("init"),initializationId:r(),status:o("error"),error:Kn})]);var Yt=n({type:o("invalidSandboxMessage"),reason:r()});var Zn=r(),Yn=n({code:Zn,message:r(),isRetryable:h()}),er=n({type:o("listUsers"),requestId:r(),startCursor:u(r()),pageSize:u(P())}),tr=v("status",[n({type:o("listUsersResult"),requestId:r(),status:o("success"),list:Vt}),n({type:o("listUsersResult"),requestId:r(),status:o("error"),error:Yn})]);var eo=r(),to=n({code:eo,message:r(),isRetryable:h()}),rr=n({type:o("openExternalUrl"),requestId:r(),url:r()}),nr=v("status",[n({type:o("openExternalUrlResult"),requestId:r(),status:o("success")}),n({type:o("openExternalUrlResult"),requestId:r(),status:o("error"),error:to})]);var ro=T(["side_peek","center_peek"]),no=r(),oo=n({code:no,message:r(),isRetryable:h()}),or=n({type:o("openPage"),requestId:r(),pageId:U,mode:ro}),sr=v("status",[n({type:o("openPageResult"),requestId:r(),status:o("success"),pageId:U}),n({type:o("openPageResult"),requestId:r(),status:o("error"),error:oo})]);var ir=n({type:o("pageChanged"),page:be});var ar=n({type:o("parentChanged"),parent:ae});var ur=g([r(),P(),h(),Tt,E(r()),E(Ue)]);var cr=n({id:U,is_archived:h(),in_trash:h(),propertiesById:V(r(),u(ur))});var so=r(),lr=n({code:so,message:r(),isRetryable:h()}),pr=v("status",[n({type:o("queryDataSourceResult"),subscriptionId:r(),status:o("success"),items:E(ne),hasMore:h()}),n({type:o("queryDataSourceResult"),subscriptionId:r(),status:o("error"),error:lr})]),fr=v("status",[n({type:o("queryDataSourceResult"),subscriptionId:r(),status:o("success"),items:E(g([ne,cr])),hasMore:h()}),n({type:o("queryDataSourceResult"),subscriptionId:r(),status:o("error"),error:lr})]);var mr=n({type:o("themeChanged"),theme:ke});var io=r(),yr=n({code:io,message:r(),isRetryable:h()}),vr=v("status",[n({type:o("updatePageResult"),requestId:r(),status:o("success"),page:ne}),n({type:o("updatePageResult"),requestId:r(),status:o("error"),error:yr})]),dr=v("status",[n({type:o("updatePageResult"),requestId:r(),status:o("success"),page:g([ne,Se])}),n({type:o("updatePageResult"),requestId:r(),status:o("error"),error:yr})]);var hr=v("type",[He,mr,Dt,ar,ir,Gt,$t,Zt,tr,sr,nr,Yt]),gr=v("type",[...hr.options,pr,Wt,Lt,vr]),vi=v("type",[...hr.options,fr,Jt,Ht,dr]);function br(){return{code:"no_connect",message:"Sandbox did not send a connect message.",isRetryable:!0}}function Sr(){return{code:"invalid_connect_payload",message:"Sandbox sent an invalid connect message.",isRetryable:!1}}function it(e){let{currentBridgeProtocolVersion:t}=e;return{code:"invalid_protocol_version",message:`Sandbox reported an invalid bridge protocol version: ${t}`,isRetryable:!1}}function at(e){let{currentBridgeProtocolVersion:t,minBridgeProtocolVersion:s}=e;return{code:"unsupported_protocol_version",message:`Sandbox bridge protocol version ${t} is not supported. Minimum supported version is ${s}.`,isRetryable:!1}}function ut(){return{code:"context_unavailable",message:"Host page context is unavailable.",isRetryable:!0}}function kr(){return{code:"initial_state_timeout",message:"Host did not prepare initial state before the timeout.",isRetryable:!0}}function Ir(){return{code:"missing_data_source_binding",message:"A required data source is not mapped.",isRetryable:!1}}function _r(){return{code:"missing_property_binding",message:"A required data source property is not mapped.",isRetryable:!1}}function xr(){return{code:"invalid_property_binding",message:"A mapped data source property is missing or incompatible.",isRetryable:!1}}function Cr(){return{code:"no_init_result",message:"Sandbox did not acknowledge initialization.",isRetryable:!0}}function Pr(){return{code:"invalid_init_result_payload",message:"Sandbox sent an invalid initialization result.",isRetryable:!1}}function je(){return{code:"unknown_error",message:"Unexpected error while initializing custom block.",isRetryable:!1}}function re(e){throw new Error(`[custom-blocks-host] Unexpected value encountered: ${JSON.stringify(e)}`)}function ct(e){return Number.isFinite(e)&&Number.isInteger(e)&&e>=1}var ao=5e3,uo=5e3,co=5e3;function Er(e){let{prepareInit:t,sendInitMessage:s,warn:i,flushPendingHostStateChanges:c,minBridgeProtocolVersion:l,noConnectTimeoutMs:p=ao,initialStateTimeoutMs:y=uo,noInitResultTimeoutMs:m=co,stopHostWithFailure:x,onInitResult:_,onConnectionFailure:C}=e,b="waitingForConnect",L,q,A,O,H=!1,$=!1;function X(){L!==void 0&&(window.clearTimeout(L),L=void 0)}function ue(){q!==void 0&&(window.clearTimeout(q),q=void 0)}function W(){A!==void 0&&(window.clearTimeout(A),A=void 0)}function B(S){let{initializationId:I,error:J,phase:oe,source:N}=S;switch(b){case"waitingForConnect":case"preparingInit":break;case"waitingForInitResult":case"initialized":case"error":case"stopped":return;default:return re(b)}b="error",O=I,X(),ue(),s({type:"init",initializationId:I,status:"error",error:J}),C?.({...J,phase:oe,source:N})}async function G(S){if(b==="waitingForConnect"){b="preparingInit",O=S.initializationId,X(),q=window.setTimeout(()=>{if(b!=="preparingInit")return;let I=kr();i({...I,initializationId:S.initializationId}),B({initializationId:S.initializationId,error:I,phase:"init",source:"host"})},y);try{let I=await t(S);if(b!=="preparingInit")return;if(ue(),I.status==="error"){B({initializationId:S.initializationId,error:I.error,phase:"init",source:"host"});return}b="waitingForInitResult";let J={type:"init",initializationId:S.initializationId,status:"success",theme:I.initialState.theme,contrastMode:I.initialState.contrastMode??Bt,blockId:I.initialState.blockId,parent:I.initialState.parent,page:I.initialState.page,currentUser:I.initialState.currentUser,manifest:I.initialState.manifest,dataSources:I.initialState.dataSources};s(J),A=window.setTimeout(()=>{if(b!=="waitingForInitResult")return;b="error";let oe=Cr();C?.({...oe,phase:"initResult",source:"host"}),i({...oe,initializationId:S.initializationId})},m)}catch(I){if(b!=="preparingInit")return;i({message:"Failed to prepare custom block initialization",error:I}),B({initializationId:S.initializationId,error:je(),phase:"init",source:"host"})}}}function ee(S){if(b!=="stopped"&&b==="waitingForConnect"){if(!ct(S.bridgeProtocolVersion)){let I=it({currentBridgeProtocolVersion:S.bridgeProtocolVersion});B({initializationId:S.initializationId,error:I,phase:"connect",source:"host"});return}if(S.bridgeProtocolVersion<l){let I=at({currentBridgeProtocolVersion:S.bridgeProtocolVersion,minBridgeProtocolVersion:l});B({initializationId:S.initializationId,error:I,phase:"connect",source:"host"});return}if(S.status==="error"){B({initializationId:S.initializationId,error:S.error,phase:"connect",source:"sandbox"});return}$=!0,G(S)}}function se(S){if(b==="stopped"||b!=="waitingForConnect")return"handled";let{initializationId:I,bridgeProtocolVersion:J}=S;if(I===void 0)return"nack";let oe=S.error;return J!==void 0&&(ct(J)?J<l&&(oe=at({currentBridgeProtocolVersion:J,minBridgeProtocolVersion:l})):oe=it({currentBridgeProtocolVersion:J})),B({initializationId:I,error:oe,phase:"connect",source:"host"}),"handled"}function D(S){let{initializationId:I,error:J}=S;b!=="waitingForInitResult"||I===void 0||I!==O||(X(),W(),b="error",i(J),C?.({...J,phase:"initResult",source:"host"}))}function te(){if(b!=="stopped"){if(H){x({phase:"runtime",source:"host",code:"iframe_reloaded",message:"The iframe reloaded. Create a new host and iframe to reconnect.",isRetryable:!0});return}H=!0,X(),b==="waitingForConnect"&&(L=window.setTimeout(()=>{if(b!=="waitingForConnect")return;b="error";let S=br();i(S),C?.({...S,phase:"connect",source:"host"})},p))}}function fe(S){if(b!=="waitingForInitResult"||S.initializationId!==O){i({message:"Ignored stale or unexpected initResult",payload:S});return}W(),b=S.status==="success"?"initialized":"error",S.status==="success"?c():C?.({...S.error,phase:"initResult",source:"sandbox"}),_?.(S)}function we(){b="stopped",X(),ue(),W()}return{get status(){return b},get hasConnectedSandbox(){return $},handleConnect:ee,handleInitResult:fe,handleInvalidConnect:se,handleInvalidInitResult:D,onIframeLoad:te,stop:we}}function lt({url:e,hostOrigin:t}){return typeof t=="string"&&t!==""&&e.origin!==t&&(e.protocol==="http:"||e.protocol==="https:")&&(e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname.endsWith(".localhost"))&&e.username===""&&e.password===""}async function Or(e){let t=new AbortController,s=()=>t.abort();e.signal.addEventListener("abort",s,{once:!0});let i=new Promise((l,p)=>{t.signal.addEventListener("abort",()=>p(t.signal.reason),{once:!0})});e.signal.aborted&&t.abort();let c=e.manifestSource==="local"?window.setTimeout(()=>{t.abort(new Error("Manifest loading timed out after 5000 ms."))},5e3):void 0;try{let l=await Promise.race([e.manifestSource==="local"?lo(e.sandboxOrigin,t.signal):e.getPersistedManifest({signal:t.signal}),i]);if(t.signal.aborted)throw new Error("Manifest loading was cancelled.");return{status:"success",manifest:ie(ye,l)}}catch(l){return e.signal.aborted||e.onError(l),{status:"error",error:{code:"manifest_unavailable",message:"The custom block manifest is unavailable.",isRetryable:!0}}}finally{window.clearTimeout(c),e.signal.removeEventListener("abort",s)}}async function lo(e,t){let s=new URL(e);if(!lt({url:s,hostOrigin:window.location.origin}))throw new Error("Preview requires a separate loopback origin.");let i=await fetch(new URL("/manifest",s),{credentials:"omit",redirect:"error",cache:"no-store",signal:t});if(!i.ok)throw new Error(`Manifest request failed: HTTP ${i.status}.`);return i.json()}var de=class extends Error{};function pt(e){try{return po(e)}catch(t){throw t instanceof RangeError?new de(t.message):t}}function po(e){let{start:t,end:s,time_zone:i,reminder:c}=e;if(!t.split("T")[0])throw new de("Date values must include a date.");let l=t.includes("T")||i!=null,p=t.match(/([+-])(\d{2}):(\d{2})$/),y=p?(Number(p[2])*60+Number(p[3]))*(p[1]==="-"?-1:1):0,m=i?.match(/^UTC(?:([+-])(\d{1,2})(?::(\d{2}))?)?$/),x=m?(Number(m[2]??0)*60+Number(m[3]??0))*(m[1]==="-"?-1:1):y,_=q=>{if(!q.split("T")[0])throw new de("Date values must include a date.");if(!q.includes("T"))return{date:q,time:"00:00"};let A=q.match(/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})(?::\d{2}(?:\.\d+)?)?$/);if(A)return{date:A[1],time:A[2]};if(!i||m){let $=new Date(new Date(q).getTime()+x*6e4).toISOString();return{date:$.slice(0,10),time:$.slice(11,16)}}let O=new Intl.DateTimeFormat("en-CA",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(new Date(q)),H=$=>O.find(X=>X.type===$)?.value;return{date:`${H("year")}-${H("month")}-${H("day")}`,time:`${H("hour")}:${H("minute")}`}},C=_(t),b=s?_(s):void 0;if(!l){if(c&&!("time"in c)&&c.unit!=="none")throw new de("Hour and minute reminders require a date with a time.");return b?{type:"daterange",start_date:C.date,end_date:b.date,reminder:c}:{type:"date",start_date:C.date,reminder:c}}let L=i??(y===0?"UTC":`UTC${y<0?"-":"+"}${Math.floor(Math.abs(y)/60)}${Math.abs(y)%60===0?"":`:${String(Math.abs(y)%60).padStart(2,"0")}`}`);return b?{type:"datetimerange",start_date:C.date,start_time:C.time,end_date:b.date,end_time:b.time,time_zone:L,reminder:c}:{type:"datetime",start_date:C.date,start_time:C.time,time_zone:L,reminder:c}}function Rr(e){return{...e,properties:Object.fromEntries(Object.values(e.properties).flatMap(t=>t?[[t.id,t]]:[])),icon:e.icon??void 0,cover:e.cover??void 0,created_time:e.created_time??void 0,last_edited_time:e.last_edited_time??void 0,url:e.url??void 0,public_url:e.public_url??void 0}}function Mr(e){let t={};for(let s of Object.values(e.properties))s&&(t[s.id]=fo(s));return{id:e.id,is_archived:e.is_archived,in_trash:e.in_trash,propertiesById:t}}function jr(e){return e.map(t=>{if(typeof t.plain_text=="string")return t.plain_text;let s=t.text;return s&&typeof s=="object"&&"content"in s&&typeof s.content=="string"?s.content:""}).join("")}function ft(e){if(e==null||e==="")return;let t=new Date(e);if(Number.isFinite(t.getTime()))return{type:"datetime",start_date:t.toISOString().slice(0,10),start_time:t.toISOString().slice(11,16),time_zone:"UTC"}}function fo(e){switch(e.type){case"title":return jr(e.title);case"rich_text":return jr(e.rich_text);case"number":return e.number??void 0;case"checkbox":return e.checkbox;case"url":return e.url??"";case"email":return e.email??"";case"phone_number":return e.phone_number??"";case"select":return e.select?.name;case"status":return e.status?.name;case"multi_select":return e.multi_select.flatMap(t=>t.name??[]);case"date":return e.date?pt(e.date):void 0;case"people":return e.people.map(t=>t.object==="group"?{id:t.id,table:"space_permission_group",spaceId:t.id.split("|")[1]}:{id:t.id,table:"notion_user"});case"relation":return e.relation.map(t=>({id:t.id,table:"block"}));case"files":return e.files.map(t=>t.name).join(",");case"unique_id":return e.unique_id;case"button":return e.button;case"formula":return e.formula;case"location":return e.location;case"rollup":return e.rollup;case"verification":return e.verification;case"place":return"";case"created_time":return ft(e.created_time);case"last_edited_time":return ft(e.last_edited_time);case"last_visited_time":return ft(e.last_visited_time);case"created_by":return e.created_by?[e.created_by]:void 0;case"last_edited_by":return e.last_edited_by?[e.last_edited_by]:void 0;default:return re(e)}}function Br(e,t){if(t>=6||e.status==="error")return e;switch(e.type){case"queryDataSourceResult":return{...e,items:e.items.map(Mr)};case"getPageResult":case"createPageResult":case"updatePageResult":return{...e,page:Rr(e.page)};default:return re(e)}}function Dr(e,t){return e.type!=="queryDataSourceResult"&&e.type!=="getPageResult"&&e.type!=="createPageResult"&&e.type!=="updatePageResult"?e:Br(e,t)}var wr=n({theme:ke,contrastMode:u(ge),blockId:le,parent:ae,page:be,manifest:ye,dataSources:n({bindings:me}),currentUser:pe});function qr(e){if(e.length>2048||!URL.canParse(e))return;let t=new URL(e);if(!(t.protocol!=="http:"&&t.protocol!=="https:"||t.username!==""||t.password!==""||t.href.length>2048))return t.href}function Tr(e){switch(e.type){case"connect":case"init":case"initResult":return!0;default:return!1}}var Ar=n({code:r(),message:r(),isRetryable:h()});var Nr={type:o("connect"),initializationId:r(),bridgeProtocolVersion:P(),sdkVersion:r()},Ur=v("status",[n({status:o("success"),manifest:u(ye),...Nr}),n({status:o("error"),error:Ar,...Nr})]);var mo=v("type",[n({type:o("start")}),n({type:o("end")}),n({type:o("before"),blockId:le}),n({type:o("after"),blockId:le})]),yo=v("type",[n({type:o("page_id"),page_id:U}),n({type:o("data_source_id"),data_source_id:K})]),Fr=n({type:o("createPage"),requestId:r(),parent:yo,properties:Oe,position:u(mo)});var vo=r(),ho=n({code:vo,message:r(),isRetryable:h()}),zr=v("status",[n({type:o("initResult"),initializationId:r(),status:o("success"),initialHeight:u(z(P(),Ie(),xe(0)))}),n({type:o("initResult"),initializationId:r(),status:o("error"),error:ho})]);var Lr=n({type:o("invalidHostMessage"),reason:r()});var Hr=T(["ascending","descending"]);var Vr=z(U,Ke(/^(?:[0-9a-f]{32}|[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})$/i),Ze(e=>e.replaceAll("-","").toLowerCase().replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/,"$1-$2-$3-$4-$5"))),mt=g([f({contains:Vr}),f({does_not_contain:Vr})]),De=g([f({is_empty:o(!0)}),f({is_not_empty:o(!0)})]),Be=g([r(),E(r())]),Gr=f({object:T(["user","group"]),id:z(r(),_e(1))}),go=g([f({contains:Gr}),f({does_not_contain:Gr}),De]),$r=f({object:o("user"),id:z(r(),_e(1),Te(2e3))}),bo=g([f({contains:$r}),f({does_not_contain:$r}),f({is_empty:o(!0)}),f({is_not_empty:o(!0)})]),Re=g([f({equals:r()}),f({does_not_equal:r()}),f({contains:r()}),f({does_not_contain:r()}),f({starts_with:r()}),f({ends_with:r()}),De]),So=g([f({equals:P()}),f({does_not_equal:P()}),f({greater_than:P()}),f({less_than:P()}),f({greater_than_or_equal_to:P()}),f({less_than_or_equal_to:P()}),De]),ko=g([f({equals:h()}),f({does_not_equal:h()})]),Jr=g([f({equals:Be}),f({does_not_equal:Be}),De]),Qr=T(["To-do","In progress","Complete","Current","Future"]),Xr=g([Qr,z(E(Qr),_e(1),Te(5))]),Io=g([f({group_equals:Xr}),f({group_does_not_equal:Xr})]),_o=g([Jr,Io]),xo=g([f({contains:Be}),f({contains_all:Be}),f({does_not_contain:Be}),De]),Y=T(["start_date","end_date"]),Co=T(["today","tomorrow","yesterday","one_week_ago","one_week_from_now","one_month_ago","one_month_from_now"]),Me=g([Co,r()]),Po=g([f({target:u(Y),equals:Me}),f({target:u(Y),before:Me}),f({target:u(Y),after:Me}),f({target:u(Y),on_or_before:Me}),f({target:u(Y),on_or_after:Me}),f({target:u(Y),this_week:f({})}),f({target:u(Y),past_week:f({})}),f({target:u(Y),past_month:f({})}),f({target:u(Y),past_year:f({})}),f({target:u(Y),next_week:f({})}),f({target:u(Y),next_month:f({})}),f({target:u(Y),next_year:f({})}),f({target:u(Y),is_empty:o(!0)}),f({target:u(Y),is_not_empty:o(!0)})]),Wr=g([f({propertyId:r(),relation:mt}),f({propertyId:r(),created_by:bo}),f({propertyId:r(),title:Re}),f({propertyId:r(),rich_text:Re}),f({propertyId:r(),url:Re}),f({propertyId:r(),email:Re}),f({propertyId:r(),phone_number:Re}),f({propertyId:r(),number:So}),f({propertyId:r(),checkbox:ko}),f({propertyId:r(),select:Jr}),f({propertyId:r(),multi_select:xo}),f({propertyId:r(),status:_o}),f({propertyId:r(),date:Po}),f({propertyId:r(),people:go})]),Eo=g([Wr,f({and:E(Wr)})]),yt=10,Oo=f({propertyId:r(),direction:Hr}),Kr=n({type:o("queryDataSource"),subscriptionId:r(),dataSourceId:K,limit:P(),filter:u(Eo),sorts:u(E(Oo))});var Zr=n({type:o("resize"),height:z(P(),Ie(),xe(0))});var Yr=n({type:o("unsubscribeDataSourceQuery"),subscriptionId:r()});var en=n({type:o("updatePage"),requestId:r(),pageId:U,dataSourceId:u(K),properties:u(Oe),icon:u(ze),cover:u(Le),archived:u(h())});var tn=v("type",[Ur,zr,Kr,Yr,Fr,Xt,Kt,er,or,rr,en,Zr,Lr]);function rn(e){if(typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string")return e.type}function nn(e){let t=rn(e);return t==="invalidHostMessage"||t==="invalidSandboxMessage"?{incomingType:t}:{incomingType:t,nack:{type:"invalidSandboxMessage",reason:jo(t)}}}function jo(e){return e!==void 0?`Unsupported sandbox message of type "${e}"`:"Unsupported sandbox message (no `type` field or non-object payload)"}var on=n({initializationId:r()}),Ro=n({bridgeProtocolVersion:g([P(),Ye()])});function sn(e){let{iframe:t,sandboxOrigin:s,getInitStatus:i,emit:c,sendNack:l,onInvalidConnect:p,onInvalidInitResult:y,onConnect:m,onInitResult:x,onQueryDataSource:_,onUnsubscribeDataSourceQuery:C,onCreatePage:b,onGetPage:L,onOpenPage:q,onOpenExternalUrl:A,onGetUser:O,onListUsers:H,onUpdatePage:$,onResize:X}=e;function ue(W,B){c("warn",{message:"Ignored unsupported sandbox message",payload:vt(W),issues:B});let G=nn(W);if(G.incomingType==="connect"){let ee=Pe(on,W),se=Pe(Ro,W);if(p({initializationId:ee.success?ee.output.initializationId:void 0,error:Sr(),bridgeProtocolVersion:se.success?se.output.bridgeProtocolVersion:void 0})==="handled")return}if(G.incomingType==="initResult"){let ee=Pe(on,W);y({initializationId:ee.success?ee.output.initializationId:void 0,error:Pr()})}G.nack!==void 0&&i()!=="stopped"&&l(G.nack)}return function(B){let G=B.source===t.contentWindow,ee=B.origin===s;if(!G||!ee)return;let se=Pe(tn,B.data);if(!se.success){ue(B.data,se.issues);return}let D=se.output;if(!Tr(D)&&i()!=="initialized"){c("warn",{message:`Ignored ${D.type} before initialization completed`,payload:vt(D)});return}switch(c("in",vt(D)),D.type){case"connect":m(D);return;case"initResult":x(D);return;case"queryDataSource":_(D);return;case"unsubscribeDataSourceQuery":C(D);return;case"createPage":b(D);return;case"openPage":q(D);return;case"openExternalUrl":A(D);return;case"getPage":L(D);return;case"getUser":O(D);return;case"listUsers":H(D);return;case"updatePage":$(D);return;case"resize":X(D);return;case"invalidHostMessage":return;default:re(D)}}}function vt(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="openExternalUrl"?{type:"openExternalUrl",..."requestId"in e?{requestId:e.requestId}:{}}:e}var Ve=class{constructor(t){this.onUnsubscribe=t}onUnsubscribe;bySubscriptionId=new Map;subscribe(t){this.unsubscribe(t.subscriptionId);let s={_tag:"QuerySubscriptionToken"};return this.bySubscriptionId.set(t.subscriptionId,{message:t,token:s,isRefreshing:!0,shouldRefreshAgain:!1}),s}isCurrent(t,s){return this.bySubscriptionId.get(t)?.token===s}unsubscribe(t){this.bySubscriptionId.delete(t)&&this.onUnsubscribe(t)}refresh(t){let s=[],i=!1;for(let c of this.bySubscriptionId.values())if(c.message.dataSourceId===t){if(i=!0,c.isRefreshing){c.shouldRefreshAgain=!0;continue}c.isRefreshing=!0,s.push({message:c.message,token:c.token})}return i?s:void 0}finish(t,s){let i=this.bySubscriptionId.get(t);if(i?.token===s&&(i.isRefreshing=!1,!!i.shouldRefreshAgain))return i.shouldRefreshAgain=!1,i.isRefreshing=!0,{message:i.message,token:i.token}}unsubscribeAll(){for(let t of this.bySubscriptionId.keys())this.unsubscribe(t)}};function an(e,t){if(e===void 0)return;let s="and"in e?e.and:[e];for(let i of s){let c=Mo(i,t);if(c!==void 0)return c}}function Mo(e,t){if(!Object.hasOwn(t.propertiesById,e.propertyId))return{code:"invalid_data_source_query_filter",message:`Data source query filter property ID "${e.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let s=t.propertiesById[e.propertyId],i=Object.keys(e).find(y=>y!=="propertyId");if(i!==s.type)return{code:"invalid_data_source_query_filter",message:`Data source query filter branch "${i}" does not match property type "${s.type}".`,isRetryable:!1};if("status"in e&&s.type==="status"){let y=e.status;if("group_equals"in y||"group_does_not_equal"in y){let m="group_equals"in y?y.group_equals:y.group_does_not_equal,_=(Array.isArray(m)?m:[m]).find(C=>!s.groups.some(b=>b.name===C));return _===void 0?void 0:{code:"invalid_data_source_query_filter",message:`Unknown status group "${_}".`,isRetryable:!1}}}if("relation"in e&&!xt(mt,e.relation))return{code:"invalid_data_source_query_filter",message:"Relation filters require a page ID.",isRetryable:!1};let c=Bo(e);if(c===void 0||s.type!==c.propertyType)return;let l=new Set(s.options.map(y=>y.name)),p=Do(c.operator).find(y=>!l.has(y));if(p!==void 0)return{code:"invalid_data_source_query_filter",message:`Data source query filter option "${p}" is not defined for property "${e.propertyId}".`,isRetryable:!1}}function Bo(e){if("select"in e)return{propertyType:"select",operator:e.select};if("multi_select"in e)return{propertyType:"multi_select",operator:e.multi_select};if("status"in e){let t=e.status;return"group_equals"in t||"group_does_not_equal"in t?void 0:{propertyType:"status",operator:t}}}function Do(e){let t;if("equals"in e)t=e.equals;else if("does_not_equal"in e)t=e.does_not_equal;else if("contains"in e)t=e.contains;else if("contains_all"in e)t=e.contains_all;else if("does_not_contain"in e)t=e.does_not_contain;else return"is_empty"in e||"is_not_empty"in e?[]:re(e);return Array.isArray(t)?t:[t]}var wo=new Set(jt);function un(e,t){if(e===void 0)return;if(e.length>yt)return{code:"invalid_data_source_query_sort",message:`Data source query sorts may contain at most ${yt} entries.`,isRetryable:!1};let s=new Set;for(let i of e){if(s.has(i.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sorts cannot contain duplicate property ID "${i.propertyId}".`,isRetryable:!1};if(s.add(i.propertyId),!Object.hasOwn(t.propertiesById,i.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sort property ID "${i.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let c=t.propertiesById[i.propertyId];if(!wo.has(c.type))return{code:"invalid_data_source_query_sort",message:`Data source query sorts do not yet support property type "${c.type}".`,isRetryable:!1}}}var ln=5;function qo(e){let{iframe:t,prepareInitialState:s,handlers:i,onInitialized:c,onConnectionFailure:l,onLog:p,onQueryUnsubscribed:y,sandboxOrigin:m,minBridgeProtocolVersion:x,noConnectTimeoutMs:_,initialStateTimeoutMs:C,noInitResultTimeoutMs:b}=e,L=Math.max(x??3,3),q=new AbortController,A,O={},H=!1,$=new AbortController,X,ue,W=6,B=new Ve(a=>{y?.(a)});function G(a,k){p?.(a,k)}function ee(a){let k=N.status;switch(k){case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"initialized":case"error":break;case"stopped":return;default:return re(k)}let j=Dr(a,W);G("out",j),t.contentWindow?.postMessage(j,m)}function se(a){ee(ie(He,a))}function D(a){ee(a)}function te(a){let k=N.status;switch(k){case"initialized":ee(ie(gr,a));return;case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"error":case"stopped":return;default:re(k)}}async function fe(a,k){if(k===void 0)return;let j=await k(a);te({type:`${a.type}Result`,requestId:a.requestId,...j})}function we(a){let k=a.response.status==="error"?{type:"queryDataSourceResult",subscriptionId:a.subscriptionId,status:"error",error:a.response.error}:{type:"queryDataSourceResult",subscriptionId:a.subscriptionId,status:"success",items:a.response.items,hasMore:a.response.hasMore};te(k)}async function S(a,k=B.subscribe(a)){try{let j=To(ue,a.dataSourceId),ve=Ao(a,j);if(ve!==void 0){B.isCurrent(a.subscriptionId,k)&&(B.unsubscribe(a.subscriptionId),we({subscriptionId:a.subscriptionId,response:{status:"error",error:ve}}));return}let Ge=await i.queryDataSource(a);if(!B.isCurrent(a.subscriptionId,k))return;Ge.status==="error"&&!Ge.error.isRetryable&&B.unsubscribe(a.subscriptionId),we({subscriptionId:a.subscriptionId,response:Ge})}finally{let j=B.finish(a.subscriptionId,k);j!==void 0&&S(j.message,j.token)}}function I(a){N.status==="stopped"||N.status==="error"||(Object.assign(O,a),oe())}async function J(a){if(i.openExternalUrl===void 0||q.signal.aborted||A===a.requestId)return;if(A!==void 0){let j={type:"openExternalUrlResult",requestId:a.requestId,status:"error",error:{code:"pending_navigation",message:"Another external navigation request is pending.",isRetryable:!0}};te(j);return}let k=qr(a.url);if(k===void 0){let j={type:"openExternalUrlResult",requestId:a.requestId,status:"error",error:{code:"invalid_url",message:"Only valid HTTP or HTTPS URLs without credentials, up to 2,048 characters, can be opened.",isRetryable:!1}};te(j);return}A=a.requestId;try{let j=await i.openExternalUrl({...a,url:k},{signal:q.signal});if(q.signal.aborted)return;let ve={type:"openExternalUrlResult",requestId:a.requestId,...j};te(ve)}catch(j){if(!q.signal.aborted)throw j}finally{A===a.requestId&&(A=void 0)}}function oe(){if(N.status!=="initialized")return;let a=O;O={},a.theme!==void 0&&te({type:"themeChanged",theme:a.theme}),a.contrastMode!==void 0&&te({type:"contrastModeChanged",contrastMode:a.contrastMode}),a.parent!==void 0&&te({type:"parentChanged",parent:a.parent}),a.page!==void 0&&te({type:"pageChanged",page:a.page}),a.dataSources!==void 0&&te({type:"dataSourcesChanged",dataSources:a.dataSources}),a.currentUser!==void 0&&te({type:"currentUserChanged",currentUser:a.currentUser})}let N=Er({async prepareInit(a){W=a.bridgeProtocolVersion;let k=await mn;return N.status!=="preparingInit"?k:fn(k)},sendInitMessage:se,warn:a=>G("warn",a),flushPendingHostStateChanges:oe,minBridgeProtocolVersion:L,noConnectTimeoutMs:_,initialStateTimeoutMs:C,noInitResultTimeoutMs:b,stopHostWithFailure:gt,onInitResult(a){a.status==="success"&&X!==void 0&&c?.({manifest:X,initialHeight:a.initialHeight})},onConnectionFailure:a=>{$.abort(),l?.(a)}});function fn(a){if(a.status==="error")return a;let k=ie(wr,{...a.initialState,...O});if(X=k.manifest,O={},W<ln&&k.page.type==="unavailable")return{status:"error",error:ut()};let j=pn(k.manifest,k.dataSources);return j!==void 0?{status:"error",error:j}:(ue=k.dataSources,H=!0,{status:"success",initialState:k})}let mn=yn().catch(a=>($.signal.aborted||G("warn",{message:"Failed to prepare custom block initialization",error:a}),{status:"error",error:je()}));async function yn(){let a=await Or({...e,sandboxOrigin:m,signal:$.signal,onError:j=>{G("warn",{message:"Failed to load custom block manifest",error:j})}});if(a.status==="error")return a;if($.signal.aborted)return{status:"error",error:je()};let k=await s({manifest:a.manifest,signal:$.signal});return k.status==="error"?k:{status:"success",initialState:{...k.initialState,manifest:a.manifest}}}let dt=sn({iframe:t,sandboxOrigin:m,getInitStatus:()=>N.status,emit:G,sendNack:D,onInvalidConnect:N.handleInvalidConnect,onInvalidInitResult:N.handleInvalidInitResult,onConnect:N.handleConnect,onInitResult:N.handleInitResult,onQueryDataSource:S,onUnsubscribeDataSourceQuery:a=>B.unsubscribe(a.subscriptionId),onOpenExternalUrl:J,onCreatePage:a=>fe(a,i.createPage),onGetPage:a=>fe(a,i.getPage),onOpenPage:a=>fe(a,i.openPage),onGetUser:a=>fe(a,i.getUser),onListUsers:a=>fe(a,i.listUsers),onUpdatePage:a=>fe(a,i.updatePage),onResize:a=>i.resize?.(a)});window.addEventListener("message",dt),t.addEventListener("load",N.onIframeLoad);function ht(){q.abort(),$.abort(),window.removeEventListener("message",dt),t.removeEventListener("load",N.onIframeLoad),N.stop(),B.unsubscribeAll()}function gt(a){ht(),G("warn",a),l?.(a)}return{stop:ht,setTheme(a){I({theme:a})},setContrastMode(a){I({contrastMode:a})},setParent(a){I({parent:a})},setPage(a){if(a.type==="unavailable"&&W<ln&&(N.status==="preparingInit"&&H||N.status==="waitingForInitResult"||N.status==="initialized")){gt({...ut(),phase:"runtime",source:"host"});return}I({page:a})},setCurrentUser(a){I({currentUser:a})},setDataSources(a){let k={bindings:ie(me,a.bindings)};if(N.hasConnectedSandbox&&X!==void 0&&pn(X,k)!==void 0){G("warn",{message:"Ignored invalid data source bindings update",payload:k});return}ue=k,I({dataSources:k})},refreshQuery({dataSourceId:a}){if(N.status!=="initialized")return;let k=ie(K,a),j=B.refresh(k);if(j===void 0){G("warn",`No active query exists for data source "${a}"`);return}for(let ve of j)S(ve.message,ve.token)}}}function To(e,t){return Object.values(e?.bindings??{}).find(s=>s.collectionPointer?.id===t)?.collectionSchema}function pn(e,t){for(let[s,i]of Object.entries(e.dataSources)){let c=t.bindings[s];if(c?.collectionPointer===void 0||c.collectionSchema===void 0)return Ir();for(let[l,p]of Object.entries(i.properties??{})){let y=c.propertyIdsByKey?.[l];if(y===void 0)return _r();if(c.collectionSchema.propertiesById[y]?.type!==p.type)return xr()}}}function Ao(e,t){return t===void 0?e.filter===void 0&&(e.sorts?.length??0)===0?void 0:{code:"data_source_schema_unavailable",message:"You cannot query this data source with filters or sorts because its schema is unavailable.",isRetryable:!1}:an(e.filter,t)??un(e.sorts,t)}function No(e){return ie(U,e)}export{de as InvalidNotionDateError,$e as LATEST_BRIDGE_PROTOCOL_VERSION,Qe as LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION,qo as createCustomBlockHost,vn as getAutoBoundPropertyIdsByKey,lt as isLocalCustomBlockUrl,pt as toNotionDateValue,No as toNotionPageId};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { NotionDate, NotionDateRange, NotionDateTime, NotionDateTimeRange } from "./protocol/dataSources/dateValue.js";
|
|
2
|
+
import type { NotionDateInput } from "./protocol/pages/page.js";
|
|
3
|
+
export type CustomBlockDateValue = NotionDate | NotionDateRange | (NotionDateTime & {
|
|
4
|
+
time_zone: string;
|
|
5
|
+
}) | (NotionDateTimeRange & {
|
|
6
|
+
time_zone: string;
|
|
7
|
+
});
|
|
8
|
+
export declare class InvalidNotionDateError extends Error {
|
|
9
|
+
}
|
|
10
|
+
export declare function toNotionDateValue(value: NotionDateInput): CustomBlockDateValue;
|
|
11
|
+
//# sourceMappingURL=dateValue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateValue.d.ts","sourceRoot":"","sources":["../src/dateValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,UAAU,EACV,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,MAAM,2DAA2D,CAAA;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAA;AAErF,MAAM,MAAM,oBAAoB,GAC7B,UAAU,GACV,eAAe,GACf,CAAC,cAAc,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,GACxC,CAAC,mBAAmB,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAEhD,qBAAa,sBAAuB,SAAQ,KAAK;CAAG;AAEpD,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,eAAe,GACpB,oBAAoB,CAStB"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export class InvalidNotionDateError extends Error {
|
|
2
|
+
}
|
|
3
|
+
export function toNotionDateValue(value) {
|
|
4
|
+
try {
|
|
5
|
+
return convertDateValue(value);
|
|
6
|
+
}
|
|
7
|
+
catch (error) {
|
|
8
|
+
if (error instanceof RangeError) {
|
|
9
|
+
throw new InvalidNotionDateError(error.message);
|
|
10
|
+
}
|
|
11
|
+
throw error;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function convertDateValue(value) {
|
|
15
|
+
const { start, end, time_zone, reminder } = value;
|
|
16
|
+
if (!start.split("T")[0]) {
|
|
17
|
+
throw new InvalidNotionDateError("Date values must include a date.");
|
|
18
|
+
}
|
|
19
|
+
const timed = start.includes("T") || time_zone != null;
|
|
20
|
+
const offset = start.match(/([+-])(\d{2}):(\d{2})$/);
|
|
21
|
+
const offsetMinutes = offset
|
|
22
|
+
? (Number(offset[2]) * 60 + Number(offset[3])) *
|
|
23
|
+
(offset[1] === "-" ? -1 : 1)
|
|
24
|
+
: 0;
|
|
25
|
+
const fixedZone = time_zone?.match(/^UTC(?:([+-])(\d{1,2})(?::(\d{2}))?)?$/);
|
|
26
|
+
const targetOffsetMinutes = fixedZone
|
|
27
|
+
? (Number(fixedZone[2] ?? 0) * 60 + Number(fixedZone[3] ?? 0)) *
|
|
28
|
+
(fixedZone[1] === "-" ? -1 : 1)
|
|
29
|
+
: offsetMinutes;
|
|
30
|
+
const parts = (input) => {
|
|
31
|
+
if (!input.split("T")[0]) {
|
|
32
|
+
throw new InvalidNotionDateError("Date values must include a date.");
|
|
33
|
+
}
|
|
34
|
+
if (!input.includes("T")) {
|
|
35
|
+
return { date: input, time: "00:00" };
|
|
36
|
+
}
|
|
37
|
+
const wallClock = input.match(/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})(?::\d{2}(?:\.\d+)?)?$/);
|
|
38
|
+
if (wallClock) {
|
|
39
|
+
return { date: wallClock[1], time: wallClock[2] };
|
|
40
|
+
}
|
|
41
|
+
if (!time_zone || fixedZone) {
|
|
42
|
+
const local = new Date(new Date(input).getTime() + targetOffsetMinutes * 60_000).toISOString();
|
|
43
|
+
return { date: local.slice(0, 10), time: local.slice(11, 16) };
|
|
44
|
+
}
|
|
45
|
+
const entries = new Intl.DateTimeFormat("en-CA", {
|
|
46
|
+
timeZone: time_zone,
|
|
47
|
+
year: "numeric",
|
|
48
|
+
month: "2-digit",
|
|
49
|
+
day: "2-digit",
|
|
50
|
+
hour: "2-digit",
|
|
51
|
+
minute: "2-digit",
|
|
52
|
+
hourCycle: "h23",
|
|
53
|
+
}).formatToParts(new Date(input));
|
|
54
|
+
const get = (type) => entries.find(part => part.type === type)?.value;
|
|
55
|
+
return {
|
|
56
|
+
date: `${get("year")}-${get("month")}-${get("day")}`,
|
|
57
|
+
time: `${get("hour")}:${get("minute")}`,
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
const startParts = parts(start);
|
|
61
|
+
const endParts = end ? parts(end) : undefined;
|
|
62
|
+
if (!timed) {
|
|
63
|
+
if (reminder && !("time" in reminder) && reminder.unit !== "none") {
|
|
64
|
+
throw new InvalidNotionDateError("Hour and minute reminders require a date with a time.");
|
|
65
|
+
}
|
|
66
|
+
return endParts
|
|
67
|
+
? {
|
|
68
|
+
type: "daterange",
|
|
69
|
+
start_date: startParts.date,
|
|
70
|
+
end_date: endParts.date,
|
|
71
|
+
reminder,
|
|
72
|
+
}
|
|
73
|
+
: { type: "date", start_date: startParts.date, reminder };
|
|
74
|
+
}
|
|
75
|
+
const zone = time_zone ??
|
|
76
|
+
(offsetMinutes === 0
|
|
77
|
+
? "UTC"
|
|
78
|
+
: `UTC${offsetMinutes < 0 ? "-" : "+"}${Math.floor(Math.abs(offsetMinutes) / 60)}${Math.abs(offsetMinutes) % 60 === 0 ? "" : `:${String(Math.abs(offsetMinutes) % 60).padStart(2, "0")}`}`);
|
|
79
|
+
return endParts
|
|
80
|
+
? {
|
|
81
|
+
type: "datetimerange",
|
|
82
|
+
start_date: startParts.date,
|
|
83
|
+
start_time: startParts.time,
|
|
84
|
+
end_date: endParts.date,
|
|
85
|
+
end_time: endParts.time,
|
|
86
|
+
time_zone: zone,
|
|
87
|
+
reminder,
|
|
88
|
+
}
|
|
89
|
+
: {
|
|
90
|
+
type: "datetime",
|
|
91
|
+
start_date: startParts.date,
|
|
92
|
+
start_time: startParts.time,
|
|
93
|
+
time_zone: zone,
|
|
94
|
+
reminder,
|
|
95
|
+
};
|
|
96
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export type { NotionDateInput, NotionFileInput, NotionPageCover, NotionPageData,
|
|
|
16
16
|
export { LATEST_BRIDGE_PROTOCOL_VERSION, LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION, } from "./protocol/protocolVersion.js";
|
|
17
17
|
export { type AutoBindableProperty, getAutoBoundPropertyIdsByKey, } from "./autoBindProperties.js";
|
|
18
18
|
export { type CustomBlockHostHandle, type CustomBlockHostOptions, createCustomBlockHost, } from "./createCustomBlockHost.js";
|
|
19
|
+
export { type CustomBlockDateValue, InvalidNotionDateError, toNotionDateValue, } from "./dateValue.js";
|
|
19
20
|
export { toNotionPageId } from "./ids.js";
|
|
20
21
|
export type { CustomBlockHostManifestOptions } from "./lifecycle/manifestOptions.js";
|
|
21
22
|
export type { ConnectSuccessMessage, CustomBlockHostDataSourcesPayload, CustomBlockHostInitialState, CustomBlockHostInitialStateResult, CustomBlockHostPreparedStateResult, CustomBlockHostPrepareInitialState, } from "./lifecycle/types.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gCAAgC,EAAE,MAAM,gEAAgE,CAAA;AACtH,YAAY,EAAE,yBAAyB,EAAE,MAAM,gEAAgE,CAAA;AAC/G,YAAY,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAA;AACtF,YAAY,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAA;AAC3E,YAAY,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAA;AACvF,YAAY,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,YAAY,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,YAAY,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,YAAY,EAAE,gBAAgB,EAAE,MAAM,wDAAwD,CAAA;AAC9F,YAAY,EAAE,sBAAsB,EAAE,MAAM,8DAA8D,CAAA;AAC1G,YAAY,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAA;AAC5F,YAAY,EACX,iCAAiC,EACjC,iCAAiC,EACjC,kCAAkC,EAClC,6BAA6B,EAC7B,+BAA+B,EAC/B,+BAA+B,EAC/B,+BAA+B,EAC/B,4BAA4B,EAC5B,iCAAiC,EACjC,+BAA+B,EAC/B,oCAAoC,EACpC,0BAA0B,EAC1B,6BAA6B,EAC7B,sBAAsB,EACtB,mCAAmC,EACnC,2CAA2C,EAC3C,iCAAiC,GACjC,MAAM,8DAA8D,CAAA;AACrE,YAAY,EAAE,aAAa,EAAE,MAAM,qDAAqD,CAAA;AACxF,YAAY,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,YAAY,EACX,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,yBAAyB,EACzB,uBAAuB,EACvB,0BAA0B,EAC1B,kBAAkB,EAClB,uBAAuB,GACvB,MAAM,gDAAgD,CAAA;AACvD,OAAO,EACN,8BAA8B,EAC9B,sCAAsC,GACtC,MAAM,qDAAqD,CAAA;AAC5D,OAAO,EACN,KAAK,oBAAoB,EACzB,4BAA4B,GAC5B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,qBAAqB,GACrB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACzC,YAAY,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAA;AACpF,YAAY,EACX,qBAAqB,EACrB,iCAAiC,EACjC,2BAA2B,EAC3B,iCAAiC,EACjC,kCAAkC,EAClC,kCAAkC,GAClC,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,YAAY,EACX,sBAAsB,EACtB,+BAA+B,EAC/B,sBAAsB,EACtB,4BAA4B,EAC5B,4BAA4B,EAC5B,uBAAuB,EACvB,8BAA8B,EAC9B,2BAA2B,EAC3B,gCAAgC,EAChC,oCAAoC,EACpC,6BAA6B,EAC7B,+BAA+B,EAC/B,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,2BAA2B,EAC3B,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,sBAAsB,GACtB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAE,oCAAoC,EAAE,MAAM,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gCAAgC,EAAE,MAAM,gEAAgE,CAAA;AACtH,YAAY,EAAE,yBAAyB,EAAE,MAAM,gEAAgE,CAAA;AAC/G,YAAY,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAA;AACtF,YAAY,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAA;AAC3E,YAAY,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAA;AACvF,YAAY,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,YAAY,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,YAAY,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,YAAY,EAAE,gBAAgB,EAAE,MAAM,wDAAwD,CAAA;AAC9F,YAAY,EAAE,sBAAsB,EAAE,MAAM,8DAA8D,CAAA;AAC1G,YAAY,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAA;AAC5F,YAAY,EACX,iCAAiC,EACjC,iCAAiC,EACjC,kCAAkC,EAClC,6BAA6B,EAC7B,+BAA+B,EAC/B,+BAA+B,EAC/B,+BAA+B,EAC/B,4BAA4B,EAC5B,iCAAiC,EACjC,+BAA+B,EAC/B,oCAAoC,EACpC,0BAA0B,EAC1B,6BAA6B,EAC7B,sBAAsB,EACtB,mCAAmC,EACnC,2CAA2C,EAC3C,iCAAiC,GACjC,MAAM,8DAA8D,CAAA;AACrE,YAAY,EAAE,aAAa,EAAE,MAAM,qDAAqD,CAAA;AACxF,YAAY,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,YAAY,EACX,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,yBAAyB,EACzB,uBAAuB,EACvB,0BAA0B,EAC1B,kBAAkB,EAClB,uBAAuB,GACvB,MAAM,gDAAgD,CAAA;AACvD,OAAO,EACN,8BAA8B,EAC9B,sCAAsC,GACtC,MAAM,qDAAqD,CAAA;AAC5D,OAAO,EACN,KAAK,oBAAoB,EACzB,4BAA4B,GAC5B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,qBAAqB,GACrB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EACN,KAAK,oBAAoB,EACzB,sBAAsB,EACtB,iBAAiB,GACjB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACzC,YAAY,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAA;AACpF,YAAY,EACX,qBAAqB,EACrB,iCAAiC,EACjC,2BAA2B,EAC3B,iCAAiC,EACjC,kCAAkC,EAClC,kCAAkC,GAClC,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,YAAY,EACX,sBAAsB,EACtB,+BAA+B,EAC/B,sBAAsB,EACtB,4BAA4B,EAC5B,4BAA4B,EAC5B,uBAAuB,EACvB,8BAA8B,EAC9B,2BAA2B,EAC3B,gCAAgC,EAChC,oCAAoC,EACpC,6BAA6B,EAC7B,+BAA+B,EAC/B,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,2BAA2B,EAC3B,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,sBAAsB,GACtB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAE,oCAAoC,EAAE,MAAM,oBAAoB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { LATEST_BRIDGE_PROTOCOL_VERSION, LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION, } from "./protocol/protocolVersion.js";
|
|
2
2
|
export { getAutoBoundPropertyIdsByKey, } from "./autoBindProperties.js";
|
|
3
3
|
export { createCustomBlockHost, } from "./createCustomBlockHost.js";
|
|
4
|
+
export { InvalidNotionDateError, toNotionDateValue, } from "./dateValue.js";
|
|
4
5
|
export { toNotionPageId } from "./ids.js";
|
|
5
6
|
export { isLocalCustomBlockUrl } from "./localBlockUrl.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacyPage.d.ts","sourceRoot":"","sources":["../../src/lifecycle/legacyPage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,gBAAgB,EAEhB,oBAAoB,EACpB,MAAM,gDAAgD,CAAA;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"legacyPage.d.ts","sourceRoot":"","sources":["../../src/lifecycle/legacyPage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,gBAAgB,EAEhB,oBAAoB,EACpB,MAAM,gDAAgD,CAAA;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAI1C,wBAAgB,YAAY,CAC3B,IAAI,EAAE,WAAW,CAAC,OAAO,oBAAoB,CAAC,GAC5C,gBAAgB,CAelB;AAED,wBAAgB,iBAAiB,CAChC,IAAI,EAAE,WAAW,CAAC,OAAO,oBAAoB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAc9C"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { toNotionDateValue } from "../dateValue.js";
|
|
1
2
|
import { unreachable } from "../utils.js";
|
|
2
3
|
export function toLegacyPage(page) {
|
|
3
4
|
return {
|
|
@@ -56,67 +57,6 @@ function timestamp(value) {
|
|
|
56
57
|
time_zone: "UTC",
|
|
57
58
|
};
|
|
58
59
|
}
|
|
59
|
-
function legacyDate(value) {
|
|
60
|
-
const timed = value.start.includes("T") || value.time_zone != null;
|
|
61
|
-
const offset = value.start.match(/([+-])(\d{2}):(\d{2})$/);
|
|
62
|
-
const offsetMinutes = offset
|
|
63
|
-
? (Number(offset[2]) * 60 + Number(offset[3])) *
|
|
64
|
-
(offset[1] === "-" ? -1 : 1)
|
|
65
|
-
: 0;
|
|
66
|
-
const parts = (input) => {
|
|
67
|
-
if (!input.includes("T")) {
|
|
68
|
-
return { date: input, time: "00:00" };
|
|
69
|
-
}
|
|
70
|
-
const wallClock = input.match(/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})(?::\d{2}(?:\.\d+)?)?$/);
|
|
71
|
-
if (wallClock) {
|
|
72
|
-
return { date: wallClock[1], time: wallClock[2] };
|
|
73
|
-
}
|
|
74
|
-
if (!value.time_zone) {
|
|
75
|
-
const local = new Date(new Date(input).getTime() + offsetMinutes * 60_000).toISOString();
|
|
76
|
-
return { date: local.slice(0, 10), time: local.slice(11, 16) };
|
|
77
|
-
}
|
|
78
|
-
const entries = new Intl.DateTimeFormat("en-CA", {
|
|
79
|
-
timeZone: value.time_zone,
|
|
80
|
-
year: "numeric",
|
|
81
|
-
month: "2-digit",
|
|
82
|
-
day: "2-digit",
|
|
83
|
-
hour: "2-digit",
|
|
84
|
-
minute: "2-digit",
|
|
85
|
-
hourCycle: "h23",
|
|
86
|
-
}).formatToParts(new Date(input));
|
|
87
|
-
const get = (type) => entries.find(part => part.type === type)?.value;
|
|
88
|
-
return {
|
|
89
|
-
date: `${get("year")}-${get("month")}-${get("day")}`,
|
|
90
|
-
time: `${get("hour")}:${get("minute")}`,
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
const start = parts(value.start);
|
|
94
|
-
const end = value.end ? parts(value.end) : undefined;
|
|
95
|
-
if (!timed) {
|
|
96
|
-
return end
|
|
97
|
-
? { type: "daterange", start_date: start.date, end_date: end.date }
|
|
98
|
-
: { type: "date", start_date: start.date };
|
|
99
|
-
}
|
|
100
|
-
const zone = value.time_zone ??
|
|
101
|
-
(offsetMinutes === 0
|
|
102
|
-
? "UTC"
|
|
103
|
-
: `UTC${offsetMinutes < 0 ? "-" : "+"}${Math.floor(Math.abs(offsetMinutes) / 60)}${Math.abs(offsetMinutes) % 60 === 0 ? "" : `:${String(Math.abs(offsetMinutes) % 60).padStart(2, "0")}`}`);
|
|
104
|
-
return end
|
|
105
|
-
? {
|
|
106
|
-
type: "datetimerange",
|
|
107
|
-
start_date: start.date,
|
|
108
|
-
start_time: start.time,
|
|
109
|
-
end_date: end.date,
|
|
110
|
-
end_time: end.time,
|
|
111
|
-
time_zone: zone,
|
|
112
|
-
}
|
|
113
|
-
: {
|
|
114
|
-
type: "datetime",
|
|
115
|
-
start_date: start.date,
|
|
116
|
-
start_time: start.time,
|
|
117
|
-
time_zone: zone,
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
60
|
function toLegacyProperty(property) {
|
|
121
61
|
switch (property.type) {
|
|
122
62
|
case "title":
|
|
@@ -140,7 +80,7 @@ function toLegacyProperty(property) {
|
|
|
140
80
|
case "multi_select":
|
|
141
81
|
return property.multi_select.flatMap(option => option.name ?? []);
|
|
142
82
|
case "date":
|
|
143
|
-
return property.date ?
|
|
83
|
+
return property.date ? toNotionDateValue(property.date) : undefined;
|
|
144
84
|
case "people":
|
|
145
85
|
return property.people.map(person => person.object === "group"
|
|
146
86
|
? {
|
|
@@ -153,6 +93,18 @@ function toLegacyProperty(property) {
|
|
|
153
93
|
return property.relation.map(page => ({ id: page.id, table: "block" }));
|
|
154
94
|
case "files":
|
|
155
95
|
return property.files.map(file => file.name).join(",");
|
|
96
|
+
case "unique_id":
|
|
97
|
+
return property.unique_id;
|
|
98
|
+
case "button":
|
|
99
|
+
return property.button;
|
|
100
|
+
case "formula":
|
|
101
|
+
return property.formula;
|
|
102
|
+
case "location":
|
|
103
|
+
return property.location;
|
|
104
|
+
case "rollup":
|
|
105
|
+
return property.rollup;
|
|
106
|
+
case "verification":
|
|
107
|
+
return property.verification;
|
|
156
108
|
case "place":
|
|
157
109
|
return "";
|
|
158
110
|
case "created_time":
|
|
@@ -11,10 +11,10 @@ export declare const notionTimeReminderSchema: v.ObjectSchema<{
|
|
|
11
11
|
readonly value: v.NumberSchema<undefined>;
|
|
12
12
|
}, undefined>;
|
|
13
13
|
export type NotionTimeReminder = v.InferOutput<typeof notionTimeReminderSchema>;
|
|
14
|
-
export declare const
|
|
14
|
+
export declare const notionDisabledReminderSchema: v.ObjectSchema<{
|
|
15
15
|
readonly unit: v.LiteralSchema<"none", undefined>;
|
|
16
16
|
}, undefined>;
|
|
17
|
-
export type
|
|
17
|
+
export type NotionDisabledReminder = v.InferOutput<typeof notionDisabledReminderSchema>;
|
|
18
18
|
/**
|
|
19
19
|
* Possible types for a Notion `datetime` reminder.
|
|
20
20
|
*/
|
|
@@ -9,7 +9,9 @@ export const notionTimeReminderSchema = v.object({
|
|
|
9
9
|
unit: v.picklist(["hour", "minute"]),
|
|
10
10
|
value: v.number(),
|
|
11
11
|
});
|
|
12
|
-
|
|
12
|
+
// An omitted reminder can inherit the date property's default reminder.
|
|
13
|
+
// "none" explicitly disables reminders instead.
|
|
14
|
+
export const notionDisabledReminderSchema = v.object({
|
|
13
15
|
unit: v.literal("none"),
|
|
14
16
|
});
|
|
15
17
|
/**
|
|
@@ -19,25 +21,25 @@ export const notionDateTimeReminderSchema = v.union([
|
|
|
19
21
|
notionDateReminderSchema,
|
|
20
22
|
notionTimeReminderSchema,
|
|
21
23
|
]);
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
+
const dateOrDisabledReminder = v.optional(v.union([notionDateReminderSchema, notionDisabledReminderSchema]));
|
|
25
|
+
const dateTimeOrDisabledReminder = v.optional(v.union([notionDateTimeReminderSchema, notionDisabledReminderSchema]));
|
|
24
26
|
export const notionDateSchema = v.object({
|
|
25
27
|
type: v.literal("date"),
|
|
26
28
|
start_date: v.string(),
|
|
27
|
-
reminder:
|
|
29
|
+
reminder: dateOrDisabledReminder,
|
|
28
30
|
});
|
|
29
31
|
export const notionDateRangeSchema = v.object({
|
|
30
32
|
type: v.literal("daterange"),
|
|
31
33
|
start_date: v.string(),
|
|
32
34
|
end_date: v.string(),
|
|
33
|
-
reminder:
|
|
35
|
+
reminder: dateOrDisabledReminder,
|
|
34
36
|
});
|
|
35
37
|
export const notionDateTimeSchema = v.object({
|
|
36
38
|
type: v.literal("datetime"),
|
|
37
39
|
start_date: v.string(),
|
|
38
40
|
start_time: v.string(),
|
|
39
41
|
time_zone: v.optional(v.string()),
|
|
40
|
-
reminder:
|
|
42
|
+
reminder: dateTimeOrDisabledReminder,
|
|
41
43
|
});
|
|
42
44
|
export const notionDateTimeRangeSchema = v.object({
|
|
43
45
|
type: v.literal("datetimerange"),
|
|
@@ -46,7 +48,7 @@ export const notionDateTimeRangeSchema = v.object({
|
|
|
46
48
|
end_date: v.string(),
|
|
47
49
|
end_time: v.string(),
|
|
48
50
|
time_zone: v.optional(v.string()),
|
|
49
|
-
reminder:
|
|
51
|
+
reminder: dateTimeOrDisabledReminder,
|
|
50
52
|
});
|
|
51
53
|
/**
|
|
52
54
|
* Possible types for a Notion `date` value.
|