%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left


    %% plan dependencies
    Connection13{{"Connection[13∈0] ➊<br />ᐸ9ᐳ"}}:::plan
    Constant6{{"Constant[6∈0] ➊<br />ᐸundefinedᐳ"}}:::plan
    Constant6 & Constant6 & Constant6 --> Connection13
    Object12{{"Object[12∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    Access10{{"Access[10∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access11{{"Access[11∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access10 & Access11 --> Object12
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access10
    __Value2 --> Access11
    __Value4["__Value[4∈0] ➊<br />ᐸrootValueᐳ"]:::plan
    Constant35{{"Constant[35∈0] ➊<br />ᐸ[Function: applyInputConstant]ᐳ"}}:::plan
    PgSelect15[["PgSelect[15∈1] ➊<br />ᐸpeopleᐳ"]]:::plan
    Object12 & Constant35 & Connection13 & Constant6 & Constant6 & Constant6 --> PgSelect15
    PgSelectRows16[["PgSelectRows[16∈1] ➊"]]:::plan
    PgSelect15 --> PgSelectRows16
    Access30{{"Access[30∈1] ➊<br />ᐸ15.cursorDetailsᐳ"}}:::plan
    PgSelect15 --> Access30
    __Item17[/"__Item[17∈2]<br />ᐸ16ᐳ"\]:::itemplan
    PgSelectRows16 ==> __Item17
    PgSelectSingle18{{"PgSelectSingle[18∈2]<br />ᐸpeopleᐳ"}}:::plan
    __Item17 --> PgSelectSingle18
    PgSelect20[["PgSelect[20∈3]<br />ᐸlog_entriesᐳ"]]:::plan
    PgClassExpression19{{"PgClassExpression[19∈3]<br />ᐸ__people__.”person_id”ᐳ"}}:::plan
    Object12 & PgClassExpression19 & Constant6 & Constant6 --> PgSelect20
    PgCursor31{{"PgCursor[31∈3]"}}:::plan
    PgSelectSingle18 & Access30 --> PgCursor31
    PgSelectSingle18 --> PgClassExpression19
    PgSelectRows24[["PgSelectRows[24∈3]"]]:::plan
    PgSelect20 --> PgSelectRows24
    PgClassExpression29{{"PgClassExpression[29∈3]<br />ᐸ__people__.”username”ᐳ"}}:::plan
    PgSelectSingle18 --> PgClassExpression29
    __Item25[/"__Item[25∈4]<br />ᐸ24ᐳ"\]:::itemplan
    PgSelectRows24 ==> __Item25
    PgSelectSingle26{{"PgSelectSingle[26∈4]<br />ᐸlog_entriesᐳ"}}:::plan
    __Item25 --> PgSelectSingle26
    PgClassExpression27{{"PgClassExpression[27∈4]<br />ᐸ__log_entries__.”text”ᐳ"}}:::plan
    PgSelectSingle26 --> PgClassExpression27
    PgClassExpression28{{"PgClassExpression[28∈4]<br />ᐸ__log_entries__.”id”ᐳ"}}:::plan
    PgSelectSingle26 --> PgClassExpression28

    %% define steps

    subgraph "Buckets for queries/polymorphic/person-log-entries"
    Bucket0("Bucket 0 (root)"):::bucket
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,__Value4,Constant6,Access10,Access11,Object12,Connection13,Constant35 bucket0
    Bucket1("Bucket 1 (nullableBoundary)<br />Deps: 12, 35, 13, 6<br /><br />ROOT Connectionᐸ9ᐳ[13]<br />1: PgSelect[15]<br />ᐳ: Access[30]<br />2: PgSelectRows[16]"):::bucket
    classDef bucket1 stroke:#00bfff
    class Bucket1,PgSelect15,PgSelectRows16,Access30 bucket1
    Bucket2("Bucket 2 (listItem)<br />Deps: 12, 6, 30<br /><br />ROOT __Item{2}ᐸ16ᐳ[17]"):::bucket
    classDef bucket2 stroke:#7f007f
    class Bucket2,__Item17,PgSelectSingle18 bucket2
    Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 18, 12, 6, 30<br /><br />ROOT PgSelectSingle{2}ᐸpeopleᐳ[18]<br />1: <br />ᐳ: 19, 29, 31<br />2: PgSelect[20]<br />3: PgSelectRows[24]"):::bucket
    classDef bucket3 stroke:#ffa500
    class Bucket3,PgClassExpression19,PgSelect20,PgSelectRows24,PgClassExpression29,PgCursor31 bucket3
    Bucket4("Bucket 4 (listItem)<br /><br />ROOT __Item{4}ᐸ24ᐳ[25]"):::bucket
    classDef bucket4 stroke:#0000ff
    class Bucket4,__Item25,PgSelectSingle26,PgClassExpression27,PgClassExpression28 bucket4
    Bucket0 --> Bucket1
    Bucket1 --> Bucket2
    Bucket2 --> Bucket3
    Bucket3 --> Bucket4
    end
